-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
91 lines (88 loc) · 3.05 KB
/
eslint.config.js
File metadata and controls
91 lines (88 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// eslint.config.js
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import globals from 'globals';
import jsEslint from '@eslint/js';
import tsEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import eslintComments from 'eslint-plugin-eslint-comments';
// Recreate __dirname in ESM
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
/** @type {import('eslint').FlatConfig[]} */
export default [
// Base configuration for JavaScript
{
files: ['*.js', '*.jsx'], // Apply to JavaScript files
languageOptions: {
globals: globals.browser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
},
plugins: {
'eslint-comments': eslintComments,
js: jsEslint,
},
rules: {
// ESLint Comments Rules
'eslint-comments/no-unused-disable': 'error',
'eslint-comments/no-restricted-disable': 'off',
'eslint-comments/no-use': [
'warn',
{
allow: [
'eslint-disable',
'eslint-enable',
'eslint-disable-line',
'eslint-disable-next-line',
],
},
],
// JavaScript ESLint Recommended Rules
...jsEslint.configs.recommended.rules,
// ESLint Comments Recommended Rules
...eslintComments.configs.recommended.rules,
},
},
// Configuration for TypeScript
{
files: ['**/*.ts', '**/*.tsx'], // Apply to TypeScript files
languageOptions: {
parser: tsParser, // Correctly reference the TypeScript parser object
parserOptions: {
project: './tsconfig.json', // Path to your tsconfig.json
tsconfigRootDir: __dirname, // Ensure the parser can find tsconfig.json
ecmaVersion: 'latest',
sourceType: 'module',
},
},
plugins: {
'@typescript-eslint': tsEslint,
'eslint-comments': eslintComments,
},
rules: {
// TypeScript ESLint Rules
// Allow Unknown Types
// ESLint Comments Rules
'eslint-comments/no-unused-disable': 'error',
'eslint-comments/no-restricted-disable': 'off',
'eslint-comments/no-use': [
'warn',
{
allow: [
'eslint-disable',
'eslint-enable',
'eslint-disable-line',
'eslint-disable-next-line',
],
},
],
// TypeScript ESLint Recommended Rules
...tsEslint.configs.recommended.rules,
// ESLint Comments Recommended Rules
...eslintComments.configs.recommended.rules,
},
},
];