Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Fix [ordered-imports] "import-sources-order": any invalidate "grouped-imports" #4374

Merged
merged 2 commits into from
Dec 12, 2018
Merged

Fix [ordered-imports] "import-sources-order": any invalidate "grouped-imports" #4374

merged 2 commits into from
Dec 12, 2018

Conversation

rrogowski
Copy link
Contributor

@rrogowski rrogowski commented Dec 12, 2018

PR checklist

Overview of change:

Fixed bug where ImportsBlock always had the ImportType set to LIBRARY_IMPORT when the import-sources-order rule is set to any.

Is there anything you'd like reviewers to focus on?

I recommend toggling Hide Whitespace Changes so that the diff of getImportType is cleaner and clearer.

Moved getImportType outside of ImportsBlock class. Only referenced in one location as a helper function, and has no dependency on the state of an ImportsBlock, so it seems okay to separate it out. Could also make it a public static method and keep it inside the class, if so desired. Open to other suggestions!

CHANGELOG.md entry:

[bugfix][import-sources-order] Setting import-sources-order: any no longer invalidates grouped-imports: true

@ericanderson ericanderson merged commit f6044a5 into palantir:master Dec 12, 2018
ericanderson added a commit that referenced this pull request Dec 12, 2018
@rrogowski rrogowski deleted the rogowski-bugfix-4338 branch December 12, 2018 20:04
@abierbaum abierbaum mentioned this pull request Jan 15, 2019
4 tasks
abierbaum added a commit to abierbaum/tslint that referenced this pull request Jan 16, 2019
This change updates the refactored "group" based orderedImports
code to handle the cases fixed in the following previous PRs:

- palantir#4374: fixed grouping for import-sources-order
- palantir#3733: check all imports of same type are grouped

As part of this we removed the concept of ImportType as this
is now covered by the defined groups for sorting.

Moved the check for ensuring groups are not standing alone
into the code checkBlocksGroup() code where other group checks
are done.

Ex:
```
import './baa';
import './baz';

import './caa';  // this should fail
```

Also had to update several other test cases to include the failure
notice about import groups needing to be together.
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.

2 participants