From b81b9ce00d4258edff0f61f8d8fc549466010426 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 11 May 2025 16:23:50 +0200 Subject: [PATCH] Add a couple of new `eslint-plugin-unicorn` rules The recent `eslint-plugin-unicorn` update added, and replaced, a few rules that seem useful for us; please refer to https://github.com/sindresorhus/eslint-plugin-unicorn/releases/tag/v59.0.0 Note that none of the following rules required any code-changes: - Replace `no-array-push-push` with `prefer-single-call`, see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-single-call.md - Add `no-unnecessary-slice-end`, see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unnecessary-slice-end.md - Add `no-unnecessary-array-flat-depth`, see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unnecessary-array-flat-depth.md - Add `no-unnecessary-array-splice-count`, see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unnecessary-array-splice-count.md --- eslint.config.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index fb107d324..277475fad 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -126,7 +126,6 @@ export default [ "perfectionist/sort-exports": "error", "perfectionist/sort-named-exports": "error", "unicorn/no-abusive-eslint-disable": "error", - "unicorn/no-array-push-push": "error", "unicorn/no-array-reduce": ["error", { allowSimpleOperations: true }], "unicorn/no-console-spaces": "error", "unicorn/no-instanceof-builtins": "error", @@ -134,6 +133,9 @@ export default [ "unicorn/no-new-buffer": "error", "unicorn/no-single-promise-in-promise-methods": "error", "unicorn/no-typeof-undefined": ["error", { checkGlobalVariables: false }], + "unicorn/no-unnecessary-array-flat-depth": "error", + "unicorn/no-unnecessary-array-splice-count": "error", + "unicorn/no-unnecessary-slice-end": "error", "unicorn/no-useless-promise-resolve-reject": "error", "unicorn/no-useless-spread": "error", "unicorn/prefer-array-find": "error", @@ -153,6 +155,7 @@ export default [ "unicorn/prefer-negative-index": "error", "unicorn/prefer-optional-catch-binding": "error", "unicorn/prefer-regexp-test": "error", + "unicorn/prefer-single-call": "error", "unicorn/prefer-string-replace-all": "error", "unicorn/prefer-string-starts-ends-with": "error", "unicorn/prefer-ternary": ["error", "only-single-line"],