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/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
@@ -1,51 +1,44 @@
1
- // This is a shared configuration file for ESLint:
2
- // https://eslint.org/docs/latest/user-guide/configuring
3
- // This config contains only rules from the "jsdoc" ESLint plugin.
4
- module.exports = {
5
- plugins: [
6
- /**
7
- * Lint JSDoc style comments:
8
- * https://github.com/gajus/eslint-plugin-jsdoc
9
- */
10
- "jsdoc",
11
- ],
1
+ /**
2
+ * This ESLint config only contains rules from `eslint-plugin-jsdoc`:
3
+ * https://github.com/gajus/eslint-plugin-jsdoc
4
+ *
5
+ * @type {import("eslint").Linter.Config}
6
+ */
7
+ const config = {
8
+ plugins: ["jsdoc"],
12
9
 
13
- /**
14
- * Instead of using the recommended config, we specifically turn on every rule that is useful.
15
- *
16
- * We must specify `contexts: ["any"]` for some rules because by default, only a subset of AST
17
- * node types will be affected.
18
- */
19
10
  rules: {
20
- // - jsdoc/check-access - Not needed in TypeScript.
21
- // - jsdoc/check-alignment - Overlaps with `isaacscript/limit-jsdoc-comments`.
22
-
23
- // - jsdoc/check-examples - Does not work with ESLint 8; see:
24
- // https://github.com/eslint/eslint/issues/14745
11
+ /** Disabled because it is not needed in TypeScript. */
12
+ "jsdoc/check-access": "off",
25
13
 
26
- // - jsdoc/check-indentation - Overlaps with `isaacscript/limit-jsdoc-comments`.
27
- // - jsdoc/check-line-alignment - This is not a common formatting scheme in the wild. It's also
28
- // not recommended by the plugin.
14
+ /** Superseded by the `isaacscript/limit-jsdoc-comments` rule. */
15
+ "jsdoc/check-alignment": "off",
29
16
 
30
17
  /**
31
- * Documentation:
32
- * https://github.com/gajus/eslint-plugin-jsdoc#check-param-names
33
- *
34
- * 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).
35
20
  */
36
- "jsdoc/check-param-names": "warn",
21
+ "jsdoc/check-examples": "off",
37
22
 
38
- // - jsdoc/check-property-names - Not needed in TypeScript.
39
- // - jsdoc/check-syntax - Not needed in TypeScript.
23
+ /** Superseded by the `isaacscript/limit-jsdoc-comments` rule. */
24
+ "jsdoc/check-indentation": "off",
40
25
 
41
26
  /**
42
- * Documentation:
43
- * https://github.com/gajus/eslint-plugin-jsdoc#check-tag-names
44
- *
45
- * 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.
46
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
+
47
40
  "jsdoc/check-tag-names": [
48
- "warn",
41
+ "error",
49
42
  {
50
43
  definedTags: [
51
44
  // Ignore tags used by the TypeScript compiler:
@@ -77,115 +70,110 @@ module.exports = {
77
70
  },
78
71
  ],
79
72
 
80
- // - jsdoc/check-types - Not needed in TypeScript.
73
+ /** Disabled because it is not needed in TypeScript. */
74
+ "jsdoc/check-types": "off",
81
75
 
82
- /**
83
- * Documentation:
84
- * https://github.com/gajus/eslint-plugin-jsdoc#check-values
85
- *
86
- * Validates the content of some uncommon JSDoc tags.
87
- */
88
- "jsdoc/check-values": "warn",
76
+ "jsdoc/check-values": "error",
77
+ "jsdoc/empty-tags": "error",
78
+ "jsdoc/implements-on-classes": "error",
89
79
 
90
- /**
91
- * Documentation:
92
- * https://github.com/gajus/eslint-plugin-jsdoc#check-values
93
- *
94
- * Validates that specific tags are never empty.
95
- */
96
- "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",
97
82
 
98
- /**
99
- * Documentation:
100
- * https://github.com/gajus/eslint-plugin-jsdoc#implements-on-classes
101
- *
102
- * Reports issues with incorrect usage of `@implements`.
103
- */
104
- "jsdoc/implements-on-classes": "warn",
105
-
106
- // - jsdoc/match-description - Overlaps with `isaacscript/jsdoc-full-sentences`.
107
- // - jsdoc/match-name - Only needed for projects with specific JSDoc requirements.
108
- // - jsdoc/multiline-blocks - Overlaps with `isaacscript/limit-jsdoc-comments`.
109
- // - jsdoc/newline-after-description - Overlaps with `isaacscript/limit-jsdoc-comments`.
110
- // - jsdoc/no-bad-blocks - Provides little value, since it only detects JSDoc comments with tags
111
- // in them.
112
- // - jsdoc/no-defaults - Provides little value, since the @default tag is rare.
113
- // - jsdoc/no-missing-syntax - Not generally relevant.
114
- // - jsdoc/no-multi-asterisks - Overlaps with `isaacscript/limit-jsdoc-comments`.
115
- // - 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",
116
96
 
117
97
  /**
118
- * Documentation:
119
- * https://github.com/gajus/eslint-plugin-jsdoc#no-types
120
- *
121
- * Disallows types being used on `@param` or `@returns`.
98
+ * Disabled because it provides little value; it only detects JSDoc comments with tags in them.
122
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. */
123
121
  "jsdoc/no-types": [
124
- "warn",
122
+ "error",
125
123
  {
126
124
  contexts: ["any"],
127
125
  },
128
126
  ],
129
127
 
130
- // - jsdoc/no-undefined-types - Not needed in TypeScript.
128
+ /** Disabled because it is not needed in TypeScript. */
129
+ "jsdoc/no-undefined-types": "off",
131
130
 
132
- /**
133
- * Documentation:
134
- * https://github.com/gajus/eslint-plugin-jsdoc#require-asterisk-prefix
135
- *
136
- * Requires that each JSDoc line starts with an `*`.
137
- */
138
- "jsdoc/require-asterisk-prefix": "warn",
131
+ "jsdoc/require-asterisk-prefix": "error",
139
132
 
140
- // - jsdoc/require-description-complete-sentence - Overlaps with
141
- // `isaacscript/jsdoc-complete-sentences`.
142
- // - jsdoc/require-description - It's overboard for every function to have a description.
143
- // - jsdoc/require-example - It's overboard for every function to require an example.
144
- // - 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",
145
135
 
146
- /**
147
- * Documentation:
148
- * https://github.com/gajus/eslint-plugin-jsdoc#require-hyphen-before-param-description
149
- *
150
- * Disallow hyphens before parameter descriptions, as it is non-standard syntax.
151
- */
152
- "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",
153
141
 
154
- // - 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",
155
144
 
156
145
  /**
157
- * Documentation:
158
- * https://github.com/gajus/eslint-plugin-jsdoc#require-param-description
159
- *
160
- * 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.
161
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. */
162
155
  "jsdoc/require-param-description": [
163
- "warn",
156
+ "error",
164
157
  {
165
158
  contexts: ["any"],
166
159
  },
167
160
  ],
168
161
 
169
- /**
170
- * Documentation:
171
- * https://github.com/gajus/eslint-plugin-jsdoc#require-param-name
172
- *
173
- * Requires that each `@param` tag has a name.
174
- */
162
+ /** The `contexts` option is set to `any` to make the rule stricter. */
175
163
  "jsdoc/require-param-name": [
176
- "warn",
164
+ "error",
177
165
  {
178
166
  contexts: ["any"],
179
167
  },
180
168
  ],
181
169
 
182
- // - jsdoc/require-param-type - Not needed in TypeScript.
170
+ /** Disabled because it is not needed in TypeScript. */
171
+ "jsdoc/require-param-type": "off",
183
172
 
173
+ /** Configured to only apply when there are one or more parameters. */
184
174
  "jsdoc/require-param": [
185
- "warn",
175
+ "error",
186
176
  {
187
- // We only activate the rule when there are one or more parameters.
188
- // https://github.com/gajus/eslint-plugin-jsdoc/issues/920
189
177
  contexts: [
190
178
  {
191
179
  context: "FunctionDeclaration",
@@ -195,58 +183,58 @@ module.exports = {
195
183
  },
196
184
  ],
197
185
 
198
- // - jsdoc/require-property - Probably not needed in TypeScript.
186
+ /** Disabled because it is not needed in TypeScript. */
187
+ "jsdoc/require-property": "off",
199
188
 
200
- /**
201
- * Documentation:
202
- * https://github.com/gajus/eslint-plugin-jsdoc#require-property-description
203
- *
204
- * Requires that each `@property` tag has a description.
205
- */
206
- "jsdoc/require-property-description": "warn",
189
+ "jsdoc/require-property-description": "error",
190
+ "jsdoc/require-property-name": "error",
207
191
 
208
- /**
209
- * Documentation:
210
- * https://github.com/gajus/eslint-plugin-jsdoc#require-property-name
211
- *
212
- * Requires that each `@property` tag has a name.
213
- */
214
- "jsdoc/require-property-name": "warn",
192
+ /** Disabled because it is not needed in TypeScript. */
193
+ "jsdoc/require-property-type": "off",
215
194
 
216
- // - jsdoc/require-property-type - Not needed in TypeScript.
217
- // - jsdoc/require-returns-check - It's overboard for every function to document every return
218
- // value.
195
+ /** Disabled because it is overboard for every function to document every return value. */
196
+ "jsdoc/require-returns-check": "off",
219
197
 
220
- /**
221
- * Documentation:
222
- * https://github.com/gajus/eslint-plugin-jsdoc#require-returns-description
223
- *
224
- * Requires that each `@returns` tag has a description.
225
- */
198
+ /** The `contexts` option is set to `any` to make the rule stricter. */
226
199
  "jsdoc/require-returns-description": [
227
- "warn",
200
+ "error",
228
201
  {
229
202
  contexts: ["any"],
230
203
  },
231
204
  ],
232
205
 
233
- // - jsdoc/require-returns-type - Not needed in TypeScript.
234
- // - jsdoc/require-returns - It's overboard for every function to document every return value.
235
- // - jsdoc/require-throws - It's overboard to document every throw statement.
236
- // - jsdoc/require-yields - It's overboard to document every yield.
237
- // - jsdoc/require-yields-check - It's overboard to document every yield.
238
- // - jsdoc/sort-tags - Not very useful since there are typically only `@param` and `@return`
239
- // tags.
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",
240
229
 
241
230
  /**
242
- * Documentation:
243
- * https://github.com/gajus/eslint-plugin-jsdoc#tag-lines
244
- *
245
- * Enforces no lines between tags.
231
+ * Disabled since it is only useful in certain environments (e.g. when your project converts
232
+ * JSDoc comments to Markdown).
246
233
  */
247
- "jsdoc/tag-lines": "warn",
234
+ "jsdoc/text-escaping": "off",
248
235
 
249
- // - jsdoc/valid-types - Not needed in TypeScript.
236
+ /** Disabled because it is not needed in TypeScript. */
237
+ "jsdoc/valid-types": "off",
250
238
  },
251
239
 
252
240
  overrides: [
@@ -259,3 +247,5 @@ module.exports = {
259
247
  },
260
248
  ],
261
249
  };
250
+
251
+ module.exports = config;