-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint-config): set import/no-cycle to error (#206)
* feat(eslint-config): set import/no-cycle to error * test(eslint-config): add import-happy & import-unhappy tests
- Loading branch information
Showing
9 changed files
with
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export function a() {} |
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,3 @@ | ||
import './import-unhappy.fixture'; | ||
|
||
export function b() {} |
3 changes: 3 additions & 0 deletions
3
packages/eslint-config/test/import/__fixtures__/import-happy.fixture.js
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,3 @@ | ||
import { a } from './dep-a'; | ||
|
||
a(); |
3 changes: 3 additions & 0 deletions
3
packages/eslint-config/test/import/__fixtures__/import-unhappy.fixture.js
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,3 @@ | ||
import { b } from './dep-b'; | ||
|
||
b(); |
3 changes: 3 additions & 0 deletions
3
packages/eslint-config/test/import/__snapshots__/import-happy.test.js.snap
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`import / happy path happy 1`] = `""`; |
13 changes: 13 additions & 0 deletions
13
packages/eslint-config/test/import/__snapshots__/import-unhappy.test.js.snap
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,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`import / unhappy path unhappy 1`] = ` | ||
"error: Dependency cycle detected (import/no-cycle) at packages/eslint-config/test/import/__fixtures__/import-unhappy.fixture.js:1:1: | ||
> 1 | import { b } from './dep-b'; | ||
| ^ | ||
2 | | ||
3 | b(); | ||
4 | | ||
1 error found." | ||
`; |
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,27 @@ | ||
import ESlint from 'eslint'; | ||
import path from 'path'; | ||
|
||
describe('import / happy path', () => { | ||
const cli = new ESlint.CLIEngine({ | ||
cwd: path.join(__dirname, '..'), | ||
useEslintrc: false, | ||
baseConfig: { | ||
extends: ['../internal/import'], | ||
parserOptions: { | ||
sourceType: 'module', | ||
}, | ||
env: { | ||
es6: true, | ||
}, | ||
}, | ||
}); | ||
|
||
it('happy', () => { | ||
const codeframe = cli.getFormatter('codeframe'); | ||
const report = cli.executeOnFiles([ | ||
path.join(__dirname, './__fixtures__/import-happy.fixture.js'), | ||
]); | ||
|
||
expect(codeframe(report.results)).toMatchSnapshot(); | ||
}); | ||
}); |
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,27 @@ | ||
import ESlint from 'eslint'; | ||
import path from 'path'; | ||
|
||
describe('import / unhappy path', () => { | ||
const cli = new ESlint.CLIEngine({ | ||
cwd: path.join(__dirname, '..'), | ||
useEslintrc: false, | ||
baseConfig: { | ||
extends: ['../internal/import'], | ||
parserOptions: { | ||
sourceType: 'module', | ||
}, | ||
env: { | ||
es6: true, | ||
}, | ||
}, | ||
}); | ||
|
||
it('unhappy', () => { | ||
const codeframe = cli.getFormatter('codeframe'); | ||
const report = cli.executeOnFiles([ | ||
path.join(__dirname, './__fixtures__/import-unhappy.fixture.js'), | ||
]); | ||
|
||
expect(codeframe(report.results)).toMatchSnapshot(); | ||
}); | ||
}); |