-
Notifications
You must be signed in to change notification settings - Fork 281
Expand file tree
/
Copy patheslint.config.mjs
More file actions
154 lines (153 loc) · 6.44 KB
/
Copy patheslint.config.mjs
File metadata and controls
154 lines (153 loc) · 6.44 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
import eslint from "@eslint/js";
// import obsidianmd from "eslint-plugin-obsidianmd";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import eslintPluginUnicorn from "eslint-plugin-unicorn";
import tseslint from "typescript-eslint";
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
// ...obsidianmd.configs.recommended, // TODO: Enable this once we have a proper code base
{
languageOptions: {
parserOptions: {
projectService: true,
},
},
},
// TODO: Remove the conversion to warnings once we have a proper code base
{
rules: {
"no-var": "error",
"prefer-const": "error",
"prefer-rest-params": "warn",
"prefer-spread": "warn",
"@typescript-eslint/await-thenable": "warn",
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-array-constructor": "warn",
"@typescript-eslint/no-array-delete": "warn",
"@typescript-eslint/no-base-to-string": "warn",
"@typescript-eslint/no-duplicate-enum-values": "warn",
"@typescript-eslint/no-duplicate-type-constituents": "warn",
"@typescript-eslint/no-empty-object-type": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-extra-non-null-assertion": "warn",
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-for-in-array": "warn",
"no-implied-eval": "error",
"@typescript-eslint/no-implied-eval": "warn",
"@typescript-eslint/no-misused-new": "warn",
"@typescript-eslint/no-misused-promises": "warn",
"@typescript-eslint/no-namespace": "warn",
"@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
"@typescript-eslint/no-redundant-type-constituents": "warn",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
"@typescript-eslint/no-unsafe-argument": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
"@typescript-eslint/no-unsafe-enum-comparison": "warn",
"@typescript-eslint/no-unsafe-function-type": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/no-unsafe-unary-minus": "warn",
"no-unused-expressions": "warn",
"@typescript-eslint/no-unused-expressions": "warn",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-wrapper-object-types": "warn",
"@typescript-eslint/only-throw-error": "warn",
"@typescript-eslint/prefer-as-const": "warn",
"@typescript-eslint/prefer-namespace-keyword": "warn",
"@typescript-eslint/prefer-promise-reject-errors": "warn",
"@typescript-eslint/require-await": "warn",
"@typescript-eslint/restrict-plus-operands": "warn",
"@typescript-eslint/restrict-template-expressions": "warn",
"@typescript-eslint/triple-slash-reference": "warn",
"@typescript-eslint/unbound-method": "warn",
},
},
{
plugins: {
"simple-import-sort": simpleImportSort,
unicorn: eslintPluginUnicorn,
},
rules: {
"linebreak-style": 0,
quotes: ["warn", "double", "avoid-escape"],
semi: ["error", "always"],
camelcase: ["error"],
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
"unicorn/filename-case": [
"error",
{
case: "kebabCase",
},
],
"simple-import-sort/imports": [
"error",
{
groups: [["^"], ["^src"], ["^\\.", "^tests"]],
},
],
},
},
{
files: ["src/**"],
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["./", "../"],
message: "Relative imports are not allowed in src/.",
},
],
},
],
"no-restricted-syntax": [
"error",
{
selector: "CallExpression[callee.property.name=/^insertAdjacent/]",
message:
"insertAdjacent methods are not allowed. Use alternative DOM manipulation methods instead.",
},
{
selector: 'AssignmentExpression[left.property.name="innerHTML"]',
message:
"innerHTML assignment is not allowed. Use alternative DOM manipulation methods instead.",
},
{
selector: 'NewExpression[callee.name="Function"]',
message:
"new Function() is not allowed due to security risks. Use alternative approaches instead.",
},
{
selector: 'Identifier[name="document"]',
message: "Use activeDocument instead of document.",
},
{
selector: 'AssignmentExpression[left.object.property.name="style"]',
message:
"Avoid setting styles directly via element.style. Use CSS classes for better theming and maintainability. Use the setCssProps function if the CSS properties need to change dynamically.",
},
],
},
},
{
files: ["tests/**"],
rules: {
"@typescript-eslint/no-require-imports": "off",
},
},
);