-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
168 lines (158 loc) · 5.49 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// @ts-check
// @ts-expect-error: This module has no type declarations.
import comments from "@eslint-community/eslint-plugin-eslint-comments/configs";
import stylistic from "@stylistic/eslint-plugin";
import prettier from "eslint-config-prettier";
// @ts-expect-error: This module has no type declarations.
import esX from "eslint-plugin-es-x";
import ts from "typescript-eslint";
// @ts-expect-error: This module has no type declarations.
import vueScopedCss from "eslint-plugin-vue-scoped-css";
import withNuxt from "./.nuxt/eslint.config.mjs";
export default withNuxt([
comments.recommended,
esX.configs["flat/restrict-to-es2020"],
...ts.configs.strictTypeChecked,
...ts.configs.stylisticTypeChecked,
...vueScopedCss.configs["flat/all"],
prettier,
{
plugins: {
"@stylistic": stylistic,
},
rules: {
// #region All disabled or overwritten rules.
// ⚠️ IMPORTANT! PLEASE READ:
// For the same reason our Prettier config mustn't be modified, be
// extremely hesitant to disable or overwrite rules. Every rule in this
// region should be explained by a comment above.
// If I'm explicitly choosing to use `any`, I've already decided to use it
// and shouldn't have to re-decide that every time I interact with it.
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
// These are far too strict and barely useful.
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/restrict-template-expressions": "off",
// We use a compiler, so this rule has little benefit, making templates
// more noisy and hard to read as quickly due to less concise component
// names.
"vue/multi-word-component-names": "off",
// #endregion
// #region Enabled from `@eslint-community/eslint-plugin-eslint-comments`.
"@eslint-community/eslint-comments/require-description": "error",
// #endregion
// #region Enabled from `@stylistic/eslint-plugin`.
"@stylistic/max-len": [
"error",
{
// This is needed because `eslint-disable-next-line` comments can't be
// multiline, and it's worse to make HTML attributes multiline.
ignorePattern: /^\s*(?:\/\/|<!--) eslint-disable-next-line |="/
.source,
},
],
// #endregion
// #region Enabled from `eslint-plugin-vue`.
"vue/block-lang": [
"error",
{
script: {
lang: "ts",
},
template: {
lang: "html",
},
style: {
lang: "scss",
},
},
],
"vue/block-order": [
"error",
{
order: ["script:not([setup])", "script[setup]", "template", "style"],
},
],
"vue/block-tag-newline": [
"error",
{
multiline: "always",
singleline: "always",
},
],
"vue/component-api-style": ["error", ["script-setup"]],
"vue/component-name-in-template-casing": [
"error",
"PascalCase",
{
registeredComponentsOnly: false,
},
],
"vue/custom-event-name-casing": "error",
"vue/define-emits-declaration": "error",
"vue/define-macros-order": [
"error",
{
order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"],
},
],
"vue/define-props-declaration": "error",
"vue/html-button-has-type": "error",
"vue/html-comment-content-newline": "error",
"vue/html-comment-content-spacing": "error",
"vue/html-comment-indent": "error",
"vue/next-tick-style": "error",
"vue/no-boolean-default": "error",
"vue/no-duplicate-attr-inheritance": "error",
"vue/no-empty-component-block": "error",
"vue/no-multiple-objects-in-class": "error",
"vue/no-ref-object-reactivity-loss": "error",
"vue/no-required-prop-with-default": "error",
"vue/no-restricted-html-elements": [
"error",
...["a", "NuxtLink"].map((element) => ({
element,
message: "Use our `A` component instead.",
})),
],
"vue/no-setup-props-reactivity-loss": "error",
"vue/no-static-inline-styles": "error",
"vue/no-unused-properties": "error",
"vue/no-unused-refs": "error",
"vue/no-use-v-else-with-v-for": "error",
"vue/no-useless-mustaches": "error",
"vue/no-useless-v-bind": "error",
"vue/no-v-text": "error",
"vue/padding-line-between-blocks": "error",
"vue/prefer-define-options": "error",
"vue/prefer-prop-type-boolean-first": "error",
"vue/prefer-separate-static-class": "error",
"vue/prefer-true-attribute-shorthand": "error",
"vue/require-macro-variable-name": "error",
"vue/require-prop-comment": "error",
"vue/require-typed-ref": "error",
"vue/v-for-delimiter-style": "error",
"vue/v-on-handler-style": "error",
"vue/valid-define-options": "error",
// #endregion
},
},
{
files: ["**/*.vue"],
rules: {
// `await` in a component's setup script transpiles to not be top-level.
"es-x/no-top-level-await": "off",
},
},
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
]);