-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Description
From: eslint/eslintrc#20 (comment), #5410
The flat config should provide the way that end-users override the ignores
setting of shareable configs and ESLint built-ins.
In .eslintignore
, we can use negative patterns.
# .eslintignore
!/node_modules/my-package/
!.eslintrc.js
ESLint ignores /node_modules/*
by default, but we can un-ignore it by such as the above setting.
Similarly, ESLint ignores dotfiles by default, but we can un-ignore it to lint .eslintrc.js
-like config files.
In .eslintrc.*
, the ignorePatterns
setting is the same style as .eslintignore
. Both end-user's configs and shareable configs can have the ignorePatterns
setting. It let us override the settings of base configs.
# .eslintrc.yml
ignorePatterns:
- "!/node_modules/my-package/"
- "!.eslintrc.js"
I think we should consider it on the flat config system.
import baseConfig from "my-eslint-config"
export default [
baseConfig, // when it has `ignores: ["/foo/*"]`
{
ignores: [
"!/node_modules/my-package/", // un-ignore the built-in ignores
"!/foo/bar" // un-ignore the base config's ignores
]
}
]
Also, I think it's confusing with the following:
import baseConfig from "my-eslint-config"
export default [
baseConfig, // when it has `ignores: ["/foo/*"]`
{
files: ["/**/*.js"],
ignores: [
"!/node_modules/my-package/", //
"!/foo/bar" // what happens?
]
}
]
This is a topic that wasn't resolved in "Config File Simplification" RFC.
In eslint/rfcs#9 (comment) thread, I had tried to describe that the ignores
setting has two meaning, then argued that it should be separated.
- If the
files
field exists, theignores
field is used for the adoption of the config array element and isn't merged for the ignore check. It's glob patterns as the RFC says. It corresponds to thefiles
andexcludedFiles
of legacy configs. - If the
files
field doesn't exist, theignores
field doesn't affect the adoption of the config array element and is merged for the ignore check. It's a list of gitignore-style patterns and supports negative patterns to override base configs. It corresponds to theignorePatterns
of legacy configs and.eslintignore
.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status