Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,39 @@ module.exports = {
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
// SonarJS recommended rules (same set as sonarjs.configs.recommended),
// explicit for legacy config (ESLint 9 defaults to flat config)
'sonarjs/cognitive-complexity': 'error',
'sonarjs/elseif-without-else': 'error',
'sonarjs/max-switch-cases': 'error',
'sonarjs/no-all-duplicated-branches': 'error',
'sonarjs/no-collapsible-if': 'error',
'sonarjs/no-collection-size-mischeck': 'error',
'sonarjs/no-duplicate-string': 'error',
'sonarjs/no-duplicated-branches': 'error',
'sonarjs/no-element-overwrite': 'error',
'sonarjs/no-empty-collection': 'error',
'sonarjs/no-extra-arguments': 'error',
'sonarjs/no-gratuitous-expressions': 'error',
'sonarjs/no-identical-conditions': 'error',
'sonarjs/no-identical-expressions': 'error',
'sonarjs/no-identical-functions': 'error',
'sonarjs/no-ignored-return': 'error',
'sonarjs/no-inverted-boolean-check': 'error',
'sonarjs/no-nested-functions': 'error',
'sonarjs/no-nested-switch': 'error',
'sonarjs/no-nested-template-literals': 'error',
'sonarjs/no-redundant-boolean': 'error',
'sonarjs/no-redundant-jump': 'error',
'sonarjs/no-same-line-conditional': 'error',
'sonarjs/no-small-switch': 'error',
'sonarjs/no-unused-collection': 'error',
'sonarjs/no-use-of-empty-return-value': 'error',
'sonarjs/no-useless-catch': 'error',
'sonarjs/non-existent-operator': 'error',
'sonarjs/prefer-immediate-return': 'error',
'sonarjs/prefer-object-literal': 'error',
'sonarjs/prefer-single-boolean-return': 'error',
'sonarjs/prefer-while': 'error',
},
};
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ npm i
## Linting
This project is using StyleLint and ESLint (including the SonarJS plugin for ESLint 8).

Add "eslint.useFlatConfig": false to your workspace .vscode/settings.json.
With ESLint 9, the VS Code/Cursor ESLint extension defaults to flat config (eslint.config.js). This project still uses legacy config (.eslintrc.js), so setting eslint.useFlatConfig to false makes the extension use legacy config and the .eslintrc.js.

upgrade to sonarjs 3:
npm install eslint-plugin-sonarjs@^3.0.0 --legacy-peer-deps 2>&1
npm install globals --legacy-peer-deps --save-dev 2>&1
npm install ts-api-utils --legacy-peer-deps --save-dev 2>&1
npm install --legacy-peer-deps 2>&1
npm install @babel/core --legacy-peer-deps --save-dev 2>&1


```sh
npm run lint
```
Expand Down
Loading
Loading