Sitelet https://github.com/import-js/eslint-plugin-import/pull/1253
Skip to content

[import/order] Fix incorrect import reordering - #1253

Merged
ljharb merged 1 commit into
import-js:masterfrom
tihonove:master
Oct 9, 2019
Merged

ljharb merged 1 commit into
import-js:masterfrom
tihonove:master

Conversation

@tihonove

@tihonove tihonove commented Jan 3, 2019

Copy link
Copy Markdown
Contributor

Closes #1252

Fixes #1252.

 - Reordering import statement to line below ignores uncrossable statements
 - Add more tests for ordering around function call
@coveralls

coveralls commented Jan 3, 2019 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.1%) to 96.209% when pulling e62011f on tihonove:master into c14c9bd on benmosher:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 97.292% when pulling 9426cfb on tihonove:master into 1cd82eb on benmosher:master.

9 similar comments
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 97.292% when pulling 9426cfb on tihonove:master into 1cd82eb on benmosher:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 97.292% when pulling 9426cfb on tihonove:master into 1cd82eb on benmosher:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 97.292% when pulling 9426cfb on tihonove:master into 1cd82eb on benmosher:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 97.292% when pulling 9426cfb on tihonove:master into 1cd82eb on benmosher:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 97.292% when pulling 9426cfb on tihonove:master into 1cd82eb on benmosher:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 97.292% when pulling 9426cfb on tihonove:master into 1cd82eb on benmosher:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 97.292% when pulling 9426cfb on tihonove:master into 1cd82eb on benmosher:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 97.292% when pulling 9426cfb on tihonove:master into 1cd82eb on benmosher:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 97.292% when pulling 9426cfb on tihonove:master into 1cd82eb on benmosher:master.

@tihonove

tihonove commented Jan 3, 2019

Copy link
Copy Markdown
Contributor Author

I have no idea why ci builds failed. Seams like build for eslint5 broken.

Comment thread tests/src/rules/order.js
@ljharb

ljharb commented Feb 12, 2019

Copy link
Copy Markdown
Member

@tihonove can you rebase this?

@tilgovi

tilgovi commented Sep 19, 2019

Copy link
Copy Markdown

Anything I can do to help?

Comment thread tests/src/rules/order.js
fn_call();

const global1 = require('global1');
const global2 = require('global2');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without the fix, i get this output (and a test failure):

AssertionError [ERR_ASSERTION] [ERR_ASSERTION]: Output is incorrect.
+ expected
- actual
 
+        const local = require('./local');
 
         fn_call();
 
         const global1 = require('global1');
         const global2 = require('global2');
-        const local = require('./local');
 
         fn_call();

Comment thread tests/src/rules/order.js
// reorder fix cannot cross function call on moving below #2
test({
code: `
const local = require('./local');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AssertionError [ERR_ASSERTION] [ERR_ASSERTION]: Output is incorrect.
+ expected
- actual
 
+        const local = require('./local');
         fn_call();
         const global1 = require('global1');
         const global2 = require('global2');
-        const local = require('./local');
 
         fn_call();

Comment thread tests/src/rules/order.js
// reorder fix cannot cross function call on moving below #3
test({
code: `
const local1 = require('./local1');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AssertionError [ERR_ASSERTION] [ERR_ASSERTION]: Output is incorrect.
+ expected
- actual
 
+        const local1 = require('./local1');
         const local2 = require('./local2');
         const local3 = require('./local3');
         const local4 = require('./local4');
         fn_call();
         const global2 = require('global2');
         const global3 = require('global3');
         const global4 = require('global4');
         const global5 = require('global5');
-        const local1 = require('./local1');
         fn_call();

Comment thread tests/src/rules/order.js
// reorder fix cannot cross function call on moving below
test(withoutAutofixOutput({
code: `
const local = require('./local');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AssertionError [ERR_ASSERTION] [ERR_ASSERTION]: Output is incorrect.
+ expected
- actual
 
+        const local = require('./local');
         const global1 = require('global1');
         const global2 = require('global2');
         fn_call();
         const global3 = require('global3');
-        const local = require('./local');
 
         fn_call();

Comment thread tests/src/rules/order.js
const global1 = require('global1');
const global2 = require('global2');
fn_call();
const local2 = require('./local2');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AssertionError [ERR_ASSERTION] [ERR_ASSERTION]: Output is incorrect.
+ expected
- actual
 
+        const local1 = require('./local1');
         const global1 = require('global1');
         const global2 = require('global2');
         fn_call();
-        const local2 = require('./local2');
         const global3 = require('global3');
         const global4 = require('global4');
-        const local1 = require('./local1');
+        const local2 = require('./local2');
 
         fn_call();

Comment thread tests/src/rules/order.js
code: `
const env = require('./config');

Object.keys(env);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AssertionError [ERR_ASSERTION] [ERR_ASSERTION]: Output is incorrect.
+ expected - actual
 
+        const env = require('./config');
 
         Object.keys(env);
 
         const http = require('http');
         const express = require('express');
-        const env = require('./config');
 
         http.createServer(express());

@ljharb
ljharb merged commit e62011f into import-js:master Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

autofix "import/order" will produce new problems?

4 participants