Skip to content

Commit 6c1a0ae

Browse files
authored
Merge pull request #157 from edvardchen/fix-flat-recommended-type-142
fix: correct flat config type
2 parents 035d22a + 213ace8 commit 6c1a0ae

3 files changed

Lines changed: 32 additions & 3 deletions

File tree

lib/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { ESLint } from 'eslint';
1+
import type { ESLint, Linter } from 'eslint';
22

33
declare const plugin: ESLint.Plugin & {
44
configs: {
5-
'flat/recommended': ESLint.ConfigData;
5+
'flat/recommended': Linter.Config;
66
'recommended': ESLint.ConfigData;
77
}
88
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"preversion": "npm run test",
2626
"postpublish": "git push --follow-tags",
2727
"test:watch": "npm t -- --watch",
28-
"test": "mocha --timeout 50000 tests/lib/rules/no-literal-string/ && pnpm --filter='./examples/*' run lint"
28+
"test": "mocha --timeout 50000 tests/lib/rules/no-literal-string/ tests/lib/index.d.ts.test.js && pnpm --filter='./examples/*' run lint"
2929
},
3030
"dependencies": {
3131
"lodash": "^4.17.21",

tests/lib/index.d.ts.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
3+
const assert = require('assert');
4+
const ts = require('typescript');
5+
const path = require('path');
6+
7+
describe('types: flat recommended config', () => {
8+
it('types flat/recommended as Linter.Config', () => {
9+
const source = `
10+
import i18next = require('${path.resolve(__dirname, '../../lib')}');
11+
import type { Linter } from 'eslint';
12+
13+
const flatConfig: Linter.Config = i18next.configs['flat/recommended'];
14+
`;
15+
16+
const result = ts.transpileModule(source, {
17+
compilerOptions: {
18+
module: ts.ModuleKind.CommonJS,
19+
target: ts.ScriptTarget.ES2022,
20+
strict: true,
21+
moduleResolution: ts.ModuleResolutionKind.Node10,
22+
esModuleInterop: true,
23+
},
24+
reportDiagnostics: true,
25+
});
26+
27+
assert.deepStrictEqual(result.diagnostics || [], []);
28+
});
29+
});

0 commit comments

Comments
 (0)