-
Notifications
You must be signed in to change notification settings - Fork 184
/
eslint.config.mjs
148 lines (137 loc) · 3.36 KB
/
eslint.config.mjs
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import globals from 'globals'
import jsPlugin from '@eslint/js'
import tseslint from 'typescript-eslint'
import prettierPluginRecommended from 'eslint-plugin-prettier/recommended'
import jsdoc from 'eslint-plugin-jsdoc'
import sveltePlugin from 'eslint-plugin-svelte'
import svelteParser from 'svelte-eslint-parser'
import vuePlugin from 'eslint-plugin-vue'
import vueParser from 'vue-eslint-parser'
import reactHooksPlugin from 'eslint-plugin-react-hooks' // must use 'next' version for compatibility
import reactRecommended from 'eslint-plugin-react/configs/recommended.js' // requires @eslint/compat
import { fixupConfigRules } from '@eslint/compat' // for eslint-plugin-react which has issues
export default tseslint.config(
// Global ignores
{
ignores: [
'.husky/',
'.nx/',
'.yarn/',
'assets/',
'pages/',
'yarn.lock',
'**/.angular/',
'**/scss/',
'**/public/images',
'**/.svelte-kit/',
'**/svelte/static',
'**/dist/',
'**/test-results/',
'**/demo',
'packages/angular/' // has its own config
]
},
// Global - window and document objects
{
languageOptions: { globals: globals.browser }
},
// For very small number of JavaScript files
{
files: ['scripts/*.mjs', './*.mjs', 'packages/svelte/svelte.config.js'],
rules: jsPlugin.configs.recommended.rules
},
// Global - TypeScript
...tseslint.configs.recommended,
{
files: ['packages/**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-this-alias': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-var-requires': 'warn',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error'
}
},
// @carbon/charts-docs and @carbon/charts-react
{
files: ['packages/docs/src/**/*.{ts,tsx}', 'packages/react/src/**/*.{ts,tsx}'],
plugins: {
react: reactRecommended.plugins
},
rules: {
...fixupConfigRules(reactRecommended).rules
},
settings: {
react: {
version: 'detect'
}
}
},
// @carbon/charts-docs (@charts/react doesn't use hooks)
{
files: ['packages/docs/src/**/*.tsx'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: true
}
},
plugins: {
'react-hooks': reactHooksPlugin
},
rules: {
...reactHooksPlugin.configs.recommended.rules,
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn'
}
},
// @carbon/charts - for typedoc generation by docs website
{
name: 'jsdoc',
files: ['packages/core/src/**/*.ts'],
plugins: {
jsdoc
},
rules: {
'jsdoc/require-description': 'warn',
'jsdoc/check-values': 'warn'
}
},
// @carbon/charts-svelte - only checks .svelte files. TypeScript is checked globally.
{
files: ['packages/svelte/src/**/*.svelte'],
languageOptions: {
parser: svelteParser,
parserOptions: {
parser: tseslint.parser
}
},
plugins: {
sveltePlugin
},
rules: {
...sveltePlugin.configs['flat/prettier'].rules
}
},
// @carbon/charts-vue - Checks .vue and .ts files.
{
files: ['packages/vue/**/*.{ts,vue}'],
languageOptions: {
parser: vueParser,
parserOptions: {
parser: tseslint.parser,
extraFileExtensions: ['.vue'],
project: true
}
},
plugins: {
vuePlugin
},
rules: {
...vuePlugin.configs['flat/recommended'].rules
}
},
// Loads last to remove any conflicting rules with prettier
prettierPluginRecommended
)