@forsakringskassan/eslint-config 13.0.0 → 13.0.2

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 (3) hide show
  1. package/index.d.mts +5 -0
  2. package/index.mjs +124 -1
  3. package/package.json +2 -2
package/index.d.mts CHANGED
@@ -4,3 +4,8 @@ declare const config: Linter.Config[];
4
4
  export const globals: typeof import("globals");
5
5
 
6
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/index.mjs CHANGED
@@ -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,
@@ -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,94 @@ 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: ["*.d.ts", "packages/*/*.d.ts"],
238
+ rules: {
239
+ "import/no-unresolved": "off",
240
+ },
241
+ }),
242
+
243
+ defineConfig({
244
+ name: "@forsakringskassan/eslint-config/bin",
245
+ files: ["bin/*.{js,cjs,mjs}"],
246
+ rules: {
247
+ /* esm requires the usage of extension in this context */
248
+ "import/extensions": "off",
249
+ /* needed to run eslint before sources are compiled to dist folder */
250
+ "import/no-unresolved": "off",
251
+ },
252
+ }),
253
+
254
+ /* E2E tests may import pageobjects from monorepo packages but the import
255
+ * plugin wont resolve them, yielding lots of false positives */
256
+ {
257
+ name: "@forsakringskassan/eslint-config/cypress-pageobjects",
258
+ files: ["cypress/**/*.[jt]s"],
259
+ rules: {
260
+ "import/no-extraneous-dependencies": "off",
261
+ "import/order": "off",
262
+ },
263
+ },
199
264
  ];
265
+
266
+ const defaultDocsConfig = defineConfig({
267
+ name: "@forsakringskassan/eslint-config/docs-app",
268
+ files: ["docs/src/*.{js,ts}"],
269
+ languageOptions: {
270
+ globals: {
271
+ ...globals.browser,
272
+ },
273
+ },
274
+ });
275
+
276
+ const defaultExampleConfig = {
277
+ name: "@forsakringskassan/eslint-config/docs-examples",
278
+ files: ["**/examples/**/*.{js,ts,vue}"],
279
+ rules: {
280
+ "@eslint-community/eslint-comments/require-description": "off",
281
+ "@typescript-eslint/explicit-function-return-type": "off",
282
+ "@typescript-eslint/no-unused-vars": "off",
283
+ "import/no-duplicates": "off",
284
+ "import/no-extraneous-dependencies": "off",
285
+ "no-console": "off",
286
+ "no-unused-vars": "off",
287
+ "sonarjs/no-dead-store": "off",
288
+ "sonarjs/pseudo-random": "off",
289
+ },
290
+ };
291
+
292
+ const defaultSandboxConfig = {
293
+ name: "@forsakringskassan/eslint-config/sandbox",
294
+ files: ["internal/vue-sandbox/**/*.{js,ts,vue}"],
295
+ rules: {
296
+ "no-console": "off",
297
+ },
298
+ };
299
+
300
+ /**
301
+ * @param {Config} [override]
302
+ * @returns {Config}
303
+ */
304
+ export function docsConfig(override) {
305
+ return merge(defaultDocsConfig, override ?? {});
306
+ }
307
+
308
+ /**
309
+ * @param {Config} [override]
310
+ * @returns {Config}
311
+ */
312
+ export function examplesConfig(override) {
313
+ return merge(defaultExampleConfig, override ?? {});
314
+ }
315
+
316
+ /**
317
+ * @param {Config} [override]
318
+ * @returns {Config}
319
+ */
320
+ export function sandboxConfig(override) {
321
+ return merge(defaultSandboxConfig, override ?? {});
322
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/eslint-config",
3
- "version": "13.0.0",
3
+ "version": "13.0.2",
4
4
  "description": "Försäkringskassans eslint shareable config",
5
5
  "keywords": [
6
6
  "eslint"
@@ -41,5 +41,5 @@
41
41
  "engines": {
42
42
  "node": ">= 22.0"
43
43
  },
44
- "gitHead": "6e466e321dc87d4d3e525bbf1711e8ae9f6b8742"
44
+ "gitHead": "99ad23a49dac0b99b44be7190639b0dfb5d27355"
45
45
  }