Skip to content

Commit

Permalink
fix: rules are at top level (not under overrides)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the rules are provided at the top level,
instead of under an `overrides` property.
Providing the rules under the `overrides` property was never a good idea.
It prevents specifying which files the rules apply to (e.g. `[*.js, *.ts]`).
I apologize.
To migrate, make sure that your `extends` property is under an [`overrides` item][overrides].
An example is in the readme.
To help verify your configuration,
you could obtain a list of files that will be linted, this way:
`DEBUG=eslint:cli-engine npx eslint <path>`.

[overrides]: https://eslint.org/docs/latest/use/configure/configuration-files#how-do-overrides-work

closes #1149
closes #1088

Co-authored-by: Rostislav Simonik <rostislav.simonik@technologystudio.sk>
  • Loading branch information
mightyiam and rostislav-simonik committed Jun 30, 2023
1 parent d9f309b commit 25401c9
Show file tree
Hide file tree
Showing 6 changed files with 422 additions and 431 deletions.
13 changes: 9 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"extends": "./lib/index.js",
"parserOptions": {
"project": "./tsconfig.json"
}
"overrides": [
{
"files": ["*.js", "*.ts"],
"extends": "./lib/index.js",
"parserOptions": {
"project": "./tsconfig.json"
}
}
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "lib/index.js",
"scripts": {
"compile": "tsc",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint .",
"editorconfig": "editorconfig-checker",
"unit": "ava",
"test": "run-s clean-artifacts editorconfig compile lint unit",
Expand Down
18 changes: 13 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,29 @@ npm install --save-dev \

# Example config

Here is an example `.eslintrc.js`:
Here is an example `.eslintrc.js`.
Pay close attention to the `files` property, because it [determines which files are linted][specifying-target-files-to-lint].

```js
module.exports = {
extends: 'standard-with-typescript',
parserOptions: {
project: './tsconfig.json'
}
overrides: [
{
files: ['*.js', '*.jsx', '*.ts', '*.tsx'],
extends: 'standard-with-typescript',
parserOptions: {
project: './tsconfig.json'
}
}
],
}
```

Note: Please read some important instructions regarding the `project` option [here](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/README.md#configuration).

There are [some more `parserOptions`](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/README.md#configuration) you may care about.

[specifying-target-files-to-lint]: https://eslint.org/docs/latest/use/configure/configuration-files#specifying-target-files-to-lint

# Example command line usage:

```
Expand Down

0 comments on commit 25401c9

Please sign in to comment.