-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adapt to new eslint flat config (#277)
- Loading branch information
Showing
4 changed files
with
108 additions
and
6 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
module.exports = [ | ||
{ | ||
rules: { | ||
semi: 'error', | ||
'prefer-const': 'error' | ||
} | ||
} | ||
]; |
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,58 @@ | ||
/*eslint-env mocha*/ | ||
'use strict'; | ||
|
||
const { assert } = require('@sinonjs/referee-sinon'); | ||
const api = require('eslint'); | ||
const unsupported = require('../node_modules/eslint/lib/unsupported-api'); | ||
const caches = require('../lib/caches'); | ||
const linter = require('../lib/linter'); | ||
|
||
describe('flat-config', () => { | ||
|
||
beforeEach(() => { | ||
caches.lru_cache.clear(); | ||
delete process.env.ESLINT_USE_FLAT_CONFIG; | ||
}); | ||
afterEach(() => { | ||
caches.lru_cache.clear(); | ||
delete process.env.ESLINT_USE_FLAT_CONFIG; | ||
}); | ||
|
||
describe('without flat config', () => { | ||
it('resolves ESLint class', async () => { | ||
const cache = await caches.getCache(process.cwd()); | ||
|
||
assert.equals(typeof cache.eslint.ESLint, typeof api.ESLint); | ||
assert.isUndefined(cache.eslint.FlatESLint); | ||
}); | ||
|
||
it('runs lint with ESLint class', async () => { | ||
await linter.invoke(process.cwd(), ['.'], undefined, () => null); | ||
}); | ||
}); | ||
|
||
describe('with flat configV', () => { | ||
it('resolves FlatESLint class', async () => { | ||
process.env.ESLINT_USE_FLAT_CONFIG = 'true'; | ||
|
||
const cache = await caches.getCache(process.cwd()); | ||
|
||
assert.equals( | ||
typeof cache.eslint.FlatESLint, | ||
typeof unsupported.FlatESLint | ||
); | ||
assert.isUndefined(cache.eslint.ESLint); | ||
}); | ||
|
||
it('runs lint with FlatESLint class', async () => { | ||
process.env.ESLINT_USE_FLAT_CONFIG = 'true'; | ||
|
||
await linter.invoke( | ||
process.cwd(), | ||
['-c', `${process.cwd()}/test/fixture/eslint.config.js`], | ||
undefined, | ||
() => null | ||
); | ||
}); | ||
}); | ||
}); |