eslint-config-isaacscript 4.8.1 → 4.10.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.
@@ -147,6 +147,7 @@ const SUPPORTED_RULES = {
147
147
  "@typescript-eslint/no-unsafe-enum-comparison": "error",
148
148
  "@typescript-eslint/no-unsafe-member-access": "error",
149
149
  "@typescript-eslint/no-unsafe-return": "error",
150
+ "@typescript-eslint/no-unsafe-unary-minus": "error",
150
151
  "@typescript-eslint/no-useless-empty-export": "error",
151
152
  "@typescript-eslint/no-var-requires": "error",
152
153
  "@typescript-eslint/non-nullable-type-assertion-style": "error",
@@ -329,10 +330,59 @@ const EXTENSION_RULES = {
329
330
  "@typescript-eslint/no-redeclare": "off",
330
331
 
331
332
  /**
332
- * Disabled since it would only be needed in specific environments (such as forbidding Node.js
333
- * imports in a browser environment).
333
+ * Configured to prevent importing with some common patterns that are almost always a mistake:
334
+ *
335
+ * - "src" directories (but allowed in test files that are in a separate "tests" directory)
336
+ * - "dist" directories
337
+ * - "index" files (things in the same package should directly import instead of use the public
338
+ * API)
334
339
  */
335
- "@typescript-eslint/no-restricted-imports": "off",
340
+ "@typescript-eslint/no-restricted-imports": [
341
+ "error",
342
+ {
343
+ patterns: [
344
+ // Some "src" directories have an "index.ts" file, which means that importing from the
345
+ // directory is valid. Thus, we check for the "src" directory with no suffix.
346
+ {
347
+ group: ["**/src"],
348
+ message:
349
+ '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.',
350
+ },
351
+
352
+ {
353
+ group: ["**/src/**"],
354
+ message:
355
+ '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.',
356
+ },
357
+
358
+ // Some "dist" directories have an "index.ts" file, which means that importing from the
359
+ // directory is valid. Thus, we check for the "dist" directory with no suffix.
360
+ {
361
+ group: ["**/dist"],
362
+ message:
363
+ '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.',
364
+ },
365
+
366
+ {
367
+ group: ["**/dist/**"],
368
+ message:
369
+ '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.',
370
+ },
371
+
372
+ {
373
+ group: ["**/index"],
374
+ message:
375
+ "You cannot import from a package index. Instead, import directly from the file where the code is located.",
376
+ },
377
+
378
+ {
379
+ group: ["**/index.{js,cjs,mjs,ts,cts,mts}"],
380
+ message:
381
+ "You cannot import from a package index. Instead, import directly from the file where the code is located.",
382
+ },
383
+ ],
384
+ },
385
+ ],
336
386
 
337
387
  "@typescript-eslint/no-shadow": "error",
338
388
  "@typescript-eslint/no-throw-literal": "error",
@@ -446,11 +496,20 @@ const config = {
446
496
 
447
497
  // The built-in Node.js test-runner returns a promise which is not meant to be awaited.
448
498
  {
449
- files: ["*.test.ts"],
499
+ files: ["*.test.{js,cjs,mjs,ts,cts,mts}"],
450
500
  rules: {
451
501
  "@typescript-eslint/no-floating-promises": "off",
452
502
  },
453
503
  },
504
+
505
+ // We want to be allowed to import from the "src" directory in test files that are located in a
506
+ // separate "tests" directory.
507
+ {
508
+ files: ["**/tests/**"],
509
+ rules: {
510
+ "@typescript-eslint/no-restricted-imports": "off",
511
+ },
512
+ },
454
513
  ],
455
514
  };
456
515
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-isaacscript",
3
- "version": "4.8.1",
3
+ "version": "4.10.0",
4
4
  "description": "A sharable ESLint config for TypeScript and IsaacScript projects.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -31,7 +31,8 @@
31
31
  "README.md"
32
32
  ],
33
33
  "scripts": {
34
- "lint": "tsx ./scripts/lint.mts"
34
+ "lint": "tsx ./scripts/lint.mts",
35
+ "query-rule": "tsx ./scripts/queryRule.mts"
35
36
  },
36
37
  "dependencies": {
37
38
  "confusing-browser-globals": "^1.0.11"