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