@qualcomm-ui/eslint-config-typescript 1.1.0 → 2.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.
Files changed (2) hide show
  1. package/package.json +17 -17
  2. package/type-checks.js +52 -11
package/package.json CHANGED
@@ -1,19 +1,15 @@
1
1
  {
2
2
  "name": "@qualcomm-ui/eslint-config-typescript",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "QUI ESLint config for consistent TypeScript code",
5
5
  "author": "Ryan Bower",
6
6
  "license": "BSD-3-Clause-Clear",
7
7
  "repository": "https://github.com/qualcomm/qualcomm-ui",
8
- "sideEffects": false,
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
9
11
  "type": "module",
10
- "keywords": [
11
- "eslint",
12
- "config"
13
- ],
14
- "main": "index.js",
15
- "module": "index.js",
16
- "types": "index.d.ts",
12
+ "sideEffects": false,
17
13
  "files": [
18
14
  "index.d.ts",
19
15
  "index.js",
@@ -26,17 +22,17 @@
26
22
  "type-checks.js",
27
23
  "strict-exports.js"
28
24
  ],
29
- "publishConfig": {
30
- "access": "public"
31
- },
25
+ "main": "index.js",
26
+ "module": "index.js",
27
+ "types": "index.d.ts",
32
28
  "devDependencies": {
33
29
  "@eslint/core": "^1.0.0",
34
- "@qualcomm-ui/cli": "^1.0.2",
30
+ "@qualcomm-ui/cli": "^1.0.6",
35
31
  "@stylistic/eslint-plugin": "5.2.0",
36
- "@typescript-eslint/eslint-plugin": "8.46.2",
37
- "@typescript-eslint/parser": "8.46.2",
32
+ "@typescript-eslint/eslint-plugin": "8.48.1",
33
+ "@typescript-eslint/parser": "8.48.1",
38
34
  "eslint-plugin-comment-length": "^2.2.1",
39
- "typescript-eslint": "8.46.2"
35
+ "typescript-eslint": "8.48.1"
40
36
  },
41
37
  "peerDependencies": {
42
38
  "@eslint/js": ">=9.37.0",
@@ -55,5 +51,9 @@
55
51
  "prettier": ">=3.5.3",
56
52
  "typescript": ">=5.7.3",
57
53
  "typescript-eslint": ">=8.31.1"
58
- }
54
+ },
55
+ "keywords": [
56
+ "eslint",
57
+ "config"
58
+ ]
59
59
  }
package/type-checks.js CHANGED
@@ -3,51 +3,92 @@
3
3
 
4
4
  import {defineConfig} from "eslint/config"
5
5
 
