question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow omitting specific rules from fix

See original GitHub issue

I am aware #208 was already closed, however since then a specific API for filtering rules from being fixed was added to CLIEngine https://eslint.org/docs/developer-guide/nodejs-api#cliengine .

One of the pain points with the solution in #208 is that the no-autofix plugin requires adding it into every project specifically and only supports the builtin rules.

I’d like to propose again supporting an eslint.rulesToDisableWhileFixing option that takes a list of options. The vscode-eslint could then use this list like so:

newOptions.fix = function({ ruleId }) {
  if (!pluginOptions.rulesToDisableWhileFixing) {
    return true;
  }
  return !pluginOptions.rulesToDisableWhileFixing.includes(ruleId);
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
branflakercommented, Jun 25, 2020

Another idea for a possible implementation. Instead of specifying rules to disable for autofixing, how about specifying a path to a separate ESLint config? You get a lot more control over how you want your autofixes applied then (more than just disabling specific rules). Something like:

{
  "eslint.options": { "autofixConfigFile": "C:/mydirectory/.eslintrc.json" }
}
1reaction
Jamesernatorcommented, Jul 25, 2019

Alternatively as an even more flexible option it might be a possibility to treat eslint.options.fix as a function body if it happens to be a string e.g.:

const fix = typeof newOptions.fix === 'string'
  ? new Function('rule', newOptions.fix)
  : newOptions.fix;

Then in settings.json one could do:

{
  "eslint.options": {
    "fix": "return !['prefer-const', '@typescript-eslint/no-unnecessary-type-assertion'].includes(rule.ruleId);"
  }
}

Or maybe just eval the 'fix' option to get a function:

{
  "eslint.options": {
    "fix": "({ ruleId }) => !['prefer-const', '@typescript-eslint/no-unnecessary-type-assertion'].includes(ruleId)'"
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Turning off eslint rule for a specific file - Stack Overflow
1) Disabling "All rules" · You can go with 1.2 and add /* eslint-disable */ on top of the files, one by one....
Read more >
Listener rules for your Application Load Balancer
Each rule must include exactly one of the following actions: forward , redirect , or fixed-response , and it must be the last...
Read more >
Rule 60. Relief from a Judgment or Order - Law.Cornell.Edu
Two types of procedure to obtain relief from judgments are specified in the rules as it is proposed to amend them. One procedure...
Read more >
Ignoring code - Stylelint
stylelint-disable */ a {} /* stylelint-enable */. Or you can turn off individual rules: /* stylelint-disable selector-max-id, declaration-no-important */
Read more >
Command Line Interface - ESLint - Pluggable JavaScript Linter
Options that accept multiple values can be specified by repeating the option or ... Deprecated: Use rules from plugins Fix problems: --fix Automatically...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found