@forsakringskassan/eslint-config 13.4.2 → 13.5.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/eslint.js +2 -2
  2. package/index.mjs +156 -1
  3. package/package.json +3 -2
package/eslint.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { spawn } = require("child_process");
4
- const path = require("path");
3
+ const { spawn } = require("node:child_process");
4
+ const path = require("node:path");
5
5
 
6
6
  const pkgPath = path.dirname(require.resolve("eslint/package.json"));
7
7
  const binary = path.join(pkgPath, "bin/eslint");
package/index.mjs CHANGED
@@ -5,6 +5,7 @@ import prettierConfig from "eslint-config-prettier";
5
5
  import importPlugin from "eslint-plugin-import";
6
6
  import prettierPlugin from "eslint-plugin-prettier";
7
7
  import sonarjsPlugin from "eslint-plugin-sonarjs";
8
+ import eslintPluginUnicorn from "eslint-plugin-unicorn";
8
9
  import globals from "globals";
9
10
 
10
11
  export { default as globals } from "globals";
@@ -59,6 +60,7 @@ export default [
59
60
  import: importPlugin,
60
61
  "@eslint-community/eslint-comments": eslintCommentsPlugin,
61
62
  sonarjs: sonarjsPlugin,
63
+ unicorn: eslintPluginUnicorn,
62
64
  },
