Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Import in body of module; reorder to top import/first" ESLint (ReactJs)

When compiling my ReactJs code I get the following error import/first error:

enter image description here

The solutions presented in similar questions don't seem to work for me.

The ../recharts/es6/index.js file looks something like this:

import _Brush from './cartesian/Brush';
export { _Brush as Brush };
import _ReferenceLine from './cartesian/ReferenceLine';
export { _ReferenceLine as ReferenceLine };
import _ReferenceDot from './cartesian/ReferenceDot';
export { _ReferenceDot as ReferenceDot };
import _ReferenceArea from './cartesian/ReferenceArea';
export { _ReferenceArea as ReferenceArea };

My question, therefore, how does one disable the import/first rule for ESLint? Or might the error be due to something else entirely?

like image 798
G.Musgrave Avatar asked Nov 18 '22 15:11

G.Musgrave


1 Answers

I just resolved this error in one of my auto generated files. In my .ts source file the import rule (any and all imports must be at the top of the file) was followed but the generated .js had imports after some polyfills so I added this line to the top of my file to get around it:
/* eslint-disable import/first */

*note: the comments have already mentioned this solution. just adding this so the question can have an answer.

like image 58
ItIsEntropy Avatar answered Dec 09 '22 19:12

ItIsEntropy