Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve type suggestions with specific defineFlatConfig (#150)
Co-authored-by: Shinigami92 <chrissi92@hotmail.de>
- Loading branch information
1 parent
a0ee545
commit c83e66c
Showing
7 changed files
with
69 additions
and
25 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,9 +1,7 @@ | ||
/** | ||
* Define an eslint config. | ||
* | ||
* @param config Eslint config. | ||
* @returns Eslint config. | ||
*/ | ||
export function defineConfig(config) { | ||
return config; | ||
} | ||
|
||
export function defineFlatConfig(config) { | ||
return config; | ||
} |
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,49 @@ | ||
import { expectTypeOf } from 'expect-type'; | ||
import { describe, test } from 'vitest'; | ||
import type { ESLintConfig, FlatESLintConfig } from '../src'; | ||
import { defineConfig, defineFlatConfig } from '../src'; | ||
|
||
describe('define', () => { | ||
test('define empty config', () => { | ||
expectTypeOf(defineConfig({})).toEqualTypeOf<ESLintConfig>(); | ||
}); | ||
|
||
test('define ESLint config', () => { | ||
expectTypeOf( | ||
defineConfig({ | ||
env: {}, | ||
extends: [], | ||
rules: {}, | ||
}), | ||
).toEqualTypeOf<ESLintConfig>(); | ||
}); | ||
|
||
test('define an item of flat ESLint config', () => { | ||
expectTypeOf( | ||
defineFlatConfig({ | ||
ignores: [], | ||
plugins: {}, | ||
rules: {}, | ||
}), | ||
).toEqualTypeOf<FlatESLintConfig>(); | ||
}); | ||
|
||
test('define predefined flat ESLint config', () => { | ||
expectTypeOf( | ||
defineFlatConfig('eslint:recommended'), | ||
).toEqualTypeOf<FlatESLintConfig>(); | ||
}); | ||
|
||
test('define flat ESLint config', () => { | ||
expectTypeOf( | ||
defineFlatConfig([ | ||
'eslint:recommended', | ||
{ | ||
ignores: [], | ||
plugins: {}, | ||
rules: {}, | ||
}, | ||
]), | ||
).toEqualTypeOf<FlatESLintConfig[]>(); | ||
}); | ||
}); |