disable-next-line doesn't work with react rules in JSX
See original GitHub issueWhen using // eslint-disable-next-line react/jsx-no-bind
inside JSX, the violation is not ignored as expected.
Ignoring a built-in rule, e.g. arrow-parens
, works as expected (demo). I am only seeing this with react/
rules, like react/jsx-no-bind
or react/forbid-dom-props
.
To reproduce, lint the following code snippet with
import React from 'react'
const Comp1 = () => null
const Comp2 = () => (
<Comp1
key={1}
// eslint-disable-next-line react/jsx-no-bind
onChange={isVisible => onChangeVisibility(isVisible, i)}
></Comp1>
)
If you move the prop up to be the first prop, it works:
import React from 'react'
const Comp1 = () => null
const Comp2 = () => (
<Comp1
// eslint-disable-next-line react/jsx-no-bind
onChange={isVisible => onChangeVisibility(isVisible, i)}
key={1}
></Comp1>
)
Any other rule works too:
import React from 'react'
const Comp1 = () => null
const Comp2 = () => (
<Comp1
key={1}
// eslint-disable-next-line arrow-parens
onChange={isVisible => onChangeVisibility(isVisible, i)}
></Comp1>
)
eslint@5.16.0
eslint-plugin-react@7.14.3
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:14 (7 by maintainers)
Top Results From Across the Web
disable-next-line doesn't work with react rules in JSX #2369
I am only seeing this with react/ rules, like react/jsx-no-bind or react/forbid-dom-props . To reproduce, lint the following code snippet with.
Read more >Inline eslint comment in JSX - Stack Overflow
I think this solution will work with 'prettier' code. { // eslint-disable-next-line max-len <Chip ref="code" ...
Read more >no-console - ESLint - Pluggable JavaScript Linter
This rule disallows calls or assignments to methods of the console object. ... eslint-disable-next-line no-console console.error = function (message) ...
Read more >Introducing JSX - React
It is called JSX, and it is a syntax extension to JavaScript. ... React doesn't require using JSX, but most people find it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
this is a bit stale, but since it’s not closed, and in case anyone else runs into this thread, have you tried surrounding the rule in brackets, e.g.
{ /* eslint-disable-next-line react/jsx-no-bind */ }
?could look like this:
or this:
I just did something like that in a project after being stuck for a while and it worked. found the solution here: https://github.com/eslint/eslint/issues/7030
I have got the same issue, too. /* eslint-disable */ for multi-line does not work either.