eslint-config-isaacscript 3.7.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -30
- package/base-eslint-comments.js +59 -0
- package/base-eslint.js +714 -277
- package/base-import.js +224 -0
- package/base-jsdoc.js +134 -135
- package/base-n.js +146 -0
- package/base-no-autofix.js +18 -0
- package/base-typescript-eslint.js +359 -223
- package/base-unicorn.js +227 -0
- package/base.js +15 -324
- package/mod.js +104 -94
- package/monorepo.js +4 -24
- package/package.json +5 -2
package/mod.js
CHANGED
|
@@ -15,25 +15,25 @@ const config = {
|
|
|
15
15
|
|
|
16
16
|
rules: {
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
* https://typescript-eslint.io/rules/naming-convention
|
|
18
|
+
* Defined at: base-typescript-eslint.js
|
|
20
19
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* Modify the Airbnb config to allow for a leading underscore, which signifies that it is
|
|
25
|
-
* temporarily not being used.
|
|
26
|
-
*
|
|
27
|
-
* Additionally, ensure that all enums match the Isaac convention of using UPPER_CASE.
|
|
20
|
+
* We expand the original definition to ensure that all enums match the Isaac convention of
|
|
21
|
+
* using UPPER_CASE.
|
|
28
22
|
*/
|
|
29
23
|
"@typescript-eslint/naming-convention": [
|
|
30
|
-
"
|
|
24
|
+
"error",
|
|
31
25
|
// Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables
|
|
32
26
|
// (23.10).
|
|
33
27
|
{
|
|
34
28
|
selector: "variable",
|
|
35
29
|
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
36
30
|
leadingUnderscore: "allow",
|
|
31
|
+
|
|
32
|
+
// Polyfilling "__dirname" in ESM files is a common pattern.
|
|
33
|
+
filter: {
|
|
34
|
+
regex: "^__dirname$",
|
|
35
|
+
match: false,
|
|
36
|
+
},
|
|
37
37
|
},
|
|
38
38
|
// Allow camelCase functions (23.2), and PascalCase functions (23.8).
|
|
39
39
|
{
|
|
@@ -47,6 +47,7 @@ const config = {
|
|
|
47
47
|
{
|
|
48
48
|
selector: "typeLike",
|
|
49
49
|
format: ["PascalCase"],
|
|
50
|
+
leadingUnderscore: "allow",
|
|
50
51
|
},
|
|
51
52
|
// The vanilla Isaac enums all use UPPER_CASE:
|
|
52
53
|
// https://wofsauge.github.io/IsaacDocs/rep/enums/CollectibleType.html
|
|
@@ -57,177 +58,186 @@ const config = {
|
|
|
57
58
|
],
|
|
58
59
|
|
|
59
60
|
/**
|
|
60
|
-
*
|
|
61
|
-
* https://typescript-eslint.io/rules/no-base-to-string/
|
|
62
|
-
*
|
|
63
|
-
* Defined at:
|
|
64
|
-
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/strict.ts
|
|
61
|
+
* Defined at: base-typescript-eslint.js
|
|
65
62
|
*
|
|
66
63
|
* The `Vector` object has a `tostring` meta-method, so it can be properly printed without
|
|
67
64
|
* explicitly specifying the X and Y values.
|
|
68
65
|
*/
|
|
69
66
|
"@typescript-eslint/no-base-to-string": [
|
|
70
|
-
"
|
|
67
|
+
"error",
|
|
71
68
|
{
|
|
72
69
|
ignoredTypeNames: ["Vector"],
|
|
73
70
|
},
|
|
74
71
|
],
|
|
75
72
|
|
|
76
73
|
/**
|
|
77
|
-
*
|
|
78
|
-
* https://typescript-eslint.io/rules/no-invalid-void-type
|
|
79
|
-
*
|
|
80
|
-
* Defined at:
|
|
81
|
-
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/strict.ts
|
|
74
|
+
* Defined at: base-typescript-eslint.js
|
|
82
75
|
*
|
|
83
|
-
* TSTL has special behavior with respect to
|
|
84
|
-
* allow the
|
|
76
|
+
* TSTL has special behavior with respect to `this: void`, so we need to configure this rule to
|
|
77
|
+
* allow the `this` parameter.
|
|
85
78
|
*/
|
|
86
79
|
"@typescript-eslint/no-invalid-void-type": [
|
|
87
|
-
"
|
|
80
|
+
"error",
|
|
88
81
|
{
|
|
89
82
|
allowAsThisParameter: true,
|
|
90
83
|
},
|
|
91
84
|
],
|
|
92
85
|
|
|
93
86
|
/**
|
|
94
|
-
*
|
|
95
|
-
* https://typescript-eslint.io/rules/no-loop-func
|
|
87
|
+
* Defined at: base-typescript-eslint.js
|
|
96
88
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* This rule throws false positives with API functions. It can be worked around by supplying
|
|
101
|
-
* lists of globals to ESLint, but this is ugly. See:
|
|
89
|
+
* This rule throws false positives with Isaac API functions. It can be worked around by
|
|
90
|
+
* supplying lists of globals to ESLint, but this is ugly. See:
|
|
102
91
|
* https://github.com/typescript-eslint/typescript-eslint/issues/2780
|
|
103
92
|
*/
|
|
104
93
|
"@typescript-eslint/no-loop-func": "off",
|
|
105
94
|
|
|
106
95
|
/**
|
|
107
|
-
*
|
|
108
|
-
* https://typescript-eslint.io/rules/prefer-literal-enum-member
|
|
96
|
+
* Defined at: base-typescript-eslint.js
|
|
109
97
|
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
98
|
+
* Enums that are used with the API must be numbers since that is what the API expects. We also
|
|
99
|
+
* prefer that unofficial enums are also number enums for consistency.
|
|
100
|
+
*/
|
|
101
|
+
"@typescript-eslint/prefer-enum-initializers": "off",
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Defined at: base-typescript-eslint.js
|
|
112
105
|
*
|
|
113
106
|
* It is common to initialize enums with the `Isaac.GetEntityVariantByName` method.
|
|
114
107
|
*/
|
|
115
108
|
"@typescript-eslint/prefer-literal-enum-member": "off",
|
|
116
109
|
|
|
117
110
|
/**
|
|
118
|
-
*
|
|
119
|
-
* https://github.com/IsaacScript/isaacscript/blob/main/packages/eslint-plugin-isaacscript/docs/rules/enum-member-number-separation.md
|
|
111
|
+
* Defined at: base-typescript-eslint.js
|
|
120
112
|
*
|
|
113
|
+
* The `Number.sort` method transpiles to use `table.sort`, which does not have the
|
|
114
|
+
* coercion-based bugs of the JavaScript implementation. Thus, this lint rule is unnecessary.
|
|
115
|
+
*/
|
|
116
|
+
"@typescript-eslint/require-array-sort-compare": "off",
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Defined at: base-typescript-eslint.js
|
|
120
|
+
*
|
|
121
|
+
* It is conventional in IsaacScript mods to put the "v" object outside of the class, which
|
|
122
|
+
* makes it likely that some methods will not use any internal class variables.
|
|
123
|
+
*/
|
|
124
|
+
"@typescript-eslint/class-methods-use-this": "off",
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Defined in "isaacscript/recommended".
|
|
128
|
+
*
|
|
129
|
+
* Enums that are used with the API use upper case letters. We also prefer that unofficial enums
|
|
130
|
+
* are also use upper case letters for consistency.
|
|
131
|
+
*/
|
|
132
|
+
"isaacscript/consistent-enum-values": "off",
|
|
133
|
+
|
|
134
|
+
/**
|
|
121
135
|
* Not defined in the parent configs.
|
|
122
136
|
*
|
|
123
137
|
* Since Isaac enums use the `SHOUTING_SNAKE_CASE` convention, this rule ensures correctness.
|
|
124
138
|
*/
|
|
125
|
-
"isaacscript/enum-member-number-separation": "
|
|
139
|
+
"isaacscript/enum-member-number-separation": "error",
|
|
126
140
|
|
|
127
141
|
/**
|
|
128
|
-
*
|
|
129
|
-
* https://github.com/IsaacScript/isaacscript/blob/main/packages/eslint-plugin-isaacscript/docs/rules/no-invalid-default-map.md
|
|
142
|
+
* Defined in "isaacscript/recommended".
|
|
130
143
|
*
|
|
144
|
+
* Enums that are used with the API must be numbers since that is what the API expects. We also
|
|
145
|
+
* prefer that unofficial enums are also number enums for consistency.
|
|
146
|
+
*/
|
|
147
|
+
"isaacscript/no-number-enums": "off",
|
|
148
|
+
|
|
149
|
+
/**
|
|
131
150
|
* Not defined in the parent configs.
|
|
132
151
|
*
|
|
133
152
|
* Prevents misuse of the custom `DefaultMap` class in the standard library.
|
|
134
153
|
*/
|
|
135
|
-
"isaacscript/no-invalid-default-map": "
|
|
154
|
+
"isaacscript/no-invalid-default-map": "error",
|
|
136
155
|
|
|
137
156
|
/**
|
|
138
|
-
* Documentation:
|
|
139
|
-
* https://github.com/IsaacScript/isaacscript/blob/main/packages/eslint-plugin-isaacscript/docs/rules/no-throw.md
|
|
140
|
-
*
|
|
141
157
|
* Not defined in the parent configs.
|
|
142
158
|
*
|
|
143
159
|
* The `throw` keyword should never be used in Isaac mods.
|
|
144
160
|
*/
|
|
145
|
-
"isaacscript/no-throw": "
|
|
161
|
+
"isaacscript/no-throw": "error",
|
|
146
162
|
|
|
147
163
|
/**
|
|
148
|
-
* Documentation:
|
|
149
|
-
* https://github.com/IsaacScript/isaacscript/blob/main/packages/eslint-plugin-isaacscript/docs/rules/require-v-registration.md
|
|
150
|
-
*
|
|
151
164
|
* Not defined in the parent configs.
|
|
152
165
|
*
|
|
153
166
|
* We must explicitly enable this rule, since it should only apply to IsaacScript mods.
|
|
154
167
|
*/
|
|
155
|
-
"isaacscript/require-v-registration": "
|
|
168
|
+
"isaacscript/require-v-registration": "error",
|
|
156
169
|
|
|
157
170
|
/**
|
|
158
|
-
*
|
|
159
|
-
* https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/file-extension-in-import.md
|
|
160
|
-
*
|
|
161
|
-
* Defined in "base.js".
|
|
171
|
+
* Defined at: base-n.js
|
|
162
172
|
*
|
|
163
173
|
* IsaacScript mods to not use ESM, so we must turn this rule off.
|
|
164
174
|
*/
|
|
165
175
|
"n/file-extension-in-import": "off",
|
|
166
176
|
|
|
167
177
|
/**
|
|
168
|
-
*
|
|
169
|
-
* https://eslint.org/docs/latest/rules/class-methods-use-this
|
|
178
|
+
* Defined at: base-unicorn.js
|
|
170
179
|
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
180
|
+
* `null` values are conventionally used with the `isaacscript-common` save data manager (even
|
|
181
|
+
* though they are transpiled to `nil`).
|
|
182
|
+
*/
|
|
183
|
+
"unicorn/no-null": "off",
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Defined at: base-unicorn.js
|
|
173
187
|
*
|
|
174
|
-
*
|
|
175
|
-
* makes it likely that some methods will not use any internal class variables.
|
|
188
|
+
* TypeScriptToLua does not support the `Array.at` method.
|
|
176
189
|
*/
|
|
177
|
-
"
|
|
190
|
+
"unicorn/prefer-at": "off",
|
|
178
191
|
|
|
179
192
|
/**
|
|
180
|
-
*
|
|
181
|
-
* https://eslint.org/docs/latest/rules/no-bitwise
|
|
193
|
+
* Defined at: base-unicorn.js
|
|
182
194
|
*
|
|
183
|
-
*
|
|
184
|
-
|
|
195
|
+
* IsaacScript mods use Lua bitwise operators, which are safe.
|
|
196
|
+
*/
|
|
197
|
+
"unicorn/prefer-math-trunc": "off",
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Defined at: base-unicorn.js
|
|
201
|
+
*
|
|
202
|
+
* TypeScriptToLua supports `parseInt`, but not `Number.parseInt`:
|
|
203
|
+
* https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1471
|
|
204
|
+
*/
|
|
205
|
+
"unicorn/prefer-number-properties": "off",
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Defined at: base-eslint.js
|
|
209
|
+
*
|
|
210
|
+
* Isaac API methods use capital letters, so we must make the options for the rule less strict.
|
|
211
|
+
*/
|
|
212
|
+
"new-cap": [
|
|
213
|
+
"error",
|
|
214
|
+
{
|
|
215
|
+
newIsCap: true,
|
|
216
|
+
capIsNew: false,
|
|
217
|
+
properties: true,
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Defined at: base-eslint.js
|
|
185
223
|
*
|
|
186
224
|
* Isaac enums use bitwise operators (e.g. "EntityFlag").
|
|
187
225
|
*/
|
|
188
226
|
"no-bitwise": "off",
|
|
189
227
|
|
|
190
228
|
/**
|
|
191
|
-
*
|
|
192
|
-
* https://eslint.org/docs/latest/rules/no-param-reassign
|
|
193
|
-
*
|
|
194
|
-
* Defined at:
|
|
195
|
-
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/best-practices.js
|
|
229
|
+
* Defined at: base-eslint.js
|
|
196
230
|
*
|
|
197
231
|
* The Isaac API callback functions expect you to modify the provided object.
|
|
198
232
|
*/
|
|
199
233
|
"no-param-reassign": "off",
|
|
200
234
|
|
|
201
235
|
/**
|
|
202
|
-
*
|
|
203
|
-
* https://eslint.org/docs/latest/rules/no-restricted-globals
|
|
204
|
-
*
|
|
205
|
-
* Defined at:
|
|
206
|
-
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/variables.js
|
|
236
|
+
* Defined at: base-eslint.js
|
|
207
237
|
*
|
|
208
238
|
* "print" is used with Lua mods.
|
|
209
239
|
*/
|
|
210
240
|
"no-restricted-globals": "off",
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Documentation:
|
|
214
|
-
* https://eslint.org/docs/latest/rules/no-underscore-dangle
|
|
215
|
-
*
|
|
216
|
-
* Defined at:
|
|
217
|
-
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/style.js
|
|
218
|
-
*
|
|
219
|
-
* We keep the Airbnb specification but allow calling functions that overload Lua operators:
|
|
220
|
-
* https://moddingofisaac.com/docs/class_vector.html
|
|
221
|
-
*/
|
|
222
|
-
"no-underscore-dangle": [
|
|
223
|
-
"warn",
|
|
224
|
-
{
|
|
225
|
-
allow: ["__add", "__sub", "__mul", "__div", "__unm", "__len"],
|
|
226
|
-
allowAfterThis: false,
|
|
227
|
-
allowAfterSuper: false,
|
|
228
|
-
enforceInMethodNames: true,
|
|
229
|
-
},
|
|
230
|
-
],
|
|
231
241
|
},
|
|
232
242
|
};
|
|
233
243
|
|
package/monorepo.js
CHANGED
|
@@ -8,38 +8,18 @@ const REPO_ROOT = path.join(__dirname, "..", "..", "..");
|
|
|
8
8
|
* @type {import("eslint").Linter.Config}
|
|
9
9
|
*/
|
|
10
10
|
const config = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// From:
|
|
14
|
-
// https://github.com/nrwl/nx/blob/master/packages/eslint-plugin-nx/src/configs/typescript.ts
|
|
11
|
+
// We need to add the `tsconfigRootDir` property, but we must also repeat the options from
|
|
12
|
+
// "base-typescript-eslint.js" or they will be deleted.
|
|
15
13
|
parserOptions: {
|
|
16
|
-
ecmaVersion:
|
|
14
|
+
ecmaVersion: "latest",
|
|
17
15
|
sourceType: "module",
|
|
18
|
-
// This cannot be simplified to `./../..` because of relative path shenanigans.
|
|
19
16
|
tsconfigRootDir: REPO_ROOT,
|
|
20
17
|
},
|
|
21
18
|
|
|
22
|
-
// The ".prettierrc.cjs" file is ignored by default, so we have to un-ignore it.
|
|
23
|
-
ignorePatterns: ["!.prettierrc.cjs"],
|
|
24
|
-
|
|
25
19
|
rules: {
|
|
26
|
-
"@nrwl/nx/enforce-module-boundaries": [
|
|
27
|
-
"warn",
|
|
28
|
-
{
|
|
29
|
-
enforceBuildableLibDependency: true,
|
|
30
|
-
allow: [],
|
|
31
|
-
depConstraints: [
|
|
32
|
-
{
|
|
33
|
-
sourceTag: "*",
|
|
34
|
-
onlyDependOnLibsWithTags: ["*"],
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
|
|
40
20
|
// This rule has to be told which "package.json" file that the dependencies are located in.
|
|
41
21
|
"import/no-extraneous-dependencies": [
|
|
42
|
-
"
|
|
22
|
+
"error",
|
|
43
23
|
{
|
|
44
24
|
packageDir: REPO_ROOT,
|
|
45
25
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-isaacscript",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "A sharable ESLint config for TypeScript and IsaacScript projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -21,5 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"author": "Zamiell",
|
|
24
|
-
"type": "commonjs"
|
|
24
|
+
"type": "commonjs",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"confusing-browser-globals": "^1.0.11"
|
|
27
|
+
}
|
|
25
28
|
}
|