Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
158 lines (150 loc) · 4.35 KB
/
Copy pathindex.js
File metadata and controls
158 lines (150 loc) · 4.35 KB
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
import eslintConfigPrettier from "eslint-config-prettier";
import globals from "globals";
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import tsParser from "@typescript-eslint/parser";
import vueParser from "vue-eslint-parser";
import pluginCypress from "eslint-plugin-cypress";
import pluginChaiFriendly from "eslint-plugin-chai-friendly";
import pluginVue from "eslint-plugin-vue";
import pluginJsdoc from "eslint-plugin-jsdoc";
/**
* Helper to dynamically convert error levels to warnings
* so that new rules do not break existing CI pipelines.
* @param {Array<object>|object} configs - ESLint configuration object(s)
* @returns {Array<object>} The modified configs with errors downgraded to warnings
*/
function mapConfigsToWarn(configs) {
if (!Array.isArray(configs)) {
configs = [configs];
}
return configs.map((config) => {
if (!config.rules) return config;
const newRules = {};
for (const [key, value] of Object.entries(config.rules)) {
if (Array.isArray(value)) {
if (value[0] === "error" || value[0] === 2) {
newRules[key] = ["warn", ...value.slice(1)];
} else {
newRules[key] = value;
}
} else if (value === "error" || value === 2) {
newRules[key] = "warn";
} else {
newRules[key] = value;
}
}
return { ...config, rules: newRules };
});
}
export const cypress = [
pluginCypress.configs.recommended,
{
plugins: { "chai-friendly": pluginChaiFriendly },
rules: {
"chai-friendly/no-unused-expressions": "error",
},
},
];
export const js = [
eslint.configs.recommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.browser,
},
},
},
];
export const typescript = [
...mapConfigsToWarn(tseslint.configs.recommended),
{
languageOptions: {
parserOptions: {
parser: tsParser,
},
},
rules: {
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": [
"error",
{
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-unused-expressions": "off",
},
},
];
export const vue3 = [
...mapConfigsToWarn(pluginVue.configs["flat/recommended"]),
{
languageOptions: {
parser: vueParser,
parserOptions: {
parser: tsParser,
extraFileExtensions: [".vue"],
},
},
rules: {
"vue/multi-word-component-names": "off",
"vue/require-default-prop": "off",
// eox web components expose camelCase properties bound via `.prop` /
// `:attr` and namespaced (`@x:y`) events; hyphenating them sets the wrong
// property/attribute name and silently breaks the binding.
"vue/attribute-hyphenation": "off",
"vue/v-on-event-hyphenation": "off",
"vue/no-deprecated-slot-attribute": [
"warn",
{
// native `slot` attributes are valid light DOM inside eox web
// components (e.g. titles/slots of eox-itemfilter, eox-layercontrol)
ignore: ["/^eox-/"],
},
],
},
},
];
export const jsdocRules = [
...mapConfigsToWarn([
pluginJsdoc.configs["flat/recommended-typescript-flavor"],
]),
{
// keep only the correctness-oriented jsdoc checks
rules: {
"jsdoc/require-jsdoc": "off",
"jsdoc/require-param": "off",
"jsdoc/require-param-type": "off",
"jsdoc/require-param-description": "off",
"jsdoc/require-returns": "off",
"jsdoc/require-returns-type": "off",
"jsdoc/require-returns-description": "off",
"jsdoc/require-property": "off",
"jsdoc/require-property-type": "off",
"jsdoc/require-property-description": "off",
"jsdoc/require-description": "off",
"jsdoc/reject-any-type": "off",
"jsdoc/reject-function-type": "off",
"jsdoc/tag-lines": "off",
"jsdoc/no-multi-asterisks": "off",
"jsdoc/no-defaults": "off",
"jsdoc/multiline-blocks": "off",
"jsdoc/escape-inline-tags": "off",
"jsdoc/check-alignment": "off",
"jsdoc/check-line-alignment": "off",
"jsdoc/lines-before-block": "off",
},
},
];
export const prettier = [eslintConfigPrettier];
export default [
...cypress,
...js,
...typescript,
...vue3,
...jsdocRules,
...prettier,
];