Turning off eslint rule for a specific line2019 Community Moderator ElectionDisabling linting errors when writing test files?Intellij plugin: AirBnB ESLint w/ ReactESLint Disallow Use of Alert (no-alert)ESLint no-undef - js issue with BigCommerceIgnore the indentation in a template literal, with the ESLint `indent` ruleAdding exceptions to esLinteslint - disable error notificationSetting up Vue.js with Vuex$ is not defined in ejs file when trying to add and remove classModify an ESLint rule for a single lineSafely turning a JSON string into an objectHow to insert an item into an array at a specific index (JavaScript)?JavaScript chop/slice/trim off last character in stringGenerating random whole numbers in JavaScript in a specific range?How do I pass command line arguments to a Node.js program?How to decide when to use Node.js?ESLint - “window” is not defined. How to allow global variables in package.jsonTurning off eslint rule for a specific fileTurn off ESLint rule (in React app, using WebStorm)Turn off error for console.log on my eslint
How to find the largest number(s) in a list of elements, possibly non-unique?
When should a starting writer get his own webpage?
Knife as defense against stray dogs
Extraneous elements in "Europe countries" list
What are the rules for concealing thieves' tools (or items in general)?
What is the difference between something being completely legal and being completely decriminalized?
TDE Master Key Rotation
Why does Surtur say that Thor is Asgard's doom?
Would this string work as string?
What is the tangent at a sharp point on a curve?
Unfrosted light bulb
Weird lines in Microsoft Word
Homology of the fiber
10 year ban after applying for a UK student visa
How can I create URL shortcuts/redirects for task/diff IDs in Phabricator?
Difficulty understanding group delay concept
How do researchers send unsolicited emails asking for feedback on their works?
Friend wants my recommendation but I don't want to
Why doesn't the fusion process of the sun speed up?
Single word to change groups
Do people actually use the word "kaputt" in conversation?
Hackerrank All Women's Codesprint 2019: Name the Product
Error in master's thesis, I do not know what to do
Nested Dynamic SOQL Query
Turning off eslint rule for a specific line
2019 Community Moderator ElectionDisabling linting errors when writing test files?Intellij plugin: AirBnB ESLint w/ ReactESLint Disallow Use of Alert (no-alert)ESLint no-undef - js issue with BigCommerceIgnore the indentation in a template literal, with the ESLint `indent` ruleAdding exceptions to esLinteslint - disable error notificationSetting up Vue.js with Vuex$ is not defined in ejs file when trying to add and remove classModify an ESLint rule for a single lineSafely turning a JSON string into an objectHow to insert an item into an array at a specific index (JavaScript)?JavaScript chop/slice/trim off last character in stringGenerating random whole numbers in JavaScript in a specific range?How do I pass command line arguments to a Node.js program?How to decide when to use Node.js?ESLint - “window” is not defined. How to allow global variables in package.jsonTurning off eslint rule for a specific fileTurn off ESLint rule (in React app, using WebStorm)Turn off error for console.log on my eslint
In order to turn off linting rule for a particular line in JSHint we use the following rule:
/* jshint ignore:start*/
$scope.someVar = ConstructorFunction();
/* jshint ignore:end */
I have been trying to locate the equivalent of the above for eslint.
javascript jshint eslint
add a comment |
In order to turn off linting rule for a particular line in JSHint we use the following rule:
/* jshint ignore:start*/
$scope.someVar = ConstructorFunction();
/* jshint ignore:end */
I have been trying to locate the equivalent of the above for eslint.
javascript jshint eslint
35
Useeslint-disable-next-line:
– Brylie Christopher Oxley
May 17 '17 at 6:53
add a comment |
In order to turn off linting rule for a particular line in JSHint we use the following rule:
/* jshint ignore:start*/
$scope.someVar = ConstructorFunction();
/* jshint ignore:end */
I have been trying to locate the equivalent of the above for eslint.
javascript jshint eslint
In order to turn off linting rule for a particular line in JSHint we use the following rule:
/* jshint ignore:start*/
$scope.someVar = ConstructorFunction();
/* jshint ignore:end */
I have been trying to locate the equivalent of the above for eslint.
javascript jshint eslint
javascript jshint eslint
edited Oct 11 '16 at 1:14
runtimeZero
asked Jan 1 '15 at 15:47
runtimeZeroruntimeZero
8,219155298
8,219155298
35
Useeslint-disable-next-line:
– Brylie Christopher Oxley
May 17 '17 at 6:53
add a comment |
35
Useeslint-disable-next-line:
– Brylie Christopher Oxley
May 17 '17 at 6:53
35
35
Use
eslint-disable-next-line:– Brylie Christopher Oxley
May 17 '17 at 6:53
Use
eslint-disable-next-line:– Brylie Christopher Oxley
May 17 '17 at 6:53
add a comment |
9 Answers
9
active
oldest
votes
You can use the single line syntax now:
var thing = new Thing(); // eslint-disable-line no-use-before-define
thing.sayHello();
function Thing()
this.sayHello = function() console.log("hello"); ;
Or if you don't want to have a comment on the same line with the actual code, it is possible to disable next line:
// eslint-disable-next-line no-use-before-define
var thing = new Thing();
Requested docs link: http://eslint.org/docs/user-guide/configuring.html#configuring-rules
4
Now I get another eslint problem: warning Unexpected comment inline with code no-inline-comments :(
– arcseldon
Dec 19 '15 at 10:59
28
Works great for me. Also if you don't care about specificity you can just do//eslint-disable-lineand it appears to disable all rules for the given line.
– KhalilRavanna
Jan 22 '16 at 17:08
6
For some reason this doesn't work for me; I'm running eslint 3.8.0. I have to use /*eslint-disable */ and /*eslint-enable */. Any idea why this might be? I like the single line approach
– SomethingOn
Oct 17 '16 at 14:43
6
@SomethingOn had the same problem, turned out I had--no-inline-configturned on, whichPrevent comments from changing config or rules
– tibalt
Dec 20 '16 at 11:18
3
Not working with "gulp-eslint": "^3.0.1". I have to use /*eslint-disable */
– olefrank
Jan 22 '17 at 16:46
|
show 1 more comment
You can use the following
/*eslint-disable */
//suppress all warnings between comments
alert('foo');
/*eslint-enable */
Which is slightly buried the "configuring rules" section of the docs;
To disable a warning for an entire file, you can include a comment at the top of the file e.g.
/*eslint eqeqeq:0*/
Update
ESlint has now been updated with a better way disable a single line, see @goofballLogic's excellent answer.
2
BTW, it seems that the//comment syntax does not work…
– MonsieurDart
Dec 12 '17 at 0:29
Also a side note, i was looking for disabling eslint for one line in html. this works :thumbsup:
– Adil H. Raza
Oct 8 '18 at 8:39
add a comment |
You can also disable a specific rule/rules (rather than all) by specifying them in the enable (open) and disable (close) blocks:
/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert */
via @goofballMagic's link above: http://eslint.org/docs/user-guide/configuring.html#configuring-rules
5
Be sure your eslint comments pass eslint! ->Expected exception block, space or tab after '/*' in comment.:)
– Rimian
Dec 29 '17 at 0:57
I use a combination ofprettierandeslintto format my code. This does not allow for inline comments. Many/* eslint-disable-next-line ... */statements are hard to read and to spot in the code.
– Bernhard Döbler
Nov 20 '18 at 13:13
add a comment |
Disabling Rules with Inline Comments
http://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments
/* eslint-disable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-enable */
/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-disable no-alert */
alert('foo');
alert('foo'); // eslint-disable-line
// eslint-disable-next-line
alert('foo');
alert('foo'); // eslint-disable-line no-alert
// eslint-disable-next-line no-alert
alert('foo');
alert('foo'); // eslint-disable-line no-alert, quotes, semi
// eslint-disable-next-line no-alert, quotes, semi
alert('foo');
foo(); // eslint-disable-line example/rule-nameadd a comment |
The general end of line comment, // eslint-disable-line, does not need anything after it: no need to look up a code to specify what you wish ES Lint to ignore.
If you need to have any syntax ignored for any reason other than a quick debugging, you have problems: why not update your delint config?
I enjoy // eslint-disable-line to allow me to insert console for a quick inspection of a service, without my development environment holding me back because of the breach of protocol. (I generally ban console, and use a logging class - which sometimes builds upon console.)
No offence, but this is the same solution as the accepted answer, so not sure how this helps?
– a darren
Jan 28 '16 at 10:23
1
Good point. I've made it more explicit
– LeeGee
Jan 29 '16 at 8:55
17
Do NOT do this. If you have 5 errors on the line, they will all be ignored. Always explicitly set the rule which is to be ignored or the kids will make a mess.
– Filip Dupanović
Mar 17 '16 at 10:48
3
@FilipDupanović If your programmers can make a mess within a single line of code, just because eslint is not looking over their shoulders for a single line. There is really something else going wrong at your company... That said, saying what rule you wish to ignore makes it more clear why you put the disable line there in the first place.
– Edwin Stoteler
May 2 '16 at 14:14
2
@FilipDupanović Maybe eslint should have a meta rule for requiring explicit rule to ignore? Maybe it already does.
– Josef.B
Dec 3 '16 at 15:39
|
show 1 more comment
Answer
You can use an inline comment: // eslint-disable-next-line rule-name.
Example
// eslint-disable-next-line no-console
console.log('eslint will ignore the no-console on this line of code');Reference
ESLint - Disabling Rules with Inline Comments
add a comment |
To disable a single rule for the rest of the file below:
/* eslint no-undef: "off"*/
const uploadData = new FormData();
or/* eslint-disable no-new */
– Илья Зеленько
Sep 5 '18 at 4:45
add a comment |
single line comment did not work for me inside a react dumb functional component, I have used file level disabling by adding
/* eslint-disable insertEslintErrorDefinitionHere */
(normally if you are using vs code and getting eslint error, you can click on the line which gives error and a bulb would show up in vs code, right click on the light bulb and choose any disable option and vs code will do it for you.)
add a comment |
You can add the files which give error to .eslintignore file in your project.Like for all the .vue files just add /*.vue
3
it asked for one line, not the whole file
– Kevin Danikowski
Jul 30 '18 at 15:44
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f27732209%2fturning-off-eslint-rule-for-a-specific-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
9 Answers
9
active
oldest
votes
9 Answers
9
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use the single line syntax now:
var thing = new Thing(); // eslint-disable-line no-use-before-define
thing.sayHello();
function Thing()
this.sayHello = function() console.log("hello"); ;
Or if you don't want to have a comment on the same line with the actual code, it is possible to disable next line:
// eslint-disable-next-line no-use-before-define
var thing = new Thing();
Requested docs link: http://eslint.org/docs/user-guide/configuring.html#configuring-rules
4
Now I get another eslint problem: warning Unexpected comment inline with code no-inline-comments :(
– arcseldon
Dec 19 '15 at 10:59
28
Works great for me. Also if you don't care about specificity you can just do//eslint-disable-lineand it appears to disable all rules for the given line.
– KhalilRavanna
Jan 22 '16 at 17:08
6
For some reason this doesn't work for me; I'm running eslint 3.8.0. I have to use /*eslint-disable */ and /*eslint-enable */. Any idea why this might be? I like the single line approach
– SomethingOn
Oct 17 '16 at 14:43
6
@SomethingOn had the same problem, turned out I had--no-inline-configturned on, whichPrevent comments from changing config or rules
– tibalt
Dec 20 '16 at 11:18
3
Not working with "gulp-eslint": "^3.0.1". I have to use /*eslint-disable */
– olefrank
Jan 22 '17 at 16:46
|
show 1 more comment
You can use the single line syntax now:
var thing = new Thing(); // eslint-disable-line no-use-before-define
thing.sayHello();
function Thing()
this.sayHello = function() console.log("hello"); ;
Or if you don't want to have a comment on the same line with the actual code, it is possible to disable next line:
// eslint-disable-next-line no-use-before-define
var thing = new Thing();
Requested docs link: http://eslint.org/docs/user-guide/configuring.html#configuring-rules
4
Now I get another eslint problem: warning Unexpected comment inline with code no-inline-comments :(
– arcseldon
Dec 19 '15 at 10:59
28
Works great for me. Also if you don't care about specificity you can just do//eslint-disable-lineand it appears to disable all rules for the given line.
– KhalilRavanna
Jan 22 '16 at 17:08
6
For some reason this doesn't work for me; I'm running eslint 3.8.0. I have to use /*eslint-disable */ and /*eslint-enable */. Any idea why this might be? I like the single line approach
– SomethingOn
Oct 17 '16 at 14:43
6
@SomethingOn had the same problem, turned out I had--no-inline-configturned on, whichPrevent comments from changing config or rules
– tibalt
Dec 20 '16 at 11:18
3
Not working with "gulp-eslint": "^3.0.1". I have to use /*eslint-disable */
– olefrank
Jan 22 '17 at 16:46
|
show 1 more comment
You can use the single line syntax now:
var thing = new Thing(); // eslint-disable-line no-use-before-define
thing.sayHello();
function Thing()
this.sayHello = function() console.log("hello"); ;
Or if you don't want to have a comment on the same line with the actual code, it is possible to disable next line:
// eslint-disable-next-line no-use-before-define
var thing = new Thing();
Requested docs link: http://eslint.org/docs/user-guide/configuring.html#configuring-rules
You can use the single line syntax now:
var thing = new Thing(); // eslint-disable-line no-use-before-define
thing.sayHello();
function Thing()
this.sayHello = function() console.log("hello"); ;
Or if you don't want to have a comment on the same line with the actual code, it is possible to disable next line:
// eslint-disable-next-line no-use-before-define
var thing = new Thing();
Requested docs link: http://eslint.org/docs/user-guide/configuring.html#configuring-rules
edited May 14 '16 at 16:07
Michael Radionov
9,00213558
9,00213558
answered Apr 12 '15 at 17:27
goofballLogicgoofballLogic
19.2k62846
19.2k62846
4
Now I get another eslint problem: warning Unexpected comment inline with code no-inline-comments :(
– arcseldon
Dec 19 '15 at 10:59
28
Works great for me. Also if you don't care about specificity you can just do//eslint-disable-lineand it appears to disable all rules for the given line.
– KhalilRavanna
Jan 22 '16 at 17:08
6
For some reason this doesn't work for me; I'm running eslint 3.8.0. I have to use /*eslint-disable */ and /*eslint-enable */. Any idea why this might be? I like the single line approach
– SomethingOn
Oct 17 '16 at 14:43
6
@SomethingOn had the same problem, turned out I had--no-inline-configturned on, whichPrevent comments from changing config or rules
– tibalt
Dec 20 '16 at 11:18
3
Not working with "gulp-eslint": "^3.0.1". I have to use /*eslint-disable */
– olefrank
Jan 22 '17 at 16:46
|
show 1 more comment
4
Now I get another eslint problem: warning Unexpected comment inline with code no-inline-comments :(
– arcseldon
Dec 19 '15 at 10:59
28
Works great for me. Also if you don't care about specificity you can just do//eslint-disable-lineand it appears to disable all rules for the given line.
– KhalilRavanna
Jan 22 '16 at 17:08
6
For some reason this doesn't work for me; I'm running eslint 3.8.0. I have to use /*eslint-disable */ and /*eslint-enable */. Any idea why this might be? I like the single line approach
– SomethingOn
Oct 17 '16 at 14:43
6
@SomethingOn had the same problem, turned out I had--no-inline-configturned on, whichPrevent comments from changing config or rules
– tibalt
Dec 20 '16 at 11:18
3
Not working with "gulp-eslint": "^3.0.1". I have to use /*eslint-disable */
– olefrank
Jan 22 '17 at 16:46
4
4
Now I get another eslint problem: warning Unexpected comment inline with code no-inline-comments :(
– arcseldon
Dec 19 '15 at 10:59
Now I get another eslint problem: warning Unexpected comment inline with code no-inline-comments :(
– arcseldon
Dec 19 '15 at 10:59
28
28
Works great for me. Also if you don't care about specificity you can just do
//eslint-disable-line and it appears to disable all rules for the given line.– KhalilRavanna
Jan 22 '16 at 17:08
Works great for me. Also if you don't care about specificity you can just do
//eslint-disable-line and it appears to disable all rules for the given line.– KhalilRavanna
Jan 22 '16 at 17:08
6
6
For some reason this doesn't work for me; I'm running eslint 3.8.0. I have to use /*eslint-disable */ and /*eslint-enable */. Any idea why this might be? I like the single line approach
– SomethingOn
Oct 17 '16 at 14:43
For some reason this doesn't work for me; I'm running eslint 3.8.0. I have to use /*eslint-disable */ and /*eslint-enable */. Any idea why this might be? I like the single line approach
– SomethingOn
Oct 17 '16 at 14:43
6
6
@SomethingOn had the same problem, turned out I had
--no-inline-config turned on, which Prevent comments from changing config or rules– tibalt
Dec 20 '16 at 11:18
@SomethingOn had the same problem, turned out I had
--no-inline-config turned on, which Prevent comments from changing config or rules– tibalt
Dec 20 '16 at 11:18
3
3
Not working with "gulp-eslint": "^3.0.1". I have to use /*eslint-disable */
– olefrank
Jan 22 '17 at 16:46
Not working with "gulp-eslint": "^3.0.1". I have to use /*eslint-disable */
– olefrank
Jan 22 '17 at 16:46
|
show 1 more comment
You can use the following
/*eslint-disable */
//suppress all warnings between comments
alert('foo');
/*eslint-enable */
Which is slightly buried the "configuring rules" section of the docs;
To disable a warning for an entire file, you can include a comment at the top of the file e.g.
/*eslint eqeqeq:0*/
Update
ESlint has now been updated with a better way disable a single line, see @goofballLogic's excellent answer.
2
BTW, it seems that the//comment syntax does not work…
– MonsieurDart
Dec 12 '17 at 0:29
Also a side note, i was looking for disabling eslint for one line in html. this works :thumbsup:
– Adil H. Raza
Oct 8 '18 at 8:39
add a comment |
You can use the following
/*eslint-disable */
//suppress all warnings between comments
alert('foo');
/*eslint-enable */
Which is slightly buried the "configuring rules" section of the docs;
To disable a warning for an entire file, you can include a comment at the top of the file e.g.
/*eslint eqeqeq:0*/
Update
ESlint has now been updated with a better way disable a single line, see @goofballLogic's excellent answer.
2
BTW, it seems that the//comment syntax does not work…
– MonsieurDart
Dec 12 '17 at 0:29
Also a side note, i was looking for disabling eslint for one line in html. this works :thumbsup:
– Adil H. Raza
Oct 8 '18 at 8:39
add a comment |
You can use the following
/*eslint-disable */
//suppress all warnings between comments
alert('foo');
/*eslint-enable */
Which is slightly buried the "configuring rules" section of the docs;
To disable a warning for an entire file, you can include a comment at the top of the file e.g.
/*eslint eqeqeq:0*/
Update
ESlint has now been updated with a better way disable a single line, see @goofballLogic's excellent answer.
You can use the following
/*eslint-disable */
//suppress all warnings between comments
alert('foo');
/*eslint-enable */
Which is slightly buried the "configuring rules" section of the docs;
To disable a warning for an entire file, you can include a comment at the top of the file e.g.
/*eslint eqeqeq:0*/
Update
ESlint has now been updated with a better way disable a single line, see @goofballLogic's excellent answer.
edited May 23 '17 at 11:55
Community♦
11
11
answered Jan 1 '15 at 15:53
Nick TomlinNick Tomlin
19.9k84775
19.9k84775
2
BTW, it seems that the//comment syntax does not work…
– MonsieurDart
Dec 12 '17 at 0:29
Also a side note, i was looking for disabling eslint for one line in html. this works :thumbsup:
– Adil H. Raza
Oct 8 '18 at 8:39
add a comment |
2
BTW, it seems that the//comment syntax does not work…
– MonsieurDart
Dec 12 '17 at 0:29
Also a side note, i was looking for disabling eslint for one line in html. this works :thumbsup:
– Adil H. Raza
Oct 8 '18 at 8:39
2
2
BTW, it seems that the
// comment syntax does not work…– MonsieurDart
Dec 12 '17 at 0:29
BTW, it seems that the
// comment syntax does not work…– MonsieurDart
Dec 12 '17 at 0:29
Also a side note, i was looking for disabling eslint for one line in html. this works :thumbsup:
– Adil H. Raza
Oct 8 '18 at 8:39
Also a side note, i was looking for disabling eslint for one line in html. this works :thumbsup:
– Adil H. Raza
Oct 8 '18 at 8:39
add a comment |
You can also disable a specific rule/rules (rather than all) by specifying them in the enable (open) and disable (close) blocks:
/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert */
via @goofballMagic's link above: http://eslint.org/docs/user-guide/configuring.html#configuring-rules
5
Be sure your eslint comments pass eslint! ->Expected exception block, space or tab after '/*' in comment.:)
– Rimian
Dec 29 '17 at 0:57
I use a combination ofprettierandeslintto format my code. This does not allow for inline comments. Many/* eslint-disable-next-line ... */statements are hard to read and to spot in the code.
– Bernhard Döbler
Nov 20 '18 at 13:13
add a comment |
You can also disable a specific rule/rules (rather than all) by specifying them in the enable (open) and disable (close) blocks:
/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert */
via @goofballMagic's link above: http://eslint.org/docs/user-guide/configuring.html#configuring-rules
5
Be sure your eslint comments pass eslint! ->Expected exception block, space or tab after '/*' in comment.:)
– Rimian
Dec 29 '17 at 0:57
I use a combination ofprettierandeslintto format my code. This does not allow for inline comments. Many/* eslint-disable-next-line ... */statements are hard to read and to spot in the code.
– Bernhard Döbler
Nov 20 '18 at 13:13
add a comment |
You can also disable a specific rule/rules (rather than all) by specifying them in the enable (open) and disable (close) blocks:
/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert */
via @goofballMagic's link above: http://eslint.org/docs/user-guide/configuring.html#configuring-rules
You can also disable a specific rule/rules (rather than all) by specifying them in the enable (open) and disable (close) blocks:
/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert */
via @goofballMagic's link above: http://eslint.org/docs/user-guide/configuring.html#configuring-rules
edited Feb 16 '18 at 14:46
answered Jan 8 '16 at 13:36
a darrena darren
6,85843839
6,85843839
5
Be sure your eslint comments pass eslint! ->Expected exception block, space or tab after '/*' in comment.:)
– Rimian
Dec 29 '17 at 0:57
I use a combination ofprettierandeslintto format my code. This does not allow for inline comments. Many/* eslint-disable-next-line ... */statements are hard to read and to spot in the code.
– Bernhard Döbler
Nov 20 '18 at 13:13
add a comment |
5
Be sure your eslint comments pass eslint! ->Expected exception block, space or tab after '/*' in comment.:)
– Rimian
Dec 29 '17 at 0:57
I use a combination ofprettierandeslintto format my code. This does not allow for inline comments. Many/* eslint-disable-next-line ... */statements are hard to read and to spot in the code.
– Bernhard Döbler
Nov 20 '18 at 13:13
5
5
Be sure your eslint comments pass eslint! ->
Expected exception block, space or tab after '/*' in comment. :)– Rimian
Dec 29 '17 at 0:57
Be sure your eslint comments pass eslint! ->
Expected exception block, space or tab after '/*' in comment. :)– Rimian
Dec 29 '17 at 0:57
I use a combination of
prettier and eslint to format my code. This does not allow for inline comments. Many /* eslint-disable-next-line ... */ statements are hard to read and to spot in the code.– Bernhard Döbler
Nov 20 '18 at 13:13
I use a combination of
prettier and eslint to format my code. This does not allow for inline comments. Many /* eslint-disable-next-line ... */ statements are hard to read and to spot in the code.– Bernhard Döbler
Nov 20 '18 at 13:13
add a comment |
Disabling Rules with Inline Comments
http://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments
/* eslint-disable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-enable */
/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-disable no-alert */
alert('foo');
alert('foo'); // eslint-disable-line
// eslint-disable-next-line
alert('foo');
alert('foo'); // eslint-disable-line no-alert
// eslint-disable-next-line no-alert
alert('foo');
alert('foo'); // eslint-disable-line no-alert, quotes, semi
// eslint-disable-next-line no-alert, quotes, semi
alert('foo');
foo(); // eslint-disable-line example/rule-nameadd a comment |
Disabling Rules with Inline Comments
http://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments
/* eslint-disable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-enable */
/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-disable no-alert */
alert('foo');
alert('foo'); // eslint-disable-line
// eslint-disable-next-line
alert('foo');
alert('foo'); // eslint-disable-line no-alert
// eslint-disable-next-line no-alert
alert('foo');
alert('foo'); // eslint-disable-line no-alert, quotes, semi
// eslint-disable-next-line no-alert, quotes, semi
alert('foo');
foo(); // eslint-disable-line example/rule-nameadd a comment |
Disabling Rules with Inline Comments
http://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments
/* eslint-disable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-enable */
/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-disable no-alert */
alert('foo');
alert('foo'); // eslint-disable-line
// eslint-disable-next-line
alert('foo');
alert('foo'); // eslint-disable-line no-alert
// eslint-disable-next-line no-alert
alert('foo');
alert('foo'); // eslint-disable-line no-alert, quotes, semi
// eslint-disable-next-line no-alert, quotes, semi
alert('foo');
foo(); // eslint-disable-line example/rule-nameDisabling Rules with Inline Comments
http://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments
/* eslint-disable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-enable */
/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-disable no-alert */
alert('foo');
alert('foo'); // eslint-disable-line
// eslint-disable-next-line
alert('foo');
alert('foo'); // eslint-disable-line no-alert
// eslint-disable-next-line no-alert
alert('foo');
alert('foo'); // eslint-disable-line no-alert, quotes, semi
// eslint-disable-next-line no-alert, quotes, semi
alert('foo');
foo(); // eslint-disable-line example/rule-name/* eslint-disable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-enable */
/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-disable no-alert */
alert('foo');
alert('foo'); // eslint-disable-line
// eslint-disable-next-line
alert('foo');
alert('foo'); // eslint-disable-line no-alert
// eslint-disable-next-line no-alert
alert('foo');
alert('foo'); // eslint-disable-line no-alert, quotes, semi
// eslint-disable-next-line no-alert, quotes, semi
alert('foo');
foo(); // eslint-disable-line example/rule-name/* eslint-disable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-enable */
/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert, no-console */
/* eslint-disable */
alert('foo');
/* eslint-disable no-alert */
alert('foo');
alert('foo'); // eslint-disable-line
// eslint-disable-next-line
alert('foo');
alert('foo'); // eslint-disable-line no-alert
// eslint-disable-next-line no-alert
alert('foo');
alert('foo'); // eslint-disable-line no-alert, quotes, semi
// eslint-disable-next-line no-alert, quotes, semi
alert('foo');
foo(); // eslint-disable-line example/rule-nameanswered Aug 14 '17 at 1:35
user8202629
add a comment |
add a comment |
The general end of line comment, // eslint-disable-line, does not need anything after it: no need to look up a code to specify what you wish ES Lint to ignore.
If you need to have any syntax ignored for any reason other than a quick debugging, you have problems: why not update your delint config?
I enjoy // eslint-disable-line to allow me to insert console for a quick inspection of a service, without my development environment holding me back because of the breach of protocol. (I generally ban console, and use a logging class - which sometimes builds upon console.)
No offence, but this is the same solution as the accepted answer, so not sure how this helps?
– a darren
Jan 28 '16 at 10:23
1
Good point. I've made it more explicit
– LeeGee
Jan 29 '16 at 8:55
17
Do NOT do this. If you have 5 errors on the line, they will all be ignored. Always explicitly set the rule which is to be ignored or the kids will make a mess.
– Filip Dupanović
Mar 17 '16 at 10:48
3
@FilipDupanović If your programmers can make a mess within a single line of code, just because eslint is not looking over their shoulders for a single line. There is really something else going wrong at your company... That said, saying what rule you wish to ignore makes it more clear why you put the disable line there in the first place.
– Edwin Stoteler
May 2 '16 at 14:14
2
@FilipDupanović Maybe eslint should have a meta rule for requiring explicit rule to ignore? Maybe it already does.
– Josef.B
Dec 3 '16 at 15:39
|
show 1 more comment
The general end of line comment, // eslint-disable-line, does not need anything after it: no need to look up a code to specify what you wish ES Lint to ignore.
If you need to have any syntax ignored for any reason other than a quick debugging, you have problems: why not update your delint config?
I enjoy // eslint-disable-line to allow me to insert console for a quick inspection of a service, without my development environment holding me back because of the breach of protocol. (I generally ban console, and use a logging class - which sometimes builds upon console.)
No offence, but this is the same solution as the accepted answer, so not sure how this helps?
– a darren
Jan 28 '16 at 10:23
1
Good point. I've made it more explicit
– LeeGee
Jan 29 '16 at 8:55
17
Do NOT do this. If you have 5 errors on the line, they will all be ignored. Always explicitly set the rule which is to be ignored or the kids will make a mess.
– Filip Dupanović
Mar 17 '16 at 10:48
3
@FilipDupanović If your programmers can make a mess within a single line of code, just because eslint is not looking over their shoulders for a single line. There is really something else going wrong at your company... That said, saying what rule you wish to ignore makes it more clear why you put the disable line there in the first place.
– Edwin Stoteler
May 2 '16 at 14:14
2
@FilipDupanović Maybe eslint should have a meta rule for requiring explicit rule to ignore? Maybe it already does.
– Josef.B
Dec 3 '16 at 15:39
|
show 1 more comment
The general end of line comment, // eslint-disable-line, does not need anything after it: no need to look up a code to specify what you wish ES Lint to ignore.
If you need to have any syntax ignored for any reason other than a quick debugging, you have problems: why not update your delint config?
I enjoy // eslint-disable-line to allow me to insert console for a quick inspection of a service, without my development environment holding me back because of the breach of protocol. (I generally ban console, and use a logging class - which sometimes builds upon console.)
The general end of line comment, // eslint-disable-line, does not need anything after it: no need to look up a code to specify what you wish ES Lint to ignore.
If you need to have any syntax ignored for any reason other than a quick debugging, you have problems: why not update your delint config?
I enjoy // eslint-disable-line to allow me to insert console for a quick inspection of a service, without my development environment holding me back because of the breach of protocol. (I generally ban console, and use a logging class - which sometimes builds upon console.)
edited May 5 '16 at 7:31
answered Jan 26 '16 at 14:02
LeeGeeLeeGee
4,79132847
4,79132847
No offence, but this is the same solution as the accepted answer, so not sure how this helps?
– a darren
Jan 28 '16 at 10:23
1
Good point. I've made it more explicit
– LeeGee
Jan 29 '16 at 8:55
17
Do NOT do this. If you have 5 errors on the line, they will all be ignored. Always explicitly set the rule which is to be ignored or the kids will make a mess.
– Filip Dupanović
Mar 17 '16 at 10:48
3
@FilipDupanović If your programmers can make a mess within a single line of code, just because eslint is not looking over their shoulders for a single line. There is really something else going wrong at your company... That said, saying what rule you wish to ignore makes it more clear why you put the disable line there in the first place.
– Edwin Stoteler
May 2 '16 at 14:14
2
@FilipDupanović Maybe eslint should have a meta rule for requiring explicit rule to ignore? Maybe it already does.
– Josef.B
Dec 3 '16 at 15:39
|
show 1 more comment
No offence, but this is the same solution as the accepted answer, so not sure how this helps?
– a darren
Jan 28 '16 at 10:23
1
Good point. I've made it more explicit
– LeeGee
Jan 29 '16 at 8:55
17
Do NOT do this. If you have 5 errors on the line, they will all be ignored. Always explicitly set the rule which is to be ignored or the kids will make a mess.
– Filip Dupanović
Mar 17 '16 at 10:48
3
@FilipDupanović If your programmers can make a mess within a single line of code, just because eslint is not looking over their shoulders for a single line. There is really something else going wrong at your company... That said, saying what rule you wish to ignore makes it more clear why you put the disable line there in the first place.
– Edwin Stoteler
May 2 '16 at 14:14
2
@FilipDupanović Maybe eslint should have a meta rule for requiring explicit rule to ignore? Maybe it already does.
– Josef.B
Dec 3 '16 at 15:39
No offence, but this is the same solution as the accepted answer, so not sure how this helps?
– a darren
Jan 28 '16 at 10:23
No offence, but this is the same solution as the accepted answer, so not sure how this helps?
– a darren
Jan 28 '16 at 10:23
1
1
Good point. I've made it more explicit
– LeeGee
Jan 29 '16 at 8:55
Good point. I've made it more explicit
– LeeGee
Jan 29 '16 at 8:55
17
17
Do NOT do this. If you have 5 errors on the line, they will all be ignored. Always explicitly set the rule which is to be ignored or the kids will make a mess.
– Filip Dupanović
Mar 17 '16 at 10:48
Do NOT do this. If you have 5 errors on the line, they will all be ignored. Always explicitly set the rule which is to be ignored or the kids will make a mess.
– Filip Dupanović
Mar 17 '16 at 10:48
3
3
@FilipDupanović If your programmers can make a mess within a single line of code, just because eslint is not looking over their shoulders for a single line. There is really something else going wrong at your company... That said, saying what rule you wish to ignore makes it more clear why you put the disable line there in the first place.
– Edwin Stoteler
May 2 '16 at 14:14
@FilipDupanović If your programmers can make a mess within a single line of code, just because eslint is not looking over their shoulders for a single line. There is really something else going wrong at your company... That said, saying what rule you wish to ignore makes it more clear why you put the disable line there in the first place.
– Edwin Stoteler
May 2 '16 at 14:14
2
2
@FilipDupanović Maybe eslint should have a meta rule for requiring explicit rule to ignore? Maybe it already does.
– Josef.B
Dec 3 '16 at 15:39
@FilipDupanović Maybe eslint should have a meta rule for requiring explicit rule to ignore? Maybe it already does.
– Josef.B
Dec 3 '16 at 15:39
|
show 1 more comment
Answer
You can use an inline comment: // eslint-disable-next-line rule-name.
Example
// eslint-disable-next-line no-console
console.log('eslint will ignore the no-console on this line of code');Reference
ESLint - Disabling Rules with Inline Comments
add a comment |
Answer
You can use an inline comment: // eslint-disable-next-line rule-name.
Example
// eslint-disable-next-line no-console
console.log('eslint will ignore the no-console on this line of code');Reference
ESLint - Disabling Rules with Inline Comments
add a comment |
Answer
You can use an inline comment: // eslint-disable-next-line rule-name.
Example
// eslint-disable-next-line no-console
console.log('eslint will ignore the no-console on this line of code');Reference
ESLint - Disabling Rules with Inline Comments
Answer
You can use an inline comment: // eslint-disable-next-line rule-name.
Example
// eslint-disable-next-line no-console
console.log('eslint will ignore the no-console on this line of code');Reference
ESLint - Disabling Rules with Inline Comments
// eslint-disable-next-line no-console
console.log('eslint will ignore the no-console on this line of code');// eslint-disable-next-line no-console
console.log('eslint will ignore the no-console on this line of code');answered May 17 '17 at 6:58
Brylie Christopher OxleyBrylie Christopher Oxley
524519
524519
add a comment |
add a comment |
To disable a single rule for the rest of the file below:
/* eslint no-undef: "off"*/
const uploadData = new FormData();
or/* eslint-disable no-new */
– Илья Зеленько
Sep 5 '18 at 4:45
add a comment |
To disable a single rule for the rest of the file below:
/* eslint no-undef: "off"*/
const uploadData = new FormData();
or/* eslint-disable no-new */
– Илья Зеленько
Sep 5 '18 at 4:45
add a comment |
To disable a single rule for the rest of the file below:
/* eslint no-undef: "off"*/
const uploadData = new FormData();
To disable a single rule for the rest of the file below:
/* eslint no-undef: "off"*/
const uploadData = new FormData();
answered May 31 '17 at 21:12
Farhan SalamFarhan Salam
484511
484511
or/* eslint-disable no-new */
– Илья Зеленько
Sep 5 '18 at 4:45
add a comment |
or/* eslint-disable no-new */
– Илья Зеленько
Sep 5 '18 at 4:45
or
/* eslint-disable no-new */– Илья Зеленько
Sep 5 '18 at 4:45
or
/* eslint-disable no-new */– Илья Зеленько
Sep 5 '18 at 4:45
add a comment |
single line comment did not work for me inside a react dumb functional component, I have used file level disabling by adding
/* eslint-disable insertEslintErrorDefinitionHere */
(normally if you are using vs code and getting eslint error, you can click on the line which gives error and a bulb would show up in vs code, right click on the light bulb and choose any disable option and vs code will do it for you.)
add a comment |
single line comment did not work for me inside a react dumb functional component, I have used file level disabling by adding
/* eslint-disable insertEslintErrorDefinitionHere */
(normally if you are using vs code and getting eslint error, you can click on the line which gives error and a bulb would show up in vs code, right click on the light bulb and choose any disable option and vs code will do it for you.)
add a comment |
single line comment did not work for me inside a react dumb functional component, I have used file level disabling by adding
/* eslint-disable insertEslintErrorDefinitionHere */
(normally if you are using vs code and getting eslint error, you can click on the line which gives error and a bulb would show up in vs code, right click on the light bulb and choose any disable option and vs code will do it for you.)
single line comment did not work for me inside a react dumb functional component, I have used file level disabling by adding
/* eslint-disable insertEslintErrorDefinitionHere */
(normally if you are using vs code and getting eslint error, you can click on the line which gives error and a bulb would show up in vs code, right click on the light bulb and choose any disable option and vs code will do it for you.)
answered Feb 20 at 22:56
SidSid
15914
15914
add a comment |
add a comment |
You can add the files which give error to .eslintignore file in your project.Like for all the .vue files just add /*.vue
3
it asked for one line, not the whole file
– Kevin Danikowski
Jul 30 '18 at 15:44
add a comment |
You can add the files which give error to .eslintignore file in your project.Like for all the .vue files just add /*.vue
3
it asked for one line, not the whole file
– Kevin Danikowski
Jul 30 '18 at 15:44
add a comment |
You can add the files which give error to .eslintignore file in your project.Like for all the .vue files just add /*.vue
You can add the files which give error to .eslintignore file in your project.Like for all the .vue files just add /*.vue
answered Jul 12 '18 at 13:25
Yubin ShinhmarYubin Shinhmar
14
14
3
it asked for one line, not the whole file
– Kevin Danikowski
Jul 30 '18 at 15:44
add a comment |
3
it asked for one line, not the whole file
– Kevin Danikowski
Jul 30 '18 at 15:44
3
3
it asked for one line, not the whole file
– Kevin Danikowski
Jul 30 '18 at 15:44
it asked for one line, not the whole file
– Kevin Danikowski
Jul 30 '18 at 15:44
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f27732209%2fturning-off-eslint-rule-for-a-specific-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
35
Use
eslint-disable-next-line:– Brylie Christopher Oxley
May 17 '17 at 6:53