@forsakringskassan/eslint-config 12.2.2 → 13.0.1
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/eslint.js +1 -0
- package/index.d.mts +11 -0
- package/{flat.mjs → index.mjs} +118 -6
- package/package.json +10 -13
- package/flat.d.mts +0 -6
- package/index.cjs +0 -130
- package/patch/modern-module-resolution.js +0 -1
package/eslint.js
CHANGED
|
@@ -6,6 +6,7 @@ const { spawn } = require("child_process");
|
|
|
6
6
|
const pkgPath = path.dirname(require.resolve("eslint/package.json"));
|
|
7
7
|
const binary = path.join(pkgPath, "bin/eslint");
|
|
8
8
|
|
|
9
|
+
/* eslint-disable-next-line sonarjs/no-os-command-from-path -- want to run it from path */
|
|
9
10
|
spawn("node", [binary, ...process.argv.slice(2)], {
|
|
10
11
|
stdio: "inherit",
|
|
11
12
|
}).on("exit", (code) => {
|
package/index.d.mts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Linter } from "eslint";
|
|
2
|
+
|
|
3
|
+
declare const config: Linter.Config[];
|
|
4
|
+
export const globals: typeof import("globals");
|
|
5
|
+
|
|
6
|
+
export default config;
|
|
7
|
+
|
|
8
|
+
export function defineConfig(config: Linter.Config): Linter.Config;
|
|
9
|
+
export function docsConfig(override?: Linter.Config): Linter.Config;
|
|
10
|
+
export function examplesConfig(override?: Linter.Config): Linter.Config;
|
|
11
|
+
export function sandboxConfig(override?: Linter.Config): Linter.Config;
|
package/{flat.mjs → index.mjs}
RENAMED
|
@@ -2,7 +2,7 @@ import { fileURLToPath } from "node:url";
|
|
|
2
2
|
import js from "@eslint/js";
|
|
3
3
|
import prettierConfig from "eslint-config-prettier";
|
|
4
4
|
import importPlugin from "eslint-plugin-import";
|
|
5
|
-
import eslintCommentsPlugin from "eslint-plugin-eslint-comments";
|
|
5
|
+
import eslintCommentsPlugin from "@eslint-community/eslint-plugin-eslint-comments";
|
|
6
6
|
import prettierPlugin from "eslint-plugin-prettier";
|
|
7
7
|
import sonarjsPlugin from "eslint-plugin-sonarjs";
|
|
8
8
|
import globals from "globals";
|
|
@@ -17,10 +17,25 @@ export { default as globals } from "globals";
|
|
|
17
17
|
* @param {Config} config
|
|
18
18
|
* @returns {Config}
|
|
19
19
|
*/
|
|
20
|
-
function defineConfig(config) {
|
|
20
|
+
export function defineConfig(config) {
|
|
21
21
|
return config;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* @param {Config} result
|
|
26
|
+
* @param {Config} it
|
|
27
|
+
* @returns {Config}
|
|
28
|
+
*/
|
|
29
|
+
function merge(result, it) {
|
|
30
|
+
return {
|
|
31
|
+
...result,
|
|
32
|
+
...it,
|
|
33
|
+
languageOptions: { ...result.languageOptions, ...it.languageOptions },
|
|
34
|
+
plugins: { ...result.plugins, ...it.plugins },
|
|
35
|
+
rules: { ...result.rules, ...it.rules },
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
24
39
|
export default [
|
|
25
40
|
defineConfig({
|
|
26
41
|
...js.configs.recommended,
|
|
@@ -30,7 +45,7 @@ export default [
|
|
|
30
45
|
plugins: {
|
|
31
46
|
prettier: prettierPlugin,
|
|
32
47
|
import: importPlugin,
|
|
33
|
-
"eslint-comments": eslintCommentsPlugin,
|
|
48
|
+
"@eslint-community/eslint-comments": eslintCommentsPlugin,
|
|
34
49
|
sonarjs: sonarjsPlugin,
|
|
35
50
|
},
|
|
36
51
|
settings: {
|
|
@@ -78,11 +93,11 @@ export default [
|
|
|
78
93
|
radix: "error",
|
|
79
94
|
yoda: "error",
|
|
80
95
|
|
|
81
|
-
"eslint-comments/disable-enable-pair": [
|
|
96
|
+
"@eslint-community/eslint-comments/disable-enable-pair": [
|
|
82
97
|
"error",
|
|
83
98
|
{ allowWholeFile: true },
|
|
84
99
|
],
|
|
85
|
-
"eslint-comments/require-description": [
|
|
100
|
+
"@eslint-community/eslint-comments/require-description": [
|
|
86
101
|
"error",
|
|
87
102
|
{
|
|
88
103
|
ignore: [
|
|
@@ -94,7 +109,7 @@ export default [
|
|
|
94
109
|
],
|
|
95
110
|
},
|
|
96
111
|
],
|
|
97
|
-
"eslint-comments/no-unused-disable": "error",
|
|
112
|
+
"@eslint-community/eslint-comments/no-unused-disable": "error",
|
|
98
113
|
|
|
99
114
|
/* Use eslint native complexity rule instead */
|
|
100
115
|
"sonarjs/cognitive-complexity": "off",
|
|
@@ -109,6 +124,23 @@ export default [
|
|
|
109
124
|
* keys. */
|
|
110
125
|
"sonarjs/no-duplicate-string": "off",
|
|
111
126
|
|
|
127
|
+
"sonarjs/argument-type": "off", // handled by typescript (and this rule is sometimes wrong)
|
|
128
|
+
"sonarjs/deprecation": "off", // covered by @typescript-eslint/no-deprecated (and this rule crashes on .svelte files)
|
|
129
|
+
"sonarjs/function-return-type": "off", // overly broad and opinionated, let typescript deal with this
|
|
130
|
+
"sonarjs/no-control-regex": "off", // covered by no-control-regexp
|
|
131
|
+
"sonarjs/no-empty-test-file": "off", // could be useful but it does not handle it.each or similar constructs thus yields more false positives than its worth */
|
|
132
|
+
"sonarjs/no-selector-parameter": "off", // not always possible (e.g. watcher handler in vue)
|
|
133
|
+
"sonarjs/no-skipped-tests": "off", // covered by jest/no-disabled-tests and mocha/no-pending-tests
|
|
134
|
+
"sonarjs/no-small-switch": "off", // prefer to use small switches when the intention is to all more cases later
|
|
135
|
+
"sonarjs/no-unused-vars": "off", // covered by @typescript-eslint/no-unused-vars
|
|
136
|
+
"sonarjs/prefer-nullish-coalescing": "off", // requires typescript and strictNullChecks, which is sane, but we also use @typescript-eslint/prefer-nullish-coalescing so this becomes redundant
|
|
137
|
+
"sonarjs/prefer-regexp-exec": "off", // covered by @typescript-eslint/prefer-regexp-exec
|
|
138
|
+
"sonarjs/redundant-type-aliases": "off", // "redundant" type aliases helps with self-documenting code
|
|
139
|
+
"sonarjs/todo-tag": "off", // want to be able to leave todo tasks
|
|
140
|
+
"sonarjs/unused-import": "off", // covered by @typescript-eslint/no-unused-vars
|
|
141
|
+
"sonarjs/unused-named-groups": "off", // named groups can help readability even if not used
|
|
142
|
+
"sonarjs/use-type-alias": "off", // overly broad, lets leave this to the discretion of the author
|
|
143
|
+
|
|
112
144
|
/* Lower some errors to warnings, these are allowed on local builds (to
|
|
113
145
|
* not prevent builds during development where code is unfinished and
|
|
114
146
|
* might contain debugging code) but is disallowed when building from
|
|
@@ -116,6 +148,7 @@ export default [
|
|
|
116
148
|
"no-console": "warn",
|
|
117
149
|
"no-debugger": "warn",
|
|
118
150
|
"prettier/prettier": "warn",
|
|
151
|
+
"sonarjs/no-commented-code": "warn",
|
|
119
152
|
|
|
120
153
|
"import/default": "off",
|
|
121
154
|
"import/extensions": [
|
|
@@ -196,4 +229,83 @@ export default [
|
|
|
196
229
|
"import/extensions": ["error", "always"],
|
|
197
230
|
},
|
|
198
231
|
}),
|
|
232
|
+
|
|
233
|
+
/* These legacy files points to compiled files which may or may not exist
|
|
234
|
+
* yet */
|
|
235
|
+
defineConfig({
|
|
236
|
+
name: "@forsakringskassan/eslint-config/legacy-dts",
|
|
237
|
+
files: ["packages/*/*.d.ts"],
|
|
238
|
+
rules: {
|
|
239
|
+
"import/no-unresolved": "off",
|
|
240
|
+
},
|
|
241
|
+
}),
|
|
242
|
+
|
|
243
|
+
/* E2E tests may import pageobjects from monorepo packages but the import
|
|
244
|
+
* plugin wont resolve them, yielding lots of false positives */
|
|
245
|
+
{
|
|
246
|
+
name: "@forsakringskassan/eslint-config/cypress-pageobjects",
|
|
247
|
+
files: ["cypress/**/*.[jt]s"],
|
|
248
|
+
rules: {
|
|
249
|
+
"import/no-extraneous-dependencies": "off",
|
|
250
|
+
"import/order": "off",
|
|
251
|
+
},
|
|
252
|
+
},
|
|
199
253
|
];
|
|
254
|
+
|
|
255
|
+
const defaultDocsConfig = defineConfig({
|
|
256
|
+
name: "@forsakringskassan/eslint-config/docs-app",
|
|
257
|
+
files: ["docs/src/*.{js,ts}"],
|
|
258
|
+
languageOptions: {
|
|
259
|
+
globals: {
|
|
260
|
+
...globals.browser,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const defaultExampleConfig = {
|
|
266
|
+
name: "@forsakringskassan/eslint-config/docs-examples",
|
|
267
|
+
files: ["**/examples/**/*.{js,ts,vue}"],
|
|
268
|
+
rules: {
|
|
269
|
+
"@eslint-community/eslint-comments/require-description": "off",
|
|
270
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
271
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
272
|
+
"import/no-duplicates": "off",
|
|
273
|
+
"import/no-extraneous-dependencies": "off",
|
|
274
|
+
"no-console": "off",
|
|
275
|
+
"no-unused-vars": "off",
|
|
276
|
+
"sonarjs/no-dead-store": "off",
|
|
277
|
+
"sonarjs/pseudo-random": "off",
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const defaultSandboxConfig = {
|
|
282
|
+
name: "@forsakringskassan/eslint-config/sandbox",
|
|
283
|
+
files: ["internal/vue-sandbox/**/*.{js,ts,vue}"],
|
|
284
|
+
rules: {
|
|
285
|
+
"no-console": "off",
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* @param {Config} [override]
|
|
291
|
+
* @returns {Config}
|
|
292
|
+
*/
|
|
293
|
+
export function docsConfig(override) {
|
|
294
|
+
return merge(defaultDocsConfig, override ?? {});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* @param {Config} [override]
|
|
299
|
+
* @returns {Config}
|
|
300
|
+
*/
|
|
301
|
+
export function examplesConfig(override) {
|
|
302
|
+
return merge(defaultExampleConfig, override ?? {});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* @param {Config} [override]
|
|
307
|
+
* @returns {Config}
|
|
308
|
+
*/
|
|
309
|
+
export function sandboxConfig(override) {
|
|
310
|
+
return merge(defaultSandboxConfig, override ?? {});
|
|
311
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forsakringskassan/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.1",
|
|
4
4
|
"description": "Försäkringskassans eslint shareable config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint"
|
|
@@ -14,35 +14,32 @@
|
|
|
14
14
|
},
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"author": "Försäkringskassan",
|
|
17
|
-
"main": "index.
|
|
17
|
+
"main": "index.mjs",
|
|
18
18
|
"bin": {
|
|
19
19
|
"eslint": "eslint.js"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"patch",
|
|
23
22
|
"eslint.js",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"index.cjs"
|
|
23
|
+
"index.mjs",
|
|
24
|
+
"index.d.mts"
|
|
27
25
|
],
|
|
28
26
|
"dependencies": {
|
|
27
|
+
"@eslint-community/eslint-plugin-eslint-comments": "4.5.0",
|
|
29
28
|
"@eslint/js": "9.35.0",
|
|
30
|
-
"
|
|
31
|
-
"eslint": "8.57.1",
|
|
29
|
+
"eslint": "9.35.0",
|
|
32
30
|
"eslint-config-prettier": "10.1.8",
|
|
33
31
|
"eslint-import-resolver-node": "0.3.9",
|
|
34
32
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
35
|
-
"eslint-plugin-eslint-comments": "3.2.0",
|
|
36
33
|
"eslint-plugin-import": "2.32.0",
|
|
37
34
|
"eslint-plugin-prettier": "5.5.4",
|
|
38
|
-
"eslint-plugin-sonarjs": "
|
|
39
|
-
"globals": "
|
|
35
|
+
"eslint-plugin-sonarjs": "3.0.5",
|
|
36
|
+
"globals": "16.4.0"
|
|
40
37
|
},
|
|
41
38
|
"peerDependencies": {
|
|
42
39
|
"prettier": "^2.0.0 || ^3.0.0"
|
|
43
40
|
},
|
|
44
41
|
"engines": {
|
|
45
|
-
"node": ">=
|
|
42
|
+
"node": ">= 22.0"
|
|
46
43
|
},
|
|
47
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "57b963a69b2ccca19ef2573910796c5c8a251582"
|
|
48
45
|
}
|
package/flat.d.mts
DELETED
package/index.cjs
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
extends: [
|
|
3
|
-
"eslint:recommended",
|
|
4
|
-
"plugin:prettier/recommended",
|
|
5
|
-
"plugin:import/errors",
|
|
6
|
-
"plugin:eslint-comments/recommended",
|
|
7
|
-
"plugin:sonarjs/recommended-legacy",
|
|
8
|
-
],
|
|
9
|
-
|
|
10
|
-
env: {
|
|
11
|
-
es6: true,
|
|
12
|
-
node: true,
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
parserOptions: {
|
|
16
|
-
ecmaVersion: 2022,
|
|
17
|
-
sourceType: "module",
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
settings: {
|
|
21
|
-
"import/resolver": {
|
|
22
|
-
[require.resolve("eslint-import-resolver-node")]: true,
|
|
23
|
-
[require.resolve("eslint-import-resolver-typescript")]: true,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
rules: {
|
|
28
|
-
camelcase: "error",
|
|
29
|
-
complexity: ["error", 20],
|
|
30
|
-
"consistent-return": "error",
|
|
31
|
-
curly: "error",
|
|
32
|
-
eqeqeq: "error",
|
|
33
|
-
"max-depth": ["error", 3],
|
|
34
|
-
"max-params": ["error", { max: 5 }],
|
|
35
|
-
"no-eval": "error",
|
|
36
|
-
"no-implied-eval": "error",
|
|
37
|
-
"no-loop-func": "error",
|
|
38
|
-
"no-new": "error",
|
|
39
|
-
"no-new-func": "error",
|
|
40
|
-
"no-unreachable": "error",
|
|
41
|
-
"no-unused-vars": "error",
|
|
42
|
-
"no-var": "error",
|
|
43
|
-
"no-warning-comments": "error",
|
|
44
|
-
"prefer-const": "error",
|
|
45
|
-
"prefer-rest-params": "error",
|
|
46
|
-
"prefer-spread": "error",
|
|
47
|
-
"prefer-template": "error",
|
|
48
|
-
radix: "error",
|
|
49
|
-
yoda: "error",
|
|
50
|
-
|
|
51
|
-
"eslint-comments/disable-enable-pair": [
|
|
52
|
-
"error",
|
|
53
|
-
{ allowWholeFile: true },
|
|
54
|
-
],
|
|
55
|
-
"eslint-comments/require-description": [
|
|
56
|
-
"error",
|
|
57
|
-
{
|
|
58
|
-
ignore: [
|
|
59
|
-
"eslint-enable",
|
|
60
|
-
"eslint-env",
|
|
61
|
-
"exported",
|
|
62
|
-
"global",
|
|
63
|
-
"globals",
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
"eslint-comments/no-unused-disable": "error",
|
|
68
|
-
|
|
69
|
-
/* Use eslint native complexity rule instead */
|
|
70
|
-
"sonarjs/cognitive-complexity": "off",
|
|
71
|
-
|
|
72
|
-
/* Prefer to use multiple returns even for booleans (looks better and
|
|
73
|
-
* can yield performance increase), see example of this in
|
|
74
|
-
* "example.js". */
|
|
75
|
-
"sonarjs/prefer-single-boolean-return": "off",
|
|
76
|
-
|
|
77
|
-
/* This rule is deemed to provide more trouble than actual value.
|
|
78
|
-
* Especially because of the prevalence of translations, i.e., text
|
|
79
|
-
* keys. */
|
|
80
|
-
"sonarjs/no-duplicate-string": "off",
|
|
81
|
-
|
|
82
|
-
/* Lower some errors to warnings, these are allowed on local builds (to
|
|
83
|
-
* not prevent builds during development where code is unfinished and
|
|
84
|
-
* might contain debugging code) but is disallowed when building from
|
|
85
|
-
* Jenkins (via `--max-warnings 0`) */
|
|
86
|
-
"no-console": "warn",
|
|
87
|
-
"no-debugger": "warn",
|
|
88
|
-
"prettier/prettier": "warn",
|
|
89
|
-
|
|
90
|
-
"import/default": "off",
|
|
91
|
-
"import/extensions": [
|
|
92
|
-
"error",
|
|
93
|
-
"never",
|
|
94
|
-
{
|
|
95
|
-
css: "always",
|
|
96
|
-
json: "always",
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
"import/newline-after-import": "error",
|
|
100
|
-
"import/no-absolute-path": "error",
|
|
101
|
-
"import/no-deprecated": "error",
|
|
102
|
-
"import/no-duplicates": "error",
|
|
103
|
-
"import/no-dynamic-require": "error",
|
|
104
|
-
"import/no-extraneous-dependencies": "error",
|
|
105
|
-
"import/no-mutable-exports": "error",
|
|
106
|
-
"import/no-named-as-default": "error",
|
|
107
|
-
"import/no-named-as-default-member": "error",
|
|
108
|
-
"import/no-named-default": "error",
|
|
109
|
-
"import/no-unresolved": [
|
|
110
|
-
"error",
|
|
111
|
-
{
|
|
112
|
-
/* neither of the resolvers will handle @ alias */
|
|
113
|
-
ignore: ["^@"],
|
|
114
|
-
},
|
|
115
|
-
],
|
|
116
|
-
"import/no-useless-path-segments": "error",
|
|
117
|
-
"import/order": [
|
|
118
|
-
"error",
|
|
119
|
-
{
|
|
120
|
-
pathGroups: [
|
|
121
|
-
{
|
|
122
|
-
pattern: "@/**",
|
|
123
|
-
group: "parent",
|
|
124
|
-
position: "before",
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
},
|
|
130
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require("@rushstack/eslint-patch/modern-module-resolution");
|