Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

💄🐷 sort-imports eslint rule #712

Merged
merged 1 commit into from
May 29, 2017

Conversation

kevinansfield
Copy link
Member

no issue

  • adds eslint-plugin-sort-imports-es6-autofix dependency
    • implements ESLint's base sort-imports rule but has a distinction in that import {foo} from 'bar'; is considered multiple rather than single
    • fixes ESLint's autofix behaviour so eslint --fix will actually fix the sort order
  • updates all unordered import rules by using eslint --fix

With the increased number of import statements since Ember+ecosystem started moving towards es6 modules I've found it frustrating at times trying to search through randomly ordered import statements. Recently I've been sorting imports manually when I've added new code or touched old code so I thought I'd add an ESLint rule to codify and automate it.

Copy link
Member

@acburdine acburdine left a comment

Choose a reason for hiding this comment

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

LGTM - will try running Travis again to see if tests pass.

@kevinansfield
Copy link
Member Author

Hmm, what was the error? I already restarted it once, it looked it failed when connecting to npm 😕

@acburdine
Copy link
Member

Looks like a syntax error from the mirage config.js

@kevinansfield
Copy link
Member Author

kevinansfield commented May 29, 2017

Ugh, it's another node v4 incompatibility 😞 I've been running into these more and more frequently lately.

I'll see if there's a quick-fix by forking the eslint-plugin-sort-imports-es6-autofix dependency whilst opening a PR.

no issue
- adds `eslint-plugin-sort-imports-es6-autofix` dependency
  - implements ESLint's base `sort-imports` rule but has a distinction in that `import {foo} from 'bar';` is considered `multiple` rather than `single`
  - fixes ESLint's autofix behaviour so `eslint --fix` will actually fix the sort order
- updates all unordered import rules by using `eslint --fix`

With the increased number of `import` statements since Ember+ecosystem started moving towards es6 modules I've found it frustrating at times trying to search through randomly ordered import statements. Recently I've been sorting imports manually when I've added new code or touched old code so I thought I'd add an ESLint rule to codify it.
@kevinansfield
Copy link
Member Author

Updated with a fork of the eslint plugin, upstream PR has been opened, hopefully it'll be merged and we can remove the custom fork.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 72.682% when pulling 6457eac on kevinansfield:sort-imports into ddc8aed on TryGhost:master.

@kirrg001 kirrg001 self-requested a review May 29, 2017 18:37
Copy link
Contributor

@kirrg001 kirrg001 left a comment

Choose a reason for hiding this comment

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

pretty cool 👍

It's recommended to use the local installation of eslint.

node_modules/eslint/bin/eslint.js --fix ./app

@kirrg001 kirrg001 merged commit 7eefbba into TryGhost:master May 29, 2017
@kevinansfield kevinansfield deleted the sort-imports branch June 4, 2018 10:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants