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/base-import.js ADDED
@@ -0,0 +1,224 @@
1
+ // This ESLint config only contains rules from `eslint-plugin-import`:
2
+ // https://github.com/import-js/eslint-plugin-import
3
+
4
+ // Rules are separated into categories:
5
+ // 1) Helpful warnings
6
+ // 2) Module systems
7
+ // 3) Static analysis
8
+ // 4) Style guide
9
+
10
+ /** @type {import("eslint").Linter.RulesRecord} */
11
+ const HELPFUL_WARNINGS = {
12
+ "import/export": "error",
13
+
14
+ /**
15
+ * Superseded by the `deprecation/deprecation` rule. (That rule is better because it catches
16
+ * deprecated usage that does not come from import statements specifically.)
17
+ */
18
+ "import/no-deprecated": "off",
19
+
20
+ "import/no-empty-named-blocks": "error",
21
+
22
+ /**
23
+ * The options are [copied from
24
+ * Airbnb](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/import.js).
25
+ */
26
+ "import/no-extraneous-dependencies": [
27
+ "error",
28
+ {
29
+ devDependencies: [
30
+ "test/**", // tape, common npm pattern
31
+ "tests/**", // also common npm pattern
32
+ "spec/**", // mocha, rspec-like pattern
33
+ "**/__tests__/**", // jest pattern
34
+ "**/__mocks__/**", // jest pattern
35
+ "test.{js,jsx}", // repos with a single test file
36
+ "test-*.{js,jsx}", // repos with multiple top-level test files
37
+ "**/*{.,_}{test,spec}.{js,jsx}", // tests where the extension or filename suffix denotes that it is a test
38
+ "**/jest.config.js", // jest config
39
+ "**/jest.setup.js", // jest setup
40
+ "**/vue.config.js", // vue-cli config
41
+ "**/webpack.config.js", // webpack config
42
+ "**/webpack.config.*.js", // webpack config
43
+ "**/rollup.config.js", // rollup config
44
+ "**/rollup.config.*.js", // rollup config
45
+ "**/gulpfile.js", // gulp config
46
+ "**/gulpfile.*.js", // gulp config
47
+ "**/Gruntfile{,.js}", // grunt config
48
+ "**/protractor.conf.js", // protractor config
49
+ "**/protractor.conf.*.js", // protractor config
50
+ "**/karma.conf.js", // karma config
51
+ "**/.eslintrc.js", // eslint config
52
+ ],
53
+ optionalDependencies: false,
54
+ },
55
+ ],
56
+
57
+ "import/no-mutable-exports": "error",
58
+ "import/no-named-as-default": "error",
59
+
60
+ /**
61
+ * Disabled because this is [already handled by the TypeScript
62
+ * compiler](https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js).
63
+ */
64
+ "import/no-named-as-default-member": "off",
65
+
66
+ /**
67
+ * Disabled since this check is better performed by the [`knip`](https://github.com/webpro/knip)
68
+ * tool.
69
+ */
70
+ "import/no-unused-modules": "off",
71
+ };
72
+
73
+ /** @type {import("eslint").Linter.RulesRecord} */
74
+ const MODULE_SYSTEMS = {
75
+ "import/no-amd": "error",
76
+ "import/no-commonjs": "error",
77
+ "import/no-import-module-exports": "error",
78
+
79
+ /** Disabled because it is only used in specific environments (like the browser). */
80
+ "import/no-nodejs-modules": "off",
81
+
82
+ /** Disabled because this is already handled by the TypeScript compiler. */
83
+ "import/unambiguous": "off",
84
+ };
85
+
86
+ /** @type {import("eslint").Linter.RulesRecord} */
87
+ const STATIC_ANALYSIS = {
88
+ "import/default": "error",
89
+
90
+ /**
91
+ * Disabled because this is [already handled by the TypeScript
92
+ * compiler](https://github.com/import-js/eslint-plugin-import/blob/main/config/typescript.js).
93
+ */
94
+ "import/named": "off",
95
+
96
+ "import/namespace": "error",
97
+ "import/no-absolute-path": "error",
98
+ "import/no-cycle": "error",
99
+ "import/no-dynamic-require": "error",
100
+
101
+ /** Disabled since a prescribed import pattern is not generalizable enough across projects. */
102
+ "import/no-internal-modules": "off",
103
+
104
+ "import/no-relative-packages": "error",
105
+
106
+ /**
107
+ * Disabled since a forward import direction pattern is not generalizable enough across projects.
108
+ */
109
+ "import/no-relative-parent-imports": "off",
110
+
111
+ /** Disabled since this rule should only contain a project-specific path restriction. */
112
+ "import/no-restricted-paths": "off",
113
+
114
+ "import/no-self-import": "error",
115
+
116
+ /**
117
+ * Disabled because this is [already handled by the TypeScript
118
+ * compiler](https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js).
119
+ */
120
+ "import/no-unresolved": "off",
121
+
122
+ "import/no-useless-path-segments": "error",
123
+ "import/no-webpack-loader-syntax": "error",
124
+ };
125
+
126
+ /** @type {import("eslint").Linter.RulesRecord} */
127
+ const STYLE_GUIDE = {
128
+ "import/consistent-type-specifier-style": "error",
129
+
130
+ /** Disabled because it is only useful in environments that use webpack. */
131
+ "import/dynamic-import-chunkname": "off",
132
+
133
+ /** Disabled because this style is not generally used. */
134
+ "import/exports-last": "off",
135
+
136
+ /** Disabled because this is already handled by the TypeScript compiler. */
137
+ "import/extensions": "off",
138
+
139
+ "import/first": "error",
140
+
141
+ /** Disabled because this style is not generally used. */
142
+ "import/group-exports": "off",
143
+
144
+ /** Disabled because this rule is deprecated. */
145
+ "import/imports-first": "off",
146
+
147
+ /** Disabled since it will trigger false positives in codebases that prefer smaller files. */
148
+ "import/max-dependencies": "off",
149
+
150
+ "import/newline-after-import": "error",
151
+
152
+ /**
153
+ * Disabled since we disallow default exports elsewhere in this config (in favor of named
154
+ * exports).
155
+ */
156
+ "import/no-anonymous-default-export": "off",
157
+
158
+ /**
159
+ * The case against default exports is [layed out by Basarat Ali
160
+ * Syed](https://basarat.gitbook.io/typescript/main-1/defaultisbad).
161
+ */
162
+ "import/no-default-export": "error",
163
+
164
+ "import/no-duplicates": "error",
165
+ "import/no-named-default": "error",
166
+
167
+ /**
168
+ * Disabled since we disallow default exports elsewhere in this config (in favor of named
169
+ * exports).
170
+ */
171
+ "import/no-named-export": "off",
172
+
173
+ /**
174
+ * Disabled since it is too prescriptive for a general audience. (Using `import * as` is common.)
175
+ */
176
+ "import/no-namespace": "off",
177
+
178
+ "import/no-unassigned-import": "error",
179
+
180
+ /** Disabled because this is automatically handled by `prettier-plugin-organize-imports`. */
181
+ "import/order": "off",
182
+
183
+ /**
184
+ * Disabled because we disallow default exports elsewhere in this config (in favor of named
185
+ * exports).
186
+ */
187
+ "import/prefer-default-export": "off",
188
+ };
189
+
190
+ /*
191
+ * @type {import("eslint").Linter.Config}
192
+ */
193
+ const config = {
194
+ // No additional configuration is necessary to make the plugin work properly with TypeScript.
195
+ // (This was tested with the `import/no-default-export` rule.)
196
+ plugins: ["import"],
197
+
198
+ rules: {
199
+ ...HELPFUL_WARNINGS,
200
+ ...MODULE_SYSTEMS,
201
+ ...STATIC_ANALYSIS,
202
+ ...STYLE_GUIDE,
203
+ },
204
+
205
+ overrides: [
206
+ // Disable some TypeScript-specific rules in JavaScript files.
207
+ {
208
+ files: ["*.js", "*.cjs", "*.mjs", "*.jsx"],
209
+ rules: {
210
+ "import/no-commonjs": "off",
211
+ },
212
+ },
213
+
214
+ // Disable some specific rules in config files.
215
+ {
216
+ files: [".remarkrc.mjs", "prettier.config.mjs"],
217
+ rules: {
218
+ "import/no-default-export": "off",
219
+ },
220
+ },
221
+ ],
222
+ };
223
+
224
+ module.exports = config;
package/base-jsdoc.js CHANGED
@@ -7,42 +7,38 @@
7
7
  const config = {
8
8
  plugins: ["jsdoc"],
9
9
 
10
- /**
11
- * Instead of using the recommended config, we specifically turn on every rule that is useful.
12
- *
13
- * We must specify `contexts: ["any"]` for some rules because by default, only a subset of AST
14
- * node types will be affected.
15
- */
16
10
  rules: {
17
- // - jsdoc/check-access - Not needed in TypeScript.
18
- // - jsdoc/check-alignment - Overlaps with `isaacscript/limit-jsdoc-comments`.
11
+ /** Disabled because it is not needed in TypeScript. */
12
+ "jsdoc/check-access": "off",
19
13
 
20
- // - jsdoc/check-examples - Does not work with ESLint 8; see:
21
- // https://github.com/eslint/eslint/issues/14745
22
-
23
- // - jsdoc/check-indentation - Overlaps with `isaacscript/limit-jsdoc-comments`.
24
- // - jsdoc/check-line-alignment - This is not a common formatting scheme in the wild. It's also
25
- // not recommended by the plugin.
14
+ /** Superseded by the `isaacscript/limit-jsdoc-comments` rule. */
15
+ "jsdoc/check-alignment": "off",
26
16
 
27
17
  /**
28
- * Documentation:
29
- * https://github.com/gajus/eslint-plugin-jsdoc#check-param-names
30
- *
31
- * Ensures that parameter names in JSDoc match those in the function declaration.
18
+ * Disabled since it [does not work with ESLint
19
+ * 8](https://github.com/eslint/eslint/issues/14745).
32
20
  */
33
- "jsdoc/check-param-names": "warn",
21
+ "jsdoc/check-examples": "off",
34
22
 
35
- // - jsdoc/check-property-names - Not needed in TypeScript.
36
- // - jsdoc/check-syntax - Not needed in TypeScript.
23
+ /** Superseded by the `isaacscript/limit-jsdoc-comments` rule. */
24
+ "jsdoc/check-indentation": "off",
37
25
 
38
26
  /**
39
- * Documentation:
40
- * https://github.com/gajus/eslint-plugin-jsdoc#check-tag-names
41
- *
42
- * Reports invalid block tag names.
27
+ * Disabled since this is not a common formatting scheme. It is also not recommended by the
28
+ * plugin authors.
43
29
  */
30
+ "jsdoc/check-line-alignment": "off",
31
+
32
+ "jsdoc/check-param-names": "error",
33
+
34
+ /** Disabled because it is not needed in TypeScript. */
35
+ "jsdoc/check-property-names": "off",
36
+
37
+ /** Disabled because it is not needed in TypeScript. */
38
+ "jsdoc/check-syntax": "off",
39
+
44
40
  "jsdoc/check-tag-names": [
45
- "warn",
41
+ "error",
46
42
  {
47
43
  definedTags: [
48
44
  // Ignore tags used by the TypeScript compiler:
@@ -74,115 +70,110 @@ const config = {
74
70
  },
75
71
  ],
76
72
 
77
- // - jsdoc/check-types - Not needed in TypeScript.
73
+ /** Disabled because it is not needed in TypeScript. */
74
+ "jsdoc/check-types": "off",
78
75
 
79
- /**
80
- * Documentation:
81
- * https://github.com/gajus/eslint-plugin-jsdoc#check-values
82
- *
83
- * Validates the content of some uncommon JSDoc tags.
84
- */
85
- "jsdoc/check-values": "warn",
76
+ "jsdoc/check-values": "error",
77
+ "jsdoc/empty-tags": "error",
78
+ "jsdoc/implements-on-classes": "error",
86
79
 
87
- /**
88
- * Documentation:
89
- * https://github.com/gajus/eslint-plugin-jsdoc#check-values
90
- *
91
- * Validates that specific tags are never empty.
92
- */
93
- "jsdoc/empty-tags": "warn",
80
+ /** Disabled since you cannot configure it with a path to the correct "package.json" file. */
81
+ "jsdoc/imports-as-dependencies": "off",
94
82
 
95
- /**
96
- * Documentation:
97
- * https://github.com/gajus/eslint-plugin-jsdoc#implements-on-classes
98
- *
99
- * Reports issues with incorrect usage of `@implements`.
100
- */
101
- "jsdoc/implements-on-classes": "warn",
102
-
103
- // - jsdoc/match-description - Overlaps with `isaacscript/jsdoc-full-sentences`.
104
- // - jsdoc/match-name - Only needed for projects with specific JSDoc requirements.
105
- // - jsdoc/multiline-blocks - Overlaps with `isaacscript/limit-jsdoc-comments`.
106
- // - jsdoc/newline-after-description - Overlaps with `isaacscript/limit-jsdoc-comments`.
107
- // - jsdoc/no-bad-blocks - Provides little value, since it only detects JSDoc comments with tags
108
- // in them.
109
- // - jsdoc/no-defaults - Provides little value, since the @default tag is rare.
110
- // - jsdoc/no-missing-syntax - Not generally relevant.
111
- // - jsdoc/no-multi-asterisks - Overlaps with `isaacscript/limit-jsdoc-comments`.
112
- // - jsdoc/no-restricted-syntax - Not generally relevant.
83
+ "jsdoc/informative-docs": "error",
84
+
85
+ /** Superseded by the `isaacscript/jsdoc-full-sentences` rule. */
86
+ "jsdoc/match-description": "off",
87
+
88
+ /** Disabled because it is only needed for projects with specific JSDoc requirements. */
89
+ "jsdoc/match-name": "off",
90
+
91
+ /** Superseded by the `isaacscript/limit-jsdoc-comments` rule. */
92
+ "jsdoc/multiline-blocks": "off",
93
+
94
+ /** Superseded by the `isaacscript/limit-jsdoc-comments` rule. */
95
+ "jsdoc/newline-after-description": "off",
113
96
 
114
97
  /**
115
- * Documentation:
116
- * https://github.com/gajus/eslint-plugin-jsdoc#no-types
117
- *
118
- * Disallows types being used on `@param` or `@returns`.
98
+ * Disabled because it provides little value; it only detects JSDoc comments with tags in them.
119
99
  */
100
+ "jsdoc/no-bad-blocks": "off",
101
+
102
+ /** Superseded by the `isaacscript/format-jsdoc-comments` rule. */
103
+ "jsdoc/no-blank-block-descriptions": "off",
104
+
105
+ /** Superseded by the `isaacscript/no-empty-jsdoc` rule. */
106
+ "jsdoc/no-blank-blocks": "off",
107
+
108
+ /** Disabled because it provides little value; the `@default` tag is rare. */
109
+ "jsdoc/no-defaults": "off",
110
+
111
+ /** Disabled because it is too project-specific. */
112
+ "jsdoc/no-missing-syntax": "off",
113
+
114
+ /** Superseded by the `isaacscript/limit-jsdoc-comments` rule. */
115
+ "jsdoc/no-multi-asterisks": "off",
116
+
117
+ /** Disabled because it is intended for disabling of specific language features per-project. */
118
+ "jsdoc/no-restricted-syntax": "off",
119
+
120
+ /** The `contexts` option is set to `any` to make the rule stricter. */
120
121
  "jsdoc/no-types": [
121
- "warn",
122
+ "error",
122
123
  {
123
124
  contexts: ["any"],
124
125
  },
125
126
  ],
126
127
 
127
- // - jsdoc/no-undefined-types - Not needed in TypeScript.
128
+ /** Disabled because it is not needed in TypeScript. */
129
+ "jsdoc/no-undefined-types": "off",
128
130
 
129
- /**
130
- * Documentation:
131
- * https://github.com/gajus/eslint-plugin-jsdoc#require-asterisk-prefix
132
- *
133
- * Requires that each JSDoc line starts with an `*`.
134
- */
135
- "jsdoc/require-asterisk-prefix": "warn",
131
+ "jsdoc/require-asterisk-prefix": "error",
136
132
 
137
- // - jsdoc/require-description-complete-sentence - Overlaps with
138
- // `isaacscript/jsdoc-complete-sentences`.
139
- // - jsdoc/require-description - It's overboard for every function to have a description.
140
- // - jsdoc/require-example - It's overboard for every function to require an example.
141
- // - jsdoc/require-file-overview - It's overboard for every file to require an overview.
133
+ /** Superseded by the `isaacscript/jsdoc-complete-sentences` rule. */
134
+ "jsdoc/require-description-complete-sentence": "off",
142
135
 
143
- /**
144
- * Documentation:
145
- * https://github.com/gajus/eslint-plugin-jsdoc#require-hyphen-before-param-description
146
- *
147
- * Disallow hyphens before parameter descriptions, as it is non-standard syntax.
148
- */
149
- "jsdoc/require-hyphen-before-param-description": ["warn", "never"],
136
+ /** Disabled because it is overboard for every function to have a description. */
137
+ "jsdoc/require-description": "off",
138
+
139
+ /** Disabled because it is overboard for every function to require an example. */
140
+ "jsdoc/require-example": "off",
150
141
 
151
- // - jsdoc/require-jsdoc - It's overboard for every function to have a JSDoc comment.
142
+ /** Disabled because it is overboard for every file to require an overview. */
143
+ "jsdoc/require-file-overview": "off",
152
144
 
153
145
  /**
154
- * Documentation:
155
- * https://github.com/gajus/eslint-plugin-jsdoc#require-param-description
156
- *
157
- * Requires that each `@param` tag has a description.
146
+ * The `never` option is provided to make the rule match the format of the official TypeScript
147
+ * codebase.
158
148
  */
149
+ "jsdoc/require-hyphen-before-param-description": ["error", "never"],
150
+
151
+ /** Disabled since it is overboard for every function to have a JSDoc comment. */
152
+ "jsdoc/require-jsdoc": "off",
153
+
154
+ /** The `contexts` option is set to `any` to make the rule stricter. */
159
155
  "jsdoc/require-param-description": [
160
- "warn",
156
+ "error",
161
157
  {
162
158
  contexts: ["any"],
163
159
  },
164
160
  ],
165
161
 
166
- /**
167
- * Documentation:
168
- * https://github.com/gajus/eslint-plugin-jsdoc#require-param-name
169
- *
170
- * Requires that each `@param` tag has a name.
171
- */
162
+ /** The `contexts` option is set to `any` to make the rule stricter. */
172
163
  "jsdoc/require-param-name": [
173
- "warn",
164
+ "error",
174
165
  {
175
166
  contexts: ["any"],
176
167
  },
177
168
  ],
178
169
 
179
- // - jsdoc/require-param-type - Not needed in TypeScript.
170
+ /** Disabled because it is not needed in TypeScript. */
171
+ "jsdoc/require-param-type": "off",
180
172
 
173
+ /** Configured to only apply when there are one or more parameters. */
181
174
  "jsdoc/require-param": [
182
- "warn",
175
+ "error",
183
176
  {
184
- // We only activate the rule when there are one or more parameters.
185
- // https://github.com/gajus/eslint-plugin-jsdoc/issues/920
186
177
  contexts: [
187
178
  {
188
179
  context: "FunctionDeclaration",
@@ -192,50 +183,58 @@ const config = {
192
183
  },
193
184
  ],
194
185
 
195
- // - jsdoc/require-property - Probably not needed in TypeScript.
186
+ /** Disabled because it is not needed in TypeScript. */
187
+ "jsdoc/require-property": "off",
196
188
 
197
- /**
198
- * Documentation:
199
- * https://github.com/gajus/eslint-plugin-jsdoc#require-property-description
200
- *
201
- * Requires that each `@property` tag has a description.
202
- */
203
- "jsdoc/require-property-description": "warn",
189
+ "jsdoc/require-property-description": "error",
190
+ "jsdoc/require-property-name": "error",
204
191
 
205
- /**
206
- * Documentation:
207
- * https://github.com/gajus/eslint-plugin-jsdoc#require-property-name
208
- *
209
- * Requires that each `@property` tag has a name.
210
- */
211
- "jsdoc/require-property-name": "warn",
192
+ /** Disabled because it is not needed in TypeScript. */
193
+ "jsdoc/require-property-type": "off",
212
194
 
213
- // - jsdoc/require-property-type - Not needed in TypeScript.
214
- // - jsdoc/require-returns-check - It's overboard for every function to document every return
215
- // value.
195
+ /** Disabled because it is overboard for every function to document every return value. */
196
+ "jsdoc/require-returns-check": "off",
216
197
 
217
- /**
218
- * Documentation:
219
- * https://github.com/gajus/eslint-plugin-jsdoc#require-returns-description
220
- *
221
- * Requires that each `@returns` tag has a description.
222
- */
198
+ /** The `contexts` option is set to `any` to make the rule stricter. */
223
199
  "jsdoc/require-returns-description": [
224
- "warn",
200
+ "error",
225
201
  {
226
202
  contexts: ["any"],
227
203
  },
228
204
  ],
229
205
 
230
- // - jsdoc/require-returns-type - Not needed in TypeScript.
231
- // - jsdoc/require-returns - It's overboard for every function to document every return value.
232
- // - jsdoc/require-throws - It's overboard to document every throw statement.
233
- // - jsdoc/require-yields - It's overboard to document every yield.
234
- // - jsdoc/require-yields-check - It's overboard to document every yield.
235
- // - jsdoc/sort-tags - Not very useful since there are typically only `@param` and `@return`
236
- // tags.
237
- // - jsdoc/tag-lines - Not needed with `isaacscript/format-jsdoc-comments`.
238
- // - jsdoc/valid-types - Not needed in TypeScript.
206
+ /** Disabled because it is not needed in TypeScript. */
207
+ "jsdoc/require-returns-type": "off",
208
+
209
+ /** Disabled because it is overboard for every function to document every return value. */
210
+ "jsdoc/require-returns": "off",
211
+
212
+ /** Disabled because it is overboard to document every throw statement. */
213
+ "jsdoc/require-throws": "off",
214
+
215
+ /** Disabled because it is overboard to document every yield. */
216
+ "jsdoc/require-yields": "off",
217
+
218
+ /** Disabled because it is overboard to document every yield. */
219
+ "jsdoc/require-yields-check": "off",
220
+
221
+ /**
222
+ * Disabled because it is not very useful. In most cases, a function will only have `@param` and
223
+ * `@return` tags, making sorting unnecessary.
224
+ */
225
+ "jsdoc/sort-tags": "off",
226
+
227
+ /** Superseded by the `isaacscript/format-jsdoc-comments` rule. */
228
+ "jsdoc/tag-lines": "off",
229
+
230
+ /**
231
+ * Disabled since it is only useful in certain environments (e.g. when your project converts
232
+ * JSDoc comments to Markdown).
233
+ */
234
+ "jsdoc/text-escaping": "off",
235
+
236
+ /** Disabled because it is not needed in TypeScript. */
237
+ "jsdoc/valid-types": "off",
239
238
  },
240
239
 
241
240
  overrides: [