diff --git a/eslint.config.mjs b/eslint.config.mjs index af7b39e..ebe3843 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -3,6 +3,9 @@ import eslint from "@eslint/js"; import tseslint from "typescript-eslint"; import html from "@html-eslint/eslint-plugin"; +import unicorn from "eslint-plugin-unicorn"; +import sonarjs from "eslint-plugin-sonarjs"; +import stylistic from "@stylistic/eslint-plugin"; export default tseslint.config( eslint.configs.recommended, @@ -17,6 +20,11 @@ export default tseslint.config( }, files: ["**/*.ts", "**/*.html"], ignores: ["dist/**/*", "node_modules/**/*"], + plugins: { + unicorn, + sonarjs, + "@stylistic": stylistic, + }, rules: { "array-callback-return": 2, "block-scoped-var": 2, @@ -179,6 +187,86 @@ export default tseslint.config( "@stylistic/space-in-parens": 2, "@stylistic/space-unary-ops": 2, "@stylistic/yield-star-spacing": 2, + "unicorn/error-message": 2, + "unicorn/new-for-builtins": 2, + "unicorn/consistent-empty-array-spread": 2, + "unicorn/consistent-destructuring": 2, + "unicorn/consistent-function-scoping": 2, + "unicorn/no-array-method-this-argument": 2, + "unicorn/no-lonely-if": 1, + "unicorn/no-invalid-fetch-options": 2, + "unicorn/no-instanceof-array": 2, + "unicorn/no-magic-array-flat-depth": 2, + "unicorn/no-nested-ternary": 2, + "unicorn/no-new-buffer": 2, + "unicorn/no-console-spaces": 2, + "unicorn/no-for-loop": 2, + "unicorn/no-useless-undefined": 2, + "unicorn/no-unreadable-iife": 2, + "unicorn/no-unnecessary-await": 2, + "unicorn/no-unreadable-array-destructuring": 2, + "unicorn/no-useless-switch-case": 2, + "unicorn/no-typeof-undefined": 2, + "unicorn/no-useless-fallback-in-spread": 2, + "unicorn/no-useless-length-check": 2, + "unicorn/no-useless-spread": 2, + "unicorn/no-useless-promise-resolve-reject": 2, + "unicorn/no-zero-fractions": 2, + "unicorn/prefer-array-find": 1, + "unicorn/prefer-array-index-of": 1, + "unicorn/prefer-includes": 1, + "unicorn/prefer-logical-operator-over-ternary": 1, + "unicorn/prefer-date-now": 1, + "unicorn/prefer-default-parameters": 1, + "unicorn/prefer-array-some": 1, + "unicorn/prefer-blob-reading-methods": 1, + "unicorn/prefer-at": 1, + "unicorn/prefer-optional-catch-binding": 1, + "unicorn/prefer-regexp-test": 1, + "unicorn/prefer-set-has": 1, + "unicorn/prefer-set-size": 1, + "unicorn/prefer-keyboard-event-key": 1, + "unicorn/prefer-negative-index": 1, + "unicorn/prefer-node-protocol": 1, + "unicorn/prefer-number-properties": [ + 1, + { + checkInfinity: true, + }, + ], + "unicorn/prefer-prototype-methods": 1, + "unicorn/prefer-string-trim-start-end": 1, + "unicorn/prefer-string-starts-ends-with": 1, + "unicorn/prefer-structured-clone": 1, + "unicorn/throw-new-error": 2, + "unicorn/require-number-to-fixed-digits-argument": 2, + "unicorn/switch-case-braces": [1, "avoid"], + "unicorn/text-encoding-identifier-case": 2, + "unicorn/no-await-in-promise-methods": 2, + "unicorn/no-single-promise-in-promise-methods": 2, + "unicorn/no-negation-in-equality-check": 2, + "unicorn/no-length-as-slice-end": 2, + + "sonarjs/no-extra-arguments": 2, + "sonarjs/no-empty-collection": 2, + "sonarjs/no-element-overwrite": 2, + "sonarjs/no-use-of-empty-return-value": 2, + "sonarjs/no-all-duplicated-branches": 2, + "sonarjs/no-ignored-return": 2, + "sonarjs/no-identical-expressions": 2, + "sonarjs/no-one-iteration-loop": 2, + "sonarjs/non-existent-operator": 2, + "sonarjs/no-redundant-boolean": 2, + "sonarjs/no-unused-collection": 1, + "sonarjs/prefer-immediate-return": 2, + "sonarjs/no-inverted-boolean-check": 2, + "sonarjs/no-redundant-jump": 2, + "sonarjs/no-same-line-conditional": 2, + "sonarjs/prefer-object-literal": 2, + "sonarjs/no-collection-size-mischeck": 2, + "sonarjs/prefer-while": 2, + "sonarjs/no-gratuitous-expressions": 2, + "sonarjs/no-duplicated-branches": 2, }, } ); diff --git a/package.json b/package.json index 21e97f9..8090fe8 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,9 @@ "@html-eslint/eslint-plugin": "^0.25.0", "@types/compression": "^1.7.5", "@types/eslint__js": "^8.42.3", + "eslint-plugin-sonarjs": "^1.0.4", + "eslint-plugin-unicorn": "^55.0.0", + "@stylistic/eslint-plugin": "^2.3.0", "@types/express": "^4.17.21", "@types/node-fetch": "^2.6.11", "eslint": "^8.57.1", @@ -32,4 +35,4 @@ "typescript": "^5.6.2", "typescript-eslint": "^7.18.0" } -} +} \ No newline at end of file