-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve logic for detecting when to use flat config format
- Don't try to use flat config format on eslint versions that don't support it - Respect `process.env.ESLINT_USE_FLAT_CONFIG`
- Loading branch information
Showing
8 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
integrationTests/__fixtures__/legacy-config-at-eslint.config.js/__eslint__/file.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 @@ | ||
const a = 1; | ||
|
||
console.log('a', a); |
5 changes: 5 additions & 0 deletions
5
integrationTests/__fixtures__/legacy-config-at-eslint.config.js/eslint.config.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,5 @@ | ||
module.exports = { | ||
rules: { | ||
'no-console': 'error', | ||
}, | ||
}; |
3 changes: 3 additions & 0 deletions
3
integrationTests/__fixtures__/legacy-config-at-eslint.config.js/jest-runner-eslint.config.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 @@ | ||
module.exports = { | ||
config: './eslint.config.js', | ||
}; |
4 changes: 4 additions & 0 deletions
4
integrationTests/__fixtures__/legacy-config-at-eslint.config.js/jest.config.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,4 @@ | ||
module.exports = { | ||
runner: '../../../', | ||
testMatch: ['**/__eslint__/**/*.js'], | ||
}; |
22 changes: 22 additions & 0 deletions
22
integrationTests/__snapshots__/legacy-config-at-eslint.config.js.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,22 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Does not try to use flat config on eslint versions that don't support it 1`] = ` | ||
"PASS __eslint__/file.js | ||
● Console | ||
console.warn | ||
/mocked-path-to-jest-runner-mocha/integrationTests/__fixtures__/legacy-config-at-eslint.config.js/__eslint__/file.js | ||
3:1 warning Unexpected console statement no-console | ||
✖ 1 problem (0 errors, 1 warning) | ||
✓ ESLint | ||
Test Suites: 1 passed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: | ||
Ran all test suites. | ||
" | ||
`; |
12 changes: 12 additions & 0 deletions
12
integrationTests/legacy-config-at-eslint.config.js.test.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,12 @@ | ||
const { version } = require('eslint/package.json'); | ||
const semver = require('semver'); | ||
const runJest = require('./runJest'); | ||
|
||
(semver.satisfies(version, '<8') ? it : it.skip)( | ||
"Does not try to use flat config on eslint versions that don't support it", | ||
async () => { | ||
expect( | ||
await runJest('legacy-config-at-eslint.config.js'), | ||
).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
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