eslint-config-isaacscript 4.8.0 → 4.9.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/configs/base-import.js +2 -2
- package/configs/base-n.js +16 -0
- package/configs/base-typescript-eslint.js +61 -4
- package/package.json +1 -1
package/configs/base-import.js
CHANGED
|
@@ -23,7 +23,7 @@ const HELPFUL_WARNINGS = {
|
|
|
23
23
|
* The options are [copied from
|
|
24
24
|
* Airbnb](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/import.js).
|
|
25
25
|
*
|
|
26
|
-
* We also add a "scripts" directory entry for "
|
|
26
|
+
* We also add a "scripts" directory entry for "devDependencies".
|
|
27
27
|
*/
|
|
28
28
|
"import/no-extraneous-dependencies": [
|
|
29
29
|
"error",
|
|
@@ -52,7 +52,7 @@ const HELPFUL_WARNINGS = {
|
|
|
52
52
|
"**/karma.conf.js", // karma config
|
|
53
53
|
"**/.eslintrc.js", // eslint config
|
|
54
54
|
|
|
55
|
-
"**/scripts/*.{ts,cts,mts}", //
|
|
55
|
+
"**/scripts/*.{js,cjs,mjs,ts,cts,mts}", // Files inside of a "scripts" directory.
|
|
56
56
|
],
|
|
57
57
|
optionalDependencies: false,
|
|
58
58
|
},
|
package/configs/base-n.js
CHANGED
|
@@ -41,7 +41,13 @@ const POSSIBLE_ERRORS = {
|
|
|
41
41
|
"n/no-process-exit": "off",
|
|
42
42
|
|
|
43
43
|
"n/no-unpublished-bin": "error",
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* An exception is made for files in a "scripts" directory, since those should be allowed to
|
|
47
|
+
* import from "devDependencies".
|
|
48
|
+
*/
|
|
44
49
|
"n/no-unpublished-import": "error",
|
|
50
|
+
|
|
45
51
|
"n/no-unpublished-require": "error",
|
|
46
52
|
|
|
47
53
|
/** Disabled because this rule is deprecated. */
|
|
@@ -137,6 +143,16 @@ const config = {
|
|
|
137
143
|
...POSSIBLE_ERRORS,
|
|
138
144
|
...STYLISTIC_ISSUES,
|
|
139
145
|
},
|
|
146
|
+
|
|
147
|
+
overrides: [
|
|
148
|
+
// Imports in a "scripts" directory can use "devDependencies".
|
|
149
|
+
{
|
|
150
|
+
files: ["**/scripts/*.{js,cjs,mjs,ts,cts,mts}"],
|
|
151
|
+
rules: {
|
|
152
|
+
"n/no-unpublished-import": "off",
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
],
|
|
140
156
|
};
|
|
141
157
|
|
|
142
158
|
module.exports = config;
|
|
@@ -329,10 +329,58 @@ const EXTENSION_RULES = {
|
|
|
329
329
|
"@typescript-eslint/no-redeclare": "off",
|
|
330
330
|
|
|
331
331
|
/**
|
|
332
|
-
*
|
|
333
|
-
*
|
|
332
|
+
* Configured to prevent importing with some common patterns that are almost always a mistake:
|
|
333
|
+
*
|
|
334
|
+
* - "src" directories (but allowed in test files that are in a separate "tests" directory)
|
|
335
|
+
* - "dist" directories
|
|
336
|
+
* - "index" files
|
|
334
337
|
*/
|
|
335
|
-
"@typescript-eslint/no-restricted-imports":
|
|
338
|
+
"@typescript-eslint/no-restricted-imports": [
|
|
339
|
+
"error",
|
|
340
|
+
{
|
|
341
|
+
patterns: [
|
|
342
|
+
// Some "src" directories have an "index.ts" file, which means that importing from the
|
|
343
|
+
// directory is valid. Thus, we check for the "src" directory with no suffix.
|
|
344
|
+
{
|
|
345
|
+
group: ["*/src"],
|
|
346
|
+
message:
|
|
347
|
+
'You cannot import from a "src" directory. If this is a monorepo, import using the package name like you would in a non-monorepo project.',
|
|
348
|
+
},
|
|
349
|
+
|
|
350
|
+
{
|
|
351
|
+
group: ["*/src/*"],
|
|
352
|
+
message:
|
|
353
|
+
'You cannot import from a "src" directory. If this is a monorepo, import using the package name like you would in a non-monorepo project.',
|
|
354
|
+
},
|
|
355
|
+
|
|
356
|
+
// Some "dist" directories have an "index.ts" file, which means that importing from the
|
|
357
|
+
// directory is valid. Thus, we check for the "dist" directory with no suffix.
|
|
358
|
+
{
|
|
359
|
+
group: ["*/dist"],
|
|
360
|
+
message:
|
|
361
|
+
'You cannot import from a "dist" directory. If this is a monorepo, import using the package name like you would in a non-monorepo project.',
|
|
362
|
+
},
|
|
363
|
+
|
|
364
|
+
{
|
|
365
|
+
group: ["*/dist/*"],
|
|
366
|
+
message:
|
|
367
|
+
'You cannot import from a "dist" directory. If this is a monorepo, import using the package name like you would in a non-monorepo project.',
|
|
368
|
+
},
|
|
369
|
+
|
|
370
|
+
{
|
|
371
|
+
group: ["*/index"],
|
|
372
|
+
message:
|
|
373
|
+
"You cannot import from a package index. Instead, import directly from the file where the code is located.",
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
{
|
|
377
|
+
group: ["*/index.{js,cjs,mjs,ts,cts,mts}"],
|
|
378
|
+
message:
|
|
379
|
+
"You cannot import from a package index. Instead, import directly from the file where the code is located.",
|
|
380
|
+
},
|
|
381
|
+
],
|
|
382
|
+
},
|
|
383
|
+
],
|
|
336
384
|
|
|
337
385
|
"@typescript-eslint/no-shadow": "error",
|
|
338
386
|
"@typescript-eslint/no-throw-literal": "error",
|
|
@@ -446,11 +494,20 @@ const config = {
|
|
|
446
494
|
|
|
447
495
|
// The built-in Node.js test-runner returns a promise which is not meant to be awaited.
|
|
448
496
|
{
|
|
449
|
-
files: ["*.test.ts"],
|
|
497
|
+
files: ["*.test.{js,cjs,mjs,ts,cts,mts}"],
|
|
450
498
|
rules: {
|
|
451
499
|
"@typescript-eslint/no-floating-promises": "off",
|
|
452
500
|
},
|
|
453
501
|
},
|
|
502
|
+
|
|
503
|
+
// We want to be allowed to import from the "src" directory in test files that are located in a
|
|
504
|
+
// separate "tests" directory.
|
|
505
|
+
{
|
|
506
|
+
files: ["**/tests/**"],
|
|
507
|
+
rules: {
|
|
508
|
+
"@typescript-eslint/no-restricted-imports": "off",
|
|
509
|
+
},
|
|
510
|
+
},
|
|
454
511
|
],
|
|
455
512
|
};
|
|
456
513
|
|