forked from FreeTubeApp/FreeTube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.mjs
247 lines (216 loc) · 6.17 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
import eslintPluginVue from 'eslint-plugin-vue'
import vuejsAccessibility from 'eslint-plugin-vuejs-accessibility'
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
import intlifyVueI18N from '@intlify/eslint-plugin-vue-i18n'
import globals from 'globals'
import vueEslintParser from 'vue-eslint-parser'
import js from '@eslint/js'
import jsoncEslintParser from 'jsonc-eslint-parser'
import eslintPluginJsonc from 'eslint-plugin-jsonc'
import eslintPluginYml from 'eslint-plugin-yml'
import yamlEslintParser from 'yaml-eslint-parser'
// Faster than importing the default import,
// because the default import imports a lot of other dependencies
// for the `resolveIgnoresFromGitignore` function that we don't use
import { neostandard } from 'neostandard/lib/main.js'
import jsdoc from 'eslint-plugin-jsdoc'
import freetube from './_scripts/eslint-rules/plugin.mjs'
import activeLocales from './static/locales/activeLocales.json' with { type: 'json' }
export default [
{
ignores: [
'build/',
'dist/',
'eslint.config.mjs',
// The JSON files inside this directory are auto-generated, so they don't follow the code style rules
'static/geolocations/'
]
},
...neostandard({
noJsx: true,
ts: false,
}),
js.configs.recommended,
...eslintPluginVue.configs['flat/vue2-recommended'],
...vuejsAccessibility.configs["flat/recommended"],
...intlifyVueI18N.configs['flat/recommended'],
{
files: [
'**/*.{js,vue}',
],
ignores: [
'_scripts/',
],
plugins: {
unicorn: eslintPluginUnicorn,
jsdoc,
freetube,
},
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
parser: vueEslintParser,
ecmaVersion: 2022,
sourceType: 'module',
},
settings: {
'vue-i18n': {
localeDir: `./static/locales/{${activeLocales.join(',')}}.yaml`,
messageSyntaxVersion: '^8.0.0',
},
},
rules: {
'@stylistic/space-before-function-paren': 'off',
'@stylistic/comma-dangle': ['error', 'only-multiline'],
'vue/no-v-html': 'off',
'no-console': ['error', {
allow: ['warn', 'error'],
}],
'no-unused-vars': 'warn',
'no-undef': 'warn',
'object-shorthand': 'off',
'vue/no-template-key': 'warn',
'vue/multi-word-component-names': 'off',
'vuejs-accessibility/label-has-for': ['error', {
required: {
some: ['nesting', 'id'],
},
}],
'vuejs-accessibility/no-static-element-interactions': 'off',
'n/no-callback-literal': 'warn',
'n/no-path-concat': 'warn',
'unicorn/better-regex': 'error',
'unicorn/no-array-push-push': 'error',
'unicorn/prefer-keyboard-event-key': 'error',
'unicorn/prefer-regexp-test': 'error',
'unicorn/prefer-string-replace-all': 'error',
'@intlify/vue-i18n/no-dynamic-keys': 'error',
'@intlify/vue-i18n/no-duplicate-keys-in-locale': 'error',
'@intlify/vue-i18n/no-raw-text': ['error', {
attributes: {
'/.+/': [
'title',
'aria-label',
'aria-placeholder',
'aria-roledescription',
'aria-valuetext',
'tooltip',
'message',
],
input: ['placeholder', 'value'],
img: ['alt'],
},
ignoreText: ['-', '•', '/', 'YouTube', 'Invidious', 'FreeTube'],
}],
'@intlify/vue-i18n/no-deprecated-tc': 'off',
'vue/require-explicit-emits': 'error',
'vue/no-unused-emit-declarations': 'error',
'jsdoc/check-alignment': 'error',
'jsdoc/check-property-names': 'error',
'jsdoc/check-param-names': 'error',
'jsdoc/check-syntax': 'error',
'jsdoc/check-template-names': 'error',
'jsdoc/check-types': 'error',
'jsdoc/no-bad-blocks': 'error',
'jsdoc/no-multi-asterisks': 'error',
'freetube/prefer-use-i18n-polyfill': 'error',
},
},
...eslintPluginJsonc.configs['flat/base'],
{
files: ['**/*.json'],
ignores: [
'_scripts/',
],
languageOptions: {
parser: jsoncEslintParser,
},
rules: {
'@stylistic/no-tabs': 'off',
'@stylistic/comma-spacing': 'off',
'@stylistic/eol-last': 'off',
'no-irregular-whitespace': 'off',
},
settings: {
'vue-i18n': {
localeDir: `./static/locales/{${activeLocales.join(',')}}.yaml`,
messageSyntaxVersion: '^8.0.0',
},
},
},
...eslintPluginYml.configs['flat/recommended'],
{
files: ['**/*.{yml,yaml}'],
ignores: [
'.github/',
'_scripts/'
],
languageOptions: {
parser: yamlEslintParser,
},
rules: {
'yml/no-irregular-whitespace': 'off',
'@stylistic/spaced-comment': 'off',
},
settings: {
'vue-i18n': {
localeDir: `./static/locales/{${activeLocales.join(',')}}.yaml`,
messageSyntaxVersion: '^8.0.0',
},
},
},
{
files: ['.github/**/*.{yml,yaml}'],
languageOptions: {
parser: yamlEslintParser,
},
rules: {
'yml/no-empty-mapping-value': 'off',
'yml/no-irregular-whitespace': 'off',
},
settings: {
'vue-i18n': {
localeDir: `./static/locales/{${activeLocales.join(',')}}.yaml`,
messageSyntaxVersion: '^8.0.0',
},
},
},
{
files: ['_scripts/*.js'],
languageOptions: {
globals: globals.node,
ecmaVersion: 'latest',
sourceType: 'commonjs'
},
plugins: {
unicorn: eslintPluginUnicorn,
},
rules: {
'@stylistic/space-before-function-paren': 'off',
'@stylistic/comma-dangle': ['error', 'only-multiline'],
'no-console': 'off',
'n/no-path-concat': 'off',
'unicorn/better-regex': 'error',
}
},
{
files: ['_scripts/**/*.mjs'],
languageOptions: {
globals: globals.node,
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: {
unicorn: eslintPluginUnicorn,
},
rules: {
'no-console': 'off',
'@stylistic/space-before-function-paren': 'off',
'@stylistic/comma-dangle': ['error', 'only-multiline'],
'n/no-path-concat': 'off',
'unicorn/better-regex': 'error',
}
}
]