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

add fixer for first - #1046

Merged
benmosher merged 6 commits into
import-js:masterfrom
fnknzzz:dev
Mar 30, 2018
Merged

benmosher merged 6 commits into
import-js:masterfrom
fnknzzz:dev

Conversation

@fnknzzz

@fnknzzz fnknzzz commented Mar 14, 2018

Copy link
Copy Markdown
Contributor

Add autofixer for rule first. Refer issue #1040.

@coveralls

coveralls commented Mar 14, 2018 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.2%) to 96.458% when pulling 2429205 on fengkfengk:dev into 158f4e8 on benmosher:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-1.2%) to 95.011% when pulling c638fdd on fengkfengk:dev into 158f4e8 on benmosher:master.

Comment thread tests/src/rules/first.js
import { z } from './baz';\
export { x };"
})
, test({ code: "import { x } from './foo'; import { y } from 'bar'"

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.

can we validate that the output matches the input here?

Comment thread tests/src/rules/first.js Outdated
, errors: 3
, output: "import { x } from './foo';\
import { y } from './bar';\
import { z } from './baz';\nvar foo = bar;"

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.

nbd but could this use a continuation instead of a literal \n?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it must be a seperator here. I thought a line-breaker is suitable, or may be another option?

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.

It just looks odd to see the previous lines using \ but this one using \n

Comment thread tests/src/rules/first.js Outdated
import { z } from './baz';"
, errors: 2
, output: "import { y } from './bar';\
import { z } from './baz';\nvar a = x;\

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.

this is actually incorrect; because foo might depend on side effects from bar and baz - this example can't be reordered at all.

Comment thread tests/src/rules/first.js Outdated
import { y } from './bar';\
import { z } from './baz';"
, errors: 3
, output: "import { x } from './foo';\

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.

same here.

@ljharb

ljharb commented Mar 16, 2018

Copy link
Copy Markdown
Member

Are you no longer interested in completing this PR?

(If so, please reopen this one instead of opening another)

@fnknzzz fnknzzz reopened this Mar 24, 2018
@fnknzzz

fnknzzz commented Mar 24, 2018

Copy link
Copy Markdown
Contributor Author

now if a specifier is referenced before the import, it won't be reordered.

@ljharb
ljharb requested review from benmosher and jfmengels March 25, 2018 21:57

@benmosher benmosher left a comment

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.

I don't know anything about fixers but the tests look good 👍

@ljharb

ljharb commented Mar 28, 2018

Copy link
Copy Markdown
Member

@fengkfengk now we just need to get coverage metrics back up, and we can merge this!

@fnknzzz

fnknzzz commented Mar 30, 2018

Copy link
Copy Markdown
Contributor Author

now the coverage improved, some unreachable lines are fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants