Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Include info about VS Code and package-lock.json #11

Merged
merged 1 commit into from
Jul 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ deno add @eslint/json
This package exports two different languages:

- `"json/json"` is for regular JSON files
- `"json/jsonc"` is for JSON files that support comments (JSON-C)
- `"json/jsonc"` is for JSON files that support comments (JSON-C) such as those used for Visual Studio Code configuration files

Depending on which types of JSON files you'd like to lint, you can set up your `eslint.config.js` file to include just the files you'd like. Here's an example that lints both JSON and JSON-C files:

Expand All @@ -56,7 +56,7 @@ export default [

// lint JSON-C files
{
files: ["**/*.jsonc"],
files: ["**/*.jsonc", ".vscode/*.json"],
language: "json/jsonc",
rules: {
"json/no-duplicate-keys": "error",
Expand All @@ -76,6 +76,7 @@ export default [
// lint JSON files
{
files: ["**/*.json"],
ignores: ["package-lock.json"],
language: "json/json",
...json.configs.recommended,
},
Expand All @@ -89,10 +90,12 @@ export default [
];
```

**Note:** You generally want to ignore `package-lock.json` because it is auto-generated and you typically will not want to manually make changes to it.

## Rules

- `no-duplicate-keys` - warns when there are two keys in an object with the same text.
- `no-empty-keys` - warns when there is a key in an object that is an empty string or contains only whitespace
- `no-empty-keys` - warns when there is a key in an object that is an empty string or contains only whitespace (note: `package-lock.json` uses empty keys intentionally)

## License

Expand Down