Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix order's newlines-between edge cases #339

Merged
merged 4 commits into from
May 14, 2016
Merged

Fix order's newlines-between edge cases #339

merged 4 commits into from
May 14, 2016

Conversation

singles
Copy link
Contributor

@singles singles commented May 13, 2016

Fixes all issues mentioned in #313:

  1. Empty lines between multiline import statements are detected correctly.
  2. Not assigned imports are ignored (see comments).
  3. require used inside objects are ignored.

It also changes requirement - there's no specific limit about 1 empty line between groups. Now it has to be at least 1. If one would like to have only one, then no-multiple-empty-lines core rule can be used (thx @lo1tuma for hint!).

I'm not 100% sure about implementation for last one - it works for provided test cases, yet I could use another pair of eyes.

Radek Benkel added 2 commits May 13, 2016 23:49
to be at least one, not exactly one

Before it was 1. To prevent multiple lines between imports, core
`no-multiple-empty-lines` rule can be used.
@singles singles changed the title Fix order newline edge cases Fix order's newlines-between edge cases May 14, 2016
@@ -110,28 +110,33 @@ function convertGroupsToRanks(groups) {
}

function makeNewlinesBetweenReport (context, imported, newlinesBetweenImports) {
const getLineDifference = (currentImport, previousImport) => {
return currentImport.node.loc.start.line - previousImport.node.loc.start.line
const getNumberOfEmptyLinesBeetwen = (currentImport, previousImport) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Between :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx, fixed.

Radek Benkel added 2 commits May 14, 2016 09:24
Previously it was calculated based on `loc` property of nodes. Counting
REAL empty lines is less error-prone.
@jfmengels
Copy link
Collaborator

jfmengels commented May 14, 2016

LGTM, thanks @singles :)

@benmosher benmosher merged commit 0a918b1 into import-js:master May 14, 2016
@singles singles deleted the fix-order-newline-edge-cases branch May 14, 2016 14:44
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.

None yet

3 participants