Disable check of camel case rule in eslint
Asked Answered
W

9

84

I have a large JavaScript file with multiple eslint rule violations. I am trying to disable them and address them one at a time. The code below shows that I can disable them all with no trouble, but not the rule about camelcase and perhaps other individual rules. The approaches I have used should work according to the eslint documentation, but there must be a flaw in my interpretation.

The code is short and it does not eliminate the error concerning camel case.

/* eslint-disable  /* eslint-disable//  works but gets everything.
`/* eslint (camelcase) : 0 */
    /* eslint camelcase : ["error", {ignoreDestructuring:true}] */

const Lesson_1 = {title:'The Home Row Keys.'},'lesson': 'jjj fff jjj fff'}

Just get the same camelcase error without any change. The eslint documentation says just disable the entire rule but does not specify a method other than listed above.

Wylie answered 7/7, 2019 at 1:26 Comment(0)
R
122

To disable the rule for a file add next line at the begging of a file:

for JavaScript files:

/* eslint-disable camelcase */

for TypeScript with enabled @typescript-eslint plugin:

/* eslint-disable @typescript-eslint/camelcase */

To disable the rule for all files in a project add next line to the eslint config file:

for JavaScript files:

rules: {
  ...

  'camelcase': 'off',
}

for TypeScript with enabled @typescript-eslint plugin:

rules: {
  ...

  '@typescript-eslint/camelcase': 'off',
}
Reverberatory answered 5/4, 2020 at 7:11 Comment(1)
@typescript-eslint/camelcase rule was deprecated in favour of naming-convention rule. github.com/typescript-eslint/typescript-eslint/blob/master/…Haemagglutinate
S
27

For TypeScript, we can change the rules in the eslintrc file.

rules: {
  "camelcase": "off",
  "@typescript-eslint/camelcase": ["warn"]
}

We can set "off" or "warn" here. https://eslint.org/docs/user-guide/configuring#configuring-rules

Shields answered 18/5, 2020 at 3:39 Comment(1)
@typescript-eslint/camelcase is deprecatedOrthoclase
A
19

This works for me

/* eslint-disable camelcase */
Acerbic answered 1/10, 2019 at 11:31 Comment(3)
Even though I am using @typescript-eslint -- this worked for me. Eslint v6.8.0Bb
where do you put that??Kaiak
Inside the JavaScript File. At the beginningAcerbic
T
18

Update For TypeScript:

@typescript-eslint/camelcase is deprecated

use @typescript-eslint/naming-convention instead

rules: {
  ...

  "@typescript-eslint/naming-convention": "off"
}

Or for single files

/* eslint-disable @typescript-eslint/naming-convention */

This worked for me

Traceytrachea answered 29/7, 2021 at 9:54 Comment(0)
D
4

Use following code, and add it to each corresponding file containing variables against camelcase rules :

/* eslint-disable @typescript-eslint/class-name-casing */
/* eslint-disable @typescript-eslint/camelcase */

It works for me.

Departed answered 1/4, 2020 at 18:43 Comment(0)
O
4

I had to use:

/* eslint-disable @typescript-eslint/naming-convention */

After moving Angular to eslint

Orlon answered 12/1, 2021 at 19:11 Comment(0)
G
3

You shouldn't disable this is a bad practice but in case you wanted you can add a rule to your .eslintrc.json file in the root of your project and set camelcase to as shown in the example.

    "extends": "standard",
    "rules": {
        "camelcase": 0
    }
}
Gilead answered 2/4, 2020 at 21:53 Comment(0)
H
2

Try the following options.

  1. Use the next-line or same-line syntax
// eslint-disable-next-line camelcase
const Lesson_1 = {title:'The Home Row Keys.'},'lesson': 'jjj fff jjj fff'}

or (see after semi-colon)

const Lesson_1 = {title:'The Home Row Keys.'},'lesson': 'jjj fff jjj fff'}; // eslint-disable-line camelcase
  1. Try disabling the entire file by adding the following as the first line of your file. This should ignore all camel casing errors in the entire file.
/* eslint-disable camelcase */

Note: Always check if the configuration file work against the eslint you're running. Means, there can be multiple installations of eslint - Global & local. So make sure you are running the right one. Also check the rules object in the .eslintrc configuration file.

Hootchykootchy answered 22/2, 2022 at 13:39 Comment(0)
D
0

To disable on a single file *.js or *.ts; put the following at the top of that file.

/* eslint @typescript-eslint/no-var-requires: "off" */
Drusilla answered 25/1, 2022 at 19:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.