@qlik/eslint-config 1.4.28 → 2.0.0-next.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.
@@ -1,11 +0,0 @@
1
- // @ts-check
2
-
3
- /**
4
- * @satisfies {import("../../types/index.js").ESLintFlatConfig["rules"]}
5
- * Svelte plugin https://sveltejs.github.io/eslint-plugin-svelte/rules/
6
- */
7
- const rules = {
8
- // Override rules here
9
- };
10
-
11
- export default rules;
@@ -1,228 +0,0 @@
1
- // @ts-check
2
- import eslintCoreRules from "./eslint-core.js";
3
-
4
- /**
5
- * @satisfies {import("../../types/index.js").ESLintFlatConfig["rules"]}
6
- *
7
- * typescript-eslint package https://typescript-eslint.io/rules/
8
- */
9
- const rules = {
10
- // note some eslint core rules are disabled by tsconfig https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended-raw.ts
11
-
12
- // class methods don't have to use this, but should maybe be turned into static methods
13
- // https://typescript-eslint.io/rules/class-methods-use-this
14
- "class-methods-use-this": "off",
15
- "@typescript-eslint/class-methods-use-this": eslintCoreRules["class-methods-use-this"],
16
-
17
- // enforce consistent type imports
18
- // https://typescript-eslint.io/rules/consistent-type-imports
19
- "@typescript-eslint/consistent-type-imports": "error",
20
-
21
- // enforce default parameters to be last
22
- // https://typescript-eslint.io/rules/default-param-last
23
- "default-param-last": "off",
24
- "@typescript-eslint/default-param-last": eslintCoreRules["default-param-last"],
25
-
26
- // enforce exported functions to have return types
27
- // https://typescript-eslint.io/rules/explicit-module-boundary-types
28
- "@typescript-eslint/explicit-module-boundary-types": "off",
29
-
30
- // enforce method signatures has the same style
31
- // https://typescript-eslint.io/rules/method-signature-style
32
- "@typescript-eslint/method-signature-style": "error",
33
-
34
- // don't use the delete operator on dynamic properties
35
- // https://typescript-eslint.io/rules/no-dynamic-delete
36
- "@typescript-eslint/no-dynamic-delete": "error",
37
-
38
- // don't have classes with only static members
39
- // https://typescript-eslint.io/rules/no-extraneous-class
40
- "@typescript-eslint/no-extraneous-class": "error",
41
-
42
- // use top-level type imports
43
- // https://typescript-eslint.io/rules/no-import-type-side-effects
44
- "@typescript-eslint/no-import-type-side-effects": "error",
45
-
46
- // don't use void where it shouldn't be used
47
- // https://typescript-eslint.io/rules/no-invalid-void-type
48
- "@typescript-eslint/no-invalid-void-type": "error",
49
-
50
- // don't do weird things in loops
51
- // https://typescript-eslint.io/rules/no-loop-func
52
- "no-loop-func": "off",
53
- "@typescript-eslint/no-loop-func": eslintCoreRules["no-loop-func"],
54
-
55
- // no magic numbers please
56
- // https://typescript-eslint.io/rules/no-magic-numbers
57
- "no-magic-numbers": "off",
58
- "@typescript-eslint/no-magic-numbers": eslintCoreRules["no-magic-numbers"],
59
-
60
- // disallow non-null assertions in the left operand of a nullish coalescing operator.
61
- // https://typescript-eslint.io/rules/no-non-null-asserted-nullish-coalescing
62
- "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
63
-
64
- // https://typescript-eslint.io/rules/no-non-null-assertion
65
- "@typescript-eslint/no-non-null-assertion": "error",
66
-
67
- // don't allow redeclaration of variables
68
- // https://typescript-eslint.io/rules/no-redeclare
69
- "no-redeclare": "off",
70
- "@typescript-eslint/no-redeclare": eslintCoreRules["no-redeclare"],
71
-
72
- // add forbidden imports if needed
73
- // https://typescript-eslint.io/rules/no-restricted-imports
74
- "no-restricted-imports": "off",
75
- "@typescript-eslint/no-restricted-imports": eslintCoreRules["no-restricted-imports"],
76
-
77
- // add forbidden types if needed
78
- // https://typescript-eslint.io/rules/no-restricted-types
79
- "@typescript-eslint/no-restricted-types": ["error", {}],
80
-
81
- // shadows from outer scopes are not allowed
82
- // https://typescript-eslint.io/rules/no-shadow
83
- "no-shadow": "off",
84
- "@typescript-eslint/no-shadow": eslintCoreRules["no-shadow"],
85
-
86
- // no unnecessary assignment of constructor property parameter.
87
- // https://typescript-eslint.io/rules/no-unnecessary-parameter-property-assignment
88
- "@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
89
-
90
- // don't use stuff that hasn't been defined
91
- // https://typescript-eslint.io/rules/no-useless-constructor
92
- "no-useless-constructor": "off",
93
- "@typescript-eslint/no-useless-constructor": eslintCoreRules["no-useless-constructor"],
94
-
95
- // useless exports can be removed
96
- // https://typescript-eslint.io/rules/no-useless-empty-export
97
- "@typescript-eslint/no-useless-empty-export": "error",
98
-
99
- // yes, please initialize your enums
100
- // https://typescript-eslint.io/rules/prefer-enum-initializers
101
- "@typescript-eslint/prefer-enum-initializers": "error",
102
-
103
- // allow classic for loops
104
- // https://typescript-eslint.io/rules/prefer-for-of
105
- "@typescript-eslint/prefer-for-of": "off",
106
-
107
- // enums are not based on dynamic values
108
- // https://typescript-eslint.io/rules/prefer-literal-enum-member
109
- "@typescript-eslint/prefer-literal-enum-member": "error",
110
-
111
- // disallow two overloads that could be unified into one with a union or an optional/rest parameter.
112
- // https://typescript-eslint.io/rules/unified-signatures
113
- "@typescript-eslint/unified-signatures": "error",
114
-
115
- // enforce explicityly set type exports
116
- // https://typescript-eslint.io/rules/consistent-type-exports
117
- "@typescript-eslint/consistent-type-exports": "error",
118
-
119
- // void should not be assigned to variables
120
- // https://typescript-eslint.io/rules/no-confusing-void-expression
121
- "@typescript-eslint/no-confusing-void-expression": "error",
122
-
123
- // https://typescript-eslint.io/rules/no-floating-promises
124
- "@typescript-eslint/no-floating-promises": [
125
- "error",
126
- {
127
- ignoreIIFE: true,
128
- },
129
- ],
130
-
131
- // remove void when it's not needed
132
- // https://typescript-eslint.io/rules/no-meaningless-void-operator
133
- "@typescript-eslint/no-meaningless-void-operator": "error",
134
-
135
- // https://typescript-eslint.io/rules/no-misused-promises
136
- "@typescript-eslint/no-misused-promises": [
137
- "error",
138
- {
139
- checksConditionals: false,
140
- },
141
- ],
142
-
143
- // use constistent enum types
144
- // https://typescript-eslint.io/rules/no-mixed-enums
145
- "@typescript-eslint/no-mixed-enums": "error",
146
-
147
- // don't do silly comparisons
148
- // https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare
149
- "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
150
-
151
- // Lots of false/iffy positives
152
- // watch out for always truthy conditions
153
- // https://typescript-eslint.io/rules/no-unnecessary-condition
154
- "@typescript-eslint/no-unnecessary-condition": "off",
155
-
156
- // no unnecessary namespace qualifiers.
157
- // https://typescript-eslint.io/rules/no-unnecessary-qualifier
158
- "@typescript-eslint/no-unnecessary-qualifier": "error",
159
-
160
- // no need for template literals if they just refer to a string
161
- // https://typescript-eslint.io/rules/no-unnecessary-template-expression
162
- "@typescript-eslint/no-unnecessary-template-expression": "error",
163
-
164
- // don't use type arguments when they're not needed
165
- // https://typescript-eslint.io/rules/no-unnecessary-type-arguments
166
- "@typescript-eslint/no-unnecessary-type-arguments": "error",
167
-
168
- // Not working 100%
169
- // don't use type parameters when they're not needed
170
- // https://typescript-eslint.io/rules/no-unnecessary-type-parameters
171
- "@typescript-eslint/no-unnecessary-type-parameters": "off",
172
-
173
- // reducers should be typed correctly
174
- // https://typescript-eslint.io/rules/prefer-reduce-type-parameter
175
- "@typescript-eslint/prefer-reduce-type-parameter": "error",
176
-
177
- // https://typescript-eslint.io/rules/prefer-return-this-type
178
- "@typescript-eslint/prefer-return-this-type": "error",
179
-
180
- // https://typescript-eslint.io/rules/ban-ts-comment
181
- "@typescript-eslint/ban-ts-comment": "error",
182
-
183
- // https://typescript-eslint.io/rules/require-array-sort-compare
184
- "@typescript-eslint/require-array-sort-compare": "error",
185
-
186
- // not sure about this one
187
- // https://typescript-eslint.io/rules/return-await
188
- "no-return-await": "off",
189
- "@typescript-eslint/return-await": "error",
190
-
191
- // Not sure about this one
192
- // disallow certain types in boolean expressions.
193
- // https://typescript-eslint.io/rules/strict-boolean-expressions
194
- "@typescript-eslint/strict-boolean-expressions": "off",
195
-
196
- // make sure switch statements are exhaustive
197
- // https://typescript-eslint.io/rules/switch-exhaustiveness-check
198
- "@typescript-eslint/switch-exhaustiveness-check": "error",
199
-
200
- // enforce typing arguments in Promise rejection callbacks as unknown
201
- // https://typescript-eslint.io/rules/use-unknown-in-catch-callback-variable
202
- "@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
203
-
204
- // Replace camelcase' rule with '@typescript-eslint/naming-convention'
205
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
206
- camelcase: "off",
207
- // The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings. However, the existing `no-underscore-dangle` rule already takes care of this.
208
- "@typescript-eslint/naming-convention": [
209
- "error",
210
- // Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables (23.10)
211
- {
212
- selector: "variable",
213
- format: ["camelCase", "PascalCase", "UPPER_CASE"],
214
- },
215
- // Allow camelCase functions (23.2), and PascalCase functions (23.8)
216
- {
217
- selector: "function",
218
- format: ["camelCase", "PascalCase"],
219
- },
220
- // Qlik recommends PascalCase for classes (23.3),
221
- {
222
- selector: "typeLike",
223
- format: ["PascalCase"],
224
- },
225
- ],
226
- };
227
-
228
- export default rules;
@@ -1,56 +0,0 @@
1
- // @ts-check
2
- import prettier from "eslint-config-prettier";
3
- import eslintPluginSvelte from "eslint-plugin-svelte";
4
- import svelteParser from "svelte-eslint-parser";
5
- import tsEslint from "typescript-eslint";
6
- import { mergeConfigs } from "../utils/config.js";
7
- import { recommendedJS, recommendedTS } from "./recommended.js";
8
- import svelteRules from "./rules/svelte.js";
9
-
10
- /**
11
- * @type {import("../types/index.js").ESLintFlatConfig}
12
- * config for Svelte https://github.com/sveltejs/eslint-plugin-svelte
13
- */
14
- const svelteJS = mergeConfigs(
15
- // base it on svelte plugin recommended config
16
- ...eslintPluginSvelte.configs["flat/recommended"],
17
- // add qlik's recommended svelte config
18
- {
19
- name: "svelte",
20
- files: ["**/*.svelte"],
21
- languageOptions: {
22
- parser: svelteParser,
23
- parserOptions: {
24
- parser: tsEslint.parser,
25
- extraFileExtensions: [".svelte"],
26
- },
27
- },
28
- rules: {
29
- ...svelteRules,
30
- // modify rules from eslint-plugin-svelte here
31
-
32
- // Conflicting rules
33
- // https://github.com/sveltejs/eslint-plugin-svelte3/blob/master/OTHER_PLUGINS.md
34
- "import-x/first": "off",
35
- "import-x/no-duplicates": "off",
36
- "import-x/no-mutable-exports": "off",
37
- "import-x/no-unresolved": "off",
38
- "import-x/prefer-default-export": "off",
39
- "import-x/extensions": "off",
40
-
41
- // Issues with TypeScript rules
42
- "@typescript-eslint/no-unsafe-call": "off",
43
- "@typescript-eslint/no-unsafe-return": "off",
44
- "@typescript-eslint/no-unsafe-argument": "off",
45
- "@typescript-eslint/no-unsafe-assignment": "off",
46
- "@typescript-eslint/no-unsafe-member-access": "off",
47
-
48
- // Issues with function types that define parameters
49
- "no-unused-vars": "off",
50
- },
51
- },
52
- prettier,
53
- );
54
-
55
- export default [recommendedJS, recommendedTS, svelteJS];
56
- export { svelteJS };
@@ -1,63 +0,0 @@
1
- // @ts-check
2
-
3
- import { mergeConfigs } from "./config.js";
4
-
5
- /**
6
- * Utility function to make it easy to strictly type your "Flat" config file
7
- *
8
- * @param {...(import("../types/index.js").ESLintFlatConfigWithExtend)} configs
9
- * @returns {import("../types/index.js").ESLintFlatConfig[]}
10
- *
11
- * @example
12
- * ```js
13
- * import qlik from "@qlik/eslint-config";
14
- *
15
- * export default qlik.compose(
16
- * ...qlik.configs.react,
17
- * ...qlik.configs.vitest,
18
- * {
19
- * rules: {
20
- * // Override rules if needed
21
- * },
22
- * },
23
- * // In its own object so it's global
24
- * {
25
- * ignores: ["dist", "node_modules", "script"],
26
- * },
27
- * );
28
- * ```
29
- */
30
- export default function compose(...configs) {
31
- return configs.flatMap((configWithExtends, configIndex) => {
32
- const { extend: extendArr, ...config } = configWithExtends;
33
- if (extendArr && !Array.isArray(extendArr)) {
34
- throw new Error("extend property must be an array");
35
- }
36
- if (extendArr == null || extendArr.length === 0) {
37
- return config;
38
- }
39
-
40
- const undefinedExtensions = extendArr.reduce((acc, extension, extensionIndex) => {
41
- const maybeExtension = extension;
42
- if (maybeExtension == null) {
43
- acc.push(extensionIndex);
44
- }
45
- return acc;
46
- }, /** @type {number[]} */ ([]));
47
- if (undefinedExtensions.length) {
48
- const configName = configWithExtends.name != null ? `, named "${configWithExtends.name}",` : " (anonymous)";
49
- const extensionIndices = undefinedExtensions.join(", ");
50
- throw new Error(
51
- `Your config at index ${configIndex}${configName} contains undefined` +
52
- ` extensions at the following indices: ${extensionIndices}.`,
53
- );
54
- }
55
-
56
- return [
57
- ...extendArr.map((extension) => {
58
- const name = [config.name, extension.name].filter(Boolean).join("__");
59
- return mergeConfigs(extension, config, name ? { name } : {});
60
- }),
61
- ];
62
- });
63
- }