Upgrade to ESLint 9
This commit is contained in:
@ -2,9 +2,8 @@ import type { ImportXRulesObject } from '@aet/eslint-define-config/src/rules/imp
|
||||
import type { TypeScriptRulesObject } from '@aet/eslint-define-config/src/rules/typescript-eslint';
|
||||
|
||||
import { error, off, warn } from '../constants';
|
||||
import { defineMiddleware } from '../middleware';
|
||||
|
||||
const importRules: Partial<ImportXRulesObject> = {
|
||||
export const importRules: Partial<ImportXRulesObject> = {
|
||||
'import-x/first': error,
|
||||
'import-x/no-absolute-path': error,
|
||||
'import-x/no-duplicates': warn,
|
||||
@ -20,7 +19,7 @@ const importRules: Partial<ImportXRulesObject> = {
|
||||
'import-x/unambiguous': error,
|
||||
};
|
||||
|
||||
const typescriptRules: Partial<TypeScriptRulesObject> = {
|
||||
export const typescriptRules: Partial<TypeScriptRulesObject> = {
|
||||
'@typescript-eslint/ban-ts-comment': [
|
||||
error,
|
||||
{
|
||||
@ -38,6 +37,10 @@ const typescriptRules: Partial<TypeScriptRulesObject> = {
|
||||
warn,
|
||||
{ accessibility: 'no-public' },
|
||||
],
|
||||
'@typescript-eslint/no-empty-object-type': [
|
||||
error,
|
||||
{ allowInterfaces: 'with-single-extends' },
|
||||
],
|
||||
'@typescript-eslint/no-empty-interface': [error, { allowSingleExtends: true }],
|
||||
'@typescript-eslint/no-explicit-any': off,
|
||||
'@typescript-eslint/no-misused-promises': [error, { checksVoidReturn: false }],
|
||||
@ -55,42 +58,3 @@ const typescriptRules: Partial<TypeScriptRulesObject> = {
|
||||
'@typescript-eslint/triple-slash-reference': off,
|
||||
'@typescript-eslint/unbound-method': off,
|
||||
};
|
||||
|
||||
export const importTypeScript = defineMiddleware((config, { addRules, addSettings }) => {
|
||||
config.parser = '@typescript-eslint/parser';
|
||||
config.plugins.push('@typescript-eslint', 'import-x');
|
||||
config.extends.push(
|
||||
'plugin:@typescript-eslint/recommended-type-checked',
|
||||
'plugin:import-x/errors',
|
||||
'plugin:import-x/typescript',
|
||||
);
|
||||
addSettings({
|
||||
'import-x/parsers': {
|
||||
'@typescript-eslint/parser': ['.ts', '.tsx', '.mts', '.cts'],
|
||||
},
|
||||
'import-x/resolver': {
|
||||
typescript: true,
|
||||
},
|
||||
});
|
||||
config.overrides.push(
|
||||
{
|
||||
files: ['.eslintrc.js', '*.config.js', '*.cjs', '*.mjs'],
|
||||
extends: ['plugin:@typescript-eslint/disable-type-checked'],
|
||||
rules: {
|
||||
'import-x/no-commonjs': off,
|
||||
'import-x/unambiguous': off,
|
||||
'@typescript-eslint/no-require-imports': off,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['*.d.ts'],
|
||||
rules: {
|
||||
'@typescript-eslint/consistent-type-imports': off,
|
||||
'import-x/unambiguous': off,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
addRules(importRules);
|
||||
addRules(typescriptRules);
|
||||
});
|
||||
|
Reference in New Issue
Block a user