Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline eslint comment in JSX

Tags:

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> 
like image 914
chefcurry7 Avatar asked Nov 30 '16 04:11

chefcurry7


2 Answers

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

There is currently an open issue for this in eslint

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> 
like image 138
Daniel Bank Avatar answered Oct 18 '22 05:10

Daniel Bank


Daniel's answer works fine, but it breaks "jsx-one-expression-per-line".

Latest version of eslint (6.5.1) supports the multi-line comment method as shown in question. There isn't need to change anything.

like image 39
Vikas Kumar Avatar answered Oct 18 '22 06:10

Vikas Kumar