Can we define rules to SonarLint

I want to add custom validation rules to SonarLint JS in the Visual Studio Code plugin is this possible?

Hi Omar,

Adding custom rules in SonarLint is not supported for the JS language. If you can think of interesting rules that are missing in SonarLint, please suggest, and we could possibly add them.

1 Like

hi,julien, i wonder if it is still not support for js yet ? since i cannot see which year of this question.

Hi @11136,

Still no support for custom rules for JS. Instead, don’t hesitate to suggest your rule ideas.

thanks for reply,but i saw this issues, if i could custom js rule in sonarqube not the vscode ?

if this not support just in vscode plugin? i can still custom rule by this two step ?
1.eslint -f json -o report.json
2.sonar.eslint.reportPaths", "eslint-report.json


What you are talking about is not what we call “custom rules”. Custom rules are extending SonarSource analyzers (reusing the same parsing/AST) to produce new issues. It requires the SonarSource analyzer to expose an API.

In addition to custom rules, SonarQube offers a way to import external issues that have been detected by other tools (like ESLint in your example) as a convenient way to browse all issues in the same UI.
In VSCode (and IDE in general) this doesn’t apply because SonarLint can not “orchestrate” the execution on the third party analyzer anyway.

If you have custom ESLint rules, why not simply using the VSCode ESLint extension?

Thanks for reply, Our team is using sonar to detect external developer’s code commit push ,since we have our own business limit, we want to custom some rules in sonar platform,so that we can find out some error code write. what could we definite custom rule in sonar ?

I suggest you start a new thread, after reading the existing documentation:

A post was split to a new topic: Where to find imported ESLint issues in SonarQube