forked from Zettlr/Zettlr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.mjs
141 lines (135 loc) · 5.28 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
import tsESLintParser from '@typescript-eslint/parser'
import tsESLintPlugin from '@typescript-eslint/eslint-plugin'
import stylisticTSLint from '@stylistic/eslint-plugin'
import vueParser from 'vue-eslint-parser'
import pluginVue from 'eslint-plugin-vue'
export default [
{
// With the new flat configs, we unfortunately have to ignore everything
// manually that we don't want linted.
ignores: [
'*.js',
'scripts/**/*.js',
'resources/**/*.js',
'.webpack/**/*.js'
]
},
// This extends the following configs:
{
plugins: {
'@typescript-eslint': tsESLintPlugin
},
rules: {
...tsESLintPlugin.configs.recommended.rules
}
},
// flat/recommended === vue3-recommended
...pluginVue.configs['flat/recommended'],
// Our manual extensions:
{
files: ['source/**/*.{ts,vue,js}'],
plugins: {
// The keys here must correspond to the plugin namespaces referred below
'@typescript-eslint': tsESLintPlugin,
'@stylistic': stylisticTSLint,
vue: pluginVue
},
languageOptions: {
parserOptions: {
parser: tsESLintParser,
project: './tsconfig.json',
extraFileExtensions: ['.vue'],
ecmaVersion: 2018
},
parser: vueParser
},
rules: {
////////////////////////// STYLISTIC RULES ///////////////////////////////
// Disallow semicolons except where absolutely necessary
'@stylistic/semi': [ 'error', 'never' ],
// Require multi-line arrays to have brackets on their own line
'@stylistic/array-bracket-newline': [ 'error', 'consistent' ],
'@stylistic/array-bracket-spacing': [
'error',
'always',
{ objectsInArrays: false, singleValue: false }
],
'@stylistic/arrow-spacing': [ 'error' ],
'@stylistic/brace-style': [ 'error', '1tbs', { allowSingleLine: true }],
'@stylistic/dot-location': [ 'error', 'property' ],
'@stylistic/eol-last': [ 'error', 'always' ],
'@stylistic/indent': [ 'error', 2 ],
/////////////////////// END STYLISTIC RULES //////////////////////////////
// We do use explicit anys at certain points
'@typescript-eslint/no-explicit-any': 'off',
'no-unused-vars': 'off', // We need to turn off the vanilla option ...
// ... and turn on the TypeScript one. HOWEVER, we also need to use the
// appropriate option that allows us to declare variables as unused by
// prefixing it with an underscore.
'@typescript-eslint/no-unused-vars': 'off',
// See https://typescript-eslint.io/rules/no-unused-vars/
'space-before-function-paren': [ 'error', 'always' ],
// The following rule-changes to JSStandard Coding Style are tradition,
// as they were included with the default configuration of Atom's ESLint
// plugin, so we'll keep them here for the time being.
'prefer-const': 'off',
// Sometimes, it makes sense to return a void to save a line of code, so we
// keep this rule off.
'@typescript-eslint/no-confusing-void-expression': 'off',
// Here follow vue-styles. While the short form is recommended
// I tend to value verbose code. At least for now, discussion is
// well received.
'vue/v-bind-style': [ 'error', 'longform' ],
'vue/v-on-style': [ 'error', 'longform' ],
// Let the implementation decide if self-closing is wanted or not.
'vue/html-self-closing': [
'warn',
{
html: {
void: 'any',
normal: 'any',
component: 'any'
},
svg: 'any',
math: 'any'
}
],
// Allow up to three attributes per line so that the contributor can
// decide if the attributes are too long for the 80 character column
'vue/max-attributes-per-line': [
'error',
{
singleline: 3,
multiline: 3
}
],
// We allow the use of v-html directives, because we sanitize any user
// provided HTML to only contain safe tags. The only stuff we currently
// put in there is translation strings, which we sanitise in the trans()
// function. NOTE to keep this on my mind!
'vue/no-v-html': 'off',
// If we activate this rule, we have about 500 errors that there are no
// spaces around | operators. Hasn't been a problem until now, won't be
// one in the future.
'@typescript-eslint/space-infix-ops': 'off',
'@typescript-eslint/no-base-to-string': [
'error',
{
ignoredTypeNames: ['Text']
}
],
'@typescript-eslint/no-non-null-assertion': 'off',
// DEBUG: Turn a few errors into warnings after upgrading ESLint to >6.x
// This rule is difficult to disable right now; it interferes with the
// "no-null-assertion" rule, and it won't be an easy fix. We'll have to
// think about it.
'@typescript-eslint/non-nullable-type-assertion-style': 1,
// The following two rules conflict with each other in a few edge cases, so
// we'll keep both on "warning" severity for now.
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 1,
'@typescript-eslint/strict-boolean-expressions': 1,
// The following rule basically disallows use of `any`
'@typescript-eslint/no-unsafe-argument': 1
}
}
]