chefcurry7 chefcurry7 - 2 days ago 6
Javascript Question

Inline eslint comment in JSX

I'm getting an error

(eslint): Line 199 exceeds maximum line length of 120. (max-len)


Why doesn't this inline comment work?

{/* eslint-disable-next-line max-len */}
<Chip ref="code" style={styles.chip}backgroundColor={this.state.filterSelected['School Code'] && blue300}onTouchTap={this.handleTouchTap} >
<Avatar size={32}>C</Avatar>
School Code
</Chip>

Answer

eslint-disable-line and eslint-disable-next-line are supported in only line comments.

There is currently an open issue for this in eslint: https://github.com/eslint/eslint/issues/7030

So you would have to write it as the following:

{
  // eslint-disable-next-line max-len
}
<Chip ref="code" style={styles.chip}backgroundColor={this.state.filterSelected['School Code'] && blue300}onTouchTap={this.handleTouchTap} >
            <Avatar size={32}>C</Avatar>
            School Code
</Chip>
Comments