mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
@types/eslint: Flat config support in Linter (#65668)
This commit is contained in:
@@ -692,6 +692,57 @@ const _processor: Linter.Processor = {
|
||||
},
|
||||
};
|
||||
|
||||
//#region Linter with flat config
|
||||
|
||||
const linterWithFlatConfig = new Linter({ configType: 'flat' });
|
||||
|
||||
linterWithFlatConfig.version;
|
||||
|
||||
linterWithFlatConfig.verify(SOURCE, [{}]);
|
||||
linterWithFlatConfig.verify(new SourceCode(SOURCE, AST), [{}]);
|
||||
|
||||
linterWithFlatConfig.verify(SOURCE, [{}], 'test.js');
|
||||
linterWithFlatConfig.verify(SOURCE, [{}], {});
|
||||
linterWithFlatConfig.verify(SOURCE, [{}], { filename: 'test.js' });
|
||||
linterWithFlatConfig.verify(SOURCE, [{}], { allowInlineConfig: false });
|
||||
linterWithFlatConfig.verify(SOURCE, [{}], { reportUnusedDisableDirectives: true });
|
||||
linterWithFlatConfig.verify(SOURCE, [{}], { preprocess: input => input.split(' ') });
|
||||
linterWithFlatConfig.verify(SOURCE, [{}], { postprocess: problemList => problemList[0] });
|
||||
|
||||
linterWithFlatConfig.verify(SOURCE, [{ languageOptions: { ecmaVersion: 2021 } }], 'test.js');
|
||||
linterWithFlatConfig.verify(SOURCE, [{ languageOptions: { ecmaVersion: 2022 } }], 'test.js');
|
||||
linterWithFlatConfig.verify(SOURCE, [{ languageOptions: { ecmaVersion: 'latest' } }], 'test.js');
|
||||
linterWithFlatConfig.verify(SOURCE, [{ languageOptions: { ecmaVersion: 6 } }], 'test.js');
|
||||
linterWithFlatConfig.verify(
|
||||
SOURCE,
|
||||
[{ languageOptions: { ecmaVersion: 6 } }],
|
||||
'test.js',
|
||||
);
|
||||
|
||||
linterWithFlatConfig.verify(SOURCE, [{ rules: {} }], 'test.js');
|
||||
linterWithFlatConfig.verify(SOURCE, [{ rules: { quotes: 2 } }], 'test.js');
|
||||
linterWithFlatConfig.verify(SOURCE, [{ rules: { quotes: [2, 'double'] } }], 'test.js');
|
||||
linterWithFlatConfig.verify(SOURCE, [{ rules: { 'no-unused-vars': [2, { vars: 'all' }] } }], 'test.js');
|
||||
linterWithFlatConfig.verify(SOURCE, [{ rules: { 'no-console': 1 } }], 'test.js');
|
||||
linterWithFlatConfig.verify(SOURCE, [{ rules: { 'no-console': 0 } }], 'test.js');
|
||||
linterWithFlatConfig.verify(SOURCE, [{ rules: { 'no-console': 'error' } }], 'test.js');
|
||||
linterWithFlatConfig.verify(
|
||||
SOURCE,
|
||||
[{
|
||||
rules: { 'no-console': 'error' },
|
||||
}, {
|
||||
files: ['*-test.js', '*.spec.js'],
|
||||
rules: {
|
||||
'no-unused-expressions': 'off',
|
||||
},
|
||||
}],
|
||||
'test.js',
|
||||
);
|
||||
linterWithFlatConfig.verify(SOURCE, [{ rules: { 'no-console': 'warn' } }], 'test.js');
|
||||
linterWithFlatConfig.verify(SOURCE, [{ rules: { 'no-console': 'off' } }], 'test.js');
|
||||
|
||||
//#endregion
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region ESLint
|
||||
|
||||
10
types/eslint/index.d.ts
vendored
10
types/eslint/index.d.ts
vendored
@@ -780,13 +780,13 @@ export class Linter {
|
||||
|
||||
version: string;
|
||||
|
||||
constructor(options?: { cwd?: string | undefined });
|
||||
constructor(options?: { cwd?: string | undefined, configType?: 'flat' });
|
||||
|
||||
verify(code: SourceCode | string, config: Linter.Config, filename?: string): Linter.LintMessage[];
|
||||
verify(code: SourceCode | string, config: Linter.Config, options: Linter.LintOptions): Linter.LintMessage[];
|
||||
verify(code: SourceCode | string, config: Linter.Config | Linter.FlatConfig[], filename?: string): Linter.LintMessage[];
|
||||
verify(code: SourceCode | string, config: Linter.Config | Linter.FlatConfig[], options: Linter.LintOptions): Linter.LintMessage[];
|
||||
|
||||
verifyAndFix(code: string, config: Linter.Config, filename?: string): Linter.FixReport;
|
||||
verifyAndFix(code: string, config: Linter.Config, options: Linter.FixOptions): Linter.FixReport;
|
||||
verifyAndFix(code: string, config: Linter.Config | Linter.FlatConfig[], filename?: string): Linter.FixReport;
|
||||
verifyAndFix(code: string, config: Linter.Config | Linter.FlatConfig[], options: Linter.FixOptions): Linter.FixReport;
|
||||
|
||||
getSourceCode(): SourceCode;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user