Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is SonarJs has a rule like eslint's no-undef? #621

Closed
shikelong opened this issue Jul 20, 2017 · 5 comments
Closed

Is SonarJs has a rule like eslint's no-undef? #621

shikelong opened this issue Jul 20, 2017 · 5 comments

Comments

@shikelong
Copy link

http://eslint.org/docs/rules/no-undef

Regards.

@shikelong
Copy link
Author

Variables should be declared before they are used seem can't find this issue:

someFunctionNotDefined();
var a = 'asd';

export {
 b
}

@shikelong
Copy link
Author

Non-existent variables should not be referenced can't find the issue

var a = 'asd'

export {
  b
}

@inverno
Copy link
Contributor

inverno commented Jul 20, 2017

@shikelong those rules are targeting different cases, you are probably looking for "Variables should be declared explicitly", see : https://sonarcloud.io/organizations/inverno-github/rules#rule_key=javascript%3AS2703

@shikelong
Copy link
Author

The rule "Variables should be declared explicitly" has been activate in my Quality Profile.
But It seem no work when I export a un declared variable

@inverno
Copy link
Contributor

inverno commented Jul 20, 2017

I thought you were targeting implicit declarations, not just general uses of non-existent variables. "Non-existent variables should not be referenced" should be catching that, and it does, just not for export statements.
So, the answer to your question is that "Non-existent variables..." is what you need, but it doesn't seem to be working for your specific example with exports. I'll create a new issue with label bug and reference this one from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants