eslint-config-isaacscript 4.20.0 → 5.0.1
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/LICENSE +1 -1
- package/README.md +2 -4
- package/package.json +10 -9
- package/src/mod.js +203 -0
- package/base.js +0 -68
- package/configs/base-eslint-comments.js +0 -59
- package/configs/base-eslint.js +0 -723
- package/configs/base-import.js +0 -250
- package/configs/base-jsdoc.js +0 -253
- package/configs/base-n.js +0 -158
- package/configs/base-no-autofix.js +0 -30
- package/configs/base-typescript-eslint.js +0 -551
- package/configs/base-unicorn.js +0 -233
- package/mod.js +0 -229
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022 IsaacScript
|
|
3
|
+
Copyright (c) 2022 The IsaacScript Contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
# eslint-config-isaacscript
|
|
1
|
+
# `eslint-config-isaacscript`
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/eslint-config-isaacscript)
|
|
4
4
|
|
|
5
|
-
This is a
|
|
6
|
-
|
|
7
|
-
Please see the [docs](https://isaacscript.github.io/eslint-config-isaacscript) for more information.
|
|
5
|
+
This is a shared configuration for [ESLint](https://eslint.org/) that is intended to be used in [IsaacScript](https://isaacscript.github.io/) mods. (By default, IsaacScript mods are automatically configured to use this config.)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-isaacscript",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "A sharable ESLint config for TypeScript and IsaacScript projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -21,20 +21,21 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"author": "Zamiell",
|
|
24
|
-
"type": "
|
|
24
|
+
"type": "module",
|
|
25
25
|
"files": [
|
|
26
|
-
"configs",
|
|
27
|
-
"base.js",
|
|
28
26
|
"LICENSE",
|
|
29
|
-
"mod.js",
|
|
30
27
|
"package.json",
|
|
31
|
-
"README.md"
|
|
28
|
+
"README.md",
|
|
29
|
+
"src"
|
|
32
30
|
],
|
|
33
31
|
"scripts": {
|
|
34
|
-
"lint": "tsx ./scripts/lint.
|
|
35
|
-
"query-rule": "tsx ./scripts/queryRule.mts"
|
|
32
|
+
"lint": "tsx ./scripts/lint.ts"
|
|
36
33
|
},
|
|
37
34
|
"dependencies": {
|
|
38
|
-
"
|
|
35
|
+
"eslint-plugin-isaacscript": "^4.0.0",
|
|
36
|
+
"typescript-eslint": "^8.5.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"complete-node": "^1.3.0"
|
|
39
40
|
}
|
|
40
41
|
}
|
package/src/mod.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import ESLintPluginIsaacScript from "eslint-plugin-isaacscript";
|
|
2
|
+
import tseslint from "typescript-eslint";
|
|
3
|
+
|
|
4
|
+
// Hot-patch "eslint-plugin-isaacscript" to convert errors to warnings.
|
|
5
|
+
for (const config of ESLintPluginIsaacScript.configs.recommended) {
|
|
6
|
+
if (config.rules !== undefined) {
|
|
7
|
+
for (const [key, value] of Object.entries(config.rules)) {
|
|
8
|
+
if (value === "error") {
|
|
9
|
+
config.rules[key] = "warn";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This ESLint config is meant to be used as a base for IsaacScript mods (or TypeScriptToLua
|
|
17
|
+
* projects).
|
|
18
|
+
*/
|
|
19
|
+
export const isaacScriptModConfigBase = tseslint.config(
|
|
20
|
+
// `eslint-plugin-isaacscript` provides rules specifically for IsaacScript mods.
|
|
21
|
+
...ESLintPluginIsaacScript.configs.recommended,
|
|
22
|
+
|
|
23
|
+
{
|
|
24
|
+
rules: {
|
|
25
|
+
/**
|
|
26
|
+
* Defined at: base-typescript-eslint.js
|
|
27
|
+
*
|
|
28
|
+
* It is conventional in IsaacScript mods to put the "v" object outside of the class, which
|
|
29
|
+
* makes it likely that some methods will not use any internal class variables.
|
|
30
|
+
*/
|
|
31
|
+
"@typescript-eslint/class-methods-use-this": "off",
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Defined at: base-typescript-eslint.js
|
|
35
|
+
*
|
|
36
|
+
* We expand the original definition to ensure that all enums match the Isaac convention of
|
|
37
|
+
* using UPPER_CASE.
|
|
38
|
+
*/
|
|
39
|
+
"@typescript-eslint/naming-convention": [
|
|
40
|
+
"warn",
|
|
41
|
+
// Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables
|
|
42
|
+
// (23.10).
|
|
43
|
+
{
|
|
44
|
+
selector: "variable",
|
|
45
|
+
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
46
|
+
leadingUnderscore: "allow",
|
|
47
|
+
},
|
|
48
|
+
// Allow camelCase functions (23.2), and PascalCase functions (23.8).
|
|
49
|
+
{
|
|
50
|
+
selector: "function",
|
|
51
|
+
format: ["camelCase", "PascalCase"],
|
|
52
|
+
leadingUnderscore: "allow",
|
|
53
|
+
},
|
|
54
|
+
// Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make
|
|
55
|
+
// TypeScript recommendations, we are assuming this rule would similarly apply to anything
|
|
56
|
+
// "type like", including interfaces, type aliases, and enums.
|
|
57
|
+
{
|
|
58
|
+
selector: "typeLike",
|
|
59
|
+
format: ["PascalCase"],
|
|
60
|
+
leadingUnderscore: "allow",
|
|
61
|
+
},
|
|
62
|
+
// The vanilla Isaac enums all use UPPER_CASE:
|
|
63
|
+
// https://wofsauge.github.io/IsaacDocs/rep/enums/CollectibleType.html
|
|
64
|
+
{
|
|
65
|
+
selector: "enumMember",
|
|
66
|
+
format: ["UPPER_CASE"],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Defined at: base-typescript-eslint.js
|
|
72
|
+
*
|
|
73
|
+
* The `Vector` object has a `tostring` meta-method, so it can be properly printed without
|
|
74
|
+
* explicitly specifying the X and Y values.
|
|
75
|
+
*/
|
|
76
|
+
"@typescript-eslint/no-base-to-string": [
|
|
77
|
+
"warn",
|
|
78
|
+
{
|
|
79
|
+
ignoredTypeNames: ["Vector"],
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Defined at: base-typescript-eslint.js
|
|
85
|
+
*
|
|
86
|
+
* TSTL has special behavior with respect to `this: void`, so we need to configure this rule
|
|
87
|
+
* to allow the `this` parameter.
|
|
88
|
+
*/
|
|
89
|
+
"@typescript-eslint/no-invalid-void-type": [
|
|
90
|
+
"warn",
|
|
91
|
+
{
|
|
92
|
+
allowAsThisParameter: true,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Defined at: base-typescript-eslint.js
|
|
98
|
+
*
|
|
99
|
+
* This rule throws false positives with Isaac API functions. It can be worked around by
|
|
100
|
+
* supplying lists of globals to ESLint, but this is ugly. See:
|
|
101
|
+
* https://github.com/typescript-eslint/typescript-eslint/issues/2780
|
|
102
|
+
*/
|
|
103
|
+
"@typescript-eslint/no-loop-func": "off",
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Defined at: base-typescript-eslint.js
|
|
107
|
+
*
|
|
108
|
+
* Enums that are used with the API must be numbers since that is what the API expects. We
|
|
109
|
+
* also prefer that unofficial enums are also number enums for consistency.
|
|
110
|
+
*/
|
|
111
|
+
"@typescript-eslint/prefer-enum-initializers": "off",
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Defined at: base-typescript-eslint.js
|
|
115
|
+
*
|
|
116
|
+
* It is common to initialize enums with the `Isaac.GetEntityVariantByName` method.
|
|
117
|
+
*/
|
|
118
|
+
"@typescript-eslint/prefer-literal-enum-member": "off",
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Defined at: base-typescript-eslint.js
|
|
122
|
+
*
|
|
123
|
+
* The `Number.sort` method transpiles to use `table.sort`, which does not have the
|
|
124
|
+
* coercion-based bugs of the JavaScript implementation. Thus, this lint rule is unnecessary.
|
|
125
|
+
*/
|
|
126
|
+
"@typescript-eslint/require-array-sort-compare": "off",
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Defined in "complete/recommended".
|
|
130
|
+
*
|
|
131
|
+
* Enums that are used with the API use upper case letters. We also prefer that unofficial
|
|
132
|
+
* enums are also use upper case letters for consistency.
|
|
133
|
+
*/
|
|
134
|
+
"complete/consistent-enum-values": "off",
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Defined in "complete/recommended".
|
|
138
|
+
*
|
|
139
|
+
* Enums that are used with the API must be numbers since that is what the API expects. We
|
|
140
|
+
* also prefer that unofficial enums are also number enums for consistency.
|
|
141
|
+
*/
|
|
142
|
+
"complete/no-number-enums": "off",
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Defined at: base-n.js
|
|
146
|
+
*
|
|
147
|
+
* IsaacScript mods to not use ESM, so we must turn this rule off.
|
|
148
|
+
*/
|
|
149
|
+
"n/file-extension-in-import": "off",
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Defined at: base-unicorn.js
|
|
153
|
+
*
|
|
154
|
+
* `null` values are conventionally used with the `isaacscript-common` save data manager (even
|
|
155
|
+
* though they are transpiled to `nil`).
|
|
156
|
+
*/
|
|
157
|
+
"unicorn/no-null": "off",
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Defined at: base-unicorn.js
|
|
161
|
+
*
|
|
162
|
+
* IsaacScript mods use Lua bitwise operators, which are safe.
|
|
163
|
+
*/
|
|
164
|
+
"unicorn/prefer-math-trunc": "off",
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Defined at: base-eslint.js
|
|
168
|
+
*
|
|
169
|
+
* Isaac API methods use capital letters, so we must make the options for the rule less
|
|
170
|
+
* strict.
|
|
171
|
+
*/
|
|
172
|
+
"new-cap": [
|
|
173
|
+
"warn",
|
|
174
|
+
{
|
|
175
|
+
newIsCap: true,
|
|
176
|
+
capIsNew: false,
|
|
177
|
+
properties: true,
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Defined at: base-eslint.js
|
|
183
|
+
*
|
|
184
|
+
* Isaac enums use bitwise operators (e.g. "EntityFlag").
|
|
185
|
+
*/
|
|
186
|
+
"no-bitwise": "off",
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Defined at: base-eslint.js
|
|
190
|
+
*
|
|
191
|
+
* The Isaac API callback functions expect you to modify the provided object.
|
|
192
|
+
*/
|
|
193
|
+
"no-param-reassign": "off",
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Defined at: base-eslint.js
|
|
197
|
+
*
|
|
198
|
+
* "print" is used with Lua mods.
|
|
199
|
+
*/
|
|
200
|
+
"no-restricted-globals": "off",
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
);
|
package/base.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This ESLint config is meant to be used as a base for all TypeScript projects.
|
|
3
|
-
*
|
|
4
|
-
* @type {import("eslint").Linter.Config}
|
|
5
|
-
*/
|
|
6
|
-
const config = {
|
|
7
|
-
extends: [
|
|
8
|
-
/**
|
|
9
|
-
* Find deprecated code:
|
|
10
|
-
* https://github.com/gund/eslint-plugin-deprecation
|
|
11
|
-
*/
|
|
12
|
-
"plugin:deprecation/recommended",
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* This provides extra miscellaneous rules to keep code safe:
|
|
16
|
-
* https://github.com/IsaacScript/isaacscript/tree/main/packages/eslint-plugin-isaacscript
|
|
17
|
-
*/
|
|
18
|
-
"plugin:isaacscript/recommended",
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Disable any ESLint rules that conflict with Prettier:
|
|
22
|
-
* https://github.com/prettier/eslint-config-prettier
|
|
23
|
-
* Otherwise, we will have unfixable ESLint errors. Note that the Prettier config has to be
|
|
24
|
-
* before the base ESLint config below since we customize some special rules as documented here:
|
|
25
|
-
* https://github.com/prettier/eslint-config-prettier#special-rules
|
|
26
|
-
*/
|
|
27
|
-
"prettier",
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Rule modifications are split out into different files for better organization (based on the
|
|
31
|
-
* originating plugin) .
|
|
32
|
-
*/
|
|
33
|
-
"./configs/base-eslint",
|
|
34
|
-
"./configs/base-no-autofix",
|
|
35
|
-
"./configs/base-typescript-eslint",
|
|
36
|
-
"./configs/base-eslint-comments",
|
|
37
|
-
"./configs/base-import",
|
|
38
|
-
"./configs/base-jsdoc",
|
|
39
|
-
"./configs/base-n", // "n" stands for Node.
|
|
40
|
-
"./configs/base-unicorn",
|
|
41
|
-
],
|
|
42
|
-
|
|
43
|
-
plugins: [
|
|
44
|
-
/**
|
|
45
|
-
* Activate the "eslint-plugin-only-warn" plugin to change all errors to warnings:
|
|
46
|
-
* https://github.com/bfanger/eslint-plugin-only-warn
|
|
47
|
-
*
|
|
48
|
-
* This allows the end-user to more easily distinguish between errors from the TypeScript
|
|
49
|
-
* compiler (which show up in red) and ESLint rule violations (which show up in yellow).
|
|
50
|
-
*/
|
|
51
|
-
"only-warn",
|
|
52
|
-
],
|
|
53
|
-
|
|
54
|
-
overrides: [
|
|
55
|
-
// Disable some TypeScript-specific rules in JavaScript files.
|
|
56
|
-
{
|
|
57
|
-
files: ["*.js", "*.cjs", "*.mjs", "*.jsx"],
|
|
58
|
-
rules: {
|
|
59
|
-
"isaacscript/no-let-any": "off",
|
|
60
|
-
"isaacscript/no-object-any": "off",
|
|
61
|
-
"isaacscript/require-capital-const-assertions": "off",
|
|
62
|
-
"isaacscript/require-capital-read-only": "off",
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
module.exports = config;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// This ESLint config only contains rules from `eslint-plugin-eslint-comments`:
|
|
2
|
-
// https://github.com/mysticatea/eslint-plugin-eslint-comments
|
|
3
|
-
|
|
4
|
-
// Rules are separated into categories:
|
|
5
|
-
// 1) Best Practices
|
|
6
|
-
// 2) Stylistic Issues
|
|
7
|
-
|
|
8
|
-
/** @type {import("eslint").Linter.RulesRecord} */
|
|
9
|
-
const BEST_PRACTICES = {
|
|
10
|
-
/**
|
|
11
|
-
* The `allowWholeFile` option is enabled because it is common practice to use "eslint-disable"
|
|
12
|
-
* comments for a whole file.
|
|
13
|
-
*/
|
|
14
|
-
"eslint-comments/disable-enable-pair": [
|
|
15
|
-
"error",
|
|
16
|
-
{
|
|
17
|
-
allowWholeFile: true,
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
|
|
21
|
-
"eslint-comments/no-aggregating-enable": "error",
|
|
22
|
-
"eslint-comments/no-duplicate-disable": "error",
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Disabled because if a line breaks three or more ESLint rules, then it is useful to use a single
|
|
26
|
-
* "eslint-disable" comment to make things more concise.
|
|
27
|
-
*/
|
|
28
|
-
"eslint-comments/no-unlimited-disable": "off",
|
|
29
|
-
|
|
30
|
-
"eslint-comments/no-unused-disable": "error",
|
|
31
|
-
"eslint-comments/no-unused-enable": "error",
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/** @type {import("eslint").Linter.RulesRecord} */
|
|
35
|
-
const STYLISTIC_ISSUES = {
|
|
36
|
-
/**
|
|
37
|
-
* Disabled because it is only useful in projects that want to prevent disabling specific ESLint
|
|
38
|
-
* rules.
|
|
39
|
-
*/
|
|
40
|
-
"eslint-comments/no-restricted-disable": "off",
|
|
41
|
-
|
|
42
|
-
/** Disabled because we want to allow disabling ESLint rules where appropriate. */
|
|
43
|
-
"eslint-comments/no-use": "off",
|
|
44
|
-
|
|
45
|
-
/** Disabled because requiring descriptions for every ESLint disable would be too cumbersome. */
|
|
46
|
-
"eslint-comments/require-description": "off",
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/** @type {import("eslint").Linter.Config} */
|
|
50
|
-
const config = {
|
|
51
|
-
plugins: ["eslint-comments"],
|
|
52
|
-
|
|
53
|
-
rules: {
|
|
54
|
-
...BEST_PRACTICES,
|
|
55
|
-
...STYLISTIC_ISSUES,
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
module.exports = config;
|