fix: type errors of typescript-eslint
This commit is contained in:
49
packages/core/src/env.d.ts
vendored
49
packages/core/src/env.d.ts
vendored
@@ -1,5 +1,7 @@
|
||||
import type { ESLint, Linter } from 'eslint';
|
||||
|
||||
/**
|
||||
* @see {@link https://github.com/sindresorhus/globals}
|
||||
* @see {@link https://github.com/sindresorhus/globals github repository}
|
||||
* @summary Global identifiers from different Javascript environments
|
||||
* ---
|
||||
* **Note:**
|
||||
@@ -20,3 +22,48 @@ declare module 'globals' {
|
||||
};
|
||||
export default globals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see {@link https://www.npmjs.com/package/@typescript-eslint/eslint-plugin npm package}
|
||||
* @summary An ESLint plugin which provides lint rules for TypeScript codebases.
|
||||
*
|
||||
* ---
|
||||
* **Note:** Types in this project where overridden to be compatible with ESLint new flat
|
||||
* config types. ESlint already has backwards compatibility for plugins not created in the
|
||||
* new flat config.
|
||||
*/
|
||||
declare module '@typescript-eslint/eslint-plugin' {
|
||||
interface typescriptEslintPlugin extends ESLint.Plugin {
|
||||
configs: {
|
||||
recommended: {
|
||||
rules: Linter.RulesRecord
|
||||
}
|
||||
'recommended-requiring-type-checking': {
|
||||
rules: Linter.RulesRecord
|
||||
}
|
||||
'eslint-recommended': {
|
||||
rules: Linter.RulesRecord
|
||||
}
|
||||
strict: {
|
||||
rules: Linter.RulesRecord
|
||||
}
|
||||
}
|
||||
}
|
||||
const plugin: typescriptEslintPlugin;
|
||||
export default plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see {@link https://www.npmjs.com/package/@typescript-eslint/parser npm package}
|
||||
* @summary An ESLint parser which leverages TypeScript ESTree to allow for ESLint
|
||||
* to lint TypeScript source code.
|
||||
*
|
||||
* ---
|
||||
* **Note:** Types in this project where overridden to be compatible with ESLint new flat
|
||||
* config types. ESlint already has backwards compatibility for parsers not created in the
|
||||
* new flat config.
|
||||
*/
|
||||
declare module '@typescript-eslint/parser' {
|
||||
const parser: Linter.ParserModule;
|
||||
export default parser;
|
||||
}
|
||||
|
||||
@@ -24,22 +24,16 @@ export function defineConfig(userConfig) {
|
||||
{
|
||||
files: ['**/*.js', '**/*.ts'],
|
||||
plugins: {
|
||||
// @ts-expect-error The `@typescript-eslint/eslint-plugin` package doesn't export
|
||||
// a correct type as default. But this still works because of backwards-compatibility of eslint.
|
||||
'@typescript-eslint': tsEslint,
|
||||
},
|
||||
languageOptions: {
|
||||
sourceType: 'module',
|
||||
// @ts-expect-error The `@typescript-eslint/parser` package doesn't export a correct type as default.
|
||||
// (see `plugins['@typescript-eslint']` option/property error for more info)
|
||||
parser: tsParser,
|
||||
parserOptions: {
|
||||
project: userConfig.tsconfig,
|
||||
tsconfigRootDir: process.cwd(),
|
||||
},
|
||||
},
|
||||
// @ts-expect-error The `@typescript-eslint/eslint-plugin` package doesn't export
|
||||
// rules as `RulesRecord` type.
|
||||
rules: {
|
||||
...tsEslint.configs.recommended.rules,
|
||||
...tsEslint.configs['recommended-requiring-type-checking'].rules,
|
||||
|
||||
Reference in New Issue
Block a user