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

feat!: allow changing warnIgnored via CLI #15976

Closed
wants to merge 1 commit into from
Closed

feat!: allow changing warnIgnored via CLI #15976

wants to merge 1 commit into from

Conversation

domnantas
Copy link
Contributor

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

  • Added --no-warning-on-ignored-files CLI option
  • Removed inconsistent warnIgnored defaults, replaced with a single warnIgnored: true default
  • Updated warning messages to inform users about the ability to suppress the warning
  • Added tests for CLIEngine.executeOnText, CLIEngine.executeOnFiles, ESLint.lintText, ESLint.lintFiles and CLI

Is there anything you'd like reviewers to focus on?

  • Are there any tests missing?
  • Making defaults consistent is technically a breaking change. What should be done in this case?

@eslint-github-bot eslint-github-bot bot added triage An ESLint team member will look at this issue soon feature This change adds a new feature to ESLint labels Jun 8, 2022
@netlify
Copy link

netlify bot commented Jun 8, 2022

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit 10b241f
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/62a0d4afec6f0f00087a8669
😎 Deploy Preview https://deploy-preview-15976--docs-eslint.netlify.app/user-guide/configuring/ignoring-code
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@@ -568,7 +573,7 @@ class ESLint {
}
const {
filePath,
warnIgnored = false,
Copy link
Contributor Author

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,
Copy link
Contributor Author

@domnantas domnantas Jun 8, 2022

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
Copy link
Contributor Author

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) {
Copy link
Contributor Author

@domnantas domnantas Jun 8, 2022

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(...)

Comment on lines 788 to 793
if (ignored) {
results.push(createIgnoreResult(filePath, cwd));
if (warnIgnored) {
results.push(createIgnoreResult(filePath, cwd));
}
continue;
}
Copy link
Contributor Author

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

@nzakas nzakas marked this pull request as draft June 9, 2022 18:11
@nzakas
Copy link
Member

nzakas commented Jun 9, 2022

Converting to a draft until the RFC is approved.

@mdjermanovic mdjermanovic added the breaking This change is backwards-incompatible label Jun 27, 2022
@mdjermanovic mdjermanovic changed the title feat: allow changing warnIgnored via CLI feat!: allow changing warnIgnored via CLI Jun 27, 2022
@mdjermanovic
Copy link
Member

I marked this PR as a breaking change because it changes the default behavior of eslint.lintText. In particular, its option options.warnIgnored will effectively default to true. Currently, the default value for this option is false.

Copy link

@markoenix markoenix left a 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

@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label Oct 14, 2022
@Faithfinder
Copy link

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!

@github-actions github-actions bot removed the Stale label Oct 15, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label Dec 15, 2022
@domnantas
Copy link
Contributor Author

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 warnIgnored default was true in some places, false in other places. This PR aimed to unify them and make warnIgnored: true default everywhere. However, this is considered a breaking change, so we can only include it in a major version release. However, ESLint is going though a big change in its config system called FlatESLint (read more about it in this great blog post by Nicholas), therefore it is unwise introducing such small changes into its scope.

This doesn't mean this issue will not be fixed, we will just need to rely on workarounds a little longer.

@domnantas domnantas closed this Dec 16, 2022
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jun 15, 2023
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jun 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion breaking This change is backwards-incompatible feature This change adds a new feature to ESLint Stale triage An ESLint team member will look at this issue soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants