Disable a specific linter rule in Atom (for js-standard)

How can I tell linter Atom, in particular js-standard , to ignore the rule? I want him to ignore the whole project, and I thought I could achieve this with package.json or .eslintrc, but I can't work. The rule I want to disable is camelcase

I have to do this in the package.json file because js-standard linter has the honorStyleSettings option:

Difference style settings defined in package.json.

The current style settings are supported:

ignore
analyzer

What is the syntax of these settings?

+5
source share
4 answers

For the record here, how to use js-standard in Atom when selectively disabling a specific rule.

  • Disable the linter-js-standard atom package
  • Install linter-eslint
  • Add the .eslintrc file:

     { "extends": ["standard"], "rules": { "camelcase": 0 } } 

You may also need to set the standard and eslint via npm if you do not already have them.

+2
source

Using the default installation, there is no way in linter-js-standard to do this. (I believe this was a conscious decision by the authors of the modules, who believe that standard is a tough goal, not an ideal.)

If you want to use eslint style comments to disable listing for specific lines or sections of code, install babel-eslint via npm i --save-dev babel-eslint and add

 { ... "standard": { "parser": "babel-eslint" } ... } 

into your package.json file, which will allow you to annotate your source as needed.

Example

Assuming foo defined but not used elsewhere in your file, linter will warn: "foo is assigned a value but never used. (No-unused-vars) '

 const foo = 1 

After installing babel-eslint , setting the standard in your package.json file and adding this comment, linter will ignore the line.

 const foo = 1 // eslint-disable-line 

See Configuring ESLint for other configuration annotations.

+1
source

If ESLint uses your plugin, create the .eslintrc file in the root directory of your project and write your rules there.

Here is an example .eslintrc file .eslintrc example . I need to close and reopen Atom to update lint errors

EDIT:

showEslintRules (default: false). You will need to change this parameter to true.

0
source

I managed to disable the “camelcase” rule by going to the “linter-js-standard” package folder and adding the following line to the file node_modules/standard/eslintrc.json :

 "rules": { "camelcase": [0] } 

So the whole "eslintrc.json" looks like this:

 { "extends": ["standard", "standard-jsx"], "rules": { "camelcase": [0] } } 

Just save or edit your .js file in Atom for the changes to take effect.

On my Linux desktop, the full path to eslintrc.json :

 ~/.atom/packages/linter-js-standard/node_modules/standard/eslintrc.json 

Of course, when you update the "linter-js-standard" package in Atom, you will need to complete the above steps again.

To enable the camelcase rule, you can change the "camelcase" value to [2] instead of deleting the entire rule line:

 "rules": { "camelcase": [2] } 
0
source

All Articles