Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you run eslint for only a specific rule or set of rules - command line only

I know you can define rules in an .eslintrc file, but what if I just want to run eslint and check for one specific rule?

E.g. $ eslint helpme.js --rule some-important-rule

like image 904
JBaczuk Avatar asked Aug 29 '18 19:08

JBaczuk


People also ask

How do you set rules in ESLint?

You can turn off every rule and run only with basic syntax validation or mix and match the bundled rules and your custom rules to fit the needs of your project. There are two primary ways to configure ESLint: Configuration Comments - use JavaScript comments to embed configuration information directly into a file.

How do you define a rule in ESLint?

ESLint comes with a large number of built-in rules and you can add more rules through plugins. You can modify which rules your project uses either using configuration comments or configuration files. To change a rule setting, you must set the rule ID equal to one of these values: "off" or 0 - turn the rule off.


1 Answers

If you want to use your .eslintrc file to keep your configuration (parser, plugin settings, etc), you can use eslint-nibble with the --rule=some-important-rule flag. This will respect your normal configuration, but only show you errors from that rule. There are some other flags as well like --no-interactive if you want to run this in something like a CI environment.

Disclaimer: I'm the creator of eslint-nibble.

like image 132
IanVS Avatar answered Sep 25 '22 02:09

IanVS