**Motivations :** - Le projet a déjà ESLint mais la configuration était mixte (ancien et nouveau format) - Améliorer la configuration pour gérer les Web Workers et les globals manquants - Supprimer les fichiers de configuration obsolètes **Modifications :** - Supprimer .eslintrc.json (ancien format, ignoré par ESLint 9) - Supprimer .eslintignore (remplacé par ignores dans eslint.config.js) - Améliorer eslint.config.js avec les globals nécessaires (Web Workers, IndexedDB, etc.) - Ajouter une configuration spécifique pour les fichiers worker.ts - Les ignores sont maintenant centralisés dans eslint.config.js **Pages affectées :** - eslint.config.js (amélioration de la configuration) - Suppression de .eslintrc.json et .eslintignore
123 lines
3.4 KiB
JavaScript
123 lines
3.4 KiB
JavaScript
import js from '@eslint/js';
|
|
import typescript from '@typescript-eslint/eslint-plugin';
|
|
import typescriptParser from '@typescript-eslint/parser';
|
|
|
|
export default [
|
|
js.configs.recommended,
|
|
{
|
|
files: ['**/*.ts', '**/*.tsx'],
|
|
languageOptions: {
|
|
parser: typescriptParser,
|
|
parserOptions: {
|
|
ecmaVersion: 'latest',
|
|
sourceType: 'module',
|
|
project: './tsconfig.json'
|
|
},
|
|
globals: {
|
|
'console': 'readonly',
|
|
'window': 'readonly',
|
|
'document': 'readonly',
|
|
'navigator': 'readonly',
|
|
'crypto': 'readonly',
|
|
'setTimeout': 'readonly',
|
|
'clearTimeout': 'readonly',
|
|
'setInterval': 'readonly',
|
|
'clearInterval': 'readonly',
|
|
'alert': 'readonly',
|
|
'confirm': 'readonly',
|
|
'prompt': 'readonly',
|
|
'fetch': 'readonly',
|
|
'localStorage': 'readonly',
|
|
'sessionStorage': 'readonly',
|
|
'indexedDB': 'readonly',
|
|
'IDBDatabase': 'readonly',
|
|
'IDBTransaction': 'readonly',
|
|
'IDBObjectStore': 'readonly',
|
|
'IDBRequest': 'readonly',
|
|
'customElements': 'readonly',
|
|
'requestAnimationFrame': 'readonly',
|
|
'cancelAnimationFrame': 'readonly',
|
|
'performance': 'readonly',
|
|
'WebAssembly': 'readonly',
|
|
'btoa': 'readonly',
|
|
'atob': 'readonly',
|
|
'self': 'readonly',
|
|
'SharedWorker': 'readonly',
|
|
'Worker': 'readonly'
|
|
}
|
|
},
|
|
plugins: {
|
|
'@typescript-eslint': typescript
|
|
},
|
|
rules: {
|
|
// Qualité du code - Règles plus permissives pour commencer
|
|
'complexity': ['warn', 15],
|
|
'max-lines': ['warn', 500],
|
|
'max-lines-per-function': ['warn', 100],
|
|
'max-params': ['warn', 6],
|
|
'max-depth': ['warn', 6],
|
|
|
|
// TypeScript spécifique - Plus permissif
|
|
'@typescript-eslint/no-explicit-any': 'warn',
|
|
'@typescript-eslint/no-unused-vars': ['warn', {
|
|
'argsIgnorePattern': '^_',
|
|
'varsIgnorePattern': '^_',
|
|
'ignoreRestSiblings': true
|
|
}],
|
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
|
|
'@typescript-eslint/prefer-optional-chain': 'warn',
|
|
|
|
// Bonnes pratiques - Plus permissif
|
|
'no-console': 'off', // Permettre console pour le debug
|
|
'no-debugger': 'error',
|
|
'no-alert': 'warn',
|
|
'prefer-const': 'warn',
|
|
'no-var': 'error',
|
|
'eqeqeq': 'warn',
|
|
'curly': 'warn',
|
|
|
|
// Sécurité
|
|
'no-eval': 'error',
|
|
'no-implied-eval': 'error',
|
|
'no-new-func': 'error',
|
|
|
|
// Performance - Plus permissif
|
|
'no-loop-func': 'warn',
|
|
'no-await-in-loop': 'off' // Permettre await dans les boucles pour l'instant
|
|
}
|
|
},
|
|
{
|
|
files: ['**/*.worker.ts', '**/*.worker.js'],
|
|
languageOptions: {
|
|
globals: {
|
|
'self': 'readonly',
|
|
'postMessage': 'readonly',
|
|
'onmessage': 'readonly',
|
|
'importScripts': 'readonly',
|
|
'btoa': 'readonly',
|
|
'atob': 'readonly',
|
|
'crypto': 'readonly',
|
|
'console': 'readonly'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
ignores: [
|
|
'dist/',
|
|
'node_modules/',
|
|
'*.js',
|
|
'!eslint.config.js',
|
|
'pkg/',
|
|
'vite.config.ts',
|
|
'test-browser/',
|
|
'logs/',
|
|
'coverage/',
|
|
'.nyc_output/',
|
|
'**/*.test.ts',
|
|
'**/*.spec.ts'
|
|
]
|
|
}
|
|
];
|