100 lines
2.6 KiB
JavaScript
100 lines
2.6 KiB
JavaScript
import js from '@eslint/js';
|
|
import tsParser from '@typescript-eslint/parser';
|
|
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
|
import importPlugin from 'eslint-plugin-import';
|
|
import globals from 'globals';
|
|
|
|
const typeCheckedConfigs = tsPlugin.configs['flat/recommended-type-checked'];
|
|
|
|
export default [
|
|
{
|
|
ignores: ['node_modules/**', 'dist/**', 'tmp/**', 'logs/**'],
|
|
},
|
|
js.configs.recommended,
|
|
{
|
|
files: ['**/*.js'],
|
|
languageOptions: {
|
|
ecmaVersion: 2024,
|
|
sourceType: 'module',
|
|
globals: globals.node,
|
|
},
|
|
plugins: {
|
|
import: importPlugin,
|
|
},
|
|
settings: {
|
|
'import/resolver': {
|
|
node: {
|
|
extensions: ['.js', '.ts'],
|
|
},
|
|
typescript: {
|
|
project: './tsconfig.json',
|
|
},
|
|
},
|
|
},
|
|
rules: {
|
|
'import/no-unresolved': 'error',
|
|
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
},
|
|
},
|
|
...typeCheckedConfigs.map((config) => ({
|
|
...config,
|
|
files: ['**/*.ts'],
|
|
})),
|
|
{
|
|
files: ['**/*.ts'],
|
|
languageOptions: {
|
|
parser: tsParser,
|
|
parserOptions: {
|
|
project: './tsconfig.json',
|
|
tsconfigRootDir: import.meta.dirname,
|
|
sourceType: 'module',
|
|
},
|
|
globals: globals.node,
|
|
},
|
|
plugins: {
|
|
'@typescript-eslint': tsPlugin,
|
|
import: importPlugin,
|
|
},
|
|
settings: {
|
|
'import/resolver': {
|
|
node: {
|
|
extensions: ['.js', '.ts'],
|
|
},
|
|
typescript: {
|
|
project: './tsconfig.json',
|
|
},
|
|
},
|
|
},
|
|
rules: {
|
|
'import/no-unresolved': 'error',
|
|
'no-unused-vars': 'off',
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
|
],
|
|
'@typescript-eslint/consistent-type-imports': [
|
|
'error',
|
|
{ prefer: 'type-imports' },
|
|
],
|
|
'@typescript-eslint/no-explicit-any': 'error',
|
|
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
'@typescript-eslint/no-require-imports': 'error',
|
|
'@typescript-eslint/no-unsafe-type-assertion': 'error',
|
|
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
|
'no-restricted-syntax': [
|
|
'error',
|
|
{
|
|
selector: 'TSAsExpression',
|
|
message:
|
|
'Do not use type casts in migrated backend TypeScript; use validation, guards, or typed adapters instead.',
|
|
},
|
|
{
|
|
selector: 'TSTypeAssertion',
|
|
message:
|
|
'Do not use type casts in migrated backend TypeScript; use validation, guards, or typed adapters instead.',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
];
|