File tree Expand file tree Collapse file tree
packages/eslint-config-airbnb-base/rules Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1165,6 +1165,25 @@ Other Style Guides
11651165 export default function foo() {}
11661166 ```
11671167
1168+ <a name="modules--imports-first"></a>
1169+ - [10.7](#modules--imports-first) Put all `import`s above non-import statements.
1170+ eslint: [`import/imports-first`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md)
1171+ > Why? Since `import`s are hoisted, keeping them all at the top prevents surprising behavior.
1172+
1173+ ```javascript
1174+ // bad
1175+ import foo from ' foo' ;
1176+ foo.init();
1177+
1178+ import bar from ' bar' ;
1179+
1180+ // good
1181+ import foo from ' foo' ;
1182+ import bar from ' bar' ;
1183+
1184+ foo.init();
1185+ ```
1186+
11681187**[⬆ back to top](#table-of-contents)**
11691188
11701189## Iterators and Generators
Original file line number Diff line number Diff line change @@ -86,8 +86,7 @@ module.exports = {
8686
8787 // disallow non-import statements appearing before import statements
8888 // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md
89- // TODO: enable?
90- 'import/imports-first' : [ 0 , 'absolute-first' ] ,
89+ 'import/imports-first' : [ 2 , 'absolute-first' ] ,
9190
9291 // disallow duplicate imports
9392 // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
You can’t perform that action at this time.
0 commit comments