-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
88 lines (77 loc) · 2.56 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
import configurations from '@plugjs/eslint-plugin'
import vuePlugin from 'eslint-plugin-vue'
import * as espree from 'espree'
import vueParser from 'vue-eslint-parser'
export default [
// ===== GENERAL JS/TS CONFIGURATIONS FROM PLUGJS AND VUE ====================
// Any config for TS also applies to VUE files
...configurations.map((config) => {
if (config.files?.includes('**/*.ts')) config.files.push('**/*.vue')
return config
}),
// All VUE configurations are restricted to ".vue" files
...vuePlugin.configs['flat/recommended'].map((config) => {
config.files = [ '**/*.vue' ]
return config
}),
// ===== PARSERS CONFIGURATION FOR VUE ========================================
// Set the *default* parser, for all files, to be specifically the VUE parser
// backed by TypeScript ESLint's own parser (all our .vue are in TypeScript)
{
name: 'local/parser/vue',
languageOptions: {
parser: vueParser,
parserOptions: {
extraFileExtensions: [ '.vue' ],
parser: '@typescript-eslint/parser',
},
},
rules: {
// This requires "projects", and "projects" doubles the linting time
'@typescript-eslint/no-floating-promises': [ 'off' ],
},
},
// Specifically for JavaScript files, use the default "espree" parser, as
// JavaScript sources (like this file) are not present in "tsconfig.json".
{
name: 'local/parser/js',
files: [ '**/*.mjs', '**/*.cjs', '**/*.js' ],
languageOptions: {
parser: espree,
},
},
// ===== PROJECT LOCAL CONFIGURATIONS ========================================
{
name: 'local/rules',
rules: {
// Unhandled rejections are handled by Sentry / DOM
'@typescript-eslint/no-floating-promises': [ 'off' ],
},
},
{
name: 'local/rules/vue',
files: [ '**/*.vue' ],
rules: {
// We don't care about "multiple words" in components
'vue/multi-word-component-names': [ 'off' ],
// Either 3 attributes on a single line, or all attributes on newlines!
'vue/max-attributes-per-line': [ 'warn', {
'singleline': 3,
} ],
// No unused variables, ever
'vue/no-unused-vars': 'error',
},
},
// ===== IGNORED FILES =======================================================
// REMEMBER! Ignores *must* be in its own configuration, they can not coexist
// with "rules", "languageOptions", "files", ... or anything else, otherwise
// ESLint will blaantly ignore the ignore files!
{
name: 'local/ignores',
ignores: [
'dist/',
'demo/',
'public/',
],
},
]