@forsakringskassan/eslint-config 13.4.2 → 13.5.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.
Files changed (3) hide show
  1. package/eslint.js +2 -2
  2. package/index.mjs +149 -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,152 @@ 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
+ { case: "kebabCase", ignore: ["^Gruntfile.js$"] },
223
+ ], // enforce kebab-case in filenames
224
+ "unicorn/import-style": "off", // off for now
225
+ "unicorn/isolated-functions": "error",
226
+ "unicorn/new-for-builtins": "error",
227
+ "unicorn/no-abusive-eslint-disable": "off", // covered by eslint-plugin-eslint-comments
228
+ "unicorn/no-accessor-recursion": "error",
229
+ "unicorn/no-anonymous-default-export": "off", // often used with configuration packages
230
+ "unicorn/no-array-callback-reference": "off", // opinionated, prefer to allow passing function references to array methods (and for most part typescript will handle this)
231
+ "unicorn/no-array-for-each": "error",
232
+ "unicorn/no-array-method-this-argument": "error",
233
+ "unicorn/no-array-reduce": "off", // allow usage of reduce()
234
+ "unicorn/no-array-reverse": "error", // prefer immutable .toReversed() (available in Node.js 20+)
235
+ "unicorn/no-array-sort": "error", // prefer immutable .toSorted() (available in Node.js 20+)
236
+ "unicorn/no-await-expression-member": "error",
237
+ "unicorn/no-await-in-promise-methods": "error",
238
+ "unicorn/no-console-spaces": "error",
239
+ "unicorn/no-document-cookie": "error",
240
+ "unicorn/no-empty-file": "off",
241
+ "unicorn/no-for-loop": "error",
242
+ "unicorn/no-hex-escape": "error",
243
+ "unicorn/no-immediate-mutation": "off",
244
+ "unicorn/no-instanceof-builtins": "error",
245
+ "unicorn/no-invalid-fetch-options": "off", // let typescript and tests handle this
246
+ "unicorn/no-invalid-remove-event-listener": "error",
247
+ "unicorn/no-magic-array-flat-depth": "error",
248
+ "unicorn/no-named-default": "off", // named default is useful for vue
249
+ "unicorn/no-negated-condition": "off", // mostly agree with the rule but sometimes its useful to have the common case first even if negated
250
+ "unicorn/no-negation-in-equality-check": "off",
251
+ "unicorn/no-new-array": "error",
252
+ "unicorn/no-new-buffer": "error",
253
+ "unicorn/no-null": "off", // prefer using null over undefined
254
+ "unicorn/no-object-as-default-parameter": "error",
255
+ "unicorn/no-process-exit": "off", // covered by n/no-process-exit (enabled by recommended-module preset)
256
+ "unicorn/no-single-promise-in-promise-methods": "error",
257
+ "unicorn/no-static-only-class": "off",
258
+ "unicorn/no-thenable": "off",
259
+ "unicorn/no-this-assignment": "error",
260
+ "unicorn/no-typeof-undefined": "error",
261
+ "unicorn/no-unnecessary-array-flat-depth": "error",
262
+ "unicorn/no-unnecessary-array-splice-count": "error",
263
+ "unicorn/no-unnecessary-await": "error",
264
+ "unicorn/no-unnecessary-polyfills": "off",
265
+ "unicorn/no-unnecessary-slice-end": "error",
266
+ "unicorn/no-unreadable-array-destructuring": "off",
267
+ "unicorn/no-unreadable-iife": "off",
268
+ "unicorn/no-useless-collection-argument": "error",
269
+ "unicorn/no-useless-error-capture-stack-trace": "error",
270
+ "unicorn/no-useless-fallback-in-spread": "error",
271
+ "unicorn/no-useless-length-check": "error",
272
+ "unicorn/no-useless-promise-resolve-reject": "error",
273
+ "unicorn/no-useless-spread": "error",
274
+ "unicorn/no-useless-switch-case": "off",
275
+ "unicorn/no-useless-undefined": "off", // opinionated, I prefer to explicitly pass undefined
276
+ "unicorn/no-zero-fractions": "error",
277
+ "unicorn/number-literal-case": [
278
+ "error",
279
+ { hexadecimalValue: "lowercase" },
280
+ ],
281
+ "unicorn/numeric-separators-style": "off",
282
+ "unicorn/prefer-add-event-listener": "error",
283
+ "unicorn/prefer-array-find": "error",
284
+ "unicorn/prefer-array-flat": "error",
285
+ "unicorn/prefer-array-flat-map": "error",
286
+ "unicorn/prefer-array-index-of": "error",
287
+ "unicorn/prefer-array-some": "error",
288
+ "unicorn/prefer-at": "error",
289
+ "unicorn/prefer-bigint-literals": "off",
290
+ "unicorn/prefer-blob-reading-methods": "error",
291
+ "unicorn/prefer-class-fields": "error",
292
+ "unicorn/prefer-classlist-toggle": "error",
293
+ "unicorn/prefer-code-point": "error",
294
+ "unicorn/prefer-date-now": "error",
295
+ "unicorn/prefer-default-parameters": "error",
296
+ "unicorn/prefer-dom-node-append": "error",
297
+ "unicorn/prefer-dom-node-dataset": "error",
298
+ "unicorn/prefer-dom-node-remove": "error",
299
+ "unicorn/prefer-dom-node-text-content": "error",
300
+ "unicorn/prefer-event-target": "error",
301
+ "unicorn/prefer-export-from": "error",
302
+ "unicorn/prefer-global-this": "off",
303
+ "unicorn/prefer-import-meta-properties": "error",
304
+ "unicorn/prefer-includes": "error",
305
+ "unicorn/prefer-keyboard-event-key": "error",
306
+ "unicorn/prefer-logical-operator-over-ternary": "off",
307
+ "unicorn/prefer-math-min-max": "error",
308
+ "unicorn/prefer-math-trunc": "error",
309
+ "unicorn/prefer-modern-dom-apis": "error",
310
+ "unicorn/prefer-modern-math-apis": "error",
311
+ "unicorn/prefer-module": "off",
312
+ "unicorn/prefer-native-coercion-functions": "off",
313
+ "unicorn/prefer-negative-index": "error",
314
+ "unicorn/prefer-number-properties": "error",
315
+ "unicorn/prefer-object-from-entries": "error",
316
+ "unicorn/prefer-optional-catch-binding": "off", // covered by sonarjs/no-ignored-exceptions
317
+ "unicorn/prefer-prototype-methods": "error",
318
+ "unicorn/prefer-query-selector": "error",
319
+ "unicorn/prefer-reflect-apply": "error",
320
+ "unicorn/prefer-regexp-test": "error",
321
+ "unicorn/prefer-response-static-json": "off",
322
+ "unicorn/prefer-set-has": "error",
323
+ "unicorn/prefer-set-size": "error",
324
+ "unicorn/prefer-single-call": "off",
325
+ "unicorn/prefer-spread": "off", // for now
326
+ "unicorn/prefer-string-raw": "off", // for now
327
+ "unicorn/prefer-string-replace-all": "error",
328
+ "unicorn/prefer-string-slice": "error",
329
+ "unicorn/prefer-string-starts-ends-with": "error",
330
+ "unicorn/prefer-string-trim-start-end": "error",
331
+ "unicorn/prefer-structured-clone": "off", // we use `deepClone` from `@fkui/logic` and structuredClone does not play well with jest
332
+ "unicorn/prefer-switch": "error",
333
+ "unicorn/prefer-ternary": "off",
334
+ "unicorn/prefer-top-level-await": "error",
335
+ "unicorn/prefer-type-error": "error",
336
+ "unicorn/prevent-abbreviations": "off",
337
+ "unicorn/relative-url-style": "error",
338
+ "unicorn/require-array-join-separator": "error",
339
+ "unicorn/require-module-attributes": "off",
340
+ "unicorn/require-module-specifiers": "off",
341
+ "unicorn/require-number-to-fixed-digits-argument": "error",
342
+ "unicorn/switch-case-braces": "off",
343
+ "unicorn/text-encoding-identifier-case": "error",
344
+ "unicorn/throw-new-error": "error",
345
+ ...filterRules(prettierConfig.rules, (rule) => {
346
+ return rule.startsWith("unicorn/");
347
+ }),
348
+
201
349
  /* Lower some errors to warnings, these are allowed on local builds (to
202
350
  * not prevent builds during development where code is unfinished and
203
351
  * might contain debugging code) but is disallowed when building from
@@ -280,7 +428,7 @@ export default [
280
428
  defineConfig({
281
429
  name: "@forsakringskassan/eslint-config/ecma-version",
282
430
  languageOptions: {
283
- ecmaVersion: 2024,
431
+ ecmaVersion: 2025,
284
432
  sourceType: "module",
285
433
  },
286
434
  }),
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.0",
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": "b07a58cfff4cd3500908fc166180092e63670d63"
45
46
  }