63
65
  settings: {
64
66
  "import/resolver": {
@@ -198,6 +200,159 @@ export default [
198
200
  "sonarjs/aws-sns-unencrypted-topics": "off",
199
201
  "sonarjs/aws-sqs-unencrypted-queue": "off",
200
202
 
203
+ /* enable eslint-plugin-unicorn */
204
+ ...eslintPluginUnicorn.configs.recommended.rules,
205
+ "unicorn/better-regex": "error",
206
+ "unicorn/catch-error-name": "off",
207
+ "unicorn/consistent-assert": "off",
208
+ "unicorn/consistent-date-clone": "off", // we prefer to use FDate instead of Date and structuredClone does not play well with jest
209
+ "unicorn/consistent-empty-array-spread": "off",
210
+ "unicorn/consistent-existence-index-check": "error",
211
+ "unicorn/consistent-function-scoping": "error",
212
+ "unicorn/custom-error-definition": "error",
213
+ "unicorn/error-message": "error",
214
+ "unicorn/escape-case": "off", // typically not useful for this organisation
215
+ "unicorn/expiring-todo-comments": "off", // could be useful later
216
+ "unicorn/explicit-length-check": [
217
+ "error",
218
+ { "non-zero": "greater-than" },
219
+ ],
220
+ "unicorn/filename-case": [
221
+ "error",
222
+ {
223
+ case: "kebabCase",
224
+ ignore: [
225
+ "^Gruntfile.js$",
226
+ /* ignore mocks for @forsakringskassan/apimock-express */
227
+ "_(get|post|put|delete).(js|cjs|mjs|ts)$",
228
+ ],
229
+ },
230
+ ], // enforce kebab-case in filenames
231
+ "unicorn/import-style": "off", // off for now
232
+ "unicorn/isolated-functions": "error",
233
+ "unicorn/new-for-builtins": "error",
234
+ "unicorn/no-abusive-eslint-disable": "off", // covered by eslint-plugin-eslint-comments
235
+ "unicorn/no-accessor-recursion": "error",
236
+ "unicorn/no-anonymous-default-export": "off", // often used with configuration packages
237
+ "unicorn/no-array-callback-reference": "off", // opinionated, prefer to allow passing function references to array methods (and for most part typescript will handle this)
238
+ "unicorn/no-array-for-each": "error",
239
+ "unicorn/no-array-method-this-argument": "error",
240
+ "unicorn/no-array-reduce": "off", // allow usage of reduce()
241
+ "unicorn/no-array-reverse": "error", // prefer immutable .toReversed() (available in Node.js 20+)
242
+ "unicorn/no-array-sort": "error", // prefer immutable .toSorted() (available in Node.js 20+)
243
+ "unicorn/no-await-expression-member": "error",
244
+ "unicorn/no-await-in-promise-methods": "error",
245
+ "unicorn/no-console-spaces": "error",
246
+ "unicorn/no-document-cookie": "error",
247
+ "unicorn/no-empty-file": "off",
248
+ "unicorn/no-for-loop": "error",
249
+ "unicorn/no-hex-escape": "error",
250
+ "unicorn/no-immediate-mutation": "off",
251
+ "unicorn/no-instanceof-builtins": "error",
252
+ "unicorn/no-invalid-fetch-options": "off", // let typescript and tests handle this
253
+ "unicorn/no-invalid-remove-event-listener": "error",
254
+ "unicorn/no-magic-array-flat-depth": "error",
255
+ "unicorn/no-named-default": "off", // named default is useful for vue
256
+ "unicorn/no-negated-condition": "off", // mostly agree with the rule but sometimes its useful to have the common case first even if negated
257
+ "unicorn/no-negation-in-equality-check": "off",
258
+ "unicorn/no-new-array": "error",
259
+ "unicorn/no-new-buffer": "error",
260
+ "unicorn/no-null": "off", // prefer using null over undefined
261
+ "unicorn/no-object-as-default-parameter": "error",
262
+ "unicorn/no-process-exit": "off", // covered by n/no-process-exit (enabled by recommended-module preset)
263
+ "unicorn/no-single-promise-in-promise-methods": "error",
264
+ "unicorn/no-static-only-class": "off",
265
+ "unicorn/no-thenable": "off",
266
+ "unicorn/no-this-assignment": "error",
267
+ "unicorn/no-typeof-undefined": "error",
268
+ "unicorn/no-unnecessary-array-flat-depth": "error",
269
+ "unicorn/no-unnecessary-array-splice-count": "error",
270
+ "unicorn/no-unnecessary-await": "error",
271
+ "unicorn/no-unnecessary-polyfills": "off",
272
+ "unicorn/no-unnecessary-slice-end": "error",
273
+ "unicorn/no-unreadable-array-destructuring": "off",
274
+ "unicorn/no-unreadable-iife": "off",
275
+ "unicorn/no-useless-collection-argument": "error",
276
+ "unicorn/no-useless-error-capture-stack-trace": "error",
277
+ "unicorn/no-useless-fallback-in-spread": "error",
278
+ "unicorn/no-useless-length-check": "error",
279
+ "unicorn/no-useless-promise-resolve-reject": "error",
280
+ "unicorn/no-useless-spread": "error",
281
+ "unicorn/no-useless-switch-case": "off",
282
+ "unicorn/no-useless-undefined": "off", // opinionated, I prefer to explicitly pass undefined
283
+ "unicorn/no-zero-fractions": "error",
284
+ "unicorn/number-literal-case": [
285
+ "error",
286
+ { hexadecimalValue: "lowercase" },
287
+ ],
288
+ "unicorn/numeric-separators-style": "off",
289
+ "unicorn/prefer-add-event-listener": "error",
290
+ "unicorn/prefer-array-find": "error",
291
+ "unicorn/prefer-array-flat": "error",
292
+ "unicorn/prefer-array-flat-map": "error",
293
+ "unicorn/prefer-array-index-of": "error",
294
+ "unicorn/prefer-array-some": "error",
295
+ "unicorn/prefer-at": "error",
296
+ "unicorn/prefer-bigint-literals": "off",
297
+ "unicorn/prefer-blob-reading-methods": "error",
298
+ "unicorn/prefer-class-fields": "error",
299
+ "unicorn/prefer-classlist-toggle": "error",
300
+ "unicorn/prefer-code-point": "error",
301
+ "unicorn/prefer-date-now": "error",
302
+ "unicorn/prefer-default-parameters": "error",
303
+ "unicorn/prefer-dom-node-append": "error",
304
+ "unicorn/prefer-dom-node-dataset": "error",
305
+ "unicorn/prefer-dom-node-remove": "error",
306
+ "unicorn/prefer-dom-node-text-content": "error",
307
+ "unicorn/prefer-event-target": "error",
308
+ "unicorn/prefer-export-from": "error",
309
+ "unicorn/prefer-global-this": "off",
310
+ "unicorn/prefer-import-meta-properties": "error",
311
+ "unicorn/prefer-includes": "error",
312
+ "unicorn/prefer-keyboard-event-key": "error",
313
+ "unicorn/prefer-logical-operator-over-ternary": "off",
314
+ "unicorn/prefer-math-min-max": "error",
315
+ "unicorn/prefer-math-trunc": "error",
316
+ "unicorn/prefer-modern-dom-apis": "error",
317
+ "unicorn/prefer-modern-math-apis": "error",
318
+ "unicorn/prefer-module": "off",
319
+ "unicorn/prefer-native-coercion-functions": "off",
320
+ "unicorn/prefer-negative-index": "error",
321
+ "unicorn/prefer-number-properties": "error",
322
+ "unicorn/prefer-object-from-entries": "error",
323
+ "unicorn/prefer-optional-catch-binding": "off", // covered by sonarjs/no-ignored-exceptions
324
+ "unicorn/prefer-prototype-methods": "error",
325
+ "unicorn/prefer-query-selector": "error",
326
+ "unicorn/prefer-reflect-apply": "error",
327
+ "unicorn/prefer-regexp-test": "error",
328
+ "unicorn/prefer-response-static-json": "off",
329
+ "unicorn/prefer-set-has": "error",
330
+ "unicorn/prefer-set-size": "error",
331
+ "unicorn/prefer-single-call": "off",
332
+ "unicorn/prefer-spread": "off", // for now
333
+ "unicorn/prefer-string-raw": "off", // for now
334
+ "unicorn/prefer-string-replace-all": "error",
335
+ "unicorn/prefer-string-slice": "error",
336
+ "unicorn/prefer-string-starts-ends-with": "error",
337
+ "unicorn/prefer-string-trim-start-end": "error",
338
+ "unicorn/prefer-structured-clone": "off", // we use `deepClone` from `@fkui/logic` and structuredClone does not play well with jest
339
+ "unicorn/prefer-switch": "error",
340
+ "unicorn/prefer-ternary": "off",
341
+ "unicorn/prefer-top-level-await": "error",
342
+ "unicorn/prefer-type-error": "error",
343
+ "unicorn/prevent-abbreviations": "off",
344
+ "unicorn/relative-url-style": "error",
345
+ "unicorn/require-array-join-separator": "error",
346
+ "unicorn/require-module-attributes": "off",
347
+ "unicorn/require-module-specifiers": "off",
348
+ "unicorn/require-number-to-fixed-digits-argument": "error",
349
+ "unicorn/switch-case-braces": "off",
350
+ "unicorn/text-encoding-identifier-case": "error",
351
+ "unicorn/throw-new-error": "error",
352
+ ...filterRules(prettierConfig.rules, (rule) => {
353
+ return rule.startsWith("unicorn/");
354
+ }),
355
+
201
356
  /* Lower some errors to warnings, these are allowed on local builds (to
202
357
  * not prevent builds during development where code is unfinished and
203
358
  * might contain debugging code) but is disallowed when building from
@@ -280,7 +435,7 @@ export default [
280
435
  defineConfig({
281
436
  name: "@forsakringskassan/eslint-config/ecma-version",
282
437
  languageOptions: {
283
- ecmaVersion: 2024,
438
+ ecmaVersion: 2025,
284
439
  sourceType: "module",
285
440
  },
286
441
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/eslint-config",
3
- "version": "13.4.2",
3
+ "version": "13.5.2",
4
4
  "description": "Försäkringskassans eslint shareable config",
5
5
  "keywords": [
6
6
  "eslint"
@@ -33,6 +33,7 @@
33
33
  "eslint-plugin-import": "2.32.0",
34
34
  "eslint-plugin-prettier": "5.5.5",
35
35
  "eslint-plugin-sonarjs": "4.0.0",
36
+ "eslint-plugin-unicorn": "63.0.0",
36
37
  "globals": "17.4.0"
37
38
  },
38
39
  "peerDependencies": {
@@ -41,5 +42,5 @@
41
42
  "engines": {
42
43
  "node": ">= 22.0"
43
44
  },
44
- "gitHead": "15eb7b2e84dcfd244f7cc524ded30d06c646efb0"
45
+ "gitHead": "7ce1ef387cfda0a8a275020b2058d891b39463ae"
45
46
  }