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
feat!: allow changing warnIgnored via CLI #15976
Conversation
✅ Deploy Preview for docs-eslint ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
@@ -568,7 +573,7 @@ class ESLint { | |||
} | |||
const { | |||
filePath, | |||
warnIgnored = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the inconsistent default, this will fall back to processOptions
defaults
@@ -168,6 +169,7 @@ function processOptions({ | |||
resolvePluginsRelativeTo = null, // ← should be null by default because if it's a string then it suppresses RFC47 feature. | |||
rulePaths = [], | |||
useEslintrc = true, | |||
warnIgnored = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will override default-cli-options.js
, just like all of the options above this line. Not sure if that's good.
@@ -294,8 +296,7 @@ const cli = { | |||
|
|||
if (useStdin) { | |||
results = await engine.lintText(text, { | |||
filePath: options.stdinFilename, | |||
warnIgnored: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this line, because it overrides the passed CLI option
@@ -897,7 +901,7 @@ class CLIEngine { | |||
// Clear the last used config arrays. | |||
lastConfigArrays.length = 0; | |||
if (resolvedFilename && this.isPathIgnored(resolvedFilename)) { | |||
if (warnIgnored) { | |||
if (warnIgnored ?? engineWarnIgnored) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using nullish coalescing here because engineWarnIgnored
should only be used when warnIgnored
is null or undefined. When it is warnIgnored = false, engineWarnIgnored = true
, the if should respect warnIgnored
and not execute results.push(...)
if (ignored) { | ||
results.push(createIgnoreResult(filePath, cwd)); | ||
if (warnIgnored) { | ||
results.push(createIgnoreResult(filePath, cwd)); | ||
} | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might seem odd, but
if ignored = false, warnIgnored = false
-> lint
if ignored = false, warnIgnored = true
-> lint
if ignored = true, warnIgnored = false
-> do not show warning, and do not lint
if ignored = true, warnIgnored = true
-> show warning, do not lint
Converting to a draft until the RFC is approved. |
I marked this PR as a breaking change because it changes the default behavior of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried on iphone7
Oops! It looks like we lost track of this pull request. What do we want to do here? This pull request will auto-close in 7 days without an update. |
Sorry if I'm spamming, but I'd love for this to be merged, so I'm trying to unstale it. Sorry again if that's not the right way! |
Oops! It looks like we lost track of this pull request. What do we want to do here? This pull request will auto-close in 7 days without an update. |
I think it is ok to close this. The RFC is still in progress and the PR has accrued a lot of conflicts. It can still be used as an example in the future. Previously This doesn't mean this issue will not be fixed, we will just need to rely on workarounds a little longer. |
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[x] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
This is related to eslint/rfcs#90 and #15010
--no-warning-on-ignored-files
CLI optionwarnIgnored
defaults, replaced with a singlewarnIgnored: true
defaultCLIEngine.executeOnText
,CLIEngine.executeOnFiles
,ESLint.lintText
,ESLint.lintFiles
and CLIIs there anything you'd like reviewers to focus on?