-
Notifications
You must be signed in to change notification settings - Fork 1
/
eslint.config.js
152 lines (146 loc) · 5.6 KB
/
eslint.config.js
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
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import globals from "globals";
import vueEslintParser from "vue-eslint-parser"
import eslintPluginVue from "eslint-plugin-vue"
import eslintPluginStylistic from "@stylistic/eslint-plugin"
import eslintTypeScriptPlugin from "@typescript-eslint/eslint-plugin"
import typeScriptESlintParser from "@typescript-eslint/parser"
import markdown from "@eslint/markdown";
export default tseslint.config(
// globale Einstellung für extends und ignores
// betrifft alle vue und ts-Dateien
{
files: ["**/*.ts", "**/*.vue"],
ignores: ["dist/**", "node_modules/**", "build/**"],
// verwende die Basisregeln, die mitgeliefert werden
extends: [
eslint.configs.recommended,
...eslintPluginVue.configs['flat/recommended'],
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
// ...markdown.configs.recommended,
],
languageOptions: {
parser: vueEslintParser,
parserOptions: {
parser: typeScriptESlintParser,
tsconfigRootDir: import.meta.dirname,
extraFileExtensions: [".vue"],
sourceType: "module",
programs: undefined,
project: true,
},
ecmaVersion: "latest",
sourceType: "module",
// globals mit eslint bekannt machen, u.a. window, document etc.
globals: {
...globals.browser,
},
},
plugins: {
"vue": eslintPluginVue,
"@typescript-eslint": eslintTypeScriptPlugin,
"@stylistic": eslintPluginStylistic,
},
rules: {
// Standard Regeln
//"@stylistic/semi": "warn", => Probleme mit arrow functions
"@stylistic/max-len": "off",
"@stylistic/no-mixed-spaces-and-tabs": "off",
"@stylistic/arrow-spacing": "warn",
//"@stylistic/comma-dangle": ["warn", "always-multiline"],
"@stylistic/no-mixed-operators": "error",
"@stylistic/no-multi-spaces": "error",
"@stylistic/no-trailing-spaces": "error",
"@stylistic/indent": ["error", "tab", { "SwitchCase": 1 }],
"@stylistic/comma-dangle": ["warn", {
"arrays": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"objects": "always-multiline",
"functions": "never",
"importAttributes": "never",
"dynamicImports": "never"
}],
"no-unused-vars": "off",
"no-dupe-class-members": "off",
"require-await": "off",
"eqeqeq": "error",
"no-extra-boolean-cast": "error",
// TypeScript-spezifische Regeln
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/no-confusing-void-expression": "off",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/strict-boolean-expressions": ["error", { allowString: false, allowNumber: false }],
// "@typescript-eslint/array-type": ["error", {"default": "array-simple", "readonly": "array-simple"}],
"@typescript-eslint/restrict-plus-operands": ["error", {'allowNumberAndString': true}],
"@typescript-eslint/restrict-template-expressions": ["error", {'allowNumber': true}],
"@typescript-eslint/consistent-type-imports": "warn",
// Deaktivierte Regeln:
// Temporär defekt:
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
// Zu häufig, erstmal warn
"@typescript-eslint/prefer-optional-chain": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
"@typescript-eslint/array-type": ["off"],
"@typescript-eslint/no-invalid-void-type": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/consistent-generic-constructors": "off",
"@typescript-eslint/prefer-for-of": "off",
},
},
{
files: ["**/*.vue"],
rules: {
"vue/max-len": "off",
"@stylistic/indent": "off",
"vue/no-mutating-props": "off",
"vue/singleline-html-element-content-newline": "off",
"vue/attributes-order": "off",
// prüfen
"@typescript-eslint/prefer-function-type": "off",
"vue/eqeqeq": "error",
"vue/no-required-prop-with-default": "error",
"vue/no-setup-props-reactivity-loss": "error",
"vue/script-indent": ["error", "tab", { "baseIndent": 1, "switchCase": 1 }],
"vue/max-attributes-per-line": ["error", { "singleline": 10, "multiline": 10, } ],
"vue/return-in-computed-property": ["error", { "treatUndefinedAsUnspecified": false } ],
"vue/first-attribute-linebreak": ["error", { "singleline": "ignore", "multiline": "beside" }],
"vue/html-closing-bracket-newline": ["error", { "singleline": "never", "multiline": "never" }],
"vue/html-closing-bracket-spacing": ["warn"],
"vue/html-indent": ["error", "tab", { "baseIndent": 1, "alignAttributesVertically": false, "attribute": 1 }],
}
},
{
// *.d.ts-Dateien haben 4 Leerzeichen statt Tabs, kann man auch nicht anders einstellen...
files: ['**/*.d.ts'],
rules: {
"@stylistic/indent": "off",
}
},
{
files: ["**/*.md"],
plugins: {
markdown
},
language: "markdown/gfm",
rules: {
"markdown/no-html": ["error", { allowed: ["br"]}],
"markdown/fenced-code-language": "error",
}
}
);