-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from stephdotnet/sort-imports-ignored
- Loading branch information
Showing
15 changed files
with
196 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { getImportNodes } from '../get-import-nodes'; | ||
import { isSortImportsIgnored } from '../is-sort-imports-ignored'; | ||
|
||
const codeIgnored = `// sort-imports-ignore | ||
// second comment | ||
import z from 'z'; | ||
`; | ||
|
||
const codeNotIgnored = `// second comment | ||
import z from 'z'; | ||
`; | ||
|
||
test('it should return true if specific leading comment detected', () => { | ||
const importNodes = getImportNodes(codeIgnored); | ||
|
||
expect(isSortImportsIgnored(importNodes)).toBeTruthy(); | ||
}); | ||
|
||
test('it should return false if no specific leading comment detected', () => { | ||
const importNodes = getImportNodes(codeNotIgnored); | ||
|
||
expect(isSortImportsIgnored(importNodes)).toBeFalsy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Statement } from '@babel/types'; | ||
|
||
import { sortImportsIgnoredComment } from '../constants'; | ||
import { getAllCommentsFromNodes } from './get-all-comments-from-nodes'; | ||
|
||
export const isSortImportsIgnored = (nodes: Statement[]) => | ||
getAllCommentsFromNodes(nodes).some( | ||
(comment) => | ||
comment.loc.start.line === 1 && | ||
comment.value.includes(sortImportsIgnoredComment), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// sort-imports-ignore | ||
|
||
import './commands'; | ||
import b from 'b'; | ||
import a from 'a'; | ||
|
||
// Comment | ||
|
||
function add(a:number,b:number) { | ||
return a + b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// sort-imports-ignore | ||
|
||
import './commands'; | ||
import b from 'b'; | ||
import a from 'a'; | ||
|
||
// Comment | ||
|
||
function add(a:number,b:number) { | ||
return a + b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// sort-imports-ignore | ||
|
||
import './commands'; | ||
import b from 'b'; | ||
import a from 'a'; | ||
|
||
// Comment | ||
|
||
function add(a:number,b:number) { | ||
return a + b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// sort-imports-ignore | ||
|
||
import './commands'; | ||
import b from 'b'; | ||
import a from 'a'; | ||
|
||
// Comment | ||
|
||
function add(a:number,b:number) { | ||
return a + b; | ||
} |