@qualcomm-ui/eslint-config-typescript 1.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/LICENSE.txt ADDED
@@ -0,0 +1,31 @@
1
+ Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted (subject to the limitations in the
5
+ disclaimer below) provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above
11
+ copyright notice, this list of conditions and the following
12
+ disclaimer in the documentation and/or other materials provided
13
+ with the distribution.
14
+
15
+ * Neither the name of Qualcomm Technologies, Inc. nor the names of its
16
+ contributors may be used to endorse or promote products derived
17
+ from this software without specific prior written permission.
18
+
19
+ NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
20
+ GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
21
+ HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
22
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
29
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
31
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/base.js ADDED
@@ -0,0 +1,20 @@
1
+ // Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2
+ // SPDX-License-Identifier: BSD-3-Clause-Clear
3
+
4
+ import {defineConfig} from "eslint/config"
5
+ import tseslint from "typescript-eslint"
6
+
7
+ export default defineConfig({
8
+ languageOptions: {
9
+ ecmaVersion: 2022,
10
+ parser: tseslint.parser,
11
+ parserOptions: {
12
+ ecmaFeatures: {jsx: true},
13
+ },
14
+ sourceType: "module",
15
+ },
16
+ name: "qui-typescript-base",
17
+ plugins: {
18
+ "@typescript-eslint": tseslint.plugin,
19
+ },
20
+ })
package/index.js ADDED
@@ -0,0 +1,95 @@
1
+ import base from "./base.js"
2
+ import jsdoc from "./jsdoc.js"
3
+ import namingConventions from "./naming-conventions.js"
4
+ import performance from "./performance.js"
5
+ import sortKeys from "./sort-keys.js"
6
+ import strictExports from "./strict-exports.js"
7
+ import styleGuide from "./style-guide.js"
8
+ import typeChecks from "./type-checks.js"
9
+
10
+ export default {
11
+ configs: {
12
+ /**
13
+ * Base TypeScript configuration with parser and plugin setup.
14
+ * Required for all other configs to work.
15
+ */
16
+ base,
17
+
18
+ /**
19
+ * JSDoc validation rules (alignment, tag names, formatting).
20
+ * Use for code with public APIs or documentation requirements.
21
+ */
22
+ jsdoc,
23
+
24
+ /**
25
+ * TypeScript naming conventions (PascalCase for types, camelCase for
26
+ * properties, etc). Requires type information.
27
+ */
28
+ namingConventions,
29
+
30
+ /**
31
+ * Import optimizations for library code (consistent type imports, no side
32
+ * effects). Use for packages consumed by other projects.
33
+ */
34
+ performance,
35
+
36
+ /**
37
+ * Array of recommended configs. This is equivalent to the following:
38
+ * ```js
39
+ * import qui from "@qualcomm-ui/eslint-config-typescript"
40
+ *
41
+ * const recommended = [
42
+ * qui.configs.base,
43
+ * qui.configs.styleGuide,
44
+ * qui.configs.sortKeys,
45
+ * qui.configs.typeChecks,
46
+ * qui.configs.namingConventions,
47
+ * ]
48
+ * ```
49
+ *
50
+ * Usage:
51
+ *
52
+ * @example
53
+ * ```js
54
+ * // eslint.config.js
55
+ * import {defineConfig} from "eslint/config"
56
+ * import quiEslintTs from "@qualcomm-ui/eslint-config-typescript"
57
+ *
58
+ * export default defineConfig(
59
+ * {
60
+ * // other settings
61
+ * },
62
+ * {
63
+ * extends: [...quiEslintTs.configs.recommended],
64
+ * files: [/*TS Files*\/]
65
+ * },
66
+ * )
67
+ * ```
68
+ */
69
+ recommended: [base, styleGuide, sortKeys, typeChecks, namingConventions],
70
+
71
+ /**
72
+ * Sort object properties, interface members, and type definitions
73
+ * alphabetically.
74
+ */
75
+ sortKeys,
76
+
77
+ /**
78
+ * Enforce explicit type exports for public APIs (prevents runtime bloat).
79
+ * Use for library entry points and public exports.
80
+ */
81
+ strictExports,
82
+
83
+ /**
84
+ * Code style rules (imports, formatting, unused code, etc).
85
+ * Enforces Prettier, import ordering, and code quality standards.
86
+ */
87
+ styleGuide,
88
+
89
+ /**
90
+ * Type-aware linting rules (await-thenable, no-unsafe-call, etc).
91
+ * Requires TypeScript type information. Catches type-related bugs.
92
+ */
93
+ typeChecks,
94
+ },
95
+ }
package/jsdoc.js ADDED
@@ -0,0 +1,67 @@
1
+ // Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2
+ // SPDX-License-Identifier: BSD-3-Clause-Clear
3
+
4
+ import {defineConfig} from "eslint/config"
5
+ import jsdoc from "eslint-plugin-jsdoc"
6
+
7
+ export default defineConfig({
8
+ name: "qui-jsdoc",
9
+ plugins: {jsdoc},
10
+ rules: {
11
+ "jsdoc/check-alignment": "error",
12
+ "jsdoc/check-indentation": "warn",
13
+ "jsdoc/check-tag-names": [
14
+ "error",
15
+ {
16
+ definedTags: [
17
+ "custom",
18
+ "docLink",
19
+ "group",
20
+ "option",
21
+ "tag",
22
+ "alpha",
23
+ "beta",
24
+ "betaDocumentation",
25
+ "decorator",
26
+ "defaultValue",
27
+ "deprecated",
28
+ "eventProperty",
29
+ "example",
30
+ "experimental",
31
+ "inheritDoc",
32
+ "internal",
33
+ "internalRemarks",
34
+ "label",
35
+ "link",
36
+ "override",
37
+ "packageDocumentation",
38
+ "param",
39
+ "preapproved",
40
+ "privateRemarks",
41
+ "public",
42
+ "readonly",
43
+ "remarks",
44
+ "returns",
45
+ "sealed",
46
+ "see",
47
+ "throws",
48
+ "typeParam",
49
+ "virtual",
50
+ ],
51
+ },
52
+ ],
53
+ "jsdoc/no-blank-block-descriptions": "error",
54
+ "jsdoc/no-multi-asterisks": "error",
55
+ "jsdoc/require-asterisk-prefix": "error",
56
+ "jsdoc/require-jsdoc": "off",
57
+ "jsdoc/tag-lines": [
58
+ "error",
59
+ "always",
60
+ {
61
+ count: 0,
62
+ endLines: 0,
63
+ startLines: 1,
64
+ },
65
+ ],
66
+ },
67
+ })
@@ -0,0 +1,53 @@
1
+ // Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2
+ // SPDX-License-Identifier: BSD-3-Clause-Clear
3
+
4
+ import {defineConfig} from "eslint/config"
5
+
6
+ export default defineConfig({
7
+ name: "qui-typechecked-naming-convention",
8
+ rules: {
9
+ "@typescript-eslint/naming-convention": [
10
+ "error",
11
+ {
12
+ custom: {
13
+ match: false,
14
+ regex: "^I[A-Z]",
15
+ },
16
+ format: ["PascalCase"],
17
+ selector: ["class", "enum", "interface", "typeAlias"],
18
+ },
19
+ {
20
+ custom: {
21
+ match: false,
22
+ regex: "^I[A-Z]",
23
+ },
24
+ format: ["PascalCase"],
25
+ leadingUnderscore: "allow",
26
+ selector: ["typeParameter"],
27
+ },
28
+ {
29
+ format: ["PascalCase"],
30
+ selector: "class",
31
+ },
32
+ {
33
+ filter: {
34
+ match: false,
35
+ regex: "^((ngAcceptInputType))",
36
+ },
37
+ format: ["camelCase"],
38
+ leadingUnderscore: "allow",
39
+ selector: ["classMethod", "classProperty"],
40
+ },
41
+ {
42
+ filter: {
43
+ match: false,
44
+ regex: "^((ngAcceptInputType))",
45
+ },
46
+ format: ["camelCase", "PascalCase"],
47
+ leadingUnderscore: "allow",
48
+ modifiers: ["protected", "readonly"],
49
+ selector: ["classMethod", "classProperty", "parameterProperty"],
50
+ },
51
+ ],
52
+ },
53
+ })
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@qualcomm-ui/eslint-config-typescript",
3
+ "version": "1.0.0",
4
+ "description": "QUI ESLint config for consistent TypeScript code",
5
+ "author": "Ryan Bower",
6
+ "repository": "https://github.com/qualcomm/qualcomm-ui",
7
+ "sideEffects": false,
8
+ "type": "module",
9
+ "keywords": [
10
+ "eslint",
11
+ "config"
12
+ ],
13
+ "main": "index.js",
14
+ "files": [
15
+ "index.js",
16
+ "base.js",
17
+ "jsdoc.js",
18
+ "performance.js",
19
+ "sort-keys.js",
20
+ "style-guide.js",
21
+ "naming-conventions.js",
22
+ "type-checks.js",
23
+ "strict-exports.js"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "devDependencies": {
29
+ "@qualcomm-ui/cli": "^1",
30
+ "@stylistic/eslint-plugin": "5.2.0",
31
+ "@typescript-eslint/eslint-plugin": "8.46.2",
32
+ "@typescript-eslint/parser": "8.46.2",
33
+ "eslint-plugin-comment-length": "^2.2.1",
34
+ "typescript-eslint": "8.40.0"
35
+ },
36
+ "peerDependencies": {
37
+ "@eslint/js": ">=9.37.0",
38
+ "@stylistic/eslint-plugin": ">=5.2.0",
39
+ "@typescript-eslint/eslint-plugin": ">=8.31.1",
40
+ "@typescript-eslint/parser": ">=8.31.1",
41
+ "eslint": ">=9.37.0",
42
+ "eslint-config-prettier": ">=10.1.2",
43
+ "eslint-import-resolver-typescript": ">=4.3.4",
44
+ "eslint-plugin-comment-length": ">=2.2.1",
45
+ "eslint-plugin-import": ">=2.31.0",
46
+ "eslint-plugin-jsdoc": ">=50.6.11",
47
+ "eslint-plugin-prettier": ">=5.2.6",
48
+ "eslint-plugin-perfectionist": ">=4.12.3",
49
+ "eslint-plugin-unused-imports": ">=4.1.4",
50
+ "prettier": ">=3.5.3",
51
+ "typescript": ">=5.7.3",
52
+ "typescript-eslint": ">=8.31.1"
53
+ }
54
+ }
package/performance.js ADDED
@@ -0,0 +1,15 @@
1
+ // Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2
+ // SPDX-License-Identifier: BSD-3-Clause-Clear
3
+
4
+ import {defineConfig} from "eslint/config"
5
+
6
+ export default defineConfig({
7
+ name: "qui-performance",
8
+ rules: {
9
+ "@typescript-eslint/consistent-type-imports": [
10
+ "error",
11
+ {fixStyle: "inline-type-imports"},
12
+ ],
13
+ "@typescript-eslint/no-import-type-side-effects": "error",
14
+ },
15
+ })
package/sort-keys.js ADDED
@@ -0,0 +1,27 @@
1
+ // Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2
+ // SPDX-License-Identifier: BSD-3-Clause-Clear
3
+
4
+ import {defineConfig} from "eslint/config"
5
+ import perfectionist from "eslint-plugin-perfectionist"
6
+
7
+ export default defineConfig({
8
+ name: "qui-sort-keys",
9
+ plugins: {perfectionist},
10
+ rules: {
11
+ "perfectionist/sort-interfaces": [
12
+ "error",
13
+ {
14
+ partitionByComment: ["^group:"],
15
+ type: "natural",
16
+ },
17
+ ],
18
+ "perfectionist/sort-object-types": ["error", {type: "natural"}],
19
+ "perfectionist/sort-objects": [
20
+ "error",
21
+ {
22
+ partitionByComment: ["^group:"],
23
+ type: "natural",
24
+ },
25
+ ],
26
+ },
27
+ })
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2
+ // SPDX-License-Identifier: BSD-3-Clause-Clear
3
+
4
+ import {defineConfig} from "eslint/config"
5
+
6
+ export default defineConfig({
7
+ name: "qui-typechecked-strict-exports",
8
+ rules: {
9
+ "@typescript-eslint/consistent-type-exports": [
10
+ "error",
11
+ {fixMixedExportsWithInlineTypeSpecifier: true},
12
+ ],
13
+ },
14
+ })
package/style-guide.js ADDED
@@ -0,0 +1,171 @@
1
+ // Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2
+ // SPDX-License-Identifier: BSD-3-Clause-Clear
3
+
4
+ import stylistic from "@stylistic/eslint-plugin"
5
+ import {defineConfig} from "eslint/config"
6
+ import commentLength from "eslint-plugin-comment-length"
7
+ import importPlugin from "eslint-plugin-import"
8
+ import perfectionist from "eslint-plugin-perfectionist"
9
+ import prettierPlugin from "eslint-plugin-prettier"
10
+ import unusedImportsPlugin from "eslint-plugin-unused-imports"
11
+
12
+ export default defineConfig({
13
+ name: "qui-style-guide",
14
+ plugins: {
15
+ "@stylistic": stylistic,
16
+ "comment-length": commentLength,
17
+ import: importPlugin,
18
+ perfectionist,
19
+ prettier: prettierPlugin,
20
+ "unused-imports": unusedImportsPlugin,
21
+ },
22
+ rules: {
23
+ ...commentLength.configs["flat/recommended"].rules,
24
+ "@stylistic/spaced-comment": ["error", "always", {block: {balanced: true}}],
25
+ "@typescript-eslint/ban-ts-comment": "off",
26
+ "@typescript-eslint/explicit-member-accessibility": [
27
+ "error",
28
+ {
29
+ accessibility: "explicit",
30
+ overrides: {
31
+ accessors: "no-public",
32
+ constructors: "off",
33
+ methods: "no-public",
34
+ parameterProperties: "off",
35
+ properties: "no-public",
36
+ },
37
+ },
38
+ ],
39
+ "@typescript-eslint/no-empty-interface": "off",
40
+ "@typescript-eslint/no-extra-semi": "off",
41
+ "@typescript-eslint/no-unused-vars": "off",
42
+ "@typescript-eslint/no-var-requires": "off",
43
+ "comment-length/limit-multi-line-comments": [
44
+ "warn",
45
+ {
46
+ ignoreUrls: true,
47
+ maxLength: 85,
48
+ },
49
+ ],
50
+ "comment-length/limit-single-line-comments": [
51
+ "warn",
52
+ {
53
+ ignoreUrls: true,
54
+ maxLength: 85,
55
+ },
56
+ ],
57
+ curly: "error",
58
+ eqeqeq: [
59
+ "error",
60
+ "always",
61
+ {
62
+ null: "ignore",
63
+ },
64
+ ],
65
+ "import/newline-after-import": ["error", {count: 1}],
66
+ "import/no-cycle": [0],
67
+ "import/no-duplicates": ["error", {"prefer-inline": true}],
68
+ "import/order": [
69
+ "error",
70
+ {
71
+ alphabetize: {
72
+ caseInsensitive: true,
73
+ order: "asc",
74
+ },
75
+ groups: [
76
+ ["builtin", "external"],
77
+ ["internal"],
78
+ ["parent"],
79
+ ["sibling", "index"],
80
+ ["unknown"],
81
+ ],
82
+ "newlines-between": "always",
83
+ pathGroups: [
84
+ {
85
+ group: "external",
86
+ pattern: "react",
87
+ position: "before",
88
+ },
89
+ {
90
+ group: "external",
91
+ pattern: "@qualcomm-ui/**",
92
+ position: "after",
93
+ },
94
+ {
95
+ group: "internal",
96
+ pattern: "~**",
97
+ },
98
+ {
99
+ group: "internal",
100
+ pattern: "~**/*",
101
+ },
102
+ {
103
+ group: "internal",
104
+ pattern: "~**/**",
105
+ },
106
+ ],
107
+ pathGroupsExcludedImportTypes: ["react"],
108
+ },
109
+ ],
110
+ "multiline-comment-style": ["off"],
111
+ "no-array-constructor": "error",
112
+ "no-case-declarations": "off",
113
+ "no-const-assign": "error",
114
+ "no-duplicate-imports": "off",
115
+ "no-inner-declarations": "off",
116
+ "no-invalid-this": "off",
117
+ "no-prototype-builtins": "off",
118
+ "no-restricted-imports": [
119
+ "error",
120
+ {
121
+ patterns: [
122
+ {
123
+ group: ["@qualcomm-ui/*/src/**/*"],
124
+ message:
125
+ "Relative imports from src directories are not allowed. Please ensure that the targeted dependency is exported properly from its module",
126
+ },
127
+ {
128
+ group: ["@qualcomm-ui/*/src"],
129
+ message: 'Remove "src" (import directly)',
130
+ },
131
+ ],
132
+ },
133
+ ],
134
+ "no-restricted-syntax": [
135
+ "error",
136
+ {
137
+ message: "Use `private` instead",
138
+ selector:
139
+ ":matches(PropertyDefinition, MethodDefinition) > PrivateIdentifier.key",
140
+ },
141
+ ],
142
+ "no-undef": "off",
143
+ "no-unused-vars": "off",
144
+ "no-useless-concat": "error",
145
+ "no-useless-escape": "warn",
146
+ "no-var": "error",
147
+ "object-shorthand": "error",
148
+ "prefer-const": "error",
149
+ "prefer-template": ["error"],
150
+ "prettier/prettier": "error",
151
+ "sort-imports": [
152
+ "error",
153
+ {
154
+ ignoreCase: true,
155
+ ignoreDeclarationSort: true,
156
+ },
157
+ ],
158
+ "unused-imports/no-unused-imports": "error",
159
+ "unused-imports/no-unused-vars": [
160
+ "error",
161
+ {
162
+ args: "after-used",
163
+ argsIgnorePattern: "^_",
164
+ caughtErrors: "all",
165
+ caughtErrorsIgnorePattern: "^",
166
+ vars: "all",
167
+ varsIgnorePattern: "^_",
168
+ },
169
+ ],
170
+ },
171
+ })
package/type-checks.js ADDED
@@ -0,0 +1,60 @@
1
+ // Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2
+ // SPDX-License-Identifier: BSD-3-Clause-Clear
3
+
4
+ import {defineConfig} from "eslint/config"
5
+
6
+ export default defineConfig({
7
+ name: "qui-typechecked-recommended",
8
+ rules: {
9
+ "@typescript-eslint/await-thenable": "error",
10
+ "@typescript-eslint/ban-ts-comment": "warn",
11
+ "@typescript-eslint/no-array-constructor": "error",
12
+ "@typescript-eslint/no-array-delete": "error",
13
+ "@typescript-eslint/no-base-to-string": "error",
14
+ "@typescript-eslint/no-duplicate-enum-values": "error",
15
+ "@typescript-eslint/no-duplicate-type-constituents": "error",
16
+ "@typescript-eslint/no-empty-object-type": "off",
17
+ "@typescript-eslint/no-explicit-any": "warn",
18
+ "@typescript-eslint/no-extra-non-null-assertion": "error",
19
+ "@typescript-eslint/no-floating-promises": "warn",
20
+ "@typescript-eslint/no-for-in-array": "error",
21
+ "@typescript-eslint/no-implied-eval": "error",
22
+ "@typescript-eslint/no-misused-new": "error",
23
+ "@typescript-eslint/no-misused-promises": "warn",
24
+ "@typescript-eslint/no-namespace": "warn",
25
+ "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
26
+ "@typescript-eslint/no-redundant-type-constituents": "off",
27
+ "@typescript-eslint/no-require-imports": "off",
28
+ "@typescript-eslint/no-this-alias": "error",
29
+ "@typescript-eslint/no-unnecessary-type-assertion": "warn",
30
+ "@typescript-eslint/no-unnecessary-type-constraint": "error",
31
+ "@typescript-eslint/no-unsafe-argument": "warn",
32
+ "@typescript-eslint/no-unsafe-assignment": "off",
33
+ "@typescript-eslint/no-unsafe-call": "warn",
34
+ "@typescript-eslint/no-unsafe-declaration-merging": "error",
35
+ "@typescript-eslint/no-unsafe-enum-comparison": "error",
36
+ "@typescript-eslint/no-unsafe-function-type": "warn",
37
+ "@typescript-eslint/no-unsafe-member-access": "warn",
38
+ "@typescript-eslint/no-unsafe-return": "warn",
39
+ "@typescript-eslint/no-unsafe-unary-minus": "error",
40
+ "@typescript-eslint/no-unused-expressions": "error",
41
+ "@typescript-eslint/no-unused-vars": "off",
42
+ "@typescript-eslint/no-wrapper-object-types": "error",
43
+ "@typescript-eslint/only-throw-error": "error",
44
+ "@typescript-eslint/prefer-as-const": "error",
45
+ "@typescript-eslint/prefer-namespace-keyword": "error",
46
+ "@typescript-eslint/prefer-promise-reject-errors": "warn",
47
+ "@typescript-eslint/require-await": "warn",
48
+ "@typescript-eslint/restrict-plus-operands": "error",
49
+ "@typescript-eslint/restrict-template-expressions": "off",
50
+ "@typescript-eslint/triple-slash-reference": "off",
51
+ "@typescript-eslint/unbound-method": "off",
52
+ "no-array-constructor": "off",
53
+ "no-implied-eval": "off",
54
+ "no-throw-literal": "off",
55
+ "no-unused-expressions": "off",
56
+ "no-unused-vars": "off",
57
+ "prefer-promise-reject-errors": "off",
58
+ "require-await": "off",
59
+ },
60
+ })