6
+ /**
7
+ * This configuration is based on https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/recommended-type-checked.ts
8
+ *
9
+ * There are some key differences, primarily regarding rules involving `any`. We set
10
+ * most of these to either warn or off:
11
+ * - Interop with untyped JS is a real pain point where `any` is pragmatic.
12
+ * - Type gymnastics that satisfy the compiler but obscure intent can be worse than
13
+ * `any`
14
+ * - The ceremony of unknown + guards can be disproportionate to the actual risk.
15
+ * - External libraries that use `any` can cause issues with our own types.
16
+ */
6
17
  export default defineConfig({
7
18
  name: "qui-typechecked-recommended",
8
19
  rules: {
9
20
  "@typescript-eslint/await-thenable": "error",
10
- "@typescript-eslint/ban-ts-comment": "warn",
21
+ "@typescript-eslint/ban-ts-comment": "warn", // Allow use of @ts-ignore, but warn
11
22
  "@typescript-eslint/no-array-constructor": "error",
12
23
  "@typescript-eslint/no-array-delete": "error",
13
24
  "@typescript-eslint/no-base-to-string": "error",
14
25
  "@typescript-eslint/no-duplicate-enum-values": "error",
15
26
  "@typescript-eslint/no-duplicate-type-constituents": "error",
27
+ /**
28
+ * Empty interfaces may be provided for module augmentation.
29
+ * Empty object types may also be used as defaults in generics.
30
+ */
16
31
  "@typescript-eslint/no-empty-object-type": "off",
32
+ /* See above rational, re: `any` */
17
33
  "@typescript-eslint/no-explicit-any": "warn",
18
34
  "@typescript-eslint/no-extra-non-null-assertion": "error",
19
35
  "@typescript-eslint/no-floating-promises": "warn",
20
36
  "@typescript-eslint/no-for-in-array": "error",
21
37
  "@typescript-eslint/no-implied-eval": "error",
22
38
  "@typescript-eslint/no-misused-new": "error",
23
- "@typescript-eslint/no-misused-promises": "warn",
24
- "@typescript-eslint/no-namespace": "warn",
39
+ "@typescript-eslint/no-misused-promises": "error",
40
+ "@typescript-eslint/no-namespace": "error",
25
41
  "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
42
+ /**
43
+ * Some projects choose to occasionally intentionally include a redundant type
44
+ * constituent for documentation purposes. Like our icon, which is a union of:
45
+ * `"xs" | "sm" | "md" | "lg" | "xl" | string | number`
46
+ */
26
47
  "@typescript-eslint/no-redundant-type-constituents": "off",
27
- "@typescript-eslint/no-require-imports": "off",
48
+ "@typescript-eslint/no-require-imports": "error",
28
49
  "@typescript-eslint/no-this-alias": "error",
29
- "@typescript-eslint/no-unnecessary-type-assertion": "warn",
50
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
30
51
  "@typescript-eslint/no-unnecessary-type-constraint": "error",
52
+ /* See above rational, re: `any` */
31
53
  "@typescript-eslint/no-unsafe-argument": "warn",
54
+ /* See above rational, re: `any` */
32
55
  "@typescript-eslint/no-unsafe-assignment": "off",
56
+ /* See above rational, re: `any` */
33
57
  "@typescript-eslint/no-unsafe-call": "warn",
34
58
  "@typescript-eslint/no-unsafe-declaration-merging": "error",
35
59
  "@typescript-eslint/no-unsafe-enum-comparison": "error",
36
- "@typescript-eslint/no-unsafe-function-type": "warn",
60
+ "@typescript-eslint/no-unsafe-function-type": "error",
61
+ /* See above rational, re: `any` */
37
62
  "@typescript-eslint/no-unsafe-member-access": "warn",
63
+ /* See above rational, re: `any` */
38
64
  "@typescript-eslint/no-unsafe-return": "warn",
39
65
  "@typescript-eslint/no-unsafe-unary-minus": "error",
40
66
  "@typescript-eslint/no-unused-expressions": "error",
67
+ /* This is handled via the `unused-imports` plugin */
41
68
  "@typescript-eslint/no-unused-vars": "off",
42
69
  "@typescript-eslint/no-wrapper-object-types": "error",
43
- "@typescript-eslint/only-throw-error": "error",
70
+ "@typescript-eslint/only-throw-error": [
71
+ "error",
72
+ {
73
+ // allow throwing built-in Response and react-router redirects.
74
+ allow: [
75
+ {from: "lib", name: "Response"},
76
+ {from: "package", name: "redirect", package: "react-router"},
77
+ ],
78
+ },
79
+ ],
44
80
  "@typescript-eslint/prefer-as-const": "error",
45
81
  "@typescript-eslint/prefer-namespace-keyword": "error",
46
- "@typescript-eslint/prefer-promise-reject-errors": "warn",
47
- "@typescript-eslint/require-await": "warn",
82
+ "@typescript-eslint/prefer-promise-reject-errors": [
83
+ "error",
84
+ {
85
+ allowThrowingUnknown: true,
86
+ },
87
+ ],
88
+ "@typescript-eslint/require-await": "error",
48
89
  "@typescript-eslint/restrict-plus-operands": "error",
49
- "@typescript-eslint/restrict-template-expressions": "off",
50
- "@typescript-eslint/triple-slash-reference": "off",
90
+ "@typescript-eslint/restrict-template-expressions": "error",
91
+ "@typescript-eslint/triple-slash-reference": "error",
51
92
  "@typescript-eslint/unbound-method": "off",
52
93
  "no-array-constructor": "off",
53
94
  "no-implied-eval": "off",