Mohammad Asif cf937194cb Removed un-waned things 1. | vor 5 Monaten | |
---|---|---|
.. | ||
lib | vor 5 Monaten | |
node_modules | vor 5 Monaten | |
.eslintignore | vor 5 Monaten | |
LICENSE | vor 5 Monaten | |
README.md | vor 5 Monaten | |
package.json | vor 5 Monaten |
SonarJS rules for ESLint to detect bugs and suspicious patterns in your code.
Rules in this category aim to find places in code which have a high chance of being bugs, i.e. don't work as intended.
no-all-duplicated-branches
)no-element-overwrite
)no-empty-collection
)no-extra-arguments
)no-identical-conditions
)no-identical-expressions
)no-ignored-return
) (uses-types)no-one-iteration-loop
)no-use-of-empty-return-value
)non-existent-operator
) (:wrench: fixable)Code Smells, or maintainability issues, are raised for places of code which might be costly to change in the future. These rules also help to keep the high code quality and readability. And finally some rules report issues on different suspicious code patters.
cognitive-complexity
)elseif-without-else
) (disabled)max-switch-cases
)no-collapsible-if
)no-collection-size-mischeck
) (:wrench: fixable, uses-types)no-duplicate-string
)no-duplicated-branches
)no-gratuitous-expressions
)no-identical-functions
)no-inverted-boolean-check
) (:wrench: fixable, disabled)no-nested-switch
)no-nested-template-literals
)no-redundant-boolean
)no-redundant-jump
) (:wrench: fixable)no-same-line-conditional
) (:wrench: fixable)no-small-switch
)no-unused-collection
)no-useless-catch
)prefer-immediate-return
) (:wrench: fixable)prefer-object-literal
)prefer-single-boolean-return
) (:wrench: fixable)prefer-while
) (:wrench: fixable)eslint-plugin-sonarjs
using npm
(or yarn
) for you project or globally:npm install eslint-plugin-sonarjs --save-dev # install for your project
npm install eslint-plugin-sonarjs -g # or install globally
eslint-plugin-sonarjs
to the plugins
option of your .eslintrc
:{
"plugins": ["sonarjs"]
}
plugin:sonarjs/recommended
to the extends
option to enable all recommended rules:{
"extends": ["plugin:sonarjs/recommended"]
}
{
"rules": {
"sonarjs/cognitive-complexity": "error",
"sonarjs/no-identical-expressions": "error"
// etc.
}
}
@typescript-eslint/parser
as a parser for ESLint (like we do) and set the parserOptions.project option. Thanks to it, type information is available, which is beneficial or even essential for some rules.This plugin provides only recommended
configuration. Almost all rules are activated in this profile with a few exceptions (check disabled
tag in the rules list). recommended
configuration activates rules with error
severity.
This plugin exposes to ESLint users a subset of JS/TS rules from Sonar-* products (aka SonarJS). We extracted the rules which are not available in ESLint core or other ESLint plugins to be beneficial for ESLint community.
If you are a SonarQube or SonarCloud user, to lint your code locally, we suggest to use SonarLint IDE extension (available for VSCode, JetBrains IDEs and Eclipse). You can connect SonarLint to your SonarQube/SonarCloud project to synchronize rules configuration, issue statuses, etc.
You want to participate in the development of the project? Have a look at our contributing guide!