eslint-config-isaacscript 6.0.0 → 6.1.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/mod.js +97 -84
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-isaacscript",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "A sharable ESLint config for IsaacScript projects.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -31,10 +31,10 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "eslint-plugin-isaacscript": "4.0.0",
34
- "typescript-eslint": "8.43.0"
34
+ "typescript-eslint": "8.69.0"
35
35
  },
36
36
  "devDependencies": {
37
- "complete-node": "12.0.0"
37
+ "complete-node": "18.1.0"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "eslint": ">= 9.0.0"
package/src/mod.js CHANGED
@@ -1,4 +1,4 @@
1
- import ESLintPluginIsaacScript from "eslint-plugin-isaacscript";
1
+ import esLintPluginIsaacScript from "eslint-plugin-isaacscript";
2
2
  import { defineConfig } from "eslint/config";
3
3
 
4
4
  /**
@@ -7,208 +7,221 @@ import { defineConfig } from "eslint/config";
7
7
  */
8
8
  export const isaacScriptModConfigBase = defineConfig(
9
9
  {
10
+ // Rules that require type information will throw an error on ".json" files. (This is needed
11
+ // when using `eslint-plugin-package-json`. Even though this config does not currently use the
12
+ // plugin, we include it here defensively.)
13
+ ignores: ["*.json", "*.jsonc"],
14
+
10
15
  plugins: {
11
16
  // TODO: The `defineConfig` helper function is bugged.
12
17
  // @ts-expect-error https://github.com/typescript-eslint/typescript-eslint/issues/11543
13
- isaacscript: ESLintPluginIsaacScript,
18
+ isaacscript: esLintPluginIsaacScript,
14
19
  },
15
20
 
16
21
  rules: {
17
- "isaacscript/enum-member-number-separation": "warn",
18
- "isaacscript/no-invalid-default-map": "warn",
19
- "isaacscript/no-throw": "warn",
20
- "isaacscript/require-v-registration": "warn",
22
+ "isaacscript/enum-member-number-separation": "error",
23
+ "isaacscript/no-invalid-default-map": "error",
24
+ "isaacscript/no-throw": "error",
25
+ "isaacscript/require-v-registration": "error",
21
26
  },
27
+ },
22
28
 
29
+ {
23
30
  // Rules that require type information will throw an error on ".json" files. (This is needed
24
31
  // when using `eslint-plugin-package-json`. Even though this config does not currently use the
25
32
  // plugin, we include it here defensively.)
26
33
  ignores: ["*.json", "*.jsonc"],
27
- },
28
34
 
29
- {
30
35
  rules: {
31
36
  /**
32
- * Defined at: base-typescript-eslint.js
33
- *
34
37
  * It is conventional in IsaacScript mods to put the "v" object outside of the class, which
35
38
  * makes it likely that some methods will not use any internal class variables.
36
39
  */
37
40
  "@typescript-eslint/class-methods-use-this": "off",
38
41
 
39
42
  /**
40
- * Defined at: base-typescript-eslint.js
41
- *
42
43
  * We expand the original definition to ensure that all enums match the Isaac convention of
43
44
  * using UPPER_CASE.
44
45
  */
45
46
  "@typescript-eslint/naming-convention": [
46
- "warn",
47
+ "error",
47
48
  // Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables
48
49
  // (23.10).
49
50
  {
50
- selector: "variable",
51
51
  format: ["camelCase", "PascalCase", "UPPER_CASE"],
52
52
  leadingUnderscore: "allow",
53
+ selector: "variable",
53
54
  },
54
55
  // Allow camelCase functions (23.2), and PascalCase functions (23.8).
55
56
  {
56
- selector: "function",
57
57
  format: ["camelCase", "PascalCase"],
58
58
  leadingUnderscore: "allow",
59
+ selector: "function",
59
60
  },
60
61
  // Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make
61
62
  // TypeScript recommendations, we are assuming this rule would similarly apply to anything
62
63
  // "type like", including interfaces, type aliases, and enums.
63
64
  {
64
- selector: "typeLike",
65
65
  format: ["PascalCase"],
66
66
  leadingUnderscore: "allow",
67
+ selector: "typeLike",
67
68
  },
68
69
  // The vanilla Isaac enums all use UPPER_CASE:
69
70
  // https://wofsauge.github.io/IsaacDocs/rep/enums/CollectibleType.html
70
71
  {
71
- selector: "enumMember",
72
72
  format: ["UPPER_CASE"],
73
+ selector: "enumMember",
73
74
  },
74
75
  ],
75
76
 
76
77
  /**
77
- * Defined at: base-typescript-eslint.js
78
- *
79
78
  * The `Vector` object has a `tostring` meta-method, so it can be properly printed without
80
79
  * explicitly specifying the X and Y values.
81
80
  */
82
81
  "@typescript-eslint/no-base-to-string": [
83
- "warn",
84
- {
85
- ignoredTypeNames: ["Vector"],
86
- },
82
+ "error",
83
+ { ignoredTypeNames: ["Vector"] },
87
84
  ],
88
85
 
89
86
  /**
90
- * Defined at: base-typescript-eslint.js
91
- *
92
87
  * TSTL has special behavior with respect to `this: void`, so we need to configure this rule
93
88
  * to allow the `this` parameter.
94
89
  */
95
90
  "@typescript-eslint/no-invalid-void-type": [
96
- "warn",
97
- {
98
- allowAsThisParameter: true,
99
- },
91
+ "error",
92
+ { allowAsThisParameter: true },
100
93
  ],
101
94
 
102
95
  /**
103
- * Defined at: base-typescript-eslint.js
104
- *
105
96
  * This rule throws false positives with Isaac API functions. It can be worked around by
106
97
  * supplying lists of globals to ESLint, but this is ugly. See:
107
98
  * https://github.com/typescript-eslint/typescript-eslint/issues/2780
108
99
  */
109
100
  "@typescript-eslint/no-loop-func": "off",
110
101
 
102
+ /** This has false positives with the `int` type. */
103
+ "@typescript-eslint/no-unsafe-unary-minus": "off",
104
+
111
105
  /**
112
- * Defined at: base-typescript-eslint.js
113
- *
114
106
  * Enums that are used with the API must be numbers since that is what the API expects. We
115
107
  * also prefer that unofficial enums are also number enums for consistency.
116
108
  */
117
109
  "@typescript-eslint/prefer-enum-initializers": "off",
118
110
 
119
- /**
120
- * Defined at: base-typescript-eslint.js
121
- *
122
- * It is common to initialize enums with the `Isaac.GetEntityVariantByName` method.
123
- */
111
+ /** It is common to initialize enums with the `Isaac.GetEntityVariantByName` method. */
124
112
  "@typescript-eslint/prefer-literal-enum-member": "off",
125
113
 
126
114
  /**
127
- * Defined at: base-typescript-eslint.js
128
- *
129
115
  * The `Number.sort` method transpiles to use `table.sort`, which does not have the
130
116
  * coercion-based bugs of the JavaScript implementation. Thus, this lint rule is unnecessary.
131
117
  */
132
118
  "@typescript-eslint/require-array-sort-compare": "off",
133
119
 
134
120
  /**
135
- * Defined in "complete/recommended".
136
- *
137
121
  * Enums that are used with the API use upper case letters. We also prefer that unofficial
138
122
  * enums are also use upper case letters for consistency.
139
123
  */
140
124
  "complete/consistent-enum-values": "off",
141
125
 
142
126
  /**
143
- * Defined in "complete/recommended".
144
- *
145
127
  * Enums that are used with the API must be numbers since that is what the API expects. We
146
128
  * also prefer that unofficial enums are also number enums for consistency.
147
129
  */
148
130
  "complete/no-number-enums": "off",
149
131
 
150
132
  /**
151
- * Defined at: base-n.js
152
- *
153
- * IsaacScript mods to not use ESM, so we must turn this rule off.
133
+ * "v" objects should be in a semantic order and it would be too cumbersome to annotate all of
134
+ * them.
154
135
  */
155
- "n/file-extension-in-import": "off",
136
+ "complete/sort-objects": "off",
156
137
 
157
- /**
158
- * Defined at: base-unicorn.js
159
- *
160
- * `null` values are conventionally used with the `isaacscript-common` save data manager (even
161
- * though they are transpiled to `nil`).
162
- */
163
- "unicorn/no-null": "off",
164
-
165
- /**
166
- * Defined at: base-unicorn.js
167
- *
168
- * IsaacScript mods use Lua bitwise operators, which are safe.
169
- */
170
- "unicorn/prefer-math-trunc": "off",
138
+ /** IsaacScript mods to not use ESM, so we must turn this rule off. */
139
+ "n/file-extension-in-import": "off",
171
140
 
172
141
  /**
173
- * Defined at: base-eslint.js
174
- *
175
142
  * Isaac API methods use capital letters, so we must make the options for the rule less
176
143
  * strict.
177
144
  */
178
145
  "new-cap": [
179
- "warn",
146
+ "error",
180
147
  {
181
- newIsCap: true,
182
148
  capIsNew: false,
149
+ newIsCap: true,
183
150
  properties: true,
184
151
  },
185
152
  ],
186
153
 
187
- /**
188
- * Defined at: base-eslint.js
189
- *
190
- * Isaac enums use bitwise operators (e.g. "EntityFlag").
191
- */
154
+ /** Isaac enums use bitwise operators (e.g. "EntityFlag"). */
192
155
  "no-bitwise": "off",
193
156
 
194
- /**
195
- * Defined at: base-eslint.js
196
- *
197
- * The Isaac API callback functions expect you to modify the provided object.
198
- */
157
+ /** The Isaac API callback functions expect you to modify the provided object. */
199
158
  "no-param-reassign": "off",
200
159
 
160
+ /** "print" is used with Lua mods. */
161
+ "no-restricted-globals": "off",
162
+
163
+ /** Is it common for set ordering to have semantic meaning in Isaac mods. */
164
+ "perfectionist/sort-arrays": "off",
165
+
166
+ /* * It is idiomatic in Isaac mods to use "SubType" instead of "Subtype". */
167
+ "unicorn/consistent-compound-words": "off",
168
+
169
+ /** The rule assumes that `print` is the JavaScript one instead of the Lua one. */
170
+ "unicorn/no-invalid-argument-count": [
171
+ "error",
172
+ {
173
+ print: {
174
+ min: 0,
175
+ },
176
+ },
177
+ ],
178
+
201
179
  /**
202
- * Defined at: base-eslint.js
203
- *
204
- * "print" is used with Lua mods.
180
+ * `null` values are conventionally used with the `isaacscript-common` save data manager (even
181
+ * though they are transpiled to `nil`).
205
182
  */
206
- "no-restricted-globals": "off",
183
+ "unicorn/no-null": "off",
184
+
185
+ /** `Iterator#toArray()` is not supported by TypeScriptToLua. */
186
+ "unicorn/prefer-iterator-to-array": "off",
187
+
188
+ /** IsaacScript mods use Lua bitwise operators, which are safe. */
189
+ "unicorn/prefer-math-trunc": "off",
207
190
  },
191
+ },
208
192
 
209
- // Rules that require type information will throw an error on ".json" files. (This is needed
210
- // when using `eslint-plugin-package-json`. Even though this config does not currently use the
211
- // plugin, we include it here defensively.)
212
- ignores: ["*.json", "*.jsonc"],
193
+ {
194
+ files: [
195
+ "eslint.config.js",
196
+ "eslint.config.cjs",
197
+ "eslint.config.mjs",
198
+ "eslint.config.ts",
199
+ "eslint.config.cts",
200
+ "eslint.config.mts",
201
+ ],
202
+ rules: {
203
+ // TypeScript projects that use "complete-lint" have a false positive when importing
204
+ // "defineConfig" from "eslint/config", because "eslint" is a transitive dependency in
205
+ // "complete-lint". Similarly, importing "completeConfigBase" from "eslint-config-complete"
206
+ // fails, because "eslint-config-complete" is a transitive dependency in "complete-lint". (We
207
+ // extend the logic from "eslint-config-complete" and add a new value for
208
+ // "eslint-config-isaacscript.")
209
+ "import-x/no-extraneous-dependencies": [
210
+ "error",
211
+ {
212
+ devDependencies: ["**/eslint.config.{js,cjs,mjs,ts,cts,mts}"],
213
+ optionalDependencies: false,
214
+ whitelist: [
215
+ "eslint",
216
+ "eslint-config-complete",
217
+ "eslint-config-isaacscript",
218
+ ],
219
+ },
220
+ ],
221
+
222
+ // ESLint configuration files in monorepos often intentionally import from the "packages"
223
+ // subdirectory, because the config files are JavaScript so they cannot use tsconfig-paths.
224
+ "import-x/no-relative-packages": "off",
225
+ },
213
226
  },
214
227
  );