Repository navigation
Expand file tree
/
Copy patheslint.config.mjs
More file actions
115 lines (106 loc) · 3.14 KB
/
Copy patheslint.config.mjs
File metadata and controls
115 lines (106 loc) · 3.14 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
import eslint from "@eslint/js";
import prettier from "eslint-config-prettier";
import importPlugin from "eslint-plugin-import-x";
import noUnsanitized from "eslint-plugin-no-unsanitized";
import { configs as litConfigs } from "eslint-plugin-lit";
import globals from "globals";
const baseConfig = {
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
globals: {
...globals.node,
...globals.es2021,
...globals.mocha,
// Browser globals — intentionally limited subset.
// Using globals.browser pulls in hundreds of globals and breaks things.
window: "readonly",
document: "readonly",
navigator: "readonly",
setTimeout: "readonly",
clearTimeout: "readonly",
setInterval: "readonly",
clearInterval: "readonly",
FileReader: "readonly",
FileList: "readonly",
getComputedStyle: "readonly",
customElements: "readonly",
KeyboardEvent: "readonly",
MouseEvent: "readonly",
HTMLElement: "readonly",
Node: "readonly",
},
},
};
const pluginsConfig = {
plugins: {
// Registered as "import" to preserve backward compat with existing
// eslint-disable comments referencing import/* rules.
// The underlying package is eslint-plugin-import-x.
import: importPlugin,
"no-unsanitized": noUnsanitized,
},
rules: {
// --- Preventing bugs ---
"no-param-reassign": ["error", { props: false }],
"no-shadow": "error",
"no-use-before-define": [
"error",
{ functions: false, classes: true, variables: true },
],
eqeqeq: ["error", "always", { null: "ignore" }],
"no-return-assign": ["error", "always"],
"no-loop-func": "error",
"no-self-compare": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": [
"error",
{ allowShortCircuit: true, allowTernary: true },
],
// --- Security (beyond no-unsanitized plugin) ---
"no-implied-eval": "error",
"no-new-func": "error",
"no-extend-native": "error",
"no-new-wrappers": "error",
// --- Code style consistency ---
"no-var": "error",
"prefer-const": [
"error",
{ destructuring: "all", ignoreReadBeforeAssign: true },
],
"no-plusplus": ["error", { allowForLoopAfterthoughts: true }],
curly: ["error", "multi-line"],
"no-underscore-dangle": "warn",
// --- Import rules ---
"import/no-extraneous-dependencies": ["error", { devDependencies: true }],
"import/no-unresolved": ["error", { ignore: ["\\.(s?)css\\?inline$"] }],
// --- Security (plugin) ---
"no-unsanitized/method": "error",
"no-unsanitized/property": "error",
},
};
const testConfig = {
files: ["**/*.spec.js", "**/*.spec.mjs", "**/*.spec.cjs"],
rules: {
"no-unsanitized/method": "off",
"no-unsanitized/property": "off",
},
};
export default [
{
ignores: [
"dist/",
"_site/",
"node_modules/",
"packages/*/dist/",
"**/*.min.js",
".agents/",
],
},
litConfigs["flat/recommended"],
eslint.configs.recommended,
baseConfig,
pluginsConfig,
testConfig,
prettier, // Must be last to disable formatting rules
];