diff --git a/.cspell.json b/.cspell.json index 21ce90c..b72a2df 100644 --- a/.cspell.json +++ b/.cspell.json @@ -1,8 +1,6 @@ { - "useGitignore": true, - "version": "0.2", - "language": "en", - "words": [ - - ] - } \ No newline at end of file + "useGitignore": true, + "version": "0.2", + "language": "en", + "words": [] +} diff --git a/.eslintrc b/.eslintrc index 7cb07a2..55345d7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,14 +4,39 @@ "parserOptions": { "project": ["./tsconfig.json"] }, - "plugins": ["@typescript-eslint"], - "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], + "plugins": ["@typescript-eslint", "sonarjs"], + "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:sonarjs/recommended"], "ignorePatterns": ["**/*.js"], "rules": { - "prefer-arrow-callback": ["warn", { "allowNamedFunctions": true }], // Disallow arrow functions as expressions - "func-style": ["warn", "declaration", { "allowArrowFunctions": false }], // Disallow the use of function expressions + "prefer-arrow-callback": ["warn", { "allowNamedFunctions": true }], + "func-style": ["warn", "declaration", { "allowArrowFunctions": false }], "@typescript-eslint/no-floating-promises": "error", "@typescript-eslint/no-non-null-assertion": "error", + "constructor-super": "error", + "no-invalid-this": "off", + "@typescript-eslint/no-invalid-this": ["error"], + "no-restricted-syntax": ["error", "ForInStatement"], + "use-isnan": "error", + "@typescript-eslint/no-unused-vars": [ + "error", + { + "args": "after-used", + "ignoreRestSiblings": true, + "vars": "all", + "varsIgnorePattern": "^_", + "argsIgnorePattern": "^_" + } + ], + "@typescript-eslint/await-thenable": "error", + "@typescript-eslint/no-misused-new": "error", + "@typescript-eslint/restrict-plus-operands": "error", + "@typescript-eslint/no-unnecessary-condition": ["error", { "allowConstantLoopConditions": true }], + "sonarjs/no-all-duplicated-branches": "error", + "sonarjs/no-collection-size-mischeck": "error", + "sonarjs/no-duplicated-branches": "error", + "sonarjs/no-element-overwrite": "error", + "sonarjs/no-identical-conditions": "error", + "sonarjs/no-identical-expressions": "error", "@typescript-eslint/naming-convention": [ "error", { "selector": "typeLike", "format": ["PascalCase"] }, diff --git a/.github/workflows/cspell.yml b/.github/workflows/cspell.yml index 71f4624..d15c4a5 100644 --- a/.github/workflows/cspell.yml +++ b/.github/workflows/cspell.yml @@ -9,16 +9,16 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20.10.0' + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20.10.0" - - name: Install cspell - run: yarn add cspell + - name: Install cspell + run: yarn add cspell - - name: Run cspell - run: cspell "src/**/*.{ts,json}" + - name: Run cspell + run: cspell "src/**/*.{ts,json}" diff --git a/package.json b/package.json index 4475c3c..c435c97 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "eslint": "^8.54.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-sonarjs": "^0.23.0", "husky": "^8.0.3", "knip": "^3.3.0", "lint-staged": "^15.1.0", diff --git a/yarn.lock b/yarn.lock index 8d62a3f..e672332 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2185,6 +2185,15 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-sonarjs@npm:^0.23.0": + version: 0.23.0 + resolution: "eslint-plugin-sonarjs@npm:0.23.0" + peerDependencies: + eslint: ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 + checksum: 4f56557740ab438eee8d98e4d93363a8dadcf8d6d795a5d95e6a0b0d6335273a06c5633fe753271c6a56c14a3b0086014b8278984b5594fad5db274ec7fd7edf + languageName: node + linkType: hard + "eslint-scope@npm:^7.2.2": version: 7.2.2 resolution: "eslint-scope@npm:7.2.2" @@ -5393,6 +5402,7 @@ __metadata: eslint: ^8.54.0 eslint-config-prettier: ^9.0.0 eslint-plugin-prettier: ^5.0.1 + eslint-plugin-sonarjs: ^0.23.0 husky: ^8.0.3 knip: ^3.3.0 lint-staged: ^15.1.0