SonarCommunity/sonar-javascript — pull request #10 by david-owens-akqa (2013-08-13 09:48:56+00:00)
Title: JSLint and JSHint directives should not be flagged as commented out code

The current version of the sonar-javascript plugin flags JSLint and JSHint directives as commented out code in some instances.

This pull request addresses these false positive in the same way that JSDoc comment blocks are currently handled.

I have updated the unit tests to cover these new checks. The directives I have included in the test are taken from our developer guidelines and match the base ruleset that we use in production.

Background

It may be desirable to include a JSLint or JSHint directive at the top of a JavaScript file.

http://www.jslint.com/lint.html#options
http://www.jshint.com/docs/config/

These allow an IDE to provide feedback during development and increase code portability.

The directives look like JavaScript code, especially when they contain keywords, and trigger the "Sections of code should not be "commented out" rule.