refactor: enforce strict TypeScript linting rules
Upgrade ESLint config to use flat config with @typescript-eslint/strict-type-checked and stylistic-type-checked presets. - Use defineConfig helper, scope to .ts files only - Replace || with ??, convert type to interface, remove redundant type assertions and non-null assertions - Annotate intentional violations (unbound-method, non-null-assertion) with eslint-disable - Use querySelectorAll<T> for typed selection, Map over globalThis.Map - Add @eslint/js dev dependencymain
parent
5b0c3ecdb7
commit
e2382f1117
@ -1,24 +1,43 @@
|
|||||||
import tsParser from '@typescript-eslint/parser';
|
import { defineConfig } from 'eslint/config';
|
||||||
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
||||||
import prettierPlugin from 'eslint-plugin-prettier';
|
import prettierPlugin from 'eslint-plugin-prettier';
|
||||||
import prettierConfig from 'eslint-config-prettier';
|
import prettierConfig from 'eslint-config-prettier';
|
||||||
|
|
||||||
export default [
|
export default defineConfig([
|
||||||
{
|
{
|
||||||
files: ['src/**/*.ts'],
|
ignores: ['dist/'],
|
||||||
|
},
|
||||||
|
|
||||||
|
...tsPlugin.configs['flat/strict-type-checked'].map(c => ({
|
||||||
|
...c,
|
||||||
|
files: ['**/*.ts'],
|
||||||
|
})),
|
||||||
|
|
||||||
|
...tsPlugin.configs['flat/stylistic-type-checked'].map(c => ({
|
||||||
|
...c,
|
||||||
|
files: ['**/*.ts'],
|
||||||
|
})),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
files: ['**/*.ts'],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
parser: tsParser,
|
parserOptions: { project: true },
|
||||||
ecmaVersion: 2020,
|
|
||||||
sourceType: 'module',
|
|
||||||
},
|
},
|
||||||
plugins: {
|
plugins: {
|
||||||
'@typescript-eslint': tsPlugin,
|
|
||||||
prettier: prettierPlugin,
|
prettier: prettierPlugin,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
...tsPlugin.configs.recommended.rules,
|
|
||||||
...prettierConfig.rules,
|
...prettierConfig.rules,
|
||||||
'prettier/prettier': 'error',
|
'prettier/prettier': 'error',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
|
||||||
|
{
|
||||||
|
files: ['**/*.ts'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|||||||
Loading…
Reference in New Issue