diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..8dada3e --- /dev/null +++ b/LICENCE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 6896b5c..b8200a2 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -Sonar plugin for JS/CSS/HTML/SASS/AngularJS -=========================================== +Sonar plugin for JS/CSS/HTML/SASS/AngularJS/TypeScript +====================================================== # Introduction -Plugin for Sonarqube for the Web world with various technologies and languages (JavaScript, CSS, SASS, HTML, AngularJS...). +Sonarqube plugin for the Web world with various technologies and languages (JavaScript, CSS, SASS, HTML, AngularJS, TypeScript...). This plugin consumes reports generated by tools that are heavily used by the Web community: - Linters: @@ -11,17 +11,16 @@ This plugin consumes reports generated by tools that are heavily used by the Web - [CSS Lint](http://csslint.net/) - [SCSS Lint](https://github.com/brigade/scss-lint) - [HTMLHint](http://htmlhint.com/) - - [Angular Hint](https://github.com/angular/angular-hint) + - [ESLint](http://eslint.org/) - [ESLint plugin for AngularJS](https://github.com/Gillespie59/eslint-plugin-angular) -- Unit testing + - [TSLint](https://palantir.github.io/tslint/) +- Test results (unit tests and integration tests for JavaScript and TypeScript) - [Jasmine](http://jasmine.github.io/) - Code coverage: - [Istanbul](https://gotwarlost.github.io/istanbul/) - Code duplication - [Simian](http://www.harukizaemon.com/simian/) - [CPD](http://pmd.sourceforge.net/pmd-5.1.2/cpd-usage.html) -- Code complexity - - [Plato](https://github.com/es-analysis/plato) The reports are either directly produced by the tools or by our [gulp tasks](https://github.com/groupe-sii/front-end-continuous-integration). @@ -30,14 +29,14 @@ The reports are either directly produced by the tools or by our [gulp tasks](htt ## Build your Web project -When developping Web applications, you can use gulp to build, run tests, minimify and package your project. Some tasks will already generate reports like Istanbul that generates a LCOV file. +When developing Web applications, you can use gulp to build, run tests, minify and package your project. Some tasks will already generate reports like Istanbul that generates a LCOV file. You can also add additional tasks to run linters and produce reports. Theses tasks are already available [here](https://github.com/groupe-sii/front-end-continuous-integration). -## Configure sonar +## Configure your project for Sonar -In order to let Sonar analyze your project, you have to provide some configuration. You can define a file named sonar.properties at the root of your project with the following information: +In order to let Sonar analyze your project, you have to provide some configuration. You can define a file named sonar-project.properties at the root of your project with the following information: -``` +```ini # Required metadata sonar.projectKey= sonar.projectName= @@ -56,7 +55,7 @@ sonar.sourceEncoding=UTF-8 Example: -``` +```ini # Required metadata sonar.projectKey=my-project sonar.projectName=My Project Name @@ -75,10 +74,17 @@ sonar.sourceEncoding=UTF-8 ## Install the plugin -### Generate from sources +### Grab the plugin + +#### Download the JAR + +You can download the v2.1.0 release for Sonar 4.5.x directly [on Sonatype](https://oss.sonatype.org/content/groups/public/fr/sii/sonar/sonar-web-frontend-plugin/2.1.0/sonar-web-frontend-plugin-2.1.0.jar). + + +#### Generate from sources To build from source, you need to ensure that: -- Java JDK is installed (be sure to use JDK and not JRE) +- Java JDK 7+ is installed (be sure to use JDK and not JRE) - [Maven](https://maven.apache.org/download.cgi) is installed Clone this git repository. @@ -91,10 +97,10 @@ git checkout sonar-4.5.x Generate the plugin using [Maven](https://maven.apache.org/download.cgi): ``` -mvn clean install +mvn clean install -DskipTests ``` -This will generate a JAR file located at sonar-web-frontend-plugin/target/sonar-web-frontend-plugin-2.0-SNAPSHOT.jar. +This will generate a JAR file located at sonar-web-frontend-plugin/target/sonar-web-frontend-plugin-.jar. ### Install the plugin in Sonar @@ -110,7 +116,7 @@ The plugin provides many metrics specialized for Web and store them into Sonar. ## Code quality -The linters (JSHint, HTMLHint, CSSLint, SCSSLint) provide many information about code violations (issues) for every language or framework (JavaScript, CSS, HTML, SASS/Compass, AngularJS). These issues are integrated in Sonar and are usable in the different views of Sonar. We also provide a [dashboard widget for issues](#issueswidget). +The linters (JSHint, ESLint, HTMLHint, CSSLint, SCSSLint, TSLint) provide many information about code violations (issues) for every language or framework (JavaScript, CSS, HTML, SASS/Compass, AngularJS and TypeScript). These issues are integrated in Sonar and are usable in the different views of Sonar. We also provide a [dashboard widget for issues](#issueswidget). ## Test results @@ -122,19 +128,20 @@ If you use Istanbul in your project, it will automatically generate a LCOV file. ## Code duplication -If you use Simian or CPD in your project, it will automatically generate a report (simian.xml or cpd.xml) for code duplication. This file is consumed by the plugin and add this information into Sonar and is usable in different views of Sonar. We also provide a [dashboard widget for code duplications](#duplicationswidget). +If you use Simian or CPD in your project, it will generate a report for code duplication. This file is consumed by the plugin and adds this information into Sonar and is usable in different views of Sonar. We also provide a [dashboard widget for code duplications](#duplicationswidget). -## Code complexity - -TODO ## Widgets -The plugin provides two new widgets for multi-language projects. +The plugin provides two new widgets for multi-language projects. To add those widgets in Sonar, login as administrator and click on "Configure Widgets" button. A banner containing available widgets appears: + +![widgets](https://cloud.githubusercontent.com/assets/645363/14705599/a798d040-07ba-11e6-8d8c-83b1bc3d32b8.png) + +Just click on "Add widget" button on the widget you want on your dashboard. ### Issues -The widget separate issues counters by language instead of only one counter for all languages that is not revelant. You can have 5000 issues on HTML because you are using a particular framework that doesn't respect HTML norms but only have 1 issue for JavaScript. Without the plugin you will only see 5001 issues and your prject manager can tell you that you are a bad developper. But with this widget you can prove that your JavaScript code is really good ! +The widget separate issues counters by language instead of only one counter for all languages that is not revelant. You can have 5000 issues on HTML because you are using a particular framework that doesn't respect HTML norms but only have 1 issue for JavaScript. Without the plugin you will only see 5001 issues and your project manager can tell you that you are a bad developper. But with this widget you can prove that your JavaScript code is really good ! ![Issues](https://cloud.githubusercontent.com/assets/645363/8209254/57c3891c-150c-11e5-983e-955dbb69863e.png) @@ -153,43 +160,142 @@ Same as above, the widget separates the count of duplicated code by language. You can change the path to every generated report directly in your sonar.properties file by adding the following properties: -``` +```ini # issues reports with default paths -sonar.sii.quality.js.report.path=/report/jshint.json -sonar.sii.quality.css.report.path=/report/csslint.json -sonar.sii.quality.html.report.path=/report/htmlhint.json -sonar.sii.quality.scss.report.path=/report/scsslint.json -sonar.sii.quality.angular.report.path=/report/angular-hint.json -sonar.sii.quality.angular.eslint.report.path=/report/eslint-angular.json +sonar.sii.quality.js.report.path=/reports/sonar/jshint.json +sonar.sii.quality.js.eslint.report.path=/reports/sonar/eslint.json +sonar.sii.quality.css.report.path=/reports/sonar/csslint.json +sonar.sii.quality.html.report.path=/reports/sonar/htmlhint.json +sonar.sii.quality.scss.report.path=/reports/sonar/scsslint.json +sonar.sii.quality.angular.eslint.report.path=/reports/sonar/eslint-angular.json +sonar.sii.quality.ts.report.path=/reports/sonar/tslint.json + +# JavaScript/TypeScript unit test results with default paths +sonar.sii.test.ut.js.report.path=/reports/sonar/js-ut.xml +sonar.sii.test.it.js.report.path=/reports/sonar/js-it.xml +sonar.sii.test.ut.ts.report.path=/reports/sonar/ts-ut.xml +sonar.sii.test.it.ts.report.path=/reports/sonar/ts-it.xml + +# JavaScript/TypeScript code coverage with default paths +sonar.sii.coverage.ut.js.report.path=/reports/sonar/js-ut.lcov +sonar.sii.coverage.it.js.report.path=/reports/sonar/js-it.lcov +sonar.sii.coverage.overall.js.report.path=/reports/sonar/js-overall.lcov +sonar.sii.coverage.ut.ts.report.path=/reports/sonar/ts-ut.lcov +sonar.sii.coverage.it.ts.report.path=/reports/sonar/ts-it.lcov +sonar.sii.coverage.overall.ts.report.path=/reports/sonar/ts-overall.lcov -# unit test results with default paths -sonar.sii.test.unit.js.report.path=/report/jasmine.unit.xml -sonar.sii.test.it.js.report.path=/report/jasmine.it.xml +# code duplication with default paths +sonar.sii.duplication.js.report.path=/reports/sonar/js-duplication.xml +sonar.sii.duplication.css.report.path=/reports/sonar/css-duplication.xml +sonar.sii.duplication.html.report.path=/reports/sonar/html-duplication.xml +sonar.sii.duplication.scss.report.path=/reports/sonar/scss-duplication.xml +sonar.sii.duplication.ts.report.path=/reports/sonar/ts-duplication.xml +``` -# integration test results with default paths -sonar.sii.test.it.js.report.path=/report/jasmine.it.unit.xml +### Other options -# code coverage with default paths -sonar.sii.coverage.ut.js.report.path=/report/js-ut.lcov -sonar.sii.coverage.it.js.report.path=/report/js-it.lcov -sonar.sii.coverage.overall.js.report.path=/report/js-overall.lcov +#### Change extension of analyzed files -# code duplication with default paths -sonar.sii.duplication.js.report.path=/report/js-duplication.xml -sonar.sii.duplication.css.report.path=/report/css-duplication.xml -sonar.sii.duplication.html.report.path=/report/html-duplication.xml -sonar.sii.duplication.scss.report.path=/report/scss-duplication.xml +You can specify which files are analyzed for each language. You can change the values of the following properties in your sonar-project.properties: +```ini +# file suffixes with default values +sonar.sii.js.suffixes=.js +sonar.sii.html.suffixes=.html +sonar.sii.css.suffixes=.css +sonar.sii.scss.suffixes=.scss +sonar.sii.ts.suffixes=.ts ``` -### Other options -TODO +#### Do not warn if report is missing + +For indicating that reports are not found, the plugin logs a warning. This warning is useful when setting up your project to know if something is misconfigured. You can disable these logs using the following property in your sonar-project.properties: + +```ini +sonar.sii.logs.report.missing.skip=true +``` + +#### Do not fail if a source file is missing + +By default, in order to keep coherence, the analysis done by the plugin will fail if the generated report has an entry on a file that doesn't exist. Even if it is not recommended, you can disable the failure by using the one of the following properties in your sonar-project.properties: + +```ini +# set to false to disable missing source file while analyzing code quality +sonar.sii.quality.js.file.missing.fail=false +sonar.sii.quality.js.eslint.file.missing.fail=false +sonar.sii.quality.scss.file.missing.fail=false +sonar.sii.quality.css.file.missing.fail=false +sonar.sii.quality.html.file.missing.fail=false +sonar.sii.quality.eslint.angular.file.missing.fail=false + +# set to false to disable missing source file while analyzing test results +sonar.sii.test.ut.js.file.missing.fail=false +sonar.sii.test.it.js.file.missing.fail=false +sonar.sii.test.ut.ts.file.missing.fail=false +sonar.sii.test.it.ts.file.missing.fail=false + +# set to false to disable missing source file while analyzing code coverage +sonar.sii.coverage.ut.js.file.missing.fail=false +sonar.sii.coverage.it.js.file.missing.fail=false +sonar.sii.coverage.overall.js.file.missing.fail=false +sonar.sii.coverage.ut.ts.file.missing.fail=false +sonar.sii.coverage.it.ts.file.missing.fail=false +sonar.sii.coverage.overall.ts.file.missing.fail=false + +# set to false to disable missing source file while analyzing code duplication +sonar.sii.duplication.js.file.missing.fail=false +sonar.sii.duplication.html.file.missing.fail=false +sonar.sii.duplication.css.file.missing.fail=false +sonar.sii.duplication.scss.file.missing.fail=false +sonar.sii.duplication.ts.file.missing.fail=false +``` + +#### Skip analysis + +By default, the plugin also store information about the file (number of lines, number of lines of code, number of lines of comment...). + +Sonar doesn't allow two plugins to store the same information. So if you are using another plugin that also store this information, the second plugin analysis will fail. By default our plugin doesn't override information stored by another plugin. But we can't force plugin execution order. So it may happen that our plugin is run before the other one. That's why we provide the way to explicitly tell our plugin to not store file information. To do this, use the following properties in your sonar-project.properties: + +```ini +sonar.sii.quality.js.file.metrics.skip=true +sonar.sii.quality.js.eslint.file.metrics.skip=true +sonar.sii.quality.html.file.metrics.skip=true +sonar.sii.quality.css.file.metrics.skip=true +sonar.sii.quality.scss.file.metrics.skip=true +sonar.sii.quality.eslint.angular.file.metrics.skip=true +sonar.sii.quality.ts.file.metrics.skip=true +``` + +Sonar also provide CPD analysis. Like described above, code duplication analysis can fail if two plugins are doing it. +You can either disable our analysis or disable Sonar CPD analysis: + +```ini +# disable duplication analysis done by our plugin +sonar.sii.duplication.js.skip=true +sonar.sii.duplication.html.skip=true +sonar.sii.duplication.css.skip=true +sonar.sii.duplication.scss.skip=true +sonar.sii.duplication.ts.skip=true + +# disable Sonar CPD analysis +sonar.cpd.exclusions=** +``` # Supported Sonar versions -As Sonar team make big changes on plugin APIs between two versions, it takes really long time to update the plugin for each version. So we decided to only support the LTS version (currently 4.5.x). We also try to make the last release version (currently 5.3) but some APIs have totally disappeared while other are no more working. When Sonar 5.4 will be released, we will try to make adjustements to make our plugin working on it. No effort is made for Sonar versions between 4.5.x and 5.3. The plugin may work or not depending on what you are using and the version of Sonar. +As Sonar team makes big changes on plugin APIs between two versions, it takes really long time to update the plugin for each version. So we decided to only support the LTS version (currently 4.5.x). We also try to make the last release version (currently 5.5) but some APIs have totally disappeared while other are no more working. When Sonar 5.6 will be released, we will try to make adjustments to make our plugin working on it. No effort is made for Sonar versions between 4.5.x and latest version. The plugin may work or not depending on what you are using and the version of Sonar. # Roadmap -TODO +## Main features + +- Code complexity ([Plato](https://github.com/es-analysis/plato) ...) +- Support new languages (Less, ...) +- Support Sonar 5.x (LTS version) when it will be available +- Add new widgets for better user experience + +See [full list of features](https://github.com/groupe-sii/sonar-web-frontend-plugin/labels/feature) + +See [milestones](https://github.com/groupe-sii/sonar-web-frontend-plugin/milestones) for future versions + diff --git a/pom.xml b/pom.xml index 20cbe61..3ef659b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,15 +1,15 @@ - + 4.0.0 fr.sii.sonar sonar-sii-plugin-parent pom - 2.0-SNAPSHOT + 2.0.1-SNAPSHOT SII plugin parent SII plugin consumes reports generated by external tools and save information into Sonar + ${project.url} UTF-8 @@ -26,6 +26,13 @@ 1.12.1 2.5.1 + 2.5.2 + 1.6.3 + 1.6 + + https://github.com/groupe-sii/sonar-web-frontend-plugin + https://github.com/groupe-sii/sonar-web-frontend-plugin.git + https://github.com/groupe-sii/sonar-web-frontend-plugin @@ -40,6 +47,7 @@ sonar-web-frontend-angular-eslint sonar-duplication-cpd sonar-duplication-simian + sonar-web-frontend-typescript sonar-web-frontend-plugin @@ -109,7 +117,7 @@ org.apache.maven.plugins maven-compiler-plugin - 2.5.1 + ${maven.compiler.plugin.version} org.apache.maven.plugins maven-eclipse-plugin @@ -134,7 +172,95 @@ true + + + org.apache.maven.plugins + maven-release-plugin + ${maven.release.plugin.version} + + true + false + release + deploy + v@{project.version} + + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + release + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + ${nexus.staging.plugin.version} + true + + ossrh + https://oss.sonatype.org/ + true + + + + org.apache.maven.plugins + maven-gpg-plugin + ${gpg.plugin.version} + + + sign-artifacts + verify + + sign + + + + + + + + + + + + The Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + + Aurélien Baudet + aurelien.baudet@gmail.com + https://github.com/aurelien-baudet + Groupe SII + http://www.groupe-sii.com + + + + + ${github.url} + scm:git:${scm.url} + scm:git:${scm.url} + v${project.version} + + + + ${github.url}/issues + GitHub + diff --git a/sonar-coverage-lcov/pom.xml b/sonar-coverage-lcov/pom.xml index 3e61dd1..5701ad2 100644 --- a/sonar-coverage-lcov/pom.xml +++ b/sonar-coverage-lcov/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 fr.sii.sonar sonar-sii-plugin-parent - 2.0-SNAPSHOT + 2.0.1-SNAPSHOT sonar-coverage-lcov diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/BranchCoverageDetail.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/BranchCoverageDetail.java index 012a969..2344b95 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/BranchCoverageDetail.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/BranchCoverageDetail.java @@ -6,7 +6,7 @@ * LCOV unit branch information. It exactly corresponds to a BRDA line in the * LCOV file : * - * BRDA:,,, + * {@literal BRDA:,,,} * * @author Aurélien Baudet * @see LcovBranchCoverageStatement diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/CoverageInfo.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/CoverageInfo.java index 0dad537..1235100 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/CoverageInfo.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/CoverageInfo.java @@ -16,12 +16,12 @@ * of hit statements and the details for each statement. A statement can be a * line, a function or a branch. These information are provided by the following lines : * - * FNF: - * FNH: - * BRF: - * BRH: - * LH: - * LF: + * {@literal FNF:} + * {@literal FNH:} + * {@literal BRF:} + * {@literal BRH:} + * {@literal LH:} + * {@literal LF:} * * @author Aurélien Baudet * diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/FunctionCoverageDetail.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/FunctionCoverageDetail.java index 44d8c48..0a73e8d 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/FunctionCoverageDetail.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/FunctionCoverageDetail.java @@ -6,8 +6,8 @@ /** * LCOV format provides information about covered functions. The function detailed information are provided by two different lines in the LCOV report : * - * FN:, - * FNDA:, + * {@literal FN:,} + * {@literal FNDA:,} * * This class groups the two pieces of information. * diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/LineCoverageDetail.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/LineCoverageDetail.java index 4c67cfb..0529ea5 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/LineCoverageDetail.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/domain/LineCoverageDetail.java @@ -6,7 +6,7 @@ * Provides detail information about the number of line execution. This is * provided by the LCOV format with the line : * - * DA:,[,] + * {@literal DA:,[,]} * * @author Aurélien Baudet * diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovBranchCoverageStatement.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovBranchCoverageStatement.java index 9a9a077..b0f2f75 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovBranchCoverageStatement.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovBranchCoverageStatement.java @@ -12,7 +12,7 @@ /** * Branch coverage information is stored which one line per branch: * - * BRDA:,,, + * {@literal BRDA:,,,} * * Block number and branch number are gcc internal IDs for the branch. Taken is * either ’-’ if the basic block containing the branch was never executed or a diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovFunctionExecutionCountStatement.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovFunctionExecutionCountStatement.java index 772e428..2282343 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovFunctionExecutionCountStatement.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovFunctionExecutionCountStatement.java @@ -12,7 +12,7 @@ /** * Next, there is a list of execution counts for each instrumented function: * - * FNDA:, + * {@literal FNDA:,} * * @author Aurélien Baudet * diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovFunctionNameStatement.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovFunctionNameStatement.java index d23d161..ee3f08c 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovFunctionNameStatement.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovFunctionNameStatement.java @@ -13,7 +13,7 @@ * Following is a list of line numbers for each function name found in the * source file: * - * FN:, + * {@literal FN:,} * * @author Aurélien Baudet * diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovLineExecutionCountStatement.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovLineExecutionCountStatement.java index f40dd4b..c337233 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovLineExecutionCountStatement.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovLineExecutionCountStatement.java @@ -13,7 +13,7 @@ * Then there is a list of execution counts for each instrumented line (i.e. a * line which resulted in executable code): * - * DA:,[,] + * {@literal DA:,[,]} * * Note that there may be an optional checksum present for each instrumented * line. The current geninfo implementation uses an MD5 hash as checksumming diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberBranchFoundStatement.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberBranchFoundStatement.java index 2dc2631..3152580 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberBranchFoundStatement.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberBranchFoundStatement.java @@ -10,7 +10,7 @@ /** * Branch coverage summaries are stored in two lines: * - * BRF: + * {@literal BRF:} * * @author Aurélien Baudet * diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberBranchHitStatement.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberBranchHitStatement.java index 8a0ff2a..b3a1776 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberBranchHitStatement.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberBranchHitStatement.java @@ -10,7 +10,7 @@ /** * Branch coverage summaries are stored in two lines: * - * BRH: + * {@literal BRH:} * * @author Aurélien Baudet * diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberExecutedLineStatement.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberExecutedLineStatement.java index fe6338e..66f8031 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberExecutedLineStatement.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberExecutedLineStatement.java @@ -11,7 +11,7 @@ * At the end of a section, there is a summary about how many lines were found * and how many were actually instrumented: * - * LH: + * {@literal LH:} * * @author Aurélien Baudet * diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberFunctionFoundStatement.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberFunctionFoundStatement.java index 117db0d..d7bd94d 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberFunctionFoundStatement.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberFunctionFoundStatement.java @@ -11,7 +11,7 @@ * This list is followed by two lines containing the number of functions found * and hit: * - * FNF: + * {@literal FNF:} * * @author Aurélien Baudet * diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberFunctionHitStatement.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberFunctionHitStatement.java index 8cb9a05..3079374 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberFunctionHitStatement.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberFunctionHitStatement.java @@ -11,7 +11,7 @@ * This list is followed by two lines containing the number of functions found * and hit: * - * FNH: + * {@literal FNH:} * * @author Aurélien Baudet * diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberInstrumentedLineStatement.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberInstrumentedLineStatement.java index c2abca2..9d75d6d 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberInstrumentedLineStatement.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovNumberInstrumentedLineStatement.java @@ -11,7 +11,7 @@ * At the end of a section, there is a summary about how many lines were found * and how many were actually instrumented: * - * LF: + * {@literal LF:} * * @author Aurélien Baudet * diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovSourceFileStatement.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovSourceFileStatement.java index a92eb60..bf5e904 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovSourceFileStatement.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovSourceFileStatement.java @@ -4,7 +4,7 @@ import fr.sii.sonar.coverage.lcov.parser.domain.LcovReport; /** - * SF: + * {@literal SF:} * * @author Aurélien Baudet * diff --git a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovTestNameStatement.java b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovTestNameStatement.java index 5fc7d50..ca2d4b7 100644 --- a/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovTestNameStatement.java +++ b/sonar-coverage-lcov/src/main/java/fr/sii/sonar/coverage/lcov/parser/statement/LcovTestNameStatement.java @@ -8,7 +8,7 @@ * sections. If available, a tracefile begins with the testname which is stored * in the following format: * - * TN: + * {@literal TN:} * * @author Aurélien Baudet * diff --git a/sonar-duplication-cpd/pom.xml b/sonar-duplication-cpd/pom.xml index 556bdd1..60cbd81 100644 --- a/sonar-duplication-cpd/pom.xml +++ b/sonar-duplication-cpd/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 fr.sii.sonar sonar-sii-plugin-parent - 2.0-SNAPSHOT + 2.0.1-SNAPSHOT sonar-duplication-cpd diff --git a/sonar-duplication-simian/pom.xml b/sonar-duplication-simian/pom.xml index 1a82d8f..41ad320 100644 --- a/sonar-duplication-simian/pom.xml +++ b/sonar-duplication-simian/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 fr.sii.sonar sonar-sii-plugin-parent - 2.0-SNAPSHOT + 2.0.1-SNAPSHOT sonar-duplication-simian diff --git a/sonar-report-core/pom.xml b/sonar-report-core/pom.xml index b3f8bda..7d1accd 100644 --- a/sonar-report-core/pom.xml +++ b/sonar-report-core/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 fr.sii.sonar sonar-sii-plugin-parent - 2.0-SNAPSHOT + 2.0.1-SNAPSHOT sonar-report-core diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/ReportConstants.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/ReportConstants.java index 1d1fad1..234d89d 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/ReportConstants.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/ReportConstants.java @@ -20,12 +20,16 @@ public interface ReportConstants extends BatchExtension, ServerExtension { /** * The key for the configuration entry in sonar properties to indicate the * path to the report + * + * @return the key for the report path property */ public String getReportPathKey(); /** * The key for the configuration entry in sonar properties to indicate what * to do if a sonar source file doesn't exist + * + * @return the key for missing file property */ public String getMissingFileFailKey(); } diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/ReportSensor.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/ReportSensor.java index a6bd62c..6776e4f 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/ReportSensor.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/ReportSensor.java @@ -32,6 +32,8 @@ * * @author Aurélien Baudet * + * @param + * The type of handled report */ public abstract class ReportSensor implements Sensor { @@ -43,6 +45,15 @@ public abstract class ReportSensor implements Sensor { /** * Use of IoC to get Settings + * + * @param constants + * the constants for the current plugin + * @param pluginDependencies + * the Sonar dependencies + * @param providerFactory + * the factory for creating a new provider + * @param saverFactory + * the factory for creating a new saver */ public ReportSensor(ReportConstants constants, PluginDependencies pluginDependencies, ProviderFactory providerFactory, SaverFactory saverFactory) { super(); @@ -58,14 +69,14 @@ public boolean shouldExecuteOnProject(Project project) { try { File reportFile = getReportFile(project); boolean exists = reportFile.exists(); - if(exists) { - LOG.info("Loading and storing "+reportFile.getAbsolutePath()+" in Sonar"); - } else if(!pluginContext.getSettings().getBoolean(ReportSensorConstants.SKIP_LOG_MISSING_REPORT_KEY)) { - LOG.warn("The report file "+reportFile.getAbsolutePath()+" doesn't exist"); + if (exists) { + LOG.info("Loading and storing " + reportFile.getAbsolutePath() + " in Sonar"); + } else if (!pluginContext.getSettings().getBoolean(ReportSensorConstants.SKIP_LOG_MISSING_REPORT_KEY)) { + LOG.warn("The report file " + reportFile.getAbsolutePath() + " doesn't exist"); } return exists; } catch (Exception e) { - LOG.error("Failed to find report file "+e.getMessage()); + LOG.error("Failed to find report file " + e.getMessage()); return false; } } diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/language/LanguageConstants.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/language/LanguageConstants.java index e6cc5a5..ac16760 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/language/LanguageConstants.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/language/LanguageConstants.java @@ -4,6 +4,8 @@ public interface LanguageConstants { /** * The language key + * + * @return the language key */ public String getLanguageKey(); diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/provider/XmlFileReportProvider.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/provider/XmlFileReportProvider.java index 43bd9e4..c6cb066 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/provider/XmlFileReportProvider.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/provider/XmlFileReportProvider.java @@ -46,7 +46,7 @@ public class XmlFileReportProvider implements Provider { /** * Initialize the provider with the xml stream to parse and the class of the - * report. In this case, must extends Report + * report. In this case, {@literal } must extends Report * * @param stream * the xml stream to parse @@ -62,15 +62,17 @@ public XmlFileReportProvider(InputStream stream, Class xmlClass) { /** * Initialize the provider with the xml file to parse and the class of the - * report. In this case, must extends Report + * report. In this case, {@literal } must extends Report * - * @param stream + * @param reportFile * the xml file to parse * @param xmlClass * the class that will be instantiated and filled with the stream * content * @throws IllegalArgumentException * if xmlClass parameter doesn't implement {@link Report} + * @throws FileNotFoundException + * when the report file doesn't exist */ public XmlFileReportProvider(File reportFile, Class xmlClass) throws FileNotFoundException { this(reportFile, checkClass(xmlClass), null); @@ -110,19 +112,22 @@ public XmlFileReportProvider(InputStream stream, Class xmlClass, ReportAdapte * @param adapter * an adapter that transforms the raw structure into the final * report structure + * @throws FileNotFoundException + * when the report file doesn't exist */ public XmlFileReportProvider(File reportFile, Class xmlClass, ReportAdapter adapter) throws FileNotFoundException { this(new FileInputStream(reportFile), xmlClass, adapter); } /** - * Utility method used to check if the provided class is allowed or not. - * The class is allowed if it implements {@link Report}. + * Utility method used to check if the provided class is allowed or not. The + * class is allowed if it implements {@link Report}. * * @param xmlClass * the class to check * @return xmlClass - * @throws IllegalArgumentException if the class is not allowed. + * @throws IllegalArgumentException + * if the class is not allowed. */ private static Class checkClass(Class xmlClass) { if (!Report.class.isAssignableFrom(xmlClass)) { @@ -133,7 +138,7 @@ private static Class checkClass(Class xmlClass) { @SuppressWarnings("unchecked") public R get() throws ProviderException { - try(Reader reader = new InputStreamReader(stream)) { + try (Reader reader = new InputStreamReader(stream)) { Unmarshaller unmarshaller = JAXBContext.newInstance(xmlClass).createUnmarshaller(); Object rawStructure = unmarshaller.unmarshal(reader); if (adapter != null) { diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/FileLoader.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/FileLoader.java index df4f963..5a1de1b 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/FileLoader.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/FileLoader.java @@ -5,12 +5,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.sonar.api.rule.RuleStatus; import org.sonar.api.server.rule.RulesDefinition.NewRepository; import org.sonar.api.server.rule.RulesDefinition.NewRule; import fr.sii.sonar.report.core.common.exception.ParseException; import fr.sii.sonar.report.core.common.exception.RuleException; import fr.sii.sonar.report.core.common.parser.Parser; +import fr.sii.sonar.report.core.common.rules.debt.FirstSupportingRemadiationProviderDecorator; +import fr.sii.sonar.report.core.common.rules.debt.RemediationProvider; +import fr.sii.sonar.report.core.quality.domain.rule.Debt; import fr.sii.sonar.report.core.quality.domain.rule.RuleDefinition; /** @@ -26,33 +30,54 @@ public class FileLoader implements RulesDefinitionLoader { private static final Logger LOG = LoggerFactory.getLogger(FileLoader.class); private final InputStream stream; - + private final Parser> parser; - - public FileLoader(InputStream stream, Parser> parser) { + + private RemediationProvider remediationProvider; + + public FileLoader(InputStream stream, Parser> parser, RemediationProvider remediationProvider) { super(); this.stream = stream; this.parser = parser; + this.remediationProvider = remediationProvider; + } + + public FileLoader(InputStream stream, Parser> parser) { + this(stream, parser, new FirstSupportingRemadiationProviderDecorator()); } public void load(NewRepository repository) { - LOG.info("Loading rules for "+repository.key()); + LOG.info("Loading rules for " + repository.key()); try { List rules = parser.parse(stream); - LOG.info(rules.size()+" rules defined for "+repository.key()+". Registering them"); + LOG.info(rules.size() + " rules defined for " + repository.key() + ". Registering them"); for (RuleDefinition rule : rules) { NewRule newRule = repository.createRule(rule.getKey()); newRule.setName(rule.getName()); newRule.setHtmlDescription(rule.getDescription()); - if(rule.getSeverity() != null) { + if (rule.getSeverity() != null) { newRule.setSeverity(rule.getSeverity().toUpperCase()); } - if(rule.getStatus() != null) { - newRule.setStatus(rule.getStatus()); + if (rule.getStatus() != null) { + newRule.setStatus(RuleStatus.valueOf(rule.getStatus())); + } + // manage tags + if (rule.getTags() != null) { + for (String tag : rule.getTags()) { + newRule.addTags(tag); + } + } + // manage debt + Debt debt = rule.getDebt(); + if(debt != null) { + if(debt.getSqaleSubCharacteristic()!=null) { + newRule.setDebtSubCharacteristic(debt.getSqaleSubCharacteristic()); + } + if(debt.getSqaleRemediation()!=null) { + remediationProvider.setRemediation(newRule, debt.getSqaleRemediation()); + } } - // TODO: manage tags // TODO: manage params - // TODO: manage debt } } catch (ParseException e) { LOG.error("Failed to parse rule files", e); diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/RulesDefinitionConstants.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/RulesDefinitionConstants.java index 9f5b4b3..52c7f36 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/RulesDefinitionConstants.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/RulesDefinitionConstants.java @@ -16,21 +16,29 @@ public interface RulesDefinitionConstants { /** * The key of the repository + * + * @return the key of the repository */ public String getRepositoryKey(); /** * The name of the repository + * + * @return the name of the repository */ public String getRepositoryName(); /** * The path to the JSON file that contains the rules + * + * @return the path to the JSON file that contains the rules */ public String getRulesJsonPath(); /** * The language managed by the repository + * + * @return the language managed by the repository */ public String getLanguageKey(); } diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/ConstantRemediationProvider.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/ConstantRemediationProvider.java new file mode 100644 index 0000000..8d59019 --- /dev/null +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/ConstantRemediationProvider.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.report.core.common.rules.debt; + +import org.sonar.api.server.rule.RulesDefinition.NewRule; + +import fr.sii.sonar.report.core.quality.domain.rule.SqaleConstantRemediation; +import fr.sii.sonar.report.core.quality.domain.rule.SqaleRemediation; + +public class ConstantRemediationProvider implements RemediationProvider { + + @Override + public boolean setRemediation(NewRule sonarRule, SqaleRemediation remediation) { + if(remediation instanceof SqaleConstantRemediation) { + SqaleConstantRemediation constantRemediation = (SqaleConstantRemediation) remediation; + sonarRule.setDebtRemediationFunction(sonarRule.debtRemediationFunctions().constantPerIssue(constantRemediation.getOffset())); + return true; + } else { + return false; + } + } + +} diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/FirstSupportingRemadiationProviderDecorator.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/FirstSupportingRemadiationProviderDecorator.java new file mode 100644 index 0000000..5bebb8a --- /dev/null +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/FirstSupportingRemadiationProviderDecorator.java @@ -0,0 +1,37 @@ +package fr.sii.sonar.report.core.common.rules.debt; + +import java.util.Arrays; +import java.util.List; + +import org.sonar.api.server.rule.RulesDefinition.NewRule; + +import fr.sii.sonar.report.core.quality.domain.rule.SqaleRemediation; + +public class FirstSupportingRemadiationProviderDecorator implements RemediationProvider { + + private List delegates; + + public FirstSupportingRemadiationProviderDecorator(List delegates) { + super(); + this.delegates = delegates; + } + + public FirstSupportingRemadiationProviderDecorator(RemediationProvider... delegates) { + this(Arrays.asList(delegates)); + } + + public FirstSupportingRemadiationProviderDecorator() { + this(new LinearWithOffsetRemediationProvider(), new LinearRemediationProvider(), new ConstantRemediationProvider()); + } + + @Override + public boolean setRemediation(NewRule sonarRule, SqaleRemediation remediation) { + for(RemediationProvider delegate : delegates) { + if(delegate.setRemediation(sonarRule, remediation)) { + return true; + } + } + return false; + } + +} diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/LinearRemediationProvider.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/LinearRemediationProvider.java new file mode 100644 index 0000000..eb4e4fe --- /dev/null +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/LinearRemediationProvider.java @@ -0,0 +1,22 @@ +package fr.sii.sonar.report.core.common.rules.debt; + +import org.sonar.api.server.rule.RulesDefinition.NewRule; + +import fr.sii.sonar.report.core.quality.domain.rule.SqaleLinearRemediation; +import fr.sii.sonar.report.core.quality.domain.rule.SqaleRemediation; + +public class LinearRemediationProvider implements RemediationProvider { + + @Override + public boolean setRemediation(NewRule sonarRule, SqaleRemediation remediation) { + if(remediation instanceof SqaleLinearRemediation) { + SqaleLinearRemediation linearRemediation = (SqaleLinearRemediation) remediation; + sonarRule.setDebtRemediationFunction(sonarRule.debtRemediationFunctions().linear(linearRemediation.getCoeff())); + sonarRule.setEffortToFixDescription(linearRemediation.getEffortToFixDescription()); + return true; + } else { + return false; + } + } + +} diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/LinearWithOffsetRemediationProvider.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/LinearWithOffsetRemediationProvider.java new file mode 100644 index 0000000..4d4b0f8 --- /dev/null +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/LinearWithOffsetRemediationProvider.java @@ -0,0 +1,22 @@ +package fr.sii.sonar.report.core.common.rules.debt; + +import org.sonar.api.server.rule.RulesDefinition.NewRule; + +import fr.sii.sonar.report.core.quality.domain.rule.SqaleLinearWithOffsetRemediation; +import fr.sii.sonar.report.core.quality.domain.rule.SqaleRemediation; + +public class LinearWithOffsetRemediationProvider implements RemediationProvider { + + @Override + public boolean setRemediation(NewRule sonarRule, SqaleRemediation remediation) { + if(remediation instanceof SqaleLinearWithOffsetRemediation) { + SqaleLinearWithOffsetRemediation linearWithOffsetRemediation = (SqaleLinearWithOffsetRemediation) remediation; + sonarRule.setDebtRemediationFunction(sonarRule.debtRemediationFunctions().linearWithOffset(linearWithOffsetRemediation.getCoeff(), linearWithOffsetRemediation.getOffset())); + sonarRule.setEffortToFixDescription(linearWithOffsetRemediation.getEffortToFixDescription()); + return true; + } else { + return false; + } + } + +} diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/RemediationProvider.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/RemediationProvider.java new file mode 100644 index 0000000..a1a24e9 --- /dev/null +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/rules/debt/RemediationProvider.java @@ -0,0 +1,9 @@ +package fr.sii.sonar.report.core.common.rules.debt; + +import org.sonar.api.server.rule.RulesDefinition.NewRule; + +import fr.sii.sonar.report.core.quality.domain.rule.SqaleRemediation; + +public interface RemediationProvider { + public boolean setRemediation(NewRule sonarRule, SqaleRemediation remediation); +} diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/util/RuleUtil.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/util/RuleUtil.java index 1ec04f9..6b9813b 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/util/RuleUtil.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/util/RuleUtil.java @@ -11,7 +11,8 @@ public static String getHtmlDescription(NewRule rule) throws RuleDefinitionExcep try { Field field = rule.getClass().getDeclaredField("htmlDescription"); field.setAccessible(true); - return field.get(rule).toString(); + Object desc = field.get(rule); + return desc==null ? "" : desc.toString(); } catch (SecurityException e) { throw new RuleDefinitionException("Failed to get HTML description for rule "+rule.key(), e); } catch (NoSuchFieldException e) { @@ -27,7 +28,8 @@ public static String getName(NewRule rule) throws RuleDefinitionException { try { Field field = rule.getClass().getDeclaredField("name"); field.setAccessible(true); - return field.get(rule).toString(); + Object name = field.get(rule); + return name==null ? "" : name.toString(); } catch (SecurityException e) { throw new RuleDefinitionException("Failed to get name for rule "+rule.key(), e); } catch (NoSuchFieldException e) { diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/util/compat/StringEscapeUtils.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/util/compat/StringEscapeUtils.java index c62a50e..4faeb85 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/util/compat/StringEscapeUtils.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/util/compat/StringEscapeUtils.java @@ -9,62 +9,80 @@ * Sonar dependencies, we use our own utility classes. * *

- * Soanr 5.3 removes utility libraries + * Sonar 5.3 removes utility libraries * * @author Aurélien Baudet */ public class StringEscapeUtils { - /** - *

Escapes the characters in a String using XML entities.

- * - *

For example: "bread" & "butter" => - * "bread" & "butter". - *

- * - *

Supports only the five basic XML entities (gt, lt, quot, amp, apos). - * Does not support DTDs or external entities.

- * - *

Note that unicode characters greater than 0x7f are currently escaped to - * their numerical \\u equivalent. This may change in future releases.

- * - * @param writer the writer receiving the unescaped string, not null - * @param str the String to escape, may be null - * @throws IllegalArgumentException if the writer is null - * @throws IOException if there is a problem writing - * @see #unescapeXml(java.lang.String) - */ - public static void escapeXml(Writer writer, String str) throws IOException { - if (writer == null ) { - throw new IllegalArgumentException ("The Writer must not be null."); - } - if (str == null) { - return; - } - Entities.XML.escape(writer, str); - } + /** + *

+ * Escapes the characters in a String using XML entities. + *

+ * + *

+ * For example: "bread" & "butter" {@literal =>} + * "bread" & "butter". + *

+ * + *

+ * Supports only the five basic XML entities (gt, lt, quot, amp, apos). Does + * not support DTDs or external entities. + *

+ * + *

+ * Note that unicode characters greater than 0x7f are currently escaped to + * their numerical \\u equivalent. This may change in future releases. + *

+ * + * @param writer + * the writer receiving the unescaped string, not null + * @param str + * the String to escape, may be null + * @throws IllegalArgumentException + * if the writer is null + * @throws IOException + * if there is a problem writing + */ + public static void escapeXml(Writer writer, String str) throws IOException { + if (writer == null) { + throw new IllegalArgumentException("The Writer must not be null."); + } + if (str == null) { + return; + } + Entities.XML.escape(writer, str); + } - /** - *

Escapes the characters in a String using XML entities.

- * - *

For example: "bread" & "butter" => - * "bread" & "butter". - *

- * - *

Supports only the five basic XML entities (gt, lt, quot, amp, apos). - * Does not support DTDs or external entities.

- * - *

Note that unicode characters greater than 0x7f are currently escaped to - * their numerical \\u equivalent. This may change in future releases.

- * - * @param str the String to escape, may be null - * @return a new escaped String, null if null string input - * @see #unescapeXml(java.lang.String) - */ - public static String escapeXml(String str) { - if (str == null) { - return null; - } - return Entities.XML.escape(str); - } + /** + *

+ * Escapes the characters in a String using XML entities. + *

+ * + *

+ * For example: "bread" & "butter" {@literal =>} + * "bread" & "butter". + *

+ * + *

+ * Supports only the five basic XML entities (gt, lt, quot, amp, apos). Does + * not support DTDs or external entities. + *

+ * + *

+ * Note that unicode characters greater than 0x7f are currently escaped to + * their numerical \\u equivalent. This may change in future releases. + *

+ * + * @param str + * the String to escape, may be null + * @return a new escaped String, null if null + * string input + */ + public static String escapeXml(String str) { + if (str == null) { + return null; + } + return Entities.XML.escape(str); + } } diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/util/compat/StringUtils.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/util/compat/StringUtils.java index d7d1025..78f0d00 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/util/compat/StringUtils.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/common/util/compat/StringUtils.java @@ -30,8 +30,6 @@ private StringUtils() { *

No delimiter is added before or after the list. * A null separator is the same as an empty String ("").

* - *

See the examples here: {@link #join(Object[],String)}.

- * * @param collection the Collection of values to join together, may be null * @param separator the separator character to use, null treated as "" * @return the joined String, null if null iterator input @@ -50,8 +48,6 @@ public static String join(Collection collection, String separator) { *

No delimiter is added before or after the list. * A null separator is the same as an empty String ("").

* - *

See the examples here: {@link #join(Object[],String)}.

- * * @param iterator the Iterator of values to join together, may be null * @param separator the separator character to use, null treated as "" * @return the joined String, null if null iterator input diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/duplication/DuplicationConstants.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/duplication/DuplicationConstants.java index b80c114..2c5a9cf 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/duplication/DuplicationConstants.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/duplication/DuplicationConstants.java @@ -5,6 +5,8 @@ public interface DuplicationConstants extends ReportConstants { /** * Get the key for skipping duplication analysis + * + * @return the key for skipping duplication analysis */ public String getSkipDuplicationKey(); } diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/duplication/save/DuplicationDetailsHelper.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/duplication/save/DuplicationDetailsHelper.java index 270ceb0..c69a24e 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/duplication/save/DuplicationDetailsHelper.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/duplication/save/DuplicationDetailsHelper.java @@ -19,7 +19,7 @@ */ public class DuplicationDetailsHelper { /** - * In Sonar version < 4.5, duplication details is store in xml. This method + * In Sonar version {@literal <} 4.5, duplication details is store in xml. This method * transforms duplication information into an xml string. * * @param project @@ -32,7 +32,8 @@ public class DuplicationDetailsHelper { * the information about duplication for the file * @return the xml string to save in Sonar * @throws DuplicationException - * when the duplication details couldn't be generated for the file + * when the duplication details couldn't be generated for the + * file */ public static String toXml(Project project, FileSystem fileSystem, DuplicationReport report, DuplicationFileInformation file) throws DuplicationException { try { @@ -44,9 +45,8 @@ public static String toXml(Project project, FileSystem fileSystem, DuplicationRe boolean containsFile = false; group.append(""); for (DuplicatedBlock part : duplication.getDuplicatedBlocks()) { - group.append(""); + group.append(""); if (!containsFile) { containsFile = file.getPath().equals(part.getSourceFile()); } @@ -59,8 +59,8 @@ public static String toXml(Project project, FileSystem fileSystem, DuplicationRe } xml.append(""); return hasDuplications ? xml.toString() : null; - } catch(KeyException e) { - throw new DuplicationException("failed to generate duplication details for "+file.getPath()); + } catch (KeyException e) { + throw new DuplicationException("failed to generate duplication details for " + file.getPath()); } } diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/QualityConstants.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/QualityConstants.java index cc0a3df..8d6cc22 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/QualityConstants.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/QualityConstants.java @@ -13,11 +13,15 @@ public interface QualityConstants extends ReportConstants { /** * The key of the repository + * + * @return the key of the repository */ public String getRepositoryKey(); - + /** * The key for configuration for skipping save of file metrics + * + * @return the key for configuration for skipping save of file metrics */ public String getSkipFileMetricsKey(); diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/BasicRule.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/BasicRule.java index 0d1dc01..4139263 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/BasicRule.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/BasicRule.java @@ -14,6 +14,15 @@ public class BasicRule { * The rule key */ private String key; + + public BasicRule() { + super(); + } + + public BasicRule(String key) { + super(); + this.key = key; + } public String getKey() { return key; diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/Debt.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/Debt.java new file mode 100644 index 0000000..7ffb866 --- /dev/null +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/Debt.java @@ -0,0 +1,23 @@ +package fr.sii.sonar.report.core.quality.domain.rule; + +public class Debt { + private SqaleRemediation sqaleRemediation; + + private String sqaleSubCharacteristic; + + public SqaleRemediation getSqaleRemediation() { + return sqaleRemediation; + } + + public void setSqaleRemediation(SqaleRemediation sqaleRemediation) { + this.sqaleRemediation = sqaleRemediation; + } + + public String getSqaleSubCharacteristic() { + return sqaleSubCharacteristic; + } + + public void setSqaleSubCharacteristic(String sqaleSubCharacteristic) { + this.sqaleSubCharacteristic = sqaleSubCharacteristic; + } +} diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/RuleDefinition.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/RuleDefinition.java index 22a8eac..c5c0861 100644 --- a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/RuleDefinition.java +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/RuleDefinition.java @@ -1,6 +1,6 @@ package fr.sii.sonar.report.core.quality.domain.rule; -import org.sonar.api.rule.RuleStatus; +import java.util.List; public class RuleDefinition extends BasicRule { private String name; @@ -9,7 +9,26 @@ public class RuleDefinition extends BasicRule { private String severity; - private RuleStatus status; + private String status; + + private List tags; + + private Debt debt; + + public RuleDefinition() { + super(); + } + + public RuleDefinition(String key, String name, String description) { + this(key, name, description, null); + } + + public RuleDefinition(String key, String name, String description, String severity) { + super(key); + this.name = name; + this.description = description; + this.severity = severity; + } public String getName() { return name; @@ -35,11 +54,27 @@ public void setSeverity(String severity) { this.severity = severity; } - public RuleStatus getStatus() { + public String getStatus() { return status; } - public void setStatus(RuleStatus status) { + public void setStatus(String status) { this.status = status; } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Debt getDebt() { + return debt; + } + + public void setDebt(Debt debt) { + this.debt = debt; + } } diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/SqaleConstantRemediation.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/SqaleConstantRemediation.java new file mode 100644 index 0000000..1ff3c3a --- /dev/null +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/SqaleConstantRemediation.java @@ -0,0 +1,16 @@ +package fr.sii.sonar.report.core.quality.domain.rule; + +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("constant") +public class SqaleConstantRemediation implements SqaleRemediation { + private String offset; + + public String getOffset() { + return offset; + } + + public void setOffset(String value) { + this.offset = value; + } +} diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/SqaleLinearRemediation.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/SqaleLinearRemediation.java new file mode 100644 index 0000000..476f4f2 --- /dev/null +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/SqaleLinearRemediation.java @@ -0,0 +1,26 @@ +package fr.sii.sonar.report.core.quality.domain.rule; + +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("linear") +public class SqaleLinearRemediation implements SqaleRemediation { + private String coeff; + + private String effortToFixDescription; + + public String getCoeff() { + return coeff; + } + + public void setCoeff(String coeff) { + this.coeff = coeff; + } + + public String getEffortToFixDescription() { + return effortToFixDescription; + } + + public void setEffortToFixDescription(String effortToFixDescription) { + this.effortToFixDescription = effortToFixDescription; + } +} diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/SqaleLinearWithOffsetRemediation.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/SqaleLinearWithOffsetRemediation.java new file mode 100644 index 0000000..6d5469a --- /dev/null +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/SqaleLinearWithOffsetRemediation.java @@ -0,0 +1,16 @@ +package fr.sii.sonar.report.core.quality.domain.rule; + +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("linearWithOffset") +public class SqaleLinearWithOffsetRemediation extends SqaleLinearRemediation { + private String offset; + + public String getOffset() { + return offset; + } + + public void setOffset(String offset) { + this.offset = offset; + } +} diff --git a/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/SqaleRemediation.java b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/SqaleRemediation.java new file mode 100644 index 0000000..5872d9a --- /dev/null +++ b/sonar-report-core/src/main/java/fr/sii/sonar/report/core/quality/domain/rule/SqaleRemediation.java @@ -0,0 +1,13 @@ +package fr.sii.sonar.report.core.quality.domain.rule; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonSubTypes.Type; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.PROPERTY, property="type") +@JsonSubTypes({ + @Type(SqaleConstantRemediation.class), + @Type(SqaleLinearRemediation.class), + @Type(SqaleLinearWithOffsetRemediation.class)}) +public interface SqaleRemediation { +} diff --git a/sonar-report-core/src/test/java/fr/sii/sonar/report/core/common/rules/TestJsonLoader.java b/sonar-report-core/src/test/java/fr/sii/sonar/report/core/common/rules/TestJsonLoader.java index 8be6bb7..a3dfd88 100644 --- a/sonar-report-core/src/test/java/fr/sii/sonar/report/core/common/rules/TestJsonLoader.java +++ b/sonar-report-core/src/test/java/fr/sii/sonar/report/core/common/rules/TestJsonLoader.java @@ -1,6 +1,7 @@ package fr.sii.sonar.report.core.common.rules; import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -12,6 +13,8 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; +import org.sonar.api.server.debt.DebtRemediationFunction; +import org.sonar.api.server.rule.RulesDefinition.DebtRemediationFunctions; import org.sonar.api.server.rule.RulesDefinition.NewRepository; import org.sonar.api.server.rule.RulesDefinition.NewRule; @@ -28,9 +31,23 @@ public class TestJsonLoader { @Mock NewRule newRule; + @Mock + DebtRemediationFunctions debtRemediationFunctions; + + @Mock + DebtRemediationFunction constantRemediationFunction; + @Mock + DebtRemediationFunction linearRemediationFunction; + @Mock + DebtRemediationFunction linearWithOffsetRemediationFunction; + @Before public void setup() { when(repository.createRule(anyString())).thenReturn(newRule); + when(newRule.debtRemediationFunctions()).thenReturn(debtRemediationFunctions); + when(debtRemediationFunctions.constantPerIssue(anyString())).thenReturn(constantRemediationFunction); + when(debtRemediationFunctions.linear(anyString())).thenReturn(linearRemediationFunction); + when(debtRemediationFunctions.linearWithOffset(anyString(), anyString())).thenReturn(linearWithOffsetRemediationFunction); } @Test @@ -44,5 +61,10 @@ public void csslintRules() throws RuleDefinitionException, JsonParseException, J verify(newRule, times(1)).setSeverity("BLOCKER"); verify(newRule, times(1)).setSeverity("CRITICAL"); verify(newRule, times(0)).setStatus(null); + verify(newRule, times(2)).setEffortToFixDescription(anyString()); + verify(newRule, times(3)).setDebtSubCharacteristic(anyString()); + verify(newRule, times(1)).setDebtRemediationFunction(eq(constantRemediationFunction)); + verify(newRule, times(1)).setDebtRemediationFunction(eq(linearRemediationFunction)); + verify(newRule, times(1)).setDebtRemediationFunction(eq(linearWithOffsetRemediationFunction)); } } diff --git a/sonar-report-core/src/test/resources/profiles/csslint-external.json b/sonar-report-core/src/test/resources/profiles/csslint-external.json index c938872..9194831 100644 --- a/sonar-report-core/src/test/resources/profiles/csslint-external.json +++ b/sonar-report-core/src/test/resources/profiles/csslint-external.json @@ -3,159 +3,6 @@ "language": "css", "repositories": [{ "key": "csslint", - "rules": [{ - "key": "import", - "name": "Disallow @import", - "description": "Don't use @import, use instead." - }, { - "key": "important", - "name": "Disallow !important", - "description": "Be careful when using !important declaration" - }, { - "key": "box-model", - "name": "Beware of broken box size", - "description": "Don't use width or height when using padding or border." - }, { - "key": "empty-rules", - "name": "Disallow empty rules", - "description": "Rules without any properties specified should be removed." - }, { - "key": "adjoining-classes", - "name": "Disallow adjoining classes", - "description": "Don't use adjoining classes." - }, { - "key": "qualified-headings", - "name": "Disallow qualified headings", - "description": "Headings should not be qualified (namespaced)." - }, { - "key": "unique-headings", - "name": "Headings should only be defined once", - "description": "Headings should be defined only once." - }, { - "key": "errors", - "name": "Parsing Errors", - "description": "This rule looks for recoverable syntax errors." - }, { - "key": "overqualified-elements", - "name": "Disallow overqualified elements", - "description": "Don't use classes or IDs with elements (a.foo or a#foo)." - }, { - "key": "vendor-prefix", - "name": "Require standard property with vendor prefix", - "description": "When using a vendor-prefixed property, make sure to include the standard one." - }, { - "key": "fallback-colors", - "name": "Require fallback colors", - "description": "For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color." - }, { - "key": "regex-selectors", - "name": "Disallow selectors that look like regexs", - "description": "Selectors that look like regular expressions are slow and should be avoided." - }, { - "key": "unqualified-attributes", - "name": "Disallow unqualified attribute selectors", - "description": "Unqualified attribute selectors are known to be slow." - }, { - "key": "universal-selector", - "name": "Disallow universal selector", - "description": "The universal selector (*) is known to be slow." - }, { - "key": "box-sizing", - "name": "Disallow use of box-sizing", - "description": "The box-sizing properties isn't supported in IE6 and IE7." - }, { - "key": "display-property-grouping", - "name": "Require properties appropriate for display", - "description": "Certain properties shouldn't be used with certain display property values." - }, { - "key": "ids", - "name": "Disallow IDs in selectors", - "description": "Selectors should not contain IDs." - }, { - "key": "gradients", - "name": "Require all gradient definitions", - "description": "When using a vendor-prefixed gradient, make sure to use them all." - }, { - "key": "zero-units", - "name": "Disallow units for 0 values", - "description": "You don't need to specify units when a value is 0." - }, { - "key": "duplicate-properties", - "name": "Disallow duplicate properties", - "description": "Duplicate properties must appear one after the other." - }, { - "key": "compatible-vendor-prefixes", - "name": "Require compatible vendor prefixes", - "description": "Include all compatible vendor prefixes to reach a wider range of users." - }, { - "key": "outline-none", - "name": "Disallow outline: none", - "description": "Use of outline: none or outline: 0 should be limited to :focus rules." - }, { - "key": "floats", - "name": "Disallow too many floats", - "description": "This rule tests if the float property is used too many times" - }, { - "key": "known-properties", - "name": "Require use of known properties", - "description": "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property." - }, { - "key": "font-sizes", - "name": "Disallow too many font sizes", - "description": "Checks the number of font-size declarations." - }, { - "key": "font-faces", - "name": "Don't use too many web fonts", - "description": "Too many different web fonts in the same stylesheet." - }, { - "key": "duplicate-background-images", - "name": "Disallow duplicate background images", - "description": "Every background-image should be unique. Use a common class for e.g. sprites." - }, { - "key": "order-alphabetical", - "name": "Alphabetical order", - "description": "Assure properties are in alphabetical order" - }, { - "key": "rules-count", - "name": "Rules Count", - "description": "Assure properties are in alphabetical order" - }, { - "key": "selector-max-approaching", - "name": "Warn when approaching the 4095 selector limit for IE", - "description": "Will warn when selector count is >= 3800 selectors." - }, { - "key": "selector-max", - "name": "Error when past the 4095 selector limit for IE", - "description": "Will error when selector count is > 4095." - }, { - "key": "selector-newline", - "name": "Disallow new-line characters in selectors", - "description": "New-line characters in selectors are usually a forgotten comma and not a descendant combinator.", - "severity": "MINOR" - }, { - "key": "shorthand", - "name": "Require shorthand properties", - "description": "Use shorthand properties where possible.", - "severity": "MAJOR" - }, { - "key": "star-property-hack", - "name": "Disallow properties with a star prefix", - "description": "Checks for the star property hack (targets IE6/7)", - "severity": "BLOCKER" - }, { - "key": "text-indent", - "name": "Disallow negative text-indent", - "description": "Checks for text indent less than -99px", - "severity": "CRITICAL" - }, { - "key": "underscore-property-hack", - "name": "Disallow properties with an underscore prefix", - "description": "Checks for the underscore property hack (targets IE6)", - "severity": "major" - }, { - "key": "bulletproof-font-face", - "name": "Use the bulletproof @font-face syntax", - "description": "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax)." - }] + "rules": "/rules/csslint.json" }] -} \ No newline at end of file +} diff --git a/sonar-report-core/src/test/resources/profiles/csslint-internal.json b/sonar-report-core/src/test/resources/profiles/csslint-internal.json index 9194831..e0384c4 100644 --- a/sonar-report-core/src/test/resources/profiles/csslint-internal.json +++ b/sonar-report-core/src/test/resources/profiles/csslint-internal.json @@ -1,8 +1,188 @@ { - "name": "csslint", - "language": "css", - "repositories": [{ - "key": "csslint", - "rules": "/rules/csslint.json" + "name": "csslint", + "language": "css", + "repositories": [{ + "key": "csslint", + "rules": [{ + "key": "import", + "name": "Disallow @import", + "description": "Don't use @import, use instead.", + "status": "DEPRECATED", + "tags": ["bad-practice"], + "debt": { + "sqaleRemediation": { + "type": "constant", + "offset": "10min" + }, + "sqaleSubCharacteristic": "READABILITY" + } + }, { + "key": "important", + "name": "Disallow !important", + "description": "Be careful when using !important declaration", + "tags": ["bad-practice", "confusing", "suspicious"], + "debt": { + "sqaleRemediation": { + "type": "linear", + "coeff": "20min", + "effortToFixDescription": "Effort to remove one !important" + }, + "sqaleSubCharacteristic": "UNDERSTANDABILITY" + } + }, { + "key": "box-model", + "name": "Beware of broken box size", + "description": "Don't use width or height when using padding or border.", + "debt": { + "sqaleRemediation": { + "type": "linearWithOffset", + "coeff": "20min", + "offset": "1h", + "effortToFixDescription": "Effort to change box model" + }, + "sqaleSubCharacteristic": "UNDERSTANDABILITY" + } + }, { + "key": "empty-rules", + "name": "Disallow empty rules", + "description": "Rules without any properties specified should be removed." + }, { + "key": "adjoining-classes", + "name": "Disallow adjoining classes", + "description": "Don't use adjoining classes." + }, { + "key": "qualified-headings", + "name": "Disallow qualified headings", + "description": "Headings should not be qualified (namespaced)." + }, { + "key": "unique-headings", + "name": "Headings should only be defined once", + "description": "Headings should be defined only once." + }, { + "key": "errors", + "name": "Parsing Errors", + "description": "This rule looks for recoverable syntax errors." + }, { + "key": "overqualified-elements", + "name": "Disallow overqualified elements", + "description": "Don't use classes or IDs with elements (a.foo or a#foo)." + }, { + "key": "vendor-prefix", + "name": "Require standard property with vendor prefix", + "description": "When using a vendor-prefixed property, make sure to include the standard one." + }, { + "key": "fallback-colors", + "name": "Require fallback colors", + "description": "For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color." + }, { + "key": "regex-selectors", + "name": "Disallow selectors that look like regexs", + "description": "Selectors that look like regular expressions are slow and should be avoided." + }, { + "key": "unqualified-attributes", + "name": "Disallow unqualified attribute selectors", + "description": "Unqualified attribute selectors are known to be slow." + }, { + "key": "universal-selector", + "name": "Disallow universal selector", + "description": "The universal selector (*) is known to be slow." + }, { + "key": "box-sizing", + "name": "Disallow use of box-sizing", + "description": "The box-sizing properties isn't supported in IE6 and IE7." + }, { + "key": "display-property-grouping", + "name": "Require properties appropriate for display", + "description": "Certain properties shouldn't be used with certain display property values." + }, { + "key": "ids", + "name": "Disallow IDs in selectors", + "description": "Selectors should not contain IDs." + }, { + "key": "gradients", + "name": "Require all gradient definitions", + "description": "When using a vendor-prefixed gradient, make sure to use them all." + }, { + "key": "zero-units", + "name": "Disallow units for 0 values", + "description": "You don't need to specify units when a value is 0." + }, { + "key": "duplicate-properties", + "name": "Disallow duplicate properties", + "description": "Duplicate properties must appear one after the other." + }, { + "key": "compatible-vendor-prefixes", + "name": "Require compatible vendor prefixes", + "description": "Include all compatible vendor prefixes to reach a wider range of users." + }, { + "key": "outline-none", + "name": "Disallow outline: none", + "description": "Use of outline: none or outline: 0 should be limited to :focus rules." + }, { + "key": "floats", + "name": "Disallow too many floats", + "description": "This rule tests if the float property is used too many times" + }, { + "key": "known-properties", + "name": "Require use of known properties", + "description": "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property." + }, { + "key": "font-sizes", + "name": "Disallow too many font sizes", + "description": "Checks the number of font-size declarations." + }, { + "key": "font-faces", + "name": "Don't use too many web fonts", + "description": "Too many different web fonts in the same stylesheet." + }, { + "key": "duplicate-background-images", + "name": "Disallow duplicate background images", + "description": "Every background-image should be unique. Use a common class for e.g. sprites." + }, { + "key": "order-alphabetical", + "name": "Alphabetical order", + "description": "Assure properties are in alphabetical order" + }, { + "key": "rules-count", + "name": "Rules Count", + "description": "Assure properties are in alphabetical order" + }, { + "key": "selector-max-approaching", + "name": "Warn when approaching the 4095 selector limit for IE", + "description": "Will warn when selector count is >= 3800 selectors." + }, { + "key": "selector-max", + "name": "Error when past the 4095 selector limit for IE", + "description": "Will error when selector count is > 4095." + }, { + "key": "selector-newline", + "name": "Disallow new-line characters in selectors", + "description": "New-line characters in selectors are usually a forgotten comma and not a descendant combinator.", + "severity": "MINOR" + }, { + "key": "shorthand", + "name": "Require shorthand properties", + "description": "Use shorthand properties where possible.", + "severity": "MAJOR" + }, { + "key": "star-property-hack", + "name": "Disallow properties with a star prefix", + "description": "Checks for the star property hack (targets IE6/7)", + "severity": "BLOCKER" + }, { + "key": "text-indent", + "name": "Disallow negative text-indent", + "description": "Checks for text indent less than -99px", + "severity": "CRITICAL" + }, { + "key": "underscore-property-hack", + "name": "Disallow properties with an underscore prefix", + "description": "Checks for the underscore property hack (targets IE6)", + "severity": "major" + }, { + "key": "bulletproof-font-face", + "name": "Use the bulletproof @font-face syntax", + "description": "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax)." + }] }] } diff --git a/sonar-report-core/src/test/resources/rules/csslint.json b/sonar-report-core/src/test/resources/rules/csslint.json index 0b059b7..adbb9d5 100644 --- a/sonar-report-core/src/test/resources/rules/csslint.json +++ b/sonar-report-core/src/test/resources/rules/csslint.json @@ -1,154 +1,181 @@ [{ - "key": "import", - "name": "Disallow @import", - "description": "Don't use @import, use instead." -}, { - "key": "important", - "name": "Disallow !important", - "description": "Be careful when using !important declaration" -}, { - "key": "box-model", - "name": "Beware of broken box size", - "description": "Don't use width or height when using padding or border." -}, { - "key": "empty-rules", - "name": "Disallow empty rules", - "description": "Rules without any properties specified should be removed." -}, { - "key": "adjoining-classes", - "name": "Disallow adjoining classes", - "description": "Don't use adjoining classes." -}, { - "key": "qualified-headings", - "name": "Disallow qualified headings", - "description": "Headings should not be qualified (namespaced)." -}, { - "key": "unique-headings", - "name": "Headings should only be defined once", - "description": "Headings should be defined only once." -}, { - "key": "errors", - "name": "Parsing Errors", - "description": "This rule looks for recoverable syntax errors." -}, { - "key": "overqualified-elements", - "name": "Disallow overqualified elements", - "description": "Don't use classes or IDs with elements (a.foo or a#foo)." -}, { - "key": "vendor-prefix", - "name": "Require standard property with vendor prefix", - "description": "When using a vendor-prefixed property, make sure to include the standard one." -}, { - "key": "fallback-colors", - "name": "Require fallback colors", - "description": "For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color." -}, { - "key": "regex-selectors", - "name": "Disallow selectors that look like regexs", - "description": "Selectors that look like regular expressions are slow and should be avoided." -}, { - "key": "unqualified-attributes", - "name": "Disallow unqualified attribute selectors", - "description": "Unqualified attribute selectors are known to be slow." -}, { - "key": "universal-selector", - "name": "Disallow universal selector", - "description": "The universal selector (*) is known to be slow." -}, { - "key": "box-sizing", - "name": "Disallow use of box-sizing", - "description": "The box-sizing properties isn't supported in IE6 and IE7." -}, { - "key": "display-property-grouping", - "name": "Require properties appropriate for display", - "description": "Certain properties shouldn't be used with certain display property values." -}, { - "key": "ids", - "name": "Disallow IDs in selectors", - "description": "Selectors should not contain IDs." -}, { - "key": "gradients", - "name": "Require all gradient definitions", - "description": "When using a vendor-prefixed gradient, make sure to use them all." -}, { - "key": "zero-units", - "name": "Disallow units for 0 values", - "description": "You don't need to specify units when a value is 0." -}, { - "key": "duplicate-properties", - "name": "Disallow duplicate properties", - "description": "Duplicate properties must appear one after the other." -}, { - "key": "compatible-vendor-prefixes", - "name": "Require compatible vendor prefixes", - "description": "Include all compatible vendor prefixes to reach a wider range of users." -}, { - "key": "outline-none", - "name": "Disallow outline: none", - "description": "Use of outline: none or outline: 0 should be limited to :focus rules." -}, { - "key": "floats", - "name": "Disallow too many floats", - "description": "This rule tests if the float property is used too many times" -}, { - "key": "known-properties", - "name": "Require use of known properties", - "description": "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property." -}, { - "key": "font-sizes", - "name": "Disallow too many font sizes", - "description": "Checks the number of font-size declarations." -}, { - "key": "font-faces", - "name": "Don't use too many web fonts", - "description": "Too many different web fonts in the same stylesheet." -}, { - "key": "duplicate-background-images", - "name": "Disallow duplicate background images", - "description": "Every background-image should be unique. Use a common class for e.g. sprites." -}, { - "key": "order-alphabetical", - "name": "Alphabetical order", - "description": "Assure properties are in alphabetical order" -}, { - "key": "rules-count", - "name": "Rules Count", - "description": "Assure properties are in alphabetical order" -}, { - "key": "selector-max-approaching", - "name": "Warn when approaching the 4095 selector limit for IE", - "description": "Will warn when selector count is >= 3800 selectors." -}, { - "key": "selector-max", - "name": "Error when past the 4095 selector limit for IE", - "description": "Will error when selector count is > 4095." -}, { - "key": "selector-newline", - "name": "Disallow new-line characters in selectors", - "description": "New-line characters in selectors are usually a forgotten comma and not a descendant combinator.", - "severity": "MINOR" -}, { - "key": "shorthand", - "name": "Require shorthand properties", - "description": "Use shorthand properties where possible.", - "severity": "MAJOR" -}, { - "key": "star-property-hack", - "name": "Disallow properties with a star prefix", - "description": "Checks for the star property hack (targets IE6/7)", - "severity": "BLOCKER" -}, { - "key": "text-indent", - "name": "Disallow negative text-indent", - "description": "Checks for text indent less than -99px", - "severity": "CRITICAL" -}, { - "key": "underscore-property-hack", - "name": "Disallow properties with an underscore prefix", - "description": "Checks for the underscore property hack (targets IE6)", - "severity": "major" -}, { - "key": "bulletproof-font-face", - "name": "Use the bulletproof @font-face syntax", - "description": "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax)." -}] \ No newline at end of file + "key": "import", + "name": "Disallow @import", + "description": "Don't use @import, use instead.", + "status": "DEPRECATED", + "tags": ["bad-practice"], + "debt": { + "sqaleRemediation": { + "type": "constant", + "offset": "10min" + }, + "sqaleSubCharacteristic": "READABILITY" + } +}, { + "key": "important", + "name": "Disallow !important", + "description": "Be careful when using !important declaration", + "tags": ["bad-practice", "confusing", "suspicious"], + "debt": { + "sqaleRemediation": { + "type": "linear", + "coeff": "20min", + "effortToFixDescription": "Effort to remove one !important" + }, + "sqaleSubCharacteristic": "UNDERSTANDABILITY" + } +}, { + "key": "box-model", + "name": "Beware of broken box size", + "description": "Don't use width or height when using padding or border.", + "debt": { + "sqaleRemediation": { + "type": "linearWithOffset", + "coeff": "20min", + "offset": "1h", + "effortToFixDescription": "Effort to change box model" + }, + "sqaleSubCharacteristic": "UNDERSTANDABILITY" + } +}, { + "key": "empty-rules", + "name": "Disallow empty rules", + "description": "Rules without any properties specified should be removed." +}, { + "key": "adjoining-classes", + "name": "Disallow adjoining classes", + "description": "Don't use adjoining classes." +}, { + "key": "qualified-headings", + "name": "Disallow qualified headings", + "description": "Headings should not be qualified (namespaced)." +}, { + "key": "unique-headings", + "name": "Headings should only be defined once", + "description": "Headings should be defined only once." +}, { + "key": "errors", + "name": "Parsing Errors", + "description": "This rule looks for recoverable syntax errors." +}, { + "key": "overqualified-elements", + "name": "Disallow overqualified elements", + "description": "Don't use classes or IDs with elements (a.foo or a#foo)." +}, { + "key": "vendor-prefix", + "name": "Require standard property with vendor prefix", + "description": "When using a vendor-prefixed property, make sure to include the standard one." +}, { + "key": "fallback-colors", + "name": "Require fallback colors", + "description": "For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color." +}, { + "key": "regex-selectors", + "name": "Disallow selectors that look like regexs", + "description": "Selectors that look like regular expressions are slow and should be avoided." +}, { + "key": "unqualified-attributes", + "name": "Disallow unqualified attribute selectors", + "description": "Unqualified attribute selectors are known to be slow." +}, { + "key": "universal-selector", + "name": "Disallow universal selector", + "description": "The universal selector (*) is known to be slow." +}, { + "key": "box-sizing", + "name": "Disallow use of box-sizing", + "description": "The box-sizing properties isn't supported in IE6 and IE7." +}, { + "key": "display-property-grouping", + "name": "Require properties appropriate for display", + "description": "Certain properties shouldn't be used with certain display property values." +}, { + "key": "ids", + "name": "Disallow IDs in selectors", + "description": "Selectors should not contain IDs." +}, { + "key": "gradients", + "name": "Require all gradient definitions", + "description": "When using a vendor-prefixed gradient, make sure to use them all." +}, { + "key": "zero-units", + "name": "Disallow units for 0 values", + "description": "You don't need to specify units when a value is 0." +}, { + "key": "duplicate-properties", + "name": "Disallow duplicate properties", + "description": "Duplicate properties must appear one after the other." +}, { + "key": "compatible-vendor-prefixes", + "name": "Require compatible vendor prefixes", + "description": "Include all compatible vendor prefixes to reach a wider range of users." +}, { + "key": "outline-none", + "name": "Disallow outline: none", + "description": "Use of outline: none or outline: 0 should be limited to :focus rules." +}, { + "key": "floats", + "name": "Disallow too many floats", + "description": "This rule tests if the float property is used too many times" +}, { + "key": "known-properties", + "name": "Require use of known properties", + "description": "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property." +}, { + "key": "font-sizes", + "name": "Disallow too many font sizes", + "description": "Checks the number of font-size declarations." +}, { + "key": "font-faces", + "name": "Don't use too many web fonts", + "description": "Too many different web fonts in the same stylesheet." +}, { + "key": "duplicate-background-images", + "name": "Disallow duplicate background images", + "description": "Every background-image should be unique. Use a common class for e.g. sprites." +}, { + "key": "order-alphabetical", + "name": "Alphabetical order", + "description": "Assure properties are in alphabetical order" +}, { + "key": "rules-count", + "name": "Rules Count", + "description": "Assure properties are in alphabetical order" +}, { + "key": "selector-max-approaching", + "name": "Warn when approaching the 4095 selector limit for IE", + "description": "Will warn when selector count is >= 3800 selectors." +}, { + "key": "selector-max", + "name": "Error when past the 4095 selector limit for IE", + "description": "Will error when selector count is > 4095." +}, { + "key": "selector-newline", + "name": "Disallow new-line characters in selectors", + "description": "New-line characters in selectors are usually a forgotten comma and not a descendant combinator.", + "severity": "MINOR" +}, { + "key": "shorthand", + "name": "Require shorthand properties", + "description": "Use shorthand properties where possible.", + "severity": "MAJOR" +}, { + "key": "star-property-hack", + "name": "Disallow properties with a star prefix", + "description": "Checks for the star property hack (targets IE6/7)", + "severity": "BLOCKER" +}, { + "key": "text-indent", + "name": "Disallow negative text-indent", + "description": "Checks for text indent less than -99px", + "severity": "CRITICAL" +}, { + "key": "underscore-property-hack", + "name": "Disallow properties with an underscore prefix", + "description": "Checks for the underscore property hack (targets IE6)", + "severity": "major" +}, { + "key": "bulletproof-font-face", + "name": "Use the bulletproof @font-face syntax", + "description": "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax)." +}] diff --git a/sonar-test-junit/pom.xml b/sonar-test-junit/pom.xml index 2b60ecb..efbdee9 100644 --- a/sonar-test-junit/pom.xml +++ b/sonar-test-junit/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 fr.sii.sonar sonar-sii-plugin-parent - 2.0-SNAPSHOT + 2.0.1-SNAPSHOT sonar-test-junit diff --git a/sonar-web-frontend-angular-eslint/pom.xml b/sonar-web-frontend-angular-eslint/pom.xml index 83d8415..af9a2c4 100644 --- a/sonar-web-frontend-angular-eslint/pom.xml +++ b/sonar-web-frontend-angular-eslint/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 fr.sii.sonar sonar-sii-plugin-parent - 2.0-SNAPSHOT + 2.0.1-SNAPSHOT sonar-web-frontend-angular-eslint diff --git a/sonar-web-frontend-angular-eslint/src/main/java/fr/sii/sonar/web/frontend/ng/eslint/quality/EslintAngularQualityConstants.java b/sonar-web-frontend-angular-eslint/src/main/java/fr/sii/sonar/web/frontend/ng/eslint/quality/EslintAngularQualityConstants.java index 05c01c2..5d252b8 100644 --- a/sonar-web-frontend-angular-eslint/src/main/java/fr/sii/sonar/web/frontend/ng/eslint/quality/EslintAngularQualityConstants.java +++ b/sonar-web-frontend-angular-eslint/src/main/java/fr/sii/sonar/web/frontend/ng/eslint/quality/EslintAngularQualityConstants.java @@ -10,7 +10,7 @@ public class EslintAngularQualityConstants extends EslintAngularConstants implem public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.quality.eslint.angular.file.missing.fail"; public static final String SKIP_FILE_METRICS_KEY = "sonar.sii.quality.eslint.angular.file.metrics.skip"; public static final String SKIP_FILE_METRICS_DEFVALUE = "false"; - public static final String REPORT_PATH_DEFVALUE = "/report/eslint-angular.json"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/eslint-angular.json"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String RULES_PATH = "/rules/eslint-angular.json"; public static final String REPOSITORY_NAME = "Eslint for AngularJS"; diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular.css b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular.css new file mode 100644 index 0000000..be4a9ef --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular.css @@ -0,0 +1,83 @@ +.ehd h1.details { + margin-top: 20px; + margin-bottom: 20px; + border-bottom: 1px solid #ccc; +} + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + color: #333; + background: #f8f8f8; +} +.hljs-comment, +.hljs-quote { + color: #998; + font-style: italic; +} +.hljs-keyword, +.hljs-selector-tag, +.hljs-subst { + color: #333; + font-weight: bold; +} +.hljs-number, +.hljs-literal, +.hljs-variable, +.hljs-template-variable, +.hljs-tag .hljs-attr { + color: #008080; +} +.hljs-string, +.hljs-doctag { + color: #d14; +} +.hljs-title, +.hljs-section, +.hljs-selector-id { + color: #900; + font-weight: bold; +} +.hljs-subst { + font-weight: normal; +} +.hljs-type, +.hljs-class .hljs-title { + color: #458; + font-weight: bold; +} +.hljs-tag, +.hljs-name, +.hljs-attribute { + color: #000080; + font-weight: normal; +} +.hljs-regexp, +.hljs-link { + color: #009926; +} +.hljs-symbol, +.hljs-bullet { + color: #990073; +} +.hljs-built_in, +.hljs-builtin-name { + color: #0086b3; +} +.hljs-meta { + color: #999; + font-weight: bold; +} +.hljs-deletion { + background: #fdd; +} +.hljs-addition { + background: #dfd; +} +.hljs-emphasis { + font-style: italic; +} +.hljs-strong { + font-weight: bold; +} \ No newline at end of file diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular.json b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular.json index 63ace30..bf4311b 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular.json +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular.json @@ -1,278 +1,771 @@ -[ - { - "key": "ng_angularelement", - "name": " ng angularelement ", - "description": " The angular.element method should be used instead of the $ or jQuery object (if you are using jQuery of course). If the jQuery library is imported, angular.element will be a wrapper around the jQuery object. ", - "severity": "MAJOR" - }, - { - "key": "ng_controller_as", - "name": " ng controller as ", - "description": " You should not set properties on $scope in controllers. Use controllerAs syntax and add data to 'this'. Implements 'this' check part of [Y031](https://github.com/johnpapa/angularjs-styleguide#style-y031). The second parameter can be a Regexp for identifying controller functions (when using something like Browserify) ", - "severity": "CRITICAL" - }, - { - "key": "ng_controller_as_route", - "name": " ng controller as route ", - "description": " You should use Angular's controllerAs syntax when defining routes or states. Implements route part [Y031](https://github.com/johnpapa/angularjs-styleguide#style-y031) ", - "severity": "CRITICAL" - }, - { - "key": "ng_controller_as_vm", - "name": " ng controller as vm ", - "description": " You should use a capture variable for 'this' when using the controllerAs syntax. [Y031](https://github.com/johnpapa/angularjs-styleguide#style-y032). The second parameter specifies the capture variable you want to use in your application. The third parameter can be a Regexp for identifying controller functions (when using something like Browserify) ", - "severity": "CRITICAL" - }, - { - "key": "ng_controller_name", - "name": " ng controller name ", - "description": " All your controllers should have a name starting with the parameter you can define in your config object. The second parameter can be a Regexp. (\"ng_controller_name\": [2, \"ng\"]) [Y123](https://github.com/johnpapa/angularjs-styleguide#style-y123), [Y124](https://github.com/johnpapa/angularjs-styleguide#style-y124)", - "severity": "CRITICAL" - }, - { - "key": "ng_deferred", - "name": " ng deferred ", - "description": " When you want to create a new promise, you should not use the $q.deferred anymore. Prefer the new syntax : $q(function(resolve, reject){})", - "severity": "MINOR" - }, - { - "key": "ng_definedundefined", - "name": " ng definedundefined ", - "description": " You should use the angular.isUndefined or angular.isDefined methods instead of using the keyword undefined. We also check the use of !angular.isUndefined and !angular.isDefined (should prefer the reverse function)", - "severity": "CRITICAL" - }, - { - "key": "ng_di", - "name": " ng di ", - "description": " All your DI should use the same syntax : the Array or function syntaxes (\"ng_di\": [2, \"function or array\"])", - "severity": "CRITICAL" - }, - { - "key": "ng_directive_name", - "name": " ng directive name ", - "description": " All your directives should have a name starting with the parameter you can define in your config object. The second parameter can be a Regexp. You can not prefix your directives by \"ng\" (reserved keyword for AngularJS directives) (\"ng_directive_name\": [2, \"ng\"]) [Y073](https://github.com/johnpapa/angularjs-styleguide#style-y073), [Y126](https://github.com/johnpapa/angularjs-styleguide#style-y126) ", - "severity": "MINOR" - }, - { - "key": "ng_directive_restrict", - "name": " ng directive restrict ", - "description": " Not all directive restrictions may be desirable. Also it might be desirable to define default restrictions, or explicitly not. The default configuration limits the restrictions AE Y074 and disallows explicitly specifying a default. (\"directive-restrict\": [0, {\"restrict\": \"AE\", \"explicit\": \"never\"}])", - "severity": "MINOR" - }, - { - "key": "ng_component_limit", - "name": " ng component limit ", - "description": " The number of AngularJS components in one file should be limited. The default limit is one, which follows [Y001](https://github.com/johnpapa/angular-styleguide#style-y001)", - "severity": "MINOR" - }, - { - "key": "ng_document_service", - "name": " ng document service ", - "description": " Instead of the default document object, you should prefer the AngularJS wrapper service $document. [Y180](https://github.com/johnpapa/angularjs-styleguide#style-y180) ", - "severity": "CRITICAL" - }, - { - "key": "ng_empty_controller", - "name": " ng empty controller ", - "description": " If you have one empty controller, maybe you have linked it in your Router configuration or in one of your views. You can remove this declaration because this controller is useless ", - "severity": "MINOR" - }, - { - "key": "ng_file_name", - "name": " ng file name ", - "description": " All your file names should match the angular component name. The second parameter can be a config object [2, {nameStyle: 'dash', typeSeparator: 'dot', ignoreTypeSuffix: true, ignorePrefix: 'ui'}] to match 'avenger-profile.directive.js' or 'avanger-api.service.js'. Possible values for 'typeSeparator' and 'nameStyle' are 'dot', 'dash' and 'underscore'. The options 'ignoreTypeSuffix' ignores camel cased suffixes like 'someController' or 'myService' and 'ignorePrefix' ignores namespace prefixes like 'ui'. [Y120](https://github.com/johnpapa/angular-styleguide#style-y120) [Y121](https://github.com/johnpapa/angular-styleguide#style-y121)", - "severity": "MINOR" - }, - { - "key": "ng_filter_name", - "name": " ng filter name ", - "description": " All your filters should have a name starting with the parameter you can define in your config object. The second parameter can be a Regexp. (\"ng_filter_name\": [2, \"ng\"]) ", - "severity": "MINOR" - }, - { - "key": "ng_foreach", - "name": " ng foreach ", - "description": " You should use the angular.forEach method instead of the default JavaScript implementation [].forEach.", - "severity": "MINOR" - }, - { - "key": "ng_function_type", - "name": " ng function type ", - "description": " Anonymous or named functions inside AngularJS components. The first parameter sets which type of function is required and can be 'named' or 'anonymous'. The second parameter is an optional list of angular object names. [Y024](https://github.com/johnpapa/angular-styleguide/blob/master/README.md#style-y024)", - "severity": "MINOR" - }, - { - "key": "ng_interval_service", - "name": " ng interval service ", - "description": " Instead of the default setInterval function, you should use the AngularJS wrapper service $interval [Y181](https://github.com/johnpapa/angularjs-styleguide#style-y181) ", - "severity": "CRITICAL" - }, - { - "key": "ng_json_functions", - "name": " ng json functions ", - "description": " You should use angular.fromJson or angular.toJson instead of JSON.parse and JSON.stringify ", - "severity": "CRITICAL" - }, - { - "key": "ng_log", - "name": " ng log ", - "description": " You should use $log service instead of console for the methods 'log', 'debug', 'error', 'info', 'warn'", - "severity": "CRITICAL" - }, - { - "key": "ng_dependency_order", - "name": " ng dependency order ", - "description": " Module dependencies should be sorted in a logical manner. This rule provides two ways to sort modules, grouped or ungrouped. In grouped mode the modules should be grouped in the order: standard modules - third party modules - custom modules. The modules should be sorted alphabetically within its group. A prefix can be specified to determine which prefix the custom modules have. Without grouped set to false all dependencies combined should be sorted alphabetically. ('module-dependency-order', [2, {grouped: true, prefix: \"app\"}])", - "severity": "MINOR" - }, - { - "key": "ng_module_getter", - "name": " ng module getter ", - "description": " When using a module, avoid using a variable and instead use chaining with the getter syntax [Y022](https://github.com/johnpapa/angular-styleguide#style-y022)", - "severity": "CRITICAL" - }, - { - "key": "ng_module_name", - "name": " ng module name ", - "description": " When you create a new module, its name should start with the parameter you can define in your config object. The second parameter can be a Regexp. You can not prefix your modules by \"ng\" (reserved keyword for AngularJS modules) (\"ng_module_name\": [2, \"ng\"]) [Y127](https://github.com/johnpapa/angularjs-styleguide#style-y127)", - "severity": "MINOR" - }, - { - "key": "ng_module_setter", - "name": " ng module setter ", - "description": " Declare modules without a variable using the setter syntax.[Y021](https://github.com/johnpapa/angular-styleguide#style-y021)", - "severity": "CRITICAL" - }, - { - "key": "no_angular_mock", - "name": " ng no angular mock ", - "description": " All methods defined in the angular.mock object are also available in the object window. So you can remove angular.mock from your code", - "severity": "MINOR" - }, - { - "key": "no_controller", - "name": " ng no controller ", - "description": " According to the Component-First pattern, we should avoid the use of AngularJS controller.", - "severity": "MINOR" - }, - { - "key": "ng_no_cookiestore", - "name": " ng no cookiestore ", - "description": " In Angular 1.4, the $cookieStore service is now deprected. Please use the $cookies service instead", - "severity": "CRITICAL" - }, - { - "key": "ng_no_digest", - "name": " ng no digest ", - "description": " The scope's $digest() method shouldn't be used. You should prefer the $apply method. ", - "severity": "CRITICAL" - }, - { - "key": "ng_no_jquery_angularelement", - "name": " ng no jquery angularelement ", - "description": " You should not wrap angular.element object into jQuery(), because angular.element already return jQLite element", - "severity": "CRITICAL" - }, - { - "key": "ng_no_private_call", - "name": " ng no private call ", - "description": " All scope's properties/methods starting with $$ are used interally by AngularJS. You should not use them directly. ", - "severity": "CRITICAL" - }, - { - "key": "ng_no_services", - "name": " ng no services ", - "description": " Some services should be used only in a specific AngularJS service (Ajax-based service for example), in order to follow the separation of concerns paradigm ", - "severity": "CRITICAL" - }, - { - "key": "ng_no_service_method", - "name": " ng no service method ", - "description": " You should prefer the factory() method instead of service() [Y181](https://github.com/johnpapa/angularjs-styleguide#style-y181)", - "severity": "CRITICAL" - }, - { - "key": "ng_on_watch", - "name": " ng on watch ", - "description": " Watch and On methods on the scope object should be assigned to a variable, in order to be deleted in a $destroy event handler [Y035](https://github.com/johnpapa/angularjs-styleguide#style-y035) ", - "severity": "CRITICAL" - }, - { - "key": "ng_rest_service", - "name": " ng rest service ", - "description": " Check the service used to send request to your REST API. This rule can have one parameter, with one of the following values: $http, $resource or Restangular ('rest-service': [0, '$http']).", - "severity": "MINOR" - }, - { - "key": "ng_service_name", - "name": " ng service name ", - "description": " All your services should have a name starting with the parameter you can define in your config object. The second parameter can be a Regexp. You can not prefix your services by \"$\" (reserved keyword for AngularJS services) (\"ng_service_name\": [2, \"ng\"]) [Y125](https://github.com/johnpapa/angularjs-styleguide#style-y125) ", - "severity": "CRITICAL" - }, - { - "key": "ng_timeout_service", - "name": " ng timeout service ", - "description": " Instead of the default setTimeout function, you should use the AngularJS wrapper service $timeout [Y181](https://github.com/johnpapa/angularjs-styleguide#style-y181) ", - "severity": "CRITICAL" - }, - { - "key": "ng_typecheck_array", - "name": " ng typecheck array ", - "description": " You should use the angular.isArray method instead of the default JavaScript implementation (typeof [] === \"[object Array]\"). ", - "severity": "CRITICAL" - }, - { - "key": "ng_typecheck_boolean", - "name": " ng typecheck boolean ", - "description": " You should use the angular.isBoolean method instead of the default JavaScript implementation (typeof true === \"[object Boolean]\"). ", - "severity": "CRITICAL" - }, - { - "key": "ng_typecheck_date", - "name": " ng typecheck date ", - "description": " You should use the angular.isDate method instead of the default JavaScript implementation (typeof new Date() === \"[object Date]\"). ", - "severity": "CRITICAL" - }, - { - "key": "ng_typecheck_function", - "name": " ng typecheck function ", - "description": " You should use the angular.isFunction method instead of the default JavaScript implementation (typeof function(){} ===\"[object Function]\"). ", - "severity": "CRITICAL" - }, - { - "key": "ng_typecheck_number", - "name": " ng typecheck number ", - "description": " You should use the angular.isNumber method instead of the default JavaScript implementation (typeof 3 === \"[object Number]\"). ", - "severity": "CRITICAL" - }, - { - "key": "ng_typecheck_object", - "name": " ng typecheck object ", - "description": " You should use the angular.isObject method instead of the default JavaScript implementation (typeof {} === \"[object Object]\"). ", - "severity": "CRITICAL" - }, - { - "key": "ng_typecheck_regexp", - "name": " ng typecheck regexp ", - "description": " You should use the angular.isRegexp method instead of the default JavaScript implementation (toString.call(/^A/) === \"[object RegExp]\"). ", - "severity": "CRITICAL" - }, - { - "key": "ng_typecheck_string", - "name": " ng typecheck string ", - "description": " You should use the angular.isString method instead of the default JavaScript implementation (typeof \"\" === \"[object String]\"). ", - "severity": "CRITICAL" - }, - { - "key": "ng_watchers_execution", - "name": " ng watchers execution ", - "description": " For the execution of the watchers, the $digest method will start from the scope in which we call the method. This will cause an performance improvement comparing to the $apply method, who start from the $rootScope", - "severity": "MINOR" - }, - { - "key": "ng_window_service", - "name": " ng window service ", - "description": " Instead of the default window object, you should prefer the AngularJS wrapper service $window. [Y180](https://github.com/johnpapa/angularjs-styleguide#style-y180) ", - "severity": "CRITICAL" - } -] +[ { + "key" : "ng_angularelement", + "name" : "use angular.element instead of $ or jQuery", + "description" : "use angular.element instead of $ or jQuery", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_controller_as", + "name" : "disallow assignments to $scope in controllers (y031)", + "description" : "disallow assignments to $scope in controllers", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_CHANGEABILITY" + } +}, { + "key" : "ng_controller_as_route", + "name" : "require the use of controllerAs in routes or states (y031)", + "description" : "require the use of controllerAs in routes or states", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "pitfall", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "ng_controller_as_vm", + "name" : "require and specify a capture variable for this in controllers (y032)", + "description" : "require and specify a capture variable for this in controllers", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "pitfall", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "ng_controller_name", + "name" : "require and specify a prefix for all controller names (y123, y124)", + "description" : "require and specify a prefix for all controller names", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ng_deferred", + "name" : "use $q(function(resolve, reject){}) instead of $q.deferred", + "description" : "use $q(function(resolve, reject){}) instead of $q.deferred", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "obsolete" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_definedundefined", + "name" : "use angular.isDefined and angular.isUndefined instead of other undefined checks", + "description" : "use angular.isDefined and angular.isUndefined instead of other undefined checks", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice", "cross-browser" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_di", + "name" : "require a consistent DI syntax", + "description" : "require a consistent DI syntax", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "convention", "injection" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "ng_directive_name", + "name" : "require and specify a prefix for all directive names (y073, y126)", + "description" : "require and specify a prefix for all directive names", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ng_directive_restrict", + "name" : "disallow any other directive restrict than 'A' or 'E' (y074)", + "description" : "disallow any other directive restrict than 'A' or 'E'", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "ng_component_limit", + "name" : "limit the number of angular components per file (y001)", + "description" : "limit the number of angular components per file", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "ng_document_service", + "name" : "use $document instead of document (y180)", + "description" : "use $document instead of document", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_empty_controller", + "name" : "disallow empty controllers", + "description" : "disallow empty controllers", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention", "dead-code" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_file_name", + "name" : "require and specify a consistent component name pattern (y120, y121)", + "description" : "require and specify a consistent component name pattern", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "ng_filter_name", + "name" : "require and specify a prefix for all filter names", + "description" : "require and specify a prefix for all filter names", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ng_foreach", + "name" : "use angular.forEach instead of native Array.prototype.forEach", + "description" : "use angular.forEach instead of native Array.prototype.forEach", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_function_type", + "name" : "require and specify a consistent function style for components ('named' or 'anonymous') (y024)", + "description" : "require and specify a consistent function style for components", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "ng_interval_service", + "name" : "use $interval instead of setInterval (y181)", + "description" : "use $interval instead of setInterval", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_json_functions", + "name" : "use angular.fromJson and 'angular.toJson' instead of JSON.parse and JSON.stringify", + "description" : "enforce use of angular.fromJson and 'angular.toJson'", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_log", + "name" : "use the $log service instead of the console methods", + "description" : "use the $log service instead of the console methods", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_dependency_order", + "name" : " ng dependency order ", + "description" : " Module dependencies should be sorted in a logical manner. This rule provides two ways to sort modules, grouped or ungrouped. In grouped mode the modules should be grouped in the order: standard modules - third party modules - custom modules. The modules should be sorted alphabetically within its group. A prefix can be specified to determine which prefix the custom modules have. Without grouped set to false all dependencies combined should be sorted alphabetically. ('module-dependency-order', [2, {grouped: true, prefix: \"app\"}])", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention", "injection" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ng_module_getter", + "name" : "disallow to reference modules with variables and require to use the getter syntax instead angular.module('myModule') (y022)", + "description" : "enforce to reference modules with the getter syntax", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "ng_module_name", + "name" : "require and specify a prefix for all module names (y127)", + "description" : "require and specify a prefix for all module names", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ng_module_setter", + "name" : "disallow to assign modules to variables (linked to module-getter (y021)", + "description" : "disallow to assign modules to variables", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "ng_no_cookiestore", + "name" : "use $cookies instead of $cookieStore", + "description" : "use $cookies instead of $cookieStore", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice", "obsolete" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_no_digest", + "name" : " ng no digest ", + "description" : " The scope's $digest() method shouldn't be used. You should prefer the $apply method. ", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ng_no_jquery_angularelement", + "name" : "disallow to wrap angular.element objects with jQuery or $", + "description" : "disallow to wrap angular.element objects with jQuery or $", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "pitfall", "bad-practice", "performance", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "ng_no_private_call", + "name" : "disallow use of internal angular properties prefixed with $$", + "description" : "disallow use of internal angular properties prefixed with $$", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "ng_no_services", + "name" : "disallow DI of specified services for other angular components ($http for controllers, filters and directives)", + "description" : "disallow DI of specified services", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice", "pitfall", "injection" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_CHANGEABILITY" + } +}, { + "key" : "ng_no_service_method", + "name" : "use factory() instead of service() (y040)", + "description" : "use factory() instead of service()", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_on_watch", + "name" : "require $on and $watch deregistration callbacks to be saved in a variable", + "description" : "require $on and $watch deregistration callbacks to be saved in a variable", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice", "memory-leak" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "EFFICIENCY_COMPLIANCE" + } +}, { + "key" : "ng_rest_service", + "name" : "disallow different rest service and specify one of '$http', '$resource', 'Restangular'", + "description" : "disallow different rest service and specify one of '$http', '$resource', 'Restangular'", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "ng_service_name", + "name" : "require and specify a prefix for all service names (y125)", + "description" : "require and specify a prefix for all service names", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ng_timeout_service", + "name" : "use $timeout instead of setTimeout (y181)", + "description" : "use $timeout instead of setTimeout", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_typecheck_array", + "name" : "use angular.isArray instead of typeof comparisons", + "description" : "use angular.isArray instead of typeof comparisons", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_typecheck_boolean", + "name" : " ng typecheck boolean ", + "description" : " You should use the angular.isBoolean method instead of the default JavaScript implementation (typeof true === \"[object Boolean]\"). ", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_typecheck_date", + "name" : "use angular.isDate instead of typeof comparisons", + "description" : "use angular.isDate instead of typeof comparisons", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_typecheck_function", + "name" : "use angular.isFunction instead of typeof comparisons", + "description" : "use angular.isFunction instead of typeof comparisons", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_typecheck_number", + "name" : "use angular.isNumber instead of typeof comparisons", + "description" : "use angular.isNumber instead of typeof comparisons", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_typecheck_object", + "name" : "use angular.isObject instead of typeof comparisons", + "description" : "use angular.isObject instead of typeof comparisons", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_typecheck_regexp", + "name" : " ng typecheck regexp ", + "description" : " You should use the angular.isRegexp method instead of the default JavaScript implementation (toString.call(/^A/) === \"[object RegExp]\"). ", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_typecheck_string", + "name" : "use angular.isString instead of typeof comparisons", + "description" : "use angular.isString instead of typeof comparisons", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_watchers_execution", + "name" : "require and specify consistent use $scope.digest() or $scope.apply()", + "description" : "require and specify consistent use $scope.digest() or $scope.apply()", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "CPU_EFFICIENCY" + } +}, { + "key" : "ng_window_service", + "name" : "use $window instead of window (y180)", + "description" : "use $window instead of window", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "ng_di_unused", + "name" : "disallow unused DI parameters", + "description" : "disallow unused DI parameters", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "injection", "dead-code" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ng_no_controller", + "name" : "disallow use of controllers (according to the component first pattern)", + "description" : "disallow use of controllers (according to the component first pattern)", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "ng_no_inline_template", + "name" : "disallow the use of inline templates", + "description" : "disallow the use of inline templates", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ng_no_run_logic", + "name" : "keep run functions clean and simple (y171)", + "description" : "keep run functions clean and simple", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice", "tests" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "UNIT_TESTABILITY" + } +}, { + "key" : "ng_no_directive_replace", + "name" : "disallow the deprecated directive replace property", + "description" : "disallow the deprecated directive replace property", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice", "obsolete" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "ng_no_http_callback", + "name" : "disallow the $http methods success() and error()", + "description" : "disallow the $http methods success() and error()", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "angular", "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "ng_di_order", + "name" : "require DI parameters to be sorted alphabetically", + "description" : "require DI parameters to be sorted alphabetically", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention", "injection" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ng_dumb_inject", + "name" : "unittest inject functions should only consist of assignments from injected values to describe block variables", + "description" : "unittest inject functions should only consist of assignments from injected values to describe block variables", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention", "injection", "tests" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "TESTABILITY_COMPLIANCE" + } +}, { + "key" : "ng_module_dependency_order", + "name" : "require a consistent order of module dependencies", + "description" : "require a consistent order of module dependencies", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ng_one_dependency_per_line", + "name" : "require all DI parameters to be located in their own line", + "description" : "require all DI parameters to be located in their own line", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "convention", "injection" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ng_no_angular_mock", + "name" : "require to use angular.mock methods directly", + "description" : "require to use angular.mock methods directly", + "severity" : "MINOR", + "status" : null, + "tags" : [ "angular", "eslint", "pitfall", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +} ] \ No newline at end of file diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_angularelement.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_angularelement.html index b2d42de..7aadcfa 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_angularelement.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_angularelement.html @@ -1 +1,28 @@ - The angular.element method should be used instead of the $ or jQuery object (if you are using jQuery of course). If the jQuery library is imported, angular.element will be a wrapper around the jQuery object. \ No newline at end of file +

Details

+ + +

angularelement - use angular.element instead of $ or jQuery

+ +

The angular.element method should be used instead of the $ or jQuery object (if you are using jQuery of course). +If the jQuery library is imported, angular.element will be a wrapper around the jQuery object.

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/angularelement: 2*/

// invalid
$('.some-class'); // error: You should use angular.element instead of the jQuery $ object

// invalid
jQuery('.another-class'); // error: You should use angular.element instead of the jQuery $ object
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/angularelement: 2*/

// valid
angular.element('.some-class');
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_component_limit.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_component_limit.html new file mode 100644 index 0000000..ae63887 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_component_limit.html @@ -0,0 +1,46 @@ +

Details

+ + +

component-limit - limit the number of angular components per file

+ +

The number of AngularJS components in one file should be limited. +The default limit is one.

+ +
    +
  • The acceptable number of components. (Default: 1)
  • +
+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems with default config;

+ +
/*eslint angular/component-limit: 2*/

// invalid
angular.module('myModule').controller('ControllerOne', function() {
// ...
}).directive('directiveTwo', function() {
// ...
}); // error: There may be at most 1 AngularJS component per file, but found 2
+ +

The following patterns are not considered problems with default config;

+ +
/*eslint angular/component-limit: 2*/

// valid
angular.module('myModule').controller('SomeController', function() {
// ...
});

// valid
angular.module('myModule').directive('myDirective', function() {
// ...
});
+ +

The following patterns are considered problems when configured 3:

+ +
/*eslint angular/component-limit: [2,3]*/

// invalid
angular.module('myModule').controller('ControllerOne', function() {
// ...
}).directive('directiveTwo', function() {
// ...
}).factory('serviceThree', function() {
// ...
}).filter('filterFour', function() {
// ...
}); // error: There may be at most 3 AngularJS components per file, but found 4
+ +

The following patterns are not considered problems when configured 3:

+ +
/*eslint angular/component-limit: [2,3]*/

// valid
angular.module('myModule').controller('ControllerOne', function() {
// ...
}).directive('directiveTwo', function() {
// ...
}).factory('serviceThree', function() {
// ...
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.11.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_as.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_as.html index da83365..078e76a 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_as.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_as.html @@ -1 +1,35 @@ - You should not set properties on $scope in controllers. Use controllerAs syntax and add data to 'this'. Implements 'this' check part of [Y031](https://github.com/johnpapa/angularjs-styleguide#style-y031). The second parameter can be a Regexp for identifying controller functions (when using something like Browserify) \ No newline at end of file +

Details

+ + +

controller-as - disallow assignments to $scope in controllers

+ +

You should not set properties on $scope in controllers. +Use controllerAs syntax and add data to 'this'. +The second parameter can be a Regexp for identifying controller functions (when using something like Browserify)

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/controller-as: 2*/

// invalid
angular.module("myModule").controller("SomeController", function($scope) {
$scope.value = 42;
}); // error: You should not set properties on $scope in controllers. Use controllerAs syntax and add data to "this"
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/controller-as: 2*/

// valid
angular.module("myModule").controller("SomeController", function($scope) {
// this for values
this.value = 42;

// $scope is fine for watchers
$scope.$watch(angular.bind(this, function () {
return this.value
}), function () {
// ...
});
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_as_route.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_as_route.html index a5a0271..be9f99b 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_as_route.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_as_route.html @@ -1 +1,33 @@ - You should use Angular's controllerAs syntax when defining routes or states. Implements route part [Y031](https://github.com/johnpapa/angularjs-styleguide#style-y031) \ No newline at end of file +

Details

+ + +

controller-as-route - require the use of controllerAs in routes or states

+ +

You should use Angular's controllerAs syntax when defining routes or states.

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/controller-as-route: 2*/

// invalid
$routeProvider.when('/myroute', {
controller: 'MyController'
}) // error: Route "/myroute" should use controllerAs syntax

// invalid
$routeProvider.when('/myroute', {
controller: 'MyController as vm',
controllerAs: 'vm'
}) // error: The controllerAs syntax is defined twice for the route "/myroute"
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/controller-as-route: 2*/

// valid
$routeProvider.when('/myroute', {
controller: 'MyController',
controllerAs: 'vm'
});

// valid
$routeProvider.when('/myroute', {
controller: 'MyController as vm'
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_as_vm.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_as_vm.html index 94a006a..f1e802b 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_as_vm.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_as_vm.html @@ -1 +1,47 @@ - You should use a capture variable for 'this' when using the controllerAs syntax. [Y031](https://github.com/johnpapa/angularjs-styleguide#style-y032). The second parameter specifies the capture variable you want to use in your application. The third parameter can be a Regexp for identifying controller functions (when using something like Browserify) \ No newline at end of file +

Details

+ + +

controller-as-vm - require and specify a capture variable for this in controllers

+ +

You should use a capture variable for 'this' when using the controllerAs syntax. +The second parameter specifies the capture variable you want to use in your application. +The third parameter can be a Regexp for identifying controller functions (when using something like Browserify)

+ +
    +
  • The name that should be used for the view model.
  • +
+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems with default config;

+ +
/*eslint angular/controller-as-vm: 2*/

// invalid
angular.module('test').controller('TestController', function() {
this.test = 'test';
}); // error: You should not use "this" directly. Instead, assign it to a variable called "vm"
+ +

The following patterns are not considered problems with default config;

+ +
/*eslint angular/controller-as-vm: 2*/

// valid
angular.module('test').controller('TestController', function() {
var vm = this;
vm.test = 'test';
});
+ +

The following patterns are considered problems when configured "viewModel":

+ +
/*eslint angular/controller-as-vm: [2,"viewModel"]*/

// invalid
angular.module('test').controller('TestController', function() {
var vm = this;
vm.test = 'test';
}); // error: You should assign "this" to a consistent variable across your project: viewModel
+ +

The following patterns are not considered problems when configured "viewModel":

+ +
/*eslint angular/controller-as-vm: [2,"viewModel"]*/

// valid
angular.module('test').controller('TestController', function() {
var viewModel = this;
viewModel.test = 'test';
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_name.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_name.html index 7ffb5ca..0d5a8d5 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_name.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_controller_name.html @@ -1 +1,52 @@ - All your controllers should have a name starting with the parameter you can define in your config object. The second parameter can be a Regexp. ("ng_controller_name": [2, "ng"]) [Y123](https://github.com/johnpapa/angularjs-styleguide#style-y123), [Y124](https://github.com/johnpapa/angularjs-styleguide#style-y124) \ No newline at end of file +

Details

+ + +

controller-name - require and specify a prefix for all controller names

+ +

All your controllers should have a name starting with the parameter you can define in your config object. +The second parameter can be a Regexp wrapped in quotes. +("controller-name": [2, "ng"])

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems with default config;

+ +
/*eslint angular/controller-name: 2*/

// invalid
angular.module('myModule').controller('MyCtrl', function () {
// ...
}); // error: The MyCtrl controller should follow this pattern: /[A-Z].*Controller$/
+ +

The following patterns are not considered problems with default config;

+ +
/*eslint angular/controller-name: 2*/

// valid
angular.module('myModule').controller('MyController', function () {
// ...
});
+ +

The following patterns are considered problems when configured "ui":

+ +
/*eslint angular/controller-name: [2,"ui"]*/

// invalid
angular.module('myModule').controller('TabsController', function () {
// ...
}); // error: The TabsController controller should be prefixed by ui
+ +

The following patterns are not considered problems when configured "ui":

+ +
/*eslint angular/controller-name: [2,"ui"]*/

// valid
angular.module('myModule').controller('uiTabsController', function () {
// ...
});
+ +

The following patterns are considered problems when configured "/[A-Z].*Ctrl/":

+ +
/*eslint angular/controller-name: [2,"/[A-Z].*Ctrl/"]*/

// invalid
angular.module('myModule').controller('MyController', function () {
// ...
}); // error: The MyController controller should follow this pattern: /[A-Z].*Ctrl/
+ +

The following patterns are not considered problems when configured "/[A-Z].*Ctrl/":

+ +
/*eslint angular/controller-name: [2,"/[A-Z].*Ctrl/"]*/

// valid
angular.module('myModule').controller('MyCtrl', function () {
// ...
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_deferred.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_deferred.html new file mode 100644 index 0000000..42f8b70 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_deferred.html @@ -0,0 +1,28 @@ +

Details

+ + +

deferred - use $q(function(resolve, reject){}) instead of $q.deferred

+ +

When you want to create a new promise, you should not use the $q.deferred anymore. +Prefer the new syntax : $q(function(resolve, reject){})

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/deferred: 2*/

// invalid
var deferred = $q.defer(); // error: You should not create a new promise with this syntax. Use the $q(function(resolve, reject) {}) syntax.

// invalid
var deferred = _$q_.defer(); // error: You should not create a new promise with this syntax. Use the $q(function(resolve, reject) {}) syntax.
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/deferred: 2*/

// valid
$q(function() {
// ...
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_definedundefined.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_definedundefined.html index 2a31a68..fee7ca8 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_definedundefined.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_definedundefined.html @@ -1 +1,28 @@ - You should use the angular.isUndefined or angular.isDefined methods instead of using the keyword undefined. We also check the use of !angular.isUndefined and !angular.isDefined (should prefer the reverse function) \ No newline at end of file +

Details

+ + +

definedundefined - use angular.isDefined and angular.isUndefined instead of other undefined checks

+ +

You should use the angular.isUndefined or angular.isDefined methods instead of using the keyword undefined. +We also check the use of !angular.isUndefined and !angular.isDefined (should prefer the reverse function)

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/definedundefined: 2*/

// invalid
value === undefined // error: You should not use directly the "undefined" keyword. Prefer angular.isUndefined or angular.isDefined

// invalid
value !== undefined // error: You should not use directly the "undefined" keyword. Prefer angular.isUndefined or angular.isDefined

// invalid
!angular.isUndefined(value) // error: Instead of !angular.isUndefined, you can use the out-of-box angular.isDefined method

// invalid
!angular.isDefined(value) // error: Instead of !angular.isDefined, you can use the out-of-box angular.isUndefined method
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/definedundefined: 2*/

// valid
angular.isUndefined(value)

// valid
angular.isDefined(value)
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_di.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_di.html index 9356581..e17a0e6 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_di.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_di.html @@ -1 +1,35 @@ - All your DI should use the same syntax : the Array or function syntaxes ("ng_di": [2, "function or array"]) \ No newline at end of file +

Details

+ + +

di - require a consistent DI syntax

+ +

All your DI should use the same syntax : the Array, function, or $inject syntaxes ("di": [2, "array, function, or $inject"])

+ +

Examples

+ +

The following patterns are considered problems with default config;

+ +
/*eslint angular/di: 2*/

// invalid
angular.module('myModule').factory('myService', ['$http', '$log', 'anotherService', function ($http, $log, anotherService) {
// ...
}]); // error: You should use the function syntax for DI
+ +

The following patterns are not considered problems with default config;

+ +
/*eslint angular/di: 2*/

// valid
angular.module('myModule').factory('myService', function ($http, $log, anotherService) {
// ...
});
+ +

The following patterns are not considered problems when configured "array":

+ +
/*eslint angular/di: [2,"array"]*/

// valid
angular.module('myModule').factory('myService', ['$http', '$log', 'anotherService', function ($http, $log, anotherService) {
// ...
}]);
+ +

The following patterns are not considered problems when configured "$inject":

+ +
/*eslint angular/di: [2,"$inject"]*/

// valid
angular.module('myModule').factory('myService', myServiceFn);
myServiceFn.$inject=['$http', '$log', 'anotherService'];
function myServiceFn($http, $log, anotherService) {
// ...
}
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_di_order.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_di_order.html new file mode 100644 index 0000000..d1aac14 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_di_order.html @@ -0,0 +1,45 @@ +

Details

+ + +

di-order - require DI parameters to be sorted alphabetically

+ +

Injected dependencies should be sorted alphabetically. +If the second parameter is set to false, values which start and end with an underscore those underscores are stripped. +This means for example that _$httpBackend_ goes before _$http_.

+ +

Examples

+ +

The following patterns are considered problems with default config;

+ +
/*eslint angular/di-order: 2*/

// invalid
angular.module('myModule').factory('myService', function($q, $http) {
// ...
}); // error: Injected values should be sorted alphabetically

// invalid
angular.module('myModule').controller('SomeController', function(myService, $http) {
// ...
}); // error: Injected values should be sorted alphabetically

// invalid
angular.module('myModule').filter('myFilter', function(someService, myService) {
// ...
}); // error: Injected values should be sorted alphabetically
+ +

The following patterns are not considered problems with default config;

+ +
/*eslint angular/di-order: 2*/

// valid
angular.module('myModule').factory('myService', function($http, $location, $q, myService, someService) {
// ...
});

// valid
beforeEach(inject(function (_$compile_, $httpBackend, _$log_, _$rootScope_) {
// ...
}));

// valid
angular.module('myModule').factory('myService', function(CONFIG, URLs, authService, zero) {
// ...
});
+ +

The following patterns are considered problems when configured true:

+ +
/*eslint angular/di-order: [2,true]*/

// invalid
beforeEach(inject(function ($httpBackend, _$compile_, _$log_, _$rootScope_) {
// ...
})); // error: Injected values should be sorted alphabetically
+ +

The following patterns are not considered problems when configured true:

+ +
/*eslint angular/di-order: [2,true]*/

// valid
beforeEach(inject(function (_$compile_, $httpBackend, _$log_, _$rootScope_) {
// ...
}));
+ +

The following patterns are considered problems when configured false:

+ +
/*eslint angular/di-order: [2,false]*/

// invalid
beforeEach(inject(function (_$compile_, $httpBackend, _$log_, _$rootScope_) {
// ...
})); // error: Injected values should be sorted alphabetically
+ +

The following patterns are not considered problems when configured false:

+ +
/*eslint angular/di-order: [2,false]*/

// valid
beforeEach(inject(function ($httpBackend, _$compile_, _$log_, _$rootScope_) {
// ...
}));
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.6.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_di_unused.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_di_unused.html new file mode 100644 index 0000000..7f31d98 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_di_unused.html @@ -0,0 +1,27 @@ +

Details

+ + +

di-unused - disallow unused DI parameters

+ +

Unused dependencies should not be injected.

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/di-unused: 2*/

// invalid
angular.module('myModule').factory('myService', function ($http, $q, $log) {
$http.get('/api/someData').then(function (response) {
$log.log(response.data);
});
}); // error: Unused injected value $q
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/di-unused: 2*/

// valid
angular.module('myModule').factory('myService', function ($log, anotherService) {
$log.log(anotherService.getSomeData());
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.8.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_directive_name.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_directive_name.html index f286a34..9bd24c4 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_directive_name.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_directive_name.html @@ -1 +1,44 @@ - All your directives should have a name starting with the parameter you can define in your config object. The second parameter can be a Regexp. You can not prefix your directives by "ng" (reserved keyword for AngularJS directives) ("ng_directive_name": [2, "ng"]) [Y073](https://github.com/johnpapa/angularjs-styleguide#style-y073), [Y126](https://github.com/johnpapa/angularjs-styleguide#style-y126) \ No newline at end of file +

Details

+ + +

directive-name - require and specify a prefix for all directive names

+ +

All your directives should have a name starting with the parameter you can define in your config object. +The second parameter can be a Regexp wrapped in quotes. +You can not prefix your directives by "ng" (reserved keyword for AngularJS directives) ("directive-name": [2, "ng"])

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are not considered problems when configured "prefix":

+ +
/*eslint angular/directive-name: [2,"prefix"]*/

// valid
angular.module('myModule').directive('prefixTabs', function () {
// ...
});
+ +

The following patterns are considered problems when configured "/^ui/":

+ +
/*eslint angular/directive-name: [2,"/^ui/"]*/

// invalid
angular.module('myModule').directive('navigation', function () {
// ...
}); // error: The navigation directive should follow this pattern: /^ui/
+ +

The following patterns are not considered problems when configured "/^ui/":

+ +
/*eslint angular/directive-name: [2,"/^ui/"]*/

// valid
angular.module('myModule').directive('uiNavigation', function () {
// ...
});
+ +

The following patterns are considered problems when configured "ui":

+ +
/*eslint angular/directive-name: [2,"ui"]*/

// invalid
angular.module('myModule').directive('tabs', function () {
// ...
}); // error: The tabs directive should be prefixed by ui
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_directive_restrict.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_directive_restrict.html new file mode 100644 index 0000000..0efac18 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_directive_restrict.html @@ -0,0 +1,44 @@ +

Details

+ + +

directive-restrict - disallow any other directive restrict than 'A' or 'E'

+ +

Not all directive restrictions may be desirable. +Also it might be desirable to define default restrictions, or explicitly not. +The default configuration limits the restrictions AE and disallows explicitly specifying a default. +("directive-restrict": [0, {"restrict": "AE", "explicit": "never"}])

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are not considered problems with default config;

+ +
/*eslint angular/directive-restrict: 2*/

// valid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '&lt;h2&gt;Hello World!&lt;/h2&gt;',
restrict: 'A' // also allowed: A, E, AE, EA
};
});

// valid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '&lt;h2&gt;Hello World!&lt;/h2&gt;'
// no explicit restrict is allowed by default
};
});
+ +

The following patterns are considered problems when configured {"explicit":"always"}:

+ +
/*eslint angular/directive-restrict: [2,{"explicit":"always"}]*/

// invalid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '&lt;h2&gt;Hello World!&lt;/h2&gt;'
};
}); // error: Missing directive restriction
+ +

The following patterns are considered problems when configured {"explicit":"never"}:

+ +
/*eslint angular/directive-restrict: [2,{"explicit":"never"}]*/

// invalid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '&lt;h2&gt;Hello World!&lt;/h2&gt;',
restrict: 'AE'
};
}); // error: No need to explicitly specify a default directive restriction
+ +

The following patterns are considered problems when configured {"restrict":"A"}:

+ +
/*eslint angular/directive-restrict: [2,{"restrict":"A"}]*/

// invalid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '&lt;h2&gt;Hello World!&lt;/h2&gt;',
restrict: 'E'
};
}); // error: Disallowed directive restriction. It must be one of A in that order
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.12.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_document_service.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_document_service.html index ef8a9a0..b3d3f05 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_document_service.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_document_service.html @@ -1 +1,33 @@ - Instead of the default document object, you should prefer the AngularJS wrapper service $document. [Y180](https://github.com/johnpapa/angularjs-styleguide#style-y180) \ No newline at end of file +

Details

+ + +

document-service - use $document instead of document

+ +

Instead of the default document object, you should prefer the AngularJS wrapper service $document.

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/document-service: 2*/

// invalid
document.title // error: You should use the $document service instead of the default document object

// invalid
document.title // error: You should use the $document service instead of the default document object
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/document-service: 2*/

// valid
$document[0].title = ""
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_dumb_inject.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_dumb_inject.html new file mode 100644 index 0000000..66cc12a --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_dumb_inject.html @@ -0,0 +1,28 @@ +

Details

+ + +

dumb-inject - unittest inject functions should only consist of assignments from injected values to describe block variables

+ +

inject functions in unittests should only contain a sorted mapping of injected values to values in the describe block with matching names. +This way the dependency injection setup is separated from the other setup logic, improving readability of the test.

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/dumb-inject: 2*/

// invalid
describe(function() {
var $httpBackend;
var $rootScope;

beforeEach(inject(function(_$httpBackend_, _$rootScope_) {
$httpBackend = _$httpBackend_;
$rootScope = _$rootScope_;

$httpBackend.whenGET('/data').respond([]);
}));
}); // error: inject functions may only consist of assignments in the form myService = _myService_

// invalid
describe(function() {
var $httpBackend;
var $rootScope;

beforeEach(inject(function(_$httpBackend_, _$rootScope_) {
$rootScope = _$rootScope_;
$httpBackend = _$httpBackend_;
}));
}); // error: '$httpBackend' must be sorted before '$rootScope'
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/dumb-inject: 2*/

// valid
describe(function() {
var $httpBackend;
var $rootScope;

beforeEach(inject(function(_$httpBackend_, _$rootScope_) {
$httpBackend = _$httpBackend_;
$rootScope = _$rootScope_;
}));

beforeEach(function() {
$httpBackend.whenGET('/data').respond([]);
});
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.15.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_empty_controller.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_empty_controller.html index 6ea305f..9d0a3ad 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_empty_controller.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_empty_controller.html @@ -1 +1,28 @@ - If you have one empty controller, maybe you have linked it in your Router configuration or in one of your views. You can remove this declaration because this controller is useless \ No newline at end of file +

Details

+ + +

empty-controller - disallow empty controllers

+ +

If you have one empty controller, maybe you have linked it in your Router configuration or in one of your views. +You can remove this declaration because this controller is useless

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/empty-controller: 2*/

// invalid
angular.module('myModule').controller('EmptyController', function () {
}); // error: The EmptyController controller is useless because empty. You can remove it from your Router configuration or in one of your view
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/empty-controller: 2*/

// valid
angular.module('myModule').controller('MyController', function ($log) {
$log.log('Hello World!');
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_file_name.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_file_name.html new file mode 100644 index 0000000..d90eefe --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_file_name.html @@ -0,0 +1,77 @@ +

Details

+ + +

file-name - require and specify a consistent component name pattern

+ +

All your file names should match the angular component name. +The second parameter can be a config object [2, {nameStyle: 'dash', typeSeparator: 'dot', ignoreTypeSuffix: true, ignorePrefix: 'ui'}] to match 'avenger-profile.directive.js' or 'avanger-api.service.js'. +Possible values for 'typeSeparator' and 'nameStyle' are 'dot', 'dash' and 'underscore'. +The options 'ignoreTypeSuffix' ignores camel cased suffixes like 'someController' or 'myService' and 'ignorePrefix' ignores namespace prefixes like 'ui'.

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems with default config;

+ +
/*eslint angular/file-name: 2*/

// invalid with filename: src/app/filters.js
app.filter('usefulFilter', function() {}); // error: Filename must be "usefulFilter.js"
+ +

The following patterns are not considered problems with default config;

+ +
/*eslint angular/file-name: 2*/

// valid with filename: myModule.js
angular.module('myModule', []);

// valid with filename: app/SomeController.js
app.controller('SomeController', function() {});

// valid with filename: app/utils/myUtils.js
app.factory('myUtils', function() {});

// valid with filename: src/app/awesomeModule/beautifulDirective.js
app.directive('beautifulDirective', function() {});
+ +

The following patterns are considered problems when configured {"typeSeparator":"dot"}:

+ +
/*eslint angular/file-name: [2,{"typeSeparator":"dot"}]*/

// invalid with filename: src/app/Some.controller.js
app.controller('SomeController', function() {}); // error: Filename must be "SomeController.controller.js"
+ +

The following patterns are not considered problems when configured {"typeSeparator":"dot"}:

+ +
/*eslint angular/file-name: [2,{"typeSeparator":"dot"}]*/

// valid with filename: src/app/usefulFilter.filter.js
app.filter('usefulFilter', function() {});
+ +

The following patterns are not considered problems when configured {"typeSeparator":"dash"}:

+ +
/*eslint angular/file-name: [2,{"typeSeparator":"dash"}]*/

// valid with filename: app/utils/myUtils-service.js
app.factory('myUtils', function() {});
+ +

The following patterns are not considered problems when configured {"typeSeparator":"underscore"}:

+ +
/*eslint angular/file-name: [2,{"typeSeparator":"underscore"}]*/

// valid with filename: src/app/awesomeModule/beautifulDirective_directive.js
app.directive('beautifulDirective', function() {});
+ +

The following patterns are not considered problems when configured {"typeSeparator":"dot","ignoreTypeSuffix":true}:

+ +
/*eslint angular/file-name: [2,{"typeSeparator":"dot","ignoreTypeSuffix":true}]*/

// valid with filename: src/app/useful.filter.js
app.filter('usefulFilter', function() {});

// valid with filename: src/app/Some.controller.js
app.controller('SomeController', function() {});
+ +

The following patterns are not considered problems when configured {"typeSeparator":"dash","ignoreTypeSuffix":true}:

+ +
/*eslint angular/file-name: [2,{"typeSeparator":"dash","ignoreTypeSuffix":true}]*/

// valid with filename: app/utils/myUtils-service.js
app.factory('myUtils', function() {});
+ +

The following patterns are not considered problems when configured {"typeSeparator":"underscore","ignoreTypeSuffix":true}:

+ +
/*eslint angular/file-name: [2,{"typeSeparator":"underscore","ignoreTypeSuffix":true}]*/

// valid with filename: src/app/awesomeModule/beautiful_directive.js
app.directive('beautifulDirective', function() {});
+ +

The following patterns are not considered problems when configured {"typeSeparator":"underscore","nameStyle":"underscore"}:

+ +
/*eslint angular/file-name: [2,{"typeSeparator":"underscore","nameStyle":"underscore"}]*/

// valid with filename: src/app/tab_navigation_directive.js
app.directive('tabNavigation', function() {});
+ +

The following patterns are not considered problems when configured {"typeSeparator":"dot","nameStyle":"dash","ignoreTypeSuffix":true}:

+ +
/*eslint angular/file-name: [2,{"typeSeparator":"dot","nameStyle":"dash","ignoreTypeSuffix":true}]*/

// valid with filename: src/app/user-profile.directive.js
app.directive('userProfileDirective', function() {});
+ +

The following patterns are not considered problems when configured {"typeSeparator":"dot","ignorePrefix":"ui"}:

+ +
/*eslint angular/file-name: [2,{"typeSeparator":"dot","ignorePrefix":"ui"}]*/

// valid with filename: src/app/userUtils.service.js
angular.factory('uiUserUtils', uiUserUtils)
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.7.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_filter_name.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_filter_name.html index b1dae39..d842bfe 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_filter_name.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_filter_name.html @@ -1 +1,37 @@ - All your filters should have a name starting with the parameter you can define in your config object. The second parameter can be a Regexp. ("ng_filter_name": [2, "ng"]) \ No newline at end of file +

Details

+ + +

filter-name - require and specify a prefix for all filter names

+ +

All your filters should have a name starting with the parameter you can define in your config object. +The second parameter can be a Regexp wrapped in quotes. +("filter-name": [2, "ng"])

+ +

Examples

+ +

The following patterns are not considered problems when configured "prefix":

+ +
/*eslint angular/filter-name: [2,"prefix"]*/

// valid
angular.module('myModule').filter('prefixFilter', function () {
// ...
});
+ +

The following patterns are considered problems when configured "/^xyz/":

+ +
/*eslint angular/filter-name: [2,"/^xyz/"]*/

// invalid
angular.module('myModule').filter('otherFilter', function () {
// ...
}); // error: The otherFilter filter should follow this pattern: /^xyz/
+ +

The following patterns are not considered problems when configured "/^xyz/":

+ +
/*eslint angular/filter-name: [2,"/^xyz/"]*/

// valid
angular.module('myModule').filter('xyzFilter', function () {
// ...
});
+ +

The following patterns are considered problems when configured "xyz":

+ +
/*eslint angular/filter-name: [2,"xyz"]*/

// invalid
angular.module('myModule').filter('someFilter', function () {
// ...
}); // error: The someFilter filter should be prefixed by xyz
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_foreach.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_foreach.html new file mode 100644 index 0000000..287fb2e --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_foreach.html @@ -0,0 +1,27 @@ +

Details

+ + +

foreach - use angular.forEach instead of native Array.prototype.forEach

+ +

You should use the angular.forEach method instead of the default JavaScript implementation [].forEach.

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/foreach: 2*/

// invalid
someArray.forEach(function (element) {
// ...
}); // error: You should use the angular.forEach method
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/foreach: 2*/

// valid
angular.forEach(someArray, function (element) {
// ...
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_function_type.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_function_type.html new file mode 100644 index 0000000..bdaa39f --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_function_type.html @@ -0,0 +1,43 @@ +

Details

+ + +

function-type - require and specify a consistent function style for components

+ +

Anonymous or named functions inside AngularJS components. +The first parameter sets which type of function is required and can be 'named' or 'anonymous'. +The second parameter is an optional list of angular object names.

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems when configured "anonymous":

+ +
/*eslint angular/function-type: [2,"anonymous"]*/

// invalid
angular.module('myModule').factory('myService', myServiceFn);
function myServiceFn() {
// ...
} // error: Use anonymous functions instead of named function
+ +

The following patterns are not considered problems when configured "anonymous":

+ +
/*eslint angular/function-type: [2,"anonymous"]*/

// valid
angular.module('myModule').factory('myService', function () {
// ...
});
+ +

The following patterns are considered problems when configured "named":

+ +
/*eslint angular/function-type: [2,"named"]*/

// invalid
angular.module('myModule').factory('myService', function () {
// ...
}); // error: Use named functions instead of anonymous function
+ +

The following patterns are not considered problems when configured "named":

+ +
/*eslint angular/function-type: [2,"named"]*/

// valid
angular.module('myModule').factory('myService', function myService() {
// ...
});

// valid
angular.module('myModule').factory('myService', myServiceFn);
function myServiceFn() {
// ...
}
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_interval_service.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_interval_service.html index b0da0a7..c7ff9d1 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_interval_service.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_interval_service.html @@ -1 +1,33 @@ - Instead of the default setInterval function, you should use the AngularJS wrapper service $interval [Y181](https://github.com/johnpapa/angularjs-styleguide#style-y181) \ No newline at end of file +

Details

+ + +

interval-service - use $interval instead of setInterval

+ +

Instead of the default setInterval function, you should use the AngularJS wrapper service $interval

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/interval-service: 2*/

// invalid
setInterval(function() {
// ...
}, 1000) // error: You should use the $interval service instead of the default window.setInterval method

// invalid
window.setInterval(function() {
// ...
}, 1000) // error: You should use the $interval service instead of the default window.setInterval method
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/interval-service: 2*/

// valid
$interval(function() {
// ...
}, 1000)
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_json_functions.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_json_functions.html index 370cb34..75d060a 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_json_functions.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_json_functions.html @@ -1 +1,27 @@ - You should use angular.fromJson or angular.toJson instead of JSON.parse and JSON.stringify \ No newline at end of file +

Details

+ + +

json-functions - enforce use ofangular.fromJson and 'angular.toJson'

+ +

You should use angular.fromJson or angular.toJson instead of JSON.parse and JSON.stringify

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/json-functions: 2*/

// invalid
JSON.stringify({
// ...
}); // error: You should use the angular.toJson method instead of JSON.stringify

// invalid
var data = JSON.parse('{"message": "Hello World!"}'); // error: You should use the angular.fromJson method instead of JSON.parse
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/json-functions: 2*/

// valid
angular.toJson({
// ...
});

// valid
var data = angular.fromJson('{"message": "Hello World!"}');
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_log.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_log.html new file mode 100644 index 0000000..3c55635 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_log.html @@ -0,0 +1,27 @@ +

Details

+ + +

log - use the $log service instead of the console methods

+ +

You should use $log service instead of console for the methods 'log', 'debug', 'error', 'info', 'warn'

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/log: 2*/

// invalid
console.log('Hello world!'); // error: You should use the "log" method of the AngularJS Service $log instead of the console object

// invalid
console.error('Some error!'); // error: You should use the "error" method of the AngularJS Service $log instead of the console object
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/log: 2*/

// valid
$log.log('Hello world!');

// valid
$log.error('Some error!');
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_module_dependency_order.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_module_dependency_order.html new file mode 100644 index 0000000..7170ce2 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_module_dependency_order.html @@ -0,0 +1,49 @@ +

Details

+ + +

module-dependency-order - require a consistent order of module dependencies

+ +

Module dependencies should be sorted in a logical manner. +This rule provides two ways to sort modules, grouped or ungrouped. +In grouped mode the modules should be grouped in the order: standard modules - third party modules - custom modules. +The modules should be sorted alphabetically within its group. +A prefix can be specified to determine which prefix the custom modules have. +Without grouped set to false all dependencies combined should be sorted alphabetically. +('module-dependency-order', [2, {grouped: true, prefix: "app"}])

+ +

Examples

+ +

The following patterns are considered problems with default config;

+ +
/*eslint angular/module-dependency-order: 2*/

// invalid
angular.module('myModule', ['ngRoute', 'ngAnimate']); // error: ngAnimate should be sorted before ngRoute
+ +

The following patterns are not considered problems with default config;

+ +
/*eslint angular/module-dependency-order: 2*/

// valid
angular.module('myModule', ['ngAnimate', 'ngRoute', 'app', 'appFilters', 'ui.router']);
+ +

The following patterns are considered problems when configured {"grouped":true}:

+ +
/*eslint angular/module-dependency-order: [2,{"grouped":true}]*/

// invalid
angular.module('myModule', ['app', 'ngAnimate']); // error: ngAnimate is a standard module and should be sorted before app
+ +

The following patterns are not considered problems when configured {"grouped":true}:

+ +
/*eslint angular/module-dependency-order: [2,{"grouped":true}]*/

// valid
angular.module('myModule', ['ngAnimate', 'ngRoute', 'app', 'appFilters', 'ui.router']);
+ +

The following patterns are considered problems when configured {"grouped":true,"prefix":"app"}:

+ +
/*eslint angular/module-dependency-order: [2,{"grouped":true,"prefix":"app"}]*/

// invalid
angular.module('myModule', ['ngRoute', 'app', 'ui.router']); // error: ui.router is a third party module and should be sorted before app
+ +

The following patterns are not considered problems when configured {"grouped":true,"prefix":"app"}:

+ +
/*eslint angular/module-dependency-order: [2,{"grouped":true,"prefix":"app"}]*/

// valid
angular.module('myModule', ['ngAnimate', 'ngRoute', 'ui.router', 'app', 'appFilters']);
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.12.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_module_getter.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_module_getter.html new file mode 100644 index 0000000..5de8395 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_module_getter.html @@ -0,0 +1,33 @@ +

Details

+ + +

module-getter - enforce to reference modules with the getter syntax

+ +

When using a module, avoid using a variable and instead use chaining with the getter syntax

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/module-getter: 2*/

// invalid
app.controller('MyController', function () {
// ...
}); // error: Avoid using a variable and instead use chaining with the getter syntax.
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/module-getter: 2*/

// valid
angular.module('myModule').controller('MyController', function () {
// ...
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_module_name.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_module_name.html index fb40046..0daa82e 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_module_name.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_module_name.html @@ -1 +1,43 @@ - When you create a new module, its name should start with the parameter you can define in your config object. The second parameter can be a Regexp. You can not prefix your modules by "ng" (reserved keyword for AngularJS modules) ("ng_module_name": [2, "ng"]) [Y127](https://github.com/johnpapa/angularjs-styleguide#style-y127) \ No newline at end of file +

Details

+ + +

module-name - require and specify a prefix for all module names

+ +

When you create a new module, its name should start with the parameter you can define in your config object. +The second parameter can be a Regexp wrapped in quotes. +You can not prefix your modules by "ng" (reserved keyword for AngularJS modules) ("module-name": [2, "ng"])

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are not considered problems when configured "prefix":

+ +
/*eslint angular/module-name: [2,"prefix"]*/

// valid
angular.module('prefixModule', []);
+ +

The following patterns are considered problems when configured "/^xyz/":

+ +
/*eslint angular/module-name: [2,"/^xyz/"]*/

// invalid
angular.module('otherModule', []); // error: The otherModule module should follow this pattern: /^xyz/
+ +

The following patterns are not considered problems when configured "/^xyz/":

+ +
/*eslint angular/module-name: [2,"/^xyz/"]*/

// valid
angular.module('xyzModule', []);
+ +

The following patterns are considered problems when configured "xyz":

+ +
/*eslint angular/module-name: [2,"xyz"]*/

// invalid
angular.module('myModule', []); // error: The myModule module should be prefixed by xyz
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_module_setter.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_module_setter.html new file mode 100644 index 0000000..8091097 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_module_setter.html @@ -0,0 +1,33 @@ +

Details

+ + +

module-setter - disallow to assign modules to variables

+ +

Declare modules without a variable using the setter syntax.

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/module-setter: 2*/

// invalid
var app = angular.module('myModule', []); // error: Declare modules without a variable using the setter syntax.
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/module-setter: 2*/

// valid
angular.module('myModule', [])
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_angular_mock.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_angular_mock.html new file mode 100644 index 0000000..9bc5741 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_angular_mock.html @@ -0,0 +1,28 @@ +

Details

+ + +

no-angular-mock - require to use angular.mock methods directly

+ +

All methods defined in the angular.mock object are also available in the object window. +So you can remove angular.mock from your code

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/no-angular-mock: 2*/

// invalid
angular.mock.dump($scope); // error: You should use the "dump" method available in the window object.

// invalid
angular.mock.inject(function (someService) {
// ...
}); // error: You should use the "inject" method available in the window object.

// invalid
angular.mock.module('myModule'); // error: You should use the "module" method available in the window object.
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/no-angular-mock: 2*/

// valid
dump($scope);

// valid
inject(function (someService) {
// ...
});

// valid
module('myModule');
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.2.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_controller.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_controller.html new file mode 100644 index 0000000..95fa4f5 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_controller.html @@ -0,0 +1,27 @@ +

Details

+ + +

no-controller - disallow use of controllers (according to the component first pattern)

+ +

According to the Component-First pattern, we should avoid the use of AngularJS controller.

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/no-controller: 2*/

// invalid
angular.module('myModule').controller('HelloWorldController', function ($scope) {
$scope.text = 'Hello World';
}); // error: Based on the Component-First Pattern, you should avoid the use of controllers
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/no-controller: 2*/

// valid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '&lt;div&gt;{{ text }}',
controller: function ($scope) {
$scope.text = 'Hello World';
}
};
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.9.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_cookiestore.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_cookiestore.html new file mode 100644 index 0000000..fe4d722 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_cookiestore.html @@ -0,0 +1,28 @@ +

Details

+ + +

no-cookiestore - use $cookies instead of $cookieStore

+ +

In Angular 1.4, the $cookieStore service is now deprected. +Please use the $cookies service instead

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/no-cookiestore: 2*/

// invalid
$cookieStore.put('favoriteMeal', 'pizza'); // error: Since Angular 1.4, the $cookieStore service is deprecated. Please use now the $cookies service.

// invalid
$cookieStore.get('favoriteMeal'); // error: Since Angular 1.4, the $cookieStore service is deprecated. Please use now the $cookies service.
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/no-cookiestore: 2*/

// valid
$cookies.put('favoriteMeal', 'pizza');

// valid
$cookies.get('favoriteMeal');
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.3.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_directive_replace.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_directive_replace.html new file mode 100644 index 0000000..76187ab --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_directive_replace.html @@ -0,0 +1,38 @@ +

Details

+ + +

no-directive-replace - disallow the deprecated directive replace property

+ +

This rule disallows the replace attribute in a directive definition object. +The replace property of a directive definition object is deprecated since angular 1.3 (latest angular docs.

+ +

The option ignoreReplaceFalse let you ignore directive definitions with replace set to false.

+ +

Examples

+ +

The following patterns are considered problems with default config;

+ +
/*eslint angular/no-directive-replace: 2*/

// invalid
angular.module('myModule').directive('helloWorld', function() {
return {
template: '&lt;h2&gt;Hello World!&lt;/h2&gt;',
replace: true
};
}); // error: Directive definition property replace is deprecated.

// invalid
angular.module('myModule').directive('helloWorld', function() {
var directiveDefinition = {};
directiveDefinition.templateUrl = 'helloWorld.html';
directiveDefinition.replace = true;
return directiveDefinition;
}); // error: Directive definition property replace is deprecated.
+ +

The following patterns are not considered problems with default config;

+ +
/*eslint angular/no-directive-replace: 2*/

// valid
angular.module('myModule').directive('helloWorld', function() {
return {
template: '&lt;h2&gt;Hello World!&lt;/h2&gt;'
};
});
+ +

The following patterns are not considered problems when configured {"ignoreReplaceFalse":true}:

+ +
/*eslint angular/no-directive-replace: [2,{"ignoreReplaceFalse":true}]*/

// valid
angular.module('myModule').directive('helloWorld', function() {
return {
template: '&lt;h2&gt;Hello World!&lt;/h2&gt;',
replace: false
};
});
+ +

The following patterns are considered problems when configured {"ignoreReplaceFalse":false}:

+ +
/*eslint angular/no-directive-replace: [2,{"ignoreReplaceFalse":false}]*/

// invalid
angular.module('myModule').directive('helloWorld', function() {
return {
template: '&lt;h2&gt;Hello World!&lt;/h2&gt;',
replace: true
};
}); // error: Directive definition property replace is deprecated.
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.15.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_http_callback.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_http_callback.html new file mode 100644 index 0000000..123a6de --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_http_callback.html @@ -0,0 +1,28 @@ +

Details

+ + +

no-http-callback - disallow the $http methods success() and error()

+ +

Disallow the $http success and error function. +Instead the standard promise API should be used.

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/no-http-callback: 2*/

// invalid
$http.get('api/data').success(function onSuccess() {
// ...
}); // error: $http success is deprecated. Use then instead

// invalid
$http.get('api/data').error(function onReject() {
// ...
}); // error: $http error is deprecated. Use then or catch instead
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/no-http-callback: 2*/

// valid
$http.get('api/data').then(function onSuccess() {
// ...
}, function onReject() {
// ...
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.12.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_inline_template.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_inline_template.html new file mode 100644 index 0000000..f70b5a0 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_inline_template.html @@ -0,0 +1,45 @@ +

Details

+ + +

no-inline-template - disallow the use of inline templates

+ +

Instead of using inline HTML templates, it is better to load the HTML from an external file. +Simple HTML templates are accepted by default. +('no-inline-template': [0, {allowSimple: true}])

+ +

Examples

+ +

The following patterns are considered problems with default config;

+ +
/*eslint angular/no-inline-template: 2*/

// invalid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '&lt;div&gt;Hello World! &lt;button&gt;Say hello!&lt;/button&gt;&lt;/div&gt;'
};
}); // error: Inline template is too complex. Use an external template instead
+ +

The following patterns are not considered problems with default config;

+ +
/*eslint angular/no-inline-template: 2*/

// valid
angular.module('myModule').directive('helloWorld', function () {
return {
templateUrl: 'template/helloWorld.html'
};
});

// valid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '&lt;div&gt;Hello World&lt;/div&gt;' // simple templates are allowed by default
};
});

// valid
angular.module('myModule').config(function ($routeProvider) {
$routeProvider.when('/hello', {
template: '&lt;hello-world&gt;&lt;/hello-world&gt;' // directives for routing
});
});
+ +

The following patterns are considered problems when configured {"allowSimple":true}:

+ +
/*eslint angular/no-inline-template: [2,{"allowSimple":true}]*/

// invalid
angular.module('myModule').config(function ($routeProvider) {
$routeProvider.when('/dashboard', {
template: '&lt;div&gt;&lt;h1&gt;Dashboard&lt;/h1&gt;&lt;dashboard&gt;&lt;/dashboard&gt;&lt;/div&gt;'
});
}); // error: Inline template is too complex. Use an external template instead
+ +

The following patterns are not considered problems when configured {"allowSimple":true}:

+ +
/*eslint angular/no-inline-template: [2,{"allowSimple":true}]*/

// valid
angular.module('myModule').config(function ($routeProvider) {
$routeProvider.when('/dashboard', {
template: '&lt;dashboard&gt;&lt;/dashboard&gt;' // directives for routing
});
});
+ +

The following patterns are considered problems when configured {"allowSimple":false}:

+ +
/*eslint angular/no-inline-template: [2,{"allowSimple":false}]*/

// invalid
angular.module('myModule').config(function ($routeProvider) {
$routeProvider.when('/dashboard', {
template: '&lt;dashboard&gt;&lt;/dashboard&gt;'
});
}); // error: Inline templates are not allowed. Use an external template instead
+ +

The following patterns are not considered problems when configured {"allowSimple":false}:

+ +
/*eslint angular/no-inline-template: [2,{"allowSimple":false}]*/

// valid
angular.module('myModule').config(function ($routeProvider) {
$routeProvider.when('/dashboard', {
templateUrl: 'templates/dashboard.html'
});
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.12.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_jquery_angularelement.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_jquery_angularelement.html index 5a8b2e5..0fd9eba 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_jquery_angularelement.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_jquery_angularelement.html @@ -1 +1,27 @@ - You should not wrap angular.element object into jQuery(), because angular.element already return jQLite element \ No newline at end of file +

Details

+ + +

no-jquery-angularelement - disallow to wrap angular.element objects with jQuery or $

+ +

You should not wrap angular.element object into jQuery(), because angular.element already return jQLite element

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/no-jquery-angularelement: 2*/

// invalid
$(angular.element("#id")) // error: angular.element returns already a jQLite element. No need to wrap with the jQuery object

// invalid
jQuery(angular.element("#id")) // error: angular.element returns already a jQLite element. No need to wrap with the jQuery object
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/no-jquery-angularelement: 2*/

// valid
angular.element("#id")
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_private_call.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_private_call.html index c9daed5..0768479 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_private_call.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_private_call.html @@ -1 +1,37 @@ - All scope's properties/methods starting with $$ are used interally by AngularJS. You should not use them directly. \ No newline at end of file +

Details

+ + +

no-private-call - disallow use of internal angular properties prefixed with $$

+ +

All scope's properties/methods starting with $$ are used internally by AngularJS. +You should not use them directly. +Exception can be allowed with this option: {allow:['$$watchers']}

+ +

Examples

+ +

The following patterns are considered problems with default config;

+ +
/*eslint angular/no-private-call: 2*/

// invalid
$scope.$$watchers.forEach(function (watcher) {
// ...
}); // error: Using $$-prefixed Angular objects/methods are not recommended
+ +

The following patterns are not considered problems with default config;

+ +
/*eslint angular/no-private-call: 2*/

// valid
$scope.$apply();
+ +

The following patterns are considered problems when configured {"allow":["$$watchers"]}:

+ +
/*eslint angular/no-private-call: [2,{"allow":["$$watchers"]}]*/

// invalid
$scope.$$listeners.forEach(function (listener) {
// ...
}); // error: Using $$-prefixed Angular objects/methods are not recommended
+ +

The following patterns are not considered problems when configured {"allow":["$$watchers"]}:

+ +
/*eslint angular/no-private-call: [2,{"allow":["$$watchers"]}]*/

// valid
$scope.$$watchers.forEach(function (watcher) {
// ...
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_run_logic.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_run_logic.html new file mode 100644 index 0000000..4b3ea51 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_run_logic.html @@ -0,0 +1,41 @@ +

Details

+ + +

no-run-logic - keep run functions clean and simple

+ +

Initialization logic should be moved into a factory or service. This improves testability.

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems with default config;

+ +
/*eslint angular/no-run-logic: 2*/

// invalid
angular.module('app').run(function($window) {
$window.addEventListener('deviceready', deviceready);

function deviceready() {}
}); // error: The run function may only contain call expressions
+ +

The following patterns are not considered problems with default config;

+ +
/*eslint angular/no-run-logic: 2*/

// valid
angular.module('app').run(function(KITTENS, kittenService, startup) {
kittenService.prefetchData(KITTENS);
startup('foo', true, 1);
});
+ +

The following patterns are considered problems when configured {"allowParams":false}:

+ +
/*eslint angular/no-run-logic: [2,{"allowParams":false}]*/

// invalid
angular.module('app').run(function(startup) {
startup('foo', true, 1);
}); // error: Run function call expressions may not take any arguments
+ +

The following patterns are not considered problems when configured {"allowParams":false}:

+ +
/*eslint angular/no-run-logic: [2,{"allowParams":false}]*/

// valid
angular.module('app').run(function(kittenService, startup) {
kittenService.prefetchData();
startup();
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.15.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_service_method.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_service_method.html index d5e5e1a..56b625a 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_service_method.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_service_method.html @@ -1 +1,33 @@ - You should prefer the factory() method instead of service() [Y181](https://github.com/johnpapa/angularjs-styleguide#style-y181) \ No newline at end of file +

Details

+ + +

no-service-method - use factory() instead of service()

+ +

You should prefer the factory() method instead of service()

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/no-service-method: 2*/

// invalid
angular.module('myModule').service('myService', function() {
// ...
}); // error: You should prefer the factory() method instead of service()
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/no-service-method: 2*/

// valid
angular.module('myModule').factory('myService', function () {
// ...
});

// valid
angular.module('myModule').value('someValue', {
// ...
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_services.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_services.html index 4354e6f..6b5f883 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_services.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_no_services.html @@ -1 +1,54 @@ - Some services should be used only in a specific AngularJS service (Ajax-based service for example), in order to follow the separation of concerns paradigm \ No newline at end of file +

Details

+ + +

no-services - disallow DI of specified services

+ +

Some services should be used only in a specific AngularJS service (Ajax-based service for example), in order to follow the separation of concerns paradigm. +The second parameter specifies the services. +The third parameter can be a list of angular objects (controller, factory, etc.). +Or second parameter can be an object, where keys are angular object names and value is a list of services (like {controller: ['$http'], factory: ['$q']})

+ +

Examples

+ +

The following patterns are considered problems with default config;

+ +
/*eslint angular/no-services: 2*/

// invalid
app.controller('MyController', function($http) {
// ...
}); // error: REST API calls should be implemented in a specific service ($http in controller)

// invalid
app.directive('helloWorld', function($resource) {
// ...
}); // error: REST API calls should be implemented in a specific service ($resource in directive)
+ +

The following patterns are not considered problems with default config;

+ +
/*eslint angular/no-services: 2*/

// valid
app.controller('MyController', function(myService) {
// ...
});
+ +

The following patterns are considered problems when configured ["$http","$q"]:

+ +
/*eslint angular/no-services: [2,["$http","$q"]]*/

// invalid
app.directive('helloWorld', function($q) {
// ...
}); // error: REST API calls should be implemented in a specific service ($q in directive)
+ +

The following patterns are not considered problems when configured ["$http","$q"]:

+ +
/*eslint angular/no-services: [2,["$http","$q"]]*/

// valid
app.directive('helloWorld', function($resource) {
// ...
});
+ +

The following patterns are considered problems when configured ["$http","$q"] and ["directive"]:

+ +
/*eslint angular/no-services: [2,["$http","$q"],["directive"]]*/

// invalid
app.directive('MyController', function($http) {
// ...
}); // error: REST API calls should be implemented in a specific service ($http in directive)
+ +

The following patterns are not considered problems when configured ["$http","$q"] and ["directive"]:

+ +
/*eslint angular/no-services: [2,["$http","$q"],["directive"]]*/

// valid
app.controller('MyController', function($http) {
// ...
});
+ +

The following patterns are considered problems when configured {"directive":["$http","$q"],"controller":["$resource"]}:

+ +
/*eslint angular/no-services: [2,{"directive":["$http","$q"],"controller":["$resource"]}]*/

// invalid
app.controller('MyController', function($resource, $log) {
// ...
}); // error: REST API calls should be implemented in a specific service ($resource in controller)

// invalid
app.directive('helloWorld', function($http, $log) {
// ...
}); // error: REST API calls should be implemented in a specific service ($http in directive)
+ +

The following patterns are not considered problems when configured {"directive":["$http","$q"],"controller":["$resource"]}:

+ +
/*eslint angular/no-services: [2,{"directive":["$http","$q"],"controller":["$resource"]}]*/

// valid
app.controller('MyController', function($http, $q, $log) {
// ...
});

// valid
app.directive('helloWorld', function($resource, $log) {
// ...
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_on_watch.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_on_watch.html index 5631a15..47b4063 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_on_watch.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_on_watch.html @@ -1 +1,27 @@ - Watch and On methods on the scope object should be assigned to a variable, in order to be deleted in a $destroy event handler [Y035](https://github.com/johnpapa/angularjs-styleguide#style-y035) \ No newline at end of file +

Details

+ + +

on-watch - require $on and $watch deregistration callbacks to be saved in a variable

+ +

Watch and On methods on the scope object should be assigned to a variable, in order to be deleted in a $destroy event handler

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/on-watch: 2*/

// invalid
$rootScope.$on('event', function () {
// ...
}); // error: The "$on" call should be assigned to a variable, in order to be destroyed during the $destroy event
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/on-watch: 2*/

// valid
$scope.$on('event', function () {
// ...
});

// valid
var unregister = $rootScope.$on('event', function () {
// ...
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_one_dependency_per_line.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_one_dependency_per_line.html new file mode 100644 index 0000000..c79b350 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_one_dependency_per_line.html @@ -0,0 +1,27 @@ +

Details

+ + +

one-dependency-per-line - require all DI parameters to be located in their own line

+ +

Injected dependencies should be written one per line.

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/one-dependency-per-line: 2*/

// invalid
app.controller('MyController', MyController);

function MyController($http, $q) {} // error: Do not use multiple dependencies in one line

// invalid
app.controller('MyController', function($http, $q) {}); // error: Do not use multiple dependencies in one line

// invalid
app.controller('MyController', ['$http','$q',
function($http,
$q
)
{
}]); // error: Do not use multiple dependencies in one line

// invalid
app.controller('MyController', [
'$http',
'$q',
function($http, $q) {}]); // error: Do not use multiple dependencies in one line

// invalid
app.controller('MyController', ['$http', '$q', MyController]);

function MyController($http,
$q
)
{} // error: Do not use multiple dependencies in one line

// invalid
app.controller('MyController', [
'$http',
'$q',
MyController]);

function MyController($http, $q) {} // error: Do not use multiple dependencies in one line

// invalid
app.controller('MyController', ['$http', '$q', function($http, $q) {}]);
// error: Do not use multiple dependencies in one line, Do not use multiple dependencies in one line
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/one-dependency-per-line: 2*/

// valid
app.controller('MyController', MyController);

function MyController($http,
$q
)
{
}

// valid
app.controller('MyController', function($http,
$q
)
{
});

// valid
app.controller('MyController', [
'$http',
'$q',
function($http,
$q
)
{
}]);

// valid
app.controller('MyController', [
'$http',
'$q',
MyController]);

function MyController($http,
$q
)
{
}
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.14.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_rest_service.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_rest_service.html new file mode 100644 index 0000000..0bd2126 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_rest_service.html @@ -0,0 +1,44 @@ +

Details

+ + +

rest-service - disallow different rest service and specify one of '$http', '$resource', 'Restangular'

+ +

Check the service used to send request to your REST API. +This rule can have one parameter, with one of the following values: $http, $resource or Restangular ('rest-service': [0, '$http']).

+ +

Examples

+ +

The following patterns are considered problems when configured "$http":

+ +
/*eslint angular/rest-service: [2,"$http"]*/

// invalid
angular.module('myModule').service('myService', function($resource) {
// ...
}); // error: You should use the same service ($http) for REST API calls
+ +

The following patterns are not considered problems when configured "$http":

+ +
/*eslint angular/rest-service: [2,"$http"]*/

// valid
angular.module('myModule').service('myService', function($http) {
// ...
});
+ +

The following patterns are considered problems when configured "$resource":

+ +
/*eslint angular/rest-service: [2,"$resource"]*/

// invalid
angular.module('myModule').service('myService', function($http) {
// ...
}); // error: You should use the same service ($resource) for REST API calls
+ +

The following patterns are not considered problems when configured "$resource":

+ +
/*eslint angular/rest-service: [2,"$resource"]*/

// valid
angular.module('myModule').service('myService', function($resource) {
// ...
});
+ +

The following patterns are considered problems when configured "Restangular":

+ +
/*eslint angular/rest-service: [2,"Restangular"]*/

// invalid
angular.module('myModule').service('myService', function($http) {
// ...
}); // error: You should use the same service (Restangular) for REST API calls
+ +

The following patterns are not considered problems when configured "Restangular":

+ +
/*eslint angular/rest-service: [2,"Restangular"]*/

// valid
angular.module('myModule').service('myService', function(Restangular) {
// ...
});
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.5.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_service_name.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_service_name.html index fed33e0..4768164 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_service_name.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_service_name.html @@ -1 +1,44 @@ - All your services should have a name starting with the parameter you can define in your config object. The second parameter can be a Regexp. You can not prefix your services by "$" (reserved keyword for AngularJS services) ("ng_service_name": [2, "ng"]) [Y125](https://github.com/johnpapa/angularjs-styleguide#style-y125) \ No newline at end of file +

Details

+ + +

service-name - require and specify a prefix for all service names

+ +

All your services should have a name starting with the parameter you can define in your config object. +The second parameter can be a Regexp wrapped in quotes. +You can not prefix your services by "$" (reserved keyword for AngularJS services) ("service-name": [2, "ng"]) +*

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are not considered problems when configured "prefix":

+ +
/*eslint angular/service-name: [2,"prefix"]*/

// valid
angular.module('myModule').factory('prefixService', function () {
// ...
});
+ +

The following patterns are considered problems when configured "/^xyz/":

+ +
/*eslint angular/service-name: [2,"/^xyz/"]*/

// invalid
angular.module('myModule').factory('otherService', function () {
// ...
}); // error: The otherService service should follow this pattern: /^xyz/
+ +

The following patterns are not considered problems when configured "/^xyz/":

+ +
/*eslint angular/service-name: [2,"/^xyz/"]*/

// valid
angular.module('myModule').factory('xyzService', function () {
// ...
});
+ +

The following patterns are considered problems when configured "xyz":

+ +
/*eslint angular/service-name: [2,"xyz"]*/

// invalid
angular.module('myModule').factory('myService', function () {
// ...
}); // error: The myService service should be prefixed by xyz
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_timeout_service.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_timeout_service.html index 4b82311..6e18c33 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_timeout_service.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_timeout_service.html @@ -1 +1,34 @@ - Instead of the default setTimeout function, you should use the AngularJS wrapper service $timeout [Y181](https://github.com/johnpapa/angularjs-styleguide#style-y181) \ No newline at end of file +

Details

+ + +

timeout-service - use $timeout instead of setTimeout

+ +

Instead of the default setTimeout function, you should use the AngularJS wrapper service $timeout +*

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/timeout-service: 2*/

// invalid
setTimeout(function() {
// ...
}, 1000) // error: You should use the $timeout service instead of the default window.setTimeout method

// invalid
window.setTimeout(function() {
// ...
}, 1000) // error: You should use the $timeout service instead of the default window.setTimeout method
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/timeout-service: 2*/

// valid
$timeout(function() {
// ...
}, 1000)
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_array.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_array.html index 0604ce7..dbd72b0 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_array.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_array.html @@ -1 +1,27 @@ - You should use the angular.isArray method instead of the default JavaScript implementation (typeof [] === "[object Array]"). \ No newline at end of file +

Details

+ + +

typecheck-array - use angular.isArray instead of typeof comparisons

+ +

You should use the angular.isArray method instead of the default JavaScript implementation (typeof [] === "[object Array]").

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/typecheck-array: 2*/

// invalid
Object.prototype.toString.call(someArray) === '[object Array]'; // error: You should use the angular.isArray method

// invalid
Array.isArray(someArray) // error: You should use the angular.isArray method
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/typecheck-array: 2*/

// valid
angular.isArray(someArray);
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_date.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_date.html index 7011844..db18005 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_date.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_date.html @@ -1 +1,27 @@ - You should use the angular.isDate method instead of the default JavaScript implementation (typeof new Date() === "[object Date]"). \ No newline at end of file +

Details

+ + +

typecheck-date - use angular.isDate instead of typeof comparisons

+ +

You should use the angular.isDate method instead of the default JavaScript implementation (typeof new Date() === "[object Date]").

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/typecheck-date: 2*/

// invalid
Object.prototype.toString.call(someDate) === '[object Date]'; // error: You should use the angular.isDate method
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/typecheck-date: 2*/

// valid
angular.isDate(someDate);
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_function.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_function.html index c9bf35b..8914549 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_function.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_function.html @@ -1 +1,27 @@ - You should use the angular.isFunction method instead of the default JavaScript implementation (typeof function(){} ==="[object Function]"). \ No newline at end of file +

Details

+ + +

typecheck-function - use angular.isFunction instead of typeof comparisons

+ +

You should use the angular.isFunction method instead of the default JavaScript implementation (typeof function(){} ==="[object Function]").

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/typecheck-function: 2*/

// invalid
typeof someFunction === 'function' // error: You should use the angular.isFunction method
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/typecheck-function: 2*/

// valid
angular.isFunction(someFunction);
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_number.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_number.html index 0fef739..0befac4 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_number.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_number.html @@ -1 +1,27 @@ - You should use the angular.isNumber method instead of the default JavaScript implementation (typeof 3 === "[object Number]"). \ No newline at end of file +

Details

+ + +

typecheck-number - use angular.isNumber instead of typeof comparisons

+ +

You should use the angular.isNumber method instead of the default JavaScript implementation (typeof 3 === "[object Number]").

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/typecheck-number: 2*/

// invalid
typeof someNumber === 'number' // error: You should use the angular.isNumber method
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/typecheck-number: 2*/

// valid
angular.isNumber(someNumber);
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_object.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_object.html index 999b2b2..6213e10 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_object.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_object.html @@ -1 +1,27 @@ - You should use the angular.isObject method instead of the default JavaScript implementation (typeof {} === "[object Object]"). \ No newline at end of file +

Details

+ + +

typecheck-object - use angular.isObject instead of typeof comparisons

+ +

You should use the angular.isObject method instead of the default JavaScript implementation (typeof {} === "[object Object]").

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/typecheck-object: 2*/

// invalid
typeof someObject === 'object' // error: You should use the angular.isObject method
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/typecheck-object: 2*/

// valid
angular.isObject(someObject);
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_string.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_string.html index a11126b..6c76003 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_string.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_typecheck_string.html @@ -1 +1,27 @@ - You should use the angular.isString method instead of the default JavaScript implementation (typeof "" === "[object String]"). \ No newline at end of file +

Details

+ + +

typecheck-string - use angular.isString instead of typeof comparisons

+ +

You should use the angular.isString method instead of the default JavaScript implementation (typeof "" === "[object String]").

+ +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/typecheck-string: 2*/

// invalid
typeof someString === 'string' // error: You should use the angular.isString method
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/typecheck-string: 2*/

// valid
angular.isString(someString);
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_watchers_execution.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_watchers_execution.html new file mode 100644 index 0000000..cb29951 --- /dev/null +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_watchers_execution.html @@ -0,0 +1,36 @@ +

Details

+ + +

watchers-execution - require and specify consistent use $scope.digest() or $scope.apply()

+ +

For the execution of the watchers, the $digest method will start from the scope in which we call the method. +This will cause an performance improvement comparing to the $apply method, who start from the $rootScope

+ +

Examples

+ +

The following patterns are considered problems when configured "$apply":

+ +
/*eslint angular/watchers-execution: [2,"$apply"]*/

// invalid
$scope.$digest(); // error: Instead of using the $digest() method, you should prefer $apply()
+ +

The following patterns are not considered problems when configured "$apply":

+ +
/*eslint angular/watchers-execution: [2,"$apply"]*/

// valid
$scope.$apply(function() {
// ...
});
+ +

The following patterns are considered problems when configured "$digest":

+ +
/*eslint angular/watchers-execution: [2,"$digest"]*/

// invalid
$scope.$apply(function() {
// ...
}); // error: Instead of using the $apply() method, you should prefer $digest()
+ +

The following patterns are not considered problems when configured "$digest":

+ +
/*eslint angular/watchers-execution: [2,"$digest"]*/

// valid
$scope.$digest();
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.4.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_window_service.html b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_window_service.html index 3bfcf72..4804896 100644 --- a/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_window_service.html +++ b/sonar-web-frontend-angular-eslint/src/main/resources/rules/eslint-angular/ng_window_service.html @@ -1 +1,33 @@ - Instead of the default window object, you should prefer the AngularJS wrapper service $window. [Y180](https://github.com/johnpapa/angularjs-styleguide#style-y180) \ No newline at end of file +

Details

+ + +

window-service - use $window instead of window

+ +

Instead of the default window object, you should prefer the AngularJS wrapper service $window.

+ +

Styleguide Reference

+ + + +

Examples

+ +

The following patterns are considered problems;

+ +
/*eslint angular/window-service: 2*/

// invalid
window.alert('Hello world!'); // error: You should use the $window service instead of the default window object
+ +

The following patterns are not considered problems;

+ +
/*eslint angular/window-service: 2*/

// valid
$window.alert('Hello world!');
+ +

Version

+ +

This rule was introduced in eslint-plugin-angular 0.1.0

+ +

Links

+ + diff --git a/sonar-web-frontend-angular-hint/pom.xml b/sonar-web-frontend-angular-hint/pom.xml index 89e6f56..aa19e0c 100644 --- a/sonar-web-frontend-angular-hint/pom.xml +++ b/sonar-web-frontend-angular-hint/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 fr.sii.sonar sonar-sii-plugin-parent - 2.0-SNAPSHOT + 2.0.1-SNAPSHOT sonar-web-frontend-angular-hint diff --git a/sonar-web-frontend-angular-hint/src/main/java/fr/sii/sonar/web/frontend/ng/hint/quality/AngularHintQualityConstants.java b/sonar-web-frontend-angular-hint/src/main/java/fr/sii/sonar/web/frontend/ng/hint/quality/AngularHintQualityConstants.java index 36820e2..3257f67 100644 --- a/sonar-web-frontend-angular-hint/src/main/java/fr/sii/sonar/web/frontend/ng/hint/quality/AngularHintQualityConstants.java +++ b/sonar-web-frontend-angular-hint/src/main/java/fr/sii/sonar/web/frontend/ng/hint/quality/AngularHintQualityConstants.java @@ -10,7 +10,7 @@ public class AngularHintQualityConstants extends AngularHintConstants implements public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.quality.angular.file.missing.fail"; public static final String SKIP_FILE_METRICS_KEY = "sonar.sii.quality.angular.file.metrics.skip"; public static final String SKIP_FILE_METRICS_DEFVALUE = "false"; - public static final String REPORT_PATH_DEFVALUE = "/report/angular-hint.json"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/angular-hint.json"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String RULES_PATH = "/rules/angular-hint.json"; public static final String REPOSITORY_NAME = "Angular Hint"; diff --git a/sonar-web-frontend-angular-hint/src/main/resources/rules/angular-hint.json b/sonar-web-frontend-angular-hint/src/main/resources/rules/angular-hint.json index 739c3f2..6905775 100644 --- a/sonar-web-frontend-angular-hint/src/main/resources/rules/angular-hint.json +++ b/sonar-web-frontend-angular-hint/src/main/resources/rules/angular-hint.json @@ -2,80 +2,208 @@ "key": "controllers-global", "name": "Global controller", "description": "Angular controllers should not be globally registered. They should be registered on modules", - "severity": "CRITICAL" + "severity": "CRITICAL", + "tags" : [ "ng-hint" , "convention", "bad-practice"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } }, { "key": "controllers-naming-convention", "name": "Controller naming convention", "description": "Angular controller names should begin with a capital letter and end with -Controller", - "severity": "CRITICAL" + "severity": "CRITICAL", + "tags" : [ "ng-hint" , "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } }, { "key": "directives-following-restrict-property", "name": "Following restrict property", "description": "you use directives reserved for elements or attributes incorrectly", - "severity": "CRITICAL" + "severity": "CRITICAL", + "tags" : [ "ng-hint" , "convention", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } }, { "key": "directives-missing-namespace", "name": "Missing namespace for directive", "description": "Directives should have their own unique namespace so as to not conflict with existing components in Angular or external libraries", - "severity": "MAJOR" + "severity": "MAJOR", + "tags" : [ "ng-hint" , "convention", "pitfall", "confusing"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "TRANSPORTABILITY" + } }, { "key": "directives-missing-required-attributes", "name": "Missing required attribute", "description": "A required attribute is missing", - "severity": "CRITICAL" + "severity": "CRITICAL", + "tags" : [ "ng-hint" , "convention", "bug"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } }, { "key": "directives-misspelled-directives-and-attributes", "name": "Misspelled directive or attribute", "description": "The name of the directive or the attribute is misspelled and may not exist", - "severity": "CRITICAL" + "severity": "CRITICAL", + "tags" : [ "ng-hint" , "convention", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } }, { "key": "directives-using-angular-event-directives", "name": "Use Angular events", "description": "Avoid using DOM events, prefer using Angular events", - "severity": "MAJOR" + "severity": "MAJOR", + "tags" : [ "ng-hint" , "convention", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } }, { "key": "directives-using-deprecated-options", "name": "Deprecated directive option", "description": "Avoid using deprecated options in directives", - "severity": "MINOR" + "severity": "MINOR", + "tags" : [ "ng-hint" , "convention", "obsolete"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } }, { "key": "directives-using-ngrepeat-incorrectly", "name": "Order of ngRepeat options", "description": "ngRepeat options should always use the same declaration order", - "severity": "INFO" + "severity": "INFO", + "tags" : [ "ng-hint" , "convention", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } }, { "key": "dom-use-angular-binding", "name": "Use Angular binding", "description": "Use binding instead of DOM API", - "severity": "MAJOR" + "severity": "MAJOR", + "tags" : [ "ng-hint" , "convention", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } }, { "key": "events-identify-undefined-variables", "name": "Undefined variables in events", "description": "Identify potential undefined variables in events", - "severity": "MAJOR" + "severity": "MAJOR", + "tags" : [ "ng-hint" , "convention", "bug"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } }, { "key": "interpolation-undefined-parts-warning", "name": "Undefined parts", "description": "Chain of objects becomes undefined", - "severity": "MAJOR" + "severity": "MAJOR", + "tags" : [ "ng-hint" , "convention", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } }, { "key": "interpolation-variable-suggestion", "name": "Variable suggestion", "description": "Undefined variable value suggestion", - "severity": "MINOR" + "severity": "MINOR", + "tags" : [ "ng-hint" , "convention", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } }, { "key": "modules-creating-and-loading-modules", "name": "Creation and loading of modules", "description": "Common problems regarding the creation and loading of modules", - "severity": "MAJOR" + "severity": "MAJOR", + "tags" : [ "ng-hint" , "convention", "pitfall", "performance"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "MODULARITY" + } }, { "key": "modules-missing-namespace", "name": "Missing namespace for module", "description": "Modules should have their own unique namespace so as to not conflict with existing modules in Angular or external libraries", - "severity": "MAJOR" + "severity": "MAJOR", + "tags" : [ "ng-hint" , "convention", "pitfall", "confusing"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "MODULARITY" + } }, { "key": "modules-ngview-with-ngroute", "name": "ngView with ngRoute", "description": "Routing has been separated from Angular.js into a separate ngRoute module", - "severity": "MAJOR" + "severity": "MAJOR", + "tags" : [ "ng-hint" , "convention", "pitfall", "confusing"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "MODULARITY" + } }] \ No newline at end of file diff --git a/sonar-web-frontend-css/pom.xml b/sonar-web-frontend-css/pom.xml index 6e48a94..34363d8 100644 --- a/sonar-web-frontend-css/pom.xml +++ b/sonar-web-frontend-css/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 fr.sii.sonar sonar-sii-plugin-parent - 2.0-SNAPSHOT + 2.0.1-SNAPSHOT sonar-web-frontend-css diff --git a/sonar-web-frontend-css/src/main/java/fr/sii/sonar/web/frontend/css/duplication/CssDuplicationConstants.java b/sonar-web-frontend-css/src/main/java/fr/sii/sonar/web/frontend/css/duplication/CssDuplicationConstants.java index 6ed125e..87781a8 100644 --- a/sonar-web-frontend-css/src/main/java/fr/sii/sonar/web/frontend/css/duplication/CssDuplicationConstants.java +++ b/sonar-web-frontend-css/src/main/java/fr/sii/sonar/web/frontend/css/duplication/CssDuplicationConstants.java @@ -8,7 +8,7 @@ public class CssDuplicationConstants extends CssLanguageConstants implements Dup public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.duplication.css.file.missing.fail"; public static final String SKIP_DUPLICATION_KEY = "sonar.sii.duplication.css.skip"; public static final String SKIP_DUPLICATION_DEFVAL = "false"; - public static final String REPORT_PATH_DEFVALUE = "/report/css-duplication.xml"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/css-duplication.xml"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String SUB_CATEGORY = "Duplication"; diff --git a/sonar-web-frontend-css/src/main/java/fr/sii/sonar/web/frontend/css/quality/CssLintQualityConstants.java b/sonar-web-frontend-css/src/main/java/fr/sii/sonar/web/frontend/css/quality/CssLintQualityConstants.java index a48f98b..5c51606 100644 --- a/sonar-web-frontend-css/src/main/java/fr/sii/sonar/web/frontend/css/quality/CssLintQualityConstants.java +++ b/sonar-web-frontend-css/src/main/java/fr/sii/sonar/web/frontend/css/quality/CssLintQualityConstants.java @@ -10,7 +10,7 @@ public class CssLintQualityConstants extends CssLanguageConstants implements Qua public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.quality.css.file.missing.fail"; public static final String SKIP_FILE_METRICS_KEY = "sonar.sii.quality.css.file.metrics.skip"; public static final String SKIP_FILE_METRICS_DEFVALUE = "false"; - public static final String REPORT_PATH_DEFVALUE = "/report/csslint.json"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/csslint.json"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String RULES_PATH = "/rules/csslint.json"; public static final String REPOSITORY_NAME = "CSSLint"; diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint.css b/sonar-web-frontend-css/src/main/resources/rules/csslint.css index 157c776..2633a6c 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint.css +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint.css @@ -1,4 +1,12 @@ -.extended-html-description { +.ehd { margin-top: 20px; margin-bottom: 30px; -} \ No newline at end of file +} + +.ehd code { + background: rgba(0,0,0,0.05); + padding: 2px; +} + +/* Github styles */ +.highlight{margin-bottom:16px}.highlight pre,pre{padding:16px;overflow:auto;font-size:85%;line-height:1.45;background-color:#f7f7f7;border-radius:3px}.highlight pre{margin-bottom:0;word-break:normal}pre{word-wrap:normal}pre code,pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}pre code:before,pre code:after,pre tt:before,pre tt:after{content:normal}kbd{display:inline-block;padding:3px 5px;font-size:11px;line-height:10px;color:#555;vertical-align:middle;background-color:#fcfcfc;border:solid 1px #ccc;border-bottom-color:#bbb;border-radius:3px;box-shadow:inset 0 -1px 0 #bbb}.pl-c{color:#969896}.pl-c1,.pl-s .pl-v{color:#0086b3}.pl-e,.pl-en{color:#795da3}.pl-s .pl-s1,.pl-smi{color:#333}.pl-ent{color:#63a35c}.pl-k{color:#a71d5d}.pl-pds,.pl-s,.pl-s .pl-pse .pl-s1,.pl-sr,.pl-sr .pl-cce,.pl-sr .pl-sra,.pl-sr .pl-sre{color:#183691}.pl-v{color:#ed6a43}.pl-id{color:#b52a1d}.pl-ii{background-color:#b52a1d;color:#f8f8f8}.pl-sr .pl-cce{color:#63a35c;font-weight:bold}.pl-ml{color:#693a17}.pl-mh,.pl-mh .pl-en,.pl-ms{color:#1d3e81;font-weight:bold}.pl-mq{color:#008080}.pl-mi{color:#333;font-style:italic}.pl-mb{color:#333;font-weight:bold}.pl-md{background-color:#ffecec;color:#bd2c00}.pl-mi1{background-color:#eaffea;color:#55a532}.pl-mdr{color:#795da3;font-weight:bold}.pl-mo{color:#1d3e81} diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint.json b/sonar-web-frontend-css/src/main/resources/rules/csslint.json index 0ff2d63..a8b9df8 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint.json +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint.json @@ -1,186 +1,519 @@ -[{ - "key": "import", - "name": "Disallow @import", - "description": "Don't use @import, use instead.", - "severity": "MAJOR" -}, { - "key": "important", - "name": "Disallow !important", - "description": "Be careful when using !important declaration", - "severity": "MINOR" -}, { - "key": "box-model", - "name": "Beware of broken box size", - "description": "Don't use width or height when using padding or border.", - "severity": "INFO" -}, { - "key": "empty-rules", - "name": "Disallow empty rules", - "description": "Rules without any properties specified should be removed.", - "severity": "MAJOR" -}, { - "key": "adjoining-classes", - "name": "Disallow adjoining classes", - "description": "Don't use adjoining classes.", - "severity": "MINOR" -}, { - "key": "qualified-headings", - "name": "Disallow qualified headings", - "description": "Headings should not be qualified (namespaced).", - "severity": "MINOR" -}, { - "key": "unique-headings", - "name": "Headings should only be defined once", - "description": "Headings should be defined only once.", - "severity": "MINOR" -}, { - "key": "errors", - "name": "Parsing Errors", - "description": "This rule looks for recoverable syntax errors.", - "severity": "CRITICAL" -}, { - "key": "overqualified-elements", - "name": "Disallow overqualified elements", - "description": "Don't use classes or IDs with elements (a.foo or a#foo).", - "severity": "MINOR" -}, { - "key": "vendor-prefix", - "name": "Require standard property with vendor prefix", - "description": "When using a vendor-prefixed property, make sure to include the standard one.", - "severity": "MAJOR" -}, { - "key": "fallback-colors", - "name": "Require fallback colors", - "description": "For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color.", - "severity": "MINOR" -}, { - "key": "regex-selectors", - "name": "Disallow selectors that look like regexs", - "description": "Selectors that look like regular expressions are slow and should be avoided.", - "severity": "MAJOR" -}, { - "key": "unqualified-attributes", - "name": "Disallow unqualified attribute selectors", - "description": "Unqualified attribute selectors are known to be slow.", - "severity": "MAJOR" -}, { - "key": "universal-selector", - "name": "Disallow universal selector", - "description": "The universal selector (*) is known to be slow.", - "severity": "MAJOR" -}, { - "key": "box-sizing", - "name": "Disallow use of box-sizing", - "description": "The box-sizing properties isn't supported in IE6 and IE7.", - "severity": "MINOR" -}, { - "key": "display-property-grouping", - "name": "Require properties appropriate for display", - "description": "Certain properties shouldn't be used with certain display property values.", - "severity": "MAJOR" -}, { - "key": "ids", - "name": "Disallow IDs in selectors", - "description": "Selectors should not contain IDs.", - "severity": "MAJOR" -}, { - "key": "gradients", - "name": "Require all gradient definitions", - "description": "When using a vendor-prefixed gradient, make sure to use them all.", - "severity": "MINOR" -}, { - "key": "zero-units", - "name": "Disallow units for 0 values", - "description": "You don't need to specify units when a value is 0.", - "severity": "MINOR" -}, { - "key": "duplicate-properties", - "name": "Disallow duplicate properties", - "description": "Duplicate properties must appear one after the other.", - "severity": "MAJOR" -}, { - "key": "compatible-vendor-prefixes", - "name": "Require compatible vendor prefixes", - "description": "Include all compatible vendor prefixes to reach a wider range of users.", - "severity": "MINOR" -}, { - "key": "outline-none", - "name": "Disallow outline: none", - "description": "Use of outline: none or outline: 0 should be limited to :focus rules.", - "severity": "MAJOR" -}, { - "key": "floats", - "name": "Disallow too many floats", - "description": "This rule tests if the float property is used too many times", - "severity": "MAJOR" -}, { - "key": "known-properties", - "name": "Require use of known properties", - "description": "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.", - "severity": "CRITICAL" -}, { - "key": "font-sizes", - "name": "Disallow too many font sizes", - "description": "Checks the number of font-size declarations.", - "severity": "MAJOR" -}, { - "key": "font-faces", - "name": "Don't use too many web fonts", - "description": "Too many different web fonts in the same stylesheet.", - "severity": "MAJOR" -}, { - "key": "duplicate-background-images", - "name": "Disallow duplicate background images", - "description": "Every background-image should be unique. Use a common class for e.g. sprites.", - "severity": "MINOR" -}, { - "key": "order-alphabetical", - "name": "Alphabetical order", - "description": "Assure properties are in alphabetical order", - "severity": "INFO" -}, { - "key": "rules-count", - "name": "Rules Count", - "description": "Track how many rules there are.", - "severity": "MAJOR" -}, { - "key": "selector-max-approaching", - "name": "Warn when approaching the 4095 selector limit for IE", - "description": "Will warn when selector count is >= 3800 selectors.", - "severity": "MINOR" -}, { - "key": "selector-max", - "name": "Error when past the 4095 selector limit for IE", - "description": "Will error when selector count is > 4095.", - "severity": "CRITICAL" -}, { - "key": "selector-newline", - "name": "Disallow new-line characters in selectors", - "description": "New-line characters in selectors are usually a forgotten comma and not a descendant combinator.", - "severity": "MINOR" -}, { - "key": "shorthand", - "name": "Require shorthand properties", - "description": "Use shorthand properties where possible.", - "severity": "MINOR" -}, { - "key": "star-property-hack", - "name": "Disallow properties with a star prefix", - "description": "Checks for the star property hack (targets IE6/7)", - "severity": "MAJOR" -}, { - "key": "text-indent", - "name": "Disallow negative text-indent", - "description": "Checks for text indent less than -99px", - "severity": "MAJOR" -}, { - "key": "underscore-property-hack", - "name": "Disallow properties with an underscore prefix", - "description": "Checks for the underscore property hack (targets IE6)", - "severity": "MAJOR" -}, { - "key": "bulletproof-font-face", - "name": "Use the bulletproof @font-face syntax", - "description": "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).", - "severity": "MAJOR" -}] \ No newline at end of file +[ { + "key" : "import", + "name" : "Disallow @import", + "description" : "Don't use @import, use instead.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "bad-practice", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "NETWORK_USE" + } +}, { + "key" : "important", + "name" : "Disallow !important", + "description" : "Be careful when using !important declaration", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "bad-practice", "pitfalll" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "LOGIC_CHANGEABILITY" + } +}, { + "key" : "box-model", + "name" : "Beware of broken box size", + "description" : "Don't use width or height when using padding or border.", + "severity" : "INFO", + "status" : null, + "tags" : [ "csslint", "pitfall", "cross-browser" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "empty-rules", + "name" : "Disallow empty rules", + "description" : "Rules without any properties specified should be removed.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "unused" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "adjoining-classes", + "name" : "Disallow adjoining classes", + "description" : "Don't use adjoining classes.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "cross-browser", "ie6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "qualified-headings", + "name" : "Disallow qualified headings", + "description" : "Headings should not be qualified (namespaced).", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "oocss", "user-experience" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "USABILITY_EASE_OF_USE" + } +}, { + "key" : "unique-headings", + "name" : "Headings should only be defined once", + "description" : "Headings should be defined only once.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "oocss", "user-experience" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "errors", + "name" : "Parsing Errors", + "description" : "This rule looks for recoverable syntax errors.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "csslint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1h" + }, + "sqaleSubCharacteristic" : "RESOURCE_RELIABILITY" + } +}, { + "key" : "overqualified-elements", + "name" : "Disallow overqualified elements", + "description" : "Don't use classes or IDs with elements (a.foo or a#foo).", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "CPU_EFFICIENCY" + } +}, { + "key" : "vendor-prefix", + "name" : "Require standard property with vendor prefix", + "description" : "When using a vendor-prefixed property, make sure to include the standard one.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "PORTABILITY_COMPLIANCE" + } +}, { + "key" : "fallback-colors", + "name" : "Require fallback colors", + "description" : "For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "cross-browser", "pitfall", "ie", "ie8" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "regex-selectors", + "name" : "Disallow selectors that look like regexs", + "description" : "Selectors that look like regular expressions are slow and should be avoided.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "CPU_EFFICIENCY" + } +}, { + "key" : "unqualified-attributes", + "name" : "Disallow unqualified attribute selectors", + "description" : "Unqualified attribute selectors are known to be slow.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "CPU_EFFICIENCY" + } +}, { + "key" : "universal-selector", + "name" : "Disallow universal selector", + "description" : "The universal selector (*) is known to be slow.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "CPU_EFFICIENCY" + } +}, { + "key" : "box-sizing", + "name" : "Disallow use of box-sizing", + "description" : "The box-sizing properties isn't supported in IE6 and IE7.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "cross-browser", "ie7" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "display-property-grouping", + "name" : "Require properties appropriate for display", + "description" : "Certain properties shouldn't be used with certain display property values.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "ids", + "name" : "Disallow IDs in selectors", + "description" : "Selectors should not contain IDs.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "convention", "reusability" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "MODULARITY" + } +}, { + "key" : "gradients", + "name" : "Require all gradient definitions", + "description" : "When using a vendor-prefixed gradient, make sure to use them all.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "cross-browser" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "zero-units", + "name" : "Disallow units for 0 values", + "description" : "You don't need to specify units when a value is 0.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "duplicate-properties", + "name" : "Disallow duplicate properties", + "description" : "Duplicate properties must appear one after the other.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "confusing", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "compatible-vendor-prefixes", + "name" : "Require compatible vendor prefixes", + "description" : "Include all compatible vendor prefixes to reach a wider range of users.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "cross-browser" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "outline-none", + "name" : "Disallow outline: none", + "description" : "Use of outline: none or outline: 0 should be limited to :focus rules.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "convention", "bad-practice", "user-experience", "accessibility" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "USABILITY_ACCESSIBILITY" + } +}, { + "key" : "floats", + "name" : "Disallow too many floats", + "description" : "This rule tests if the float property is used too many times", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "bad-practice", "performance", "brain-overload" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1d" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "known-properties", + "name" : "Require use of known properties", + "description" : "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "csslint", "suspicious", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "font-sizes", + "name" : "Disallow too many font sizes", + "description" : "Checks the number of font-size declarations.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "bad-practice", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "font-faces", + "name" : "Don't use too many web fonts", + "description" : "Too many different web fonts in the same stylesheet.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "bad-practice", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "NETWORK_USE" + } +}, { + "key" : "duplicate-background-images", + "name" : "Disallow duplicate background images", + "description" : "Every background-image should be unique. Use a common class for e.g. sprites.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "confusing", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1h" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "order-alphabetical", + "name" : "Alphabetical order", + "description" : "Assure properties are in alphabetical order", + "severity" : "INFO", + "status" : null, + "tags" : [ "csslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "rules-count", + "name" : "Rules Count", + "description" : "Track how many rules there are.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "performance", "bad-practice", "brain-overload" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1h" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "selector-max-approaching", + "name" : "Warn when approaching the 4095 selector limit for IE", + "description" : "Will warn when selector count is >= 3800 selectors.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "pitfall", "cross-browser", "ie", "limit" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1d" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "selector-max", + "name" : "Error when past the 4095 selector limit for IE", + "description" : "Will error when selector count is > 4095.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "csslint", "bug", "cross-browser", "ie", "limit" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1d" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "selector-newline", + "name" : "Disallow new-line characters in selectors", + "description" : "New-line characters in selectors are usually a forgotten comma and not a descendant combinator.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "confusing", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "shorthand", + "name" : "Require shorthand properties", + "description" : "Use shorthand properties where possible.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "csslint", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "star-property-hack", + "name" : "Disallow properties with a star prefix", + "description" : "Checks for the star property hack (targets IE6/7)", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "bad-practice", "cross-browser", "ie", "ie7" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "text-indent", + "name" : "Disallow negative text-indent", + "description" : "Checks for text indent less than -99px", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "bad-practice", "accessibility" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "underscore-property-hack", + "name" : "Disallow properties with an underscore prefix", + "description" : "Checks for the underscore property hack (targets IE6)", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "bad-practice", "cross-browser", "ie", "ie6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "bulletproof-font-face", + "name" : "Use the bulletproof @font-face syntax", + "description" : "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "csslint", "pitfall", "cross-browser", "ie", "ie8" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +} ] \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/adjoining-classes.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/adjoining-classes.html index 4ecda92..a8474a1 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/adjoining-classes.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/adjoining-classes.html @@ -1,38 +1,19 @@ -

Details

-

Adjoining classes, sometimes also called class chaining, look like .foo.bar. While technically allowed in CSS, these aren't handled properly by Internet Explorer 6 and earlier. IE will match the selector as if it were simply '.bar' which means your selector will match more frequently than you intend it to and create cross-browser bugs.

+

Details

-

Generally, it's better to define styles based on single classes instead of based on multiple classes being present. Consider the following:

- -
.foo {
-    font-weight: bold;
-}
+        

Adjoining classes, sometimes also called class chaining, look like .foo.bar. While technically allowed in CSS, these aren't handled properly by Internet Explorer 6 and earlier. IE will match the selector as if it were simply '.bar' which means your selector will match more frequently than you intend it to and create cross-browser bugs.

-.bar { - padding: 10px; -} +

Generally, it's better to define styles based on single classes instead of based on multiple classes being present. Consider the following:

-.foo.bar { - color: red; -}
+
.foo {
font-weight: bold;
}

.bar {
padding: 10px;
}

.foo.bar {
color: red;
}

The rule for selector .foo.bar can be rewritten as a new class:

-
.foo {
-    font-weight: bold;
-}
-
-.bar {
-    padding: 10px;
-}
-
-.baz {
-    color: red;
-}
+
.foo {
font-weight: bold;
}

.bar {
padding: 10px;
}

.baz {
color: red;
}

That new class, baz, must now be added to the original HTML element. This is actually more maintainable because the .baz rule may now be reused whereas the .foo.bar rule could only be used in that one instance.

-Rule Details

+Rule Details

Rule ID: adjoining-classes

@@ -40,26 +21,19 @@

The following patterns are considered warnings:

-
.foo.bar {
-    border: 1px solid black;
-}
-
-.first .abc.def {
-    color: red;
-}
+
.foo.bar {
border: 1px solid black;
}

.first .abc.def {
color: red;
}

The following patterns are considered okay and do not cause a warning:

-
/* space in between classes */
-.foo .bar {
-    border: 1px solid black;
-}
+
/* space in between classes */
.foo .bar {
border: 1px solid black;
}

-Further Reading

+Further Reading -
    + + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/box-model.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/box-model.html index 1406415..3e36391 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/box-model.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/box-model.html @@ -1,33 +1,25 @@ -

    Details

    -

    The box model is one of the most frequently misunderstood parts of CSS. "Box model" refers to the series of boxes that make up an element visually. This starts with the content, which is the inner-most box. Content is surrounded by padding, which in turn is surrounded by borders. The way these measurements interact, however, is a bit confusing. Consider the following:

    +

    Details

    -
    .mybox {
    -    border: 1px solid black;
    -    padding: 5px;
    -    width: 100px;
    -}
    +

    The box model is one of the most frequently misunderstood parts of CSS. "Box model" refers to the series of boxes that make up an element visually. This starts with the content, which is the inner-most box. Content is surrounded by padding, which in turn is surrounded by borders. The way these measurements interact, however, is a bit confusing. Consider the following:

    + +
    .mybox {
    border: 1px solid black;
    padding: 5px;
    width: 100px;
    }

    A new developer might assume that the width of an element with the mybox class would be 100 pixels. In fact, the width is 112 pixels because width refers to the content box and padding and borders are added on top of that. Frequently when developers include this combination of properties, it is an error because they are expecting different behavior.

    You can force most browsers to obey width and height as the full size of an element by using the box-sizing property and setting it to border-box, as in this example:

    -
    .mybox {
    -    box-sizing: border-box;
    -    border: 1px solid black;
    -    padding: 5px;
    -    width: 100px;
    -}
    +
    .mybox {
    box-sizing: border-box;
    border: 1px solid black;
    padding: 5px;
    width: 100px;
    }

    Now an element with a class of mybox will have an actual width of 100 pixels, and the padding and borders will exist inside of that area, leaving 88 pixels for content instead of 100 pixels.

    -Rule Details

    +Rule Details

    Rule ID: box-model

    This rule is aimed at eliminating unwanted box model sizing issues. As such, the rule warns when it finds:

    -
      +
      1. width being used with border, border-left, border-right, padding, padding-left, or padding-right
      2. @@ -40,45 +32,18 @@

        The following patterns are considered warnings:

        -
        -/* width and border */
        -.mybox {
        -    border: 1px solid black;
        -    width: 100px;
        -}
        -
        -/* height and padding */
        -.mybox {
        -    height: 100px;
        -    padding: 10px;
        -}
        +
        /* width and border */
        .mybox {
        border: 1px solid black;
        width: 100px;
        }

        /* height and padding */
        .mybox {
        height: 100px;
        padding: 10px;
        }

        The following patterns are considered okay and do not cause warnings:

        -
        /* width and border with box-sizing */
        -.mybox {
        -    box-sizing: border-box;
        -    border: 1px solid black;
        -    width: 100px;
        -}
        -
        -/* width and border-top */
        -.mybox {
        -    border-top: 1px solid black;
        -    width: 100px;
        -}
        -
        -/* height and border-top of none */
        -.mybox {
        -    border-top: none;
        -    height: 100px;
        -}
        -
        +
        /* width and border with box-sizing */
        .mybox {
        box-sizing: border-box;
        border: 1px solid black;
        width: 100px;
        }

        /* width and border-top */
        .mybox {
        border-top: 1px solid black;
        width: 100px;
        }

        /* height and border-top of none */
        .mybox {
        border-top: none;
        height: 100px;
        }

        -Further Reading

        +Further Reading - + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/box-sizing.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/box-sizing.html index 4451dbe..be173ab 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/box-sizing.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/box-sizing.html @@ -1,29 +1,21 @@ -

        Details

        -

        The CSS box-sizing property is used to define how borders, padding, width, and height interact with each other. The default value is content-box, meaning that width and height refer to an element's content, and then padding and borders are added around it. Consider the following:

        +

        Details

        -
        .mybox {
        -    border: 1px solid black;
        -    padding: 5px;
        -    width: 100px;
        -}
        +

        The CSS box-sizing property is used to define how borders, padding, width, and height interact with each other. The default value is content-box, meaning that width and height refer to an element's content, and then padding and borders are added around it. Consider the following:

        + +
        .mybox {
        border: 1px solid black;
        padding: 5px;
        width: 100px;
        }

        The actual width of this box is 112 pixels. That's because the 100 pixels specified by width indicates how much area the content should take up, then 5 pixels are added on each side for padding, and 1 pixel on each side for the border.

        When you change box-sizing to border-box, the calculation is done differently:

        -
        .mybox {
        -    box-sizing: border-box;
        -    border: 1px solid black;
        -    padding: 5px;
        -    width: 100px;
        -}
        +
        .mybox {
        box-sizing: border-box;
        border: 1px solid black;
        padding: 5px;
        width: 100px;
        }

        This box has an actual width of 100 pixels while the space available for content is only 88 pixels (100 - 5px padding - 5px padding - 1px border - 1px border). Many consider the border-box setting to be more logical and more like how these properties should work.

        There is only a problem using box-sizing when you need to support Internet Explorer 6 and 7. These browsers do not support box-sizing and so will interpret the box model properties differently.

        -Rule Details

        +Rule Details

        Rule ID: box-sizing

        @@ -31,18 +23,14 @@

        The following patterns are considered warnings:

        -
        .mybox {
        -    box-sizing: border-box;
        -}
        -
        -.mybox {
        -    box-sizing: content-box;
        -}
        +
        .mybox {
        box-sizing: border-box;
        }

        .mybox {
        box-sizing: content-box;
        }

        -Further Reading

        +Further Reading -
          + + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/bulletproof-font-face.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/bulletproof-font-face.html index d49251c..831469c 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/bulletproof-font-face.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/bulletproof-font-face.html @@ -1,26 +1,15 @@ -

          Details

          -

          When using @font-face to declare multiple font types for cross browser compatibility, you can see 404's in old versions of IE due to a bug in the way that IE parses the font declarations. For example, this syntax:

          +

          Details

          -
          @font-face {
          -    font-family: 'MyFontFamily';
          -    src: url('myfont-webfont.eot') format('embedded-opentype'), 
          -        url('myfont-webfont.woff') format('woff'), 
          -        url('myfont-webfont.ttf')  format('truetype'),
          -        url('myfont-webfont.svg#svgFontName') format('svg');
          -}
          +

          When using @font-face to declare multiple font types for cross browser compatibility, you can see 404's in old versions of IE due to a bug in the way that IE parses the font declarations. For example, this syntax:

          + +
          @font-face {
          font-family: 'MyFontFamily';
          src: url('myfont-webfont.eot') format('embedded-opentype'),
          url('myfont-webfont.woff') format('woff'),
          url('myfont-webfont.ttf') format('truetype'),
          url('myfont-webfont.svg#svgFontName') format('svg');
          }

          Will cause a 404 in IE 6, 7, and 8. The fix is to add a question mark after the first font URL, so IE sees the rest of the property value as a query string. This is a correct example:

          -
          @font-face {
          -    font-family: 'MyFontFamily';
          -    src: url('myfont-webfont.eot?#iefix') format('embedded-opentype'), 
          -        url('myfont-webfont.woff') format('woff'), 
          -        url('myfont-webfont.ttf')  format('truetype'),
          -        url('myfont-webfont.svg#svgFontName') format('svg');
          -}
          +
          @font-face {
          font-family: 'MyFontFamily';
          src: url('myfont-webfont.eot?#iefix') format('embedded-opentype'),
          url('myfont-webfont.woff') format('woff'),
          url('myfont-webfont.ttf') format('truetype'),
          url('myfont-webfont.svg#svgFontName') format('svg');
          }

          -Rule Details

          +Rule Details

          Rule ID: bulletproof-font-face

          @@ -28,33 +17,21 @@

          The following patterns are considered warnings:

          -
          @font-face {
          -    font-family: 'MyFontFamily';
          -
          -    /* First web font is missing query string */
          -    src: url('myfont-webfont.eot') format('embedded-opentype'), 
          -        url('myfont-webfont.woff') format('woff'), 
          -        url('myfont-webfont.ttf')  format('truetype'),
          -        url('myfont-webfont.svg#svgFontName') format('svg');
          -}
          +
          @font-face {
          font-family: 'MyFontFamily';

          /* First web font is missing query string */
          src: url('myfont-webfont.eot') format('embedded-opentype'),
          url('myfont-webfont.woff') format('woff'),
          url('myfont-webfont.ttf') format('truetype'),
          url('myfont-webfont.svg#svgFontName') format('svg');
          }

          The following patterns are considered okay and do not cause warnings:

          -
          @font-face {
          -    font-family: 'MyFontFamily';
          -    src: url('myfont-webfont.eot?#iefix') format('embedded-opentype'), 
          -        url('myfont-webfont.woff') format('woff'), 
          -        url('myfont-webfont.ttf')  format('truetype'),
          -        url('myfont-webfont.svg#svgFontName') format('svg');
          -}
          +
          @font-face {
          font-family: 'MyFontFamily';
          src: url('myfont-webfont.eot?#iefix') format('embedded-opentype'),
          url('myfont-webfont.woff') format('woff'),
          url('myfont-webfont.ttf') format('truetype'),
          url('myfont-webfont.svg#svgFontName') format('svg');
          }

          This rule requires that the first font declared is a .eot file with a query string, but doesn't check the order of the remaining fonts (which is irrelevant, assuming you have the .eot file first).

          This rule was added in v0.9.10.

          -Further Reading

          +Further Reading -
            + + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/compatible-vendor-prefixes.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/compatible-vendor-prefixes.html index 2ecd645..d2b1e1c 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/compatible-vendor-prefixes.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/compatible-vendor-prefixes.html @@ -1,9 +1,10 @@ -

            Details

            -

            Experimental CSS properties are typically implemented using vendor prefixes until the final behavior has been established and agreed upon. Most CSS3 properties have vendor-prefixed equivalents for multiple vendors, including Firefox (-moz), Safari/Chrome (-webkit), Opera (-o), and Internet Explorer (-ms). It's easy to forget to include the vendor prefixed version of a property when there are so many to keep track of.

            +

            Details

            + +

            Experimental CSS properties are typically implemented using vendor prefixes until the final behavior has been established and agreed upon. Most CSS3 properties have vendor-prefixed equivalents for multiple vendors, including Firefox (-moz), Safari/Chrome (-webkit), Opera (-o), and Internet Explorer (-ms). It's easy to forget to include the vendor prefixed version of a property when there are so many to keep track of.

            The following properties have multiple vendor-prefixed versions:

            -
              +
              • animation
              • animation-delay
              • animation-direction
              • @@ -66,7 +67,7 @@

                Details

                If you want the same CSS effects across all browsers, then it's important to remember the vendor-prefixed properties for all supporting browsers.

                -Rule Details

                +Rule Details

                Rule ID: compatible-vendor-prefixes

                @@ -74,12 +75,6 @@

                The following patterns are considered warnings:

                -
                /* Missing -moz, -ms, and -o */
                -.mybox {
                -    -webkit-transform: translate(50px, 100px);
                -}
                +
                /* Missing -moz, -ms, and -o */
                .mybox {
                -webkit-transform: translate(50px, 100px);
                }

                /* Missing -webkit */
                .mybox {
                -moz-border-radius: 5px;
                }
                -/* Missing -webkit */ -.mybox { - -moz-border-radius: 5px; -}
                + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/display-property-grouping.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/display-property-grouping.html index 75a8e52..87a47e5 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/display-property-grouping.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/display-property-grouping.html @@ -1,11 +1,12 @@ -

                Details

                -

                Even though you can define any group of properties together in a CSS rule, some of them will be ignored due to the display of the element. This leads to extra cruft in your CSS and misunderstandings around how a rule should work.

                +

                Details

                + +

                Even though you can define any group of properties together in a CSS rule, some of them will be ignored due to the display of the element. This leads to extra cruft in your CSS and misunderstandings around how a rule should work.

                For display: inline, the width, height, margin-top, margin-bottom, and float properties have no effect because inline elements don't have a formal box with which to apply the styles. The margin-left and margin-right properties still work reliably for indentation purposes but the other margin settings do not. The float property is sometimes used as a fix for the IE6 double-margin bug.

                Other general rules based on display are:

                -
                  +
                  • display: inline-block should not use float.
                  • @@ -17,13 +18,13 @@

                    Details

                    Removing the ignored or problematic properties decreases file size thereby improving performance.

                    -Rule Details

                    +Rule Details

                    Rule ID: display-property-grouping

                    This rule is aimed at flagging properties that don't work based with the display property being used. The ultimate goal is to produce a smaller, clearer CSS file without unnecessary code. As such, the rule warns when it finds:

                    -
                      +
                      • display: inline used with width, height, margin, margin-top, margin-bottom, and float.
                      • @@ -36,41 +37,17 @@

                        The following patterns are considered warnings:

                        -
                        /* inline with height */
                        -.mybox {
                        -    display: inline;
                        -    height: 25px;
                        -}
                        -
                        -/* inline-block with float */
                        -.mybox {
                        -    display: inline-block;
                        -    float: left;
                        -}
                        -
                        -/* table-cell and margin */
                        -.mybox {
                        -    display: table-cell;
                        -    margin: 10px;
                        -}
                        +
                        /* inline with height */
                        .mybox {
                        display: inline;
                        height: 25px;
                        }

                        /* inline-block with float */
                        .mybox {
                        display: inline-block;
                        float: left;
                        }

                        /* table-cell and margin */
                        .mybox {
                        display: table-cell;
                        margin: 10px;
                        }

                        The following patterns are considered okay and do not cause warnings:

                        -
                        /* inline with margin-left */
                        -.mybox {
                        -    display: inline;
                        -    margin-left: 10px;
                        -}
                        -
                        -/* table and margin */
                        -.mybox {
                        -    display: table;
                        -    margin-bottom: 10px;
                        -}
                        +
                        /* inline with margin-left */
                        .mybox {
                        display: inline;
                        margin-left: 10px;
                        }

                        /* table and margin */
                        .mybox {
                        display: table;
                        margin-bottom: 10px;
                        }

                        -Further Reading

                        +Further Reading -
                          + + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/duplicate-background-images.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/duplicate-background-images.html index eabfd2a..25eb629 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/duplicate-background-images.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/duplicate-background-images.html @@ -1,32 +1,17 @@ -

                          Details

                          -

                          One of the main rules of performance is to use as few bytes as possible to get the job done. Along those lines, URLs are best used just once inside of CSS. If you have more than one class that needs to use the same background image, then it's better to have one class that uses the URL and simply apply that class to the various elements where it is needed. Consider the following:

                          +

                          Details

                          -
                          .heart-icon {
                          -    background: url(sprite.png) -16px 0 no-repeat;
                          -}
                          +        

                          One of the main rules of performance is to use as few bytes as possible to get the job done. Along those lines, URLs are best used just once inside of CSS. If you have more than one class that needs to use the same background image, then it's better to have one class that uses the URL and simply apply that class to the various elements where it is needed. Consider the following:

                          -.task-icon { - background: url(sprite.png) -32px 0 no-repeat; -}
                          +
                          .heart-icon {
                          background: url(sprite.png) -16px 0 no-repeat;
                          }

                          .task-icon {
                          background: url(sprite.png) -32px 0 no-repeat;
                          }

                          The background image is repeated in both classes. That's extra bytes you don't need and also increases the chances that you'll forget to change one should the filename change. An alternative is to define one class that has the URL and be sure to apply that class to the HTML elements where the other classes are used. For example:

                          -
                          .icons {
                          -    background: url(sprite.png) no-repeat;
                          -}
                          -
                          -.heart-icon {
                          -    background-position: -16px 0;
                          -}
                          -
                          -.task-icon {
                          -    background-position: -32px 0;
                          -}
                          +
                          .icons {
                          background: url(sprite.png) no-repeat;
                          }

                          .heart-icon {
                          background-position: -16px 0;
                          }

                          .task-icon {
                          background-position: -32px 0;
                          }

                          Here, the icons class contains the background image while the other classes just change the background position.

                          -Rule Details

                          +Rule Details

                          Rule ID: duplicate-background-images

                          @@ -34,27 +19,12 @@

                          The following patterns are considered warnings:

                          -
                          /* multiple instances of the same URL */
                          -.heart-icon {
                          -    background: url(sprite.png) -16px 0 no-repeat;
                          -}
                          -
                          -.task-icon {
                          -    background: url(sprite.png) -32px 0 no-repeat;
                          -}
                          +
                          /* multiple instances of the same URL */
                          +.heart-icon {
                          background: url(sprite.png) -16px 0 no-repeat;
                          }

                          .task-icon {
                          background: url(sprite.png) -32px 0 no-repeat;
                          }

                          The following patterns are considered okay and do not cause warnings:

                          -
                          /* fallback color before newer format */
                          -.icons {
                          -    background: url(sprite.png) no-repeat;
                          -}
                          -
                          -.heart-icon {
                          -    background-position: -16px 0;
                          -}
                          -
                          -.task-icon {
                          -    background-position: -32px 0;
                          -}
                          +
                          /* single instance of URL */
                          +.icons {
                          background: url(sprite.png) no-repeat;
                          }

                          .heart-icon {
                          background-position: -16px 0;
                          }

                          .task-icon {
                          background-position: -32px 0;
                          }
                          + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/duplicate-properties.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/duplicate-properties.html index 1e21e56..562b486 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/duplicate-properties.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/duplicate-properties.html @@ -1,53 +1,33 @@ -

                          Details

                          -

                          Early on in web development, including the same CSS property twice was certainly an error, especially if there were two different values. For example:

                          +

                          Details

                          -
                          .mybox {
                          -    width: 100px;
                          -    width: 120px;
                          -}
                          +

                          Early on in web development, including the same CSS property twice was certainly an error, especially if there were two different values. For example:

                          + +
                          .mybox {
                          width: 100px;
                          width: 120px;
                          }

                          Anyone looking at this code would think that this is clearly an error. Recently, however, including duplicate properties is used as a way to deal with varying levels of browser support for CSS properties. For example, some browsers support RGBA color while others do not, so it's quite common to see patterns such as:

                          -
                          .mybox {
                          -    background: #fff;
                          -    background: rgba(255, 255, 255, 0.5);
                          -}
                          +
                          .mybox {
                          background: #fff;
                          background: rgba(255, 255, 255, 0.5);
                          }

                          This is quite clearly intentional. The developer wants to use RGBA when available but wants to fall back to a regular color when not available.

                          -Rule Details

                          +Rule Details

                          Rule ID: duplicate-properties

                          This rule is intended to find errors of duplication in CSS code. It warns when:

                          -
                            +
                            1. A property is included twice and contains the same value.
                            2. A property is included twice and is separated by at least one other property.

                            The following patterns are considered warnings:

                            -
                            -/* properties with the same value */
                            -.mybox {
                            -    border: 1px solid black;
                            -    border: 1px solid black;
                            -}
                            -
                            -/* properties separated by another property */
                            -.mybox {
                            -    border: 1px solid black;
                            -    color: green;
                            -    border: 1px solid red;
                            -}
                            +
                            /* properties with the same value */
                            .mybox {
                            border: 1px solid black;
                            border: 1px solid black;
                            }

                            /* properties separated by another property */
                            .mybox {
                            border: 1px solid black;
                            color: green;
                            border: 1px solid red;
                            }

                            The following patterns are considered okay and do not cause a warning:

                            -
                            -/* one after another with different values */
                            -.mybox {
                            -    border: 1px solid black;
                            -    border: 1px solid red;
                            -}
                            +
                            /* one after another with different values */
                            .mybox {
                            border: 1px solid black;
                            border: 1px solid red;
                            }
                            + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/empty-rules.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/empty-rules.html index ab52014..55e03e9 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/empty-rules.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/empty-rules.html @@ -1,24 +1,18 @@ -

                            Details

                            -

                            An empty rule is one that doesn't contain any properties, such as:

                            +

                            Details

                            -
                            .foo {
                            -}
                            +

                            An empty rule is one that doesn't contain any properties, such as:

                            + +
                            .foo {
                            }

                            A lot of times, empty rules appear as a result of refactoring without further cleanup. Eliminating empty rules results in smaller file sizes and less style information for the browser to deal with.

                            -Rule Details

                            +Rule Details

                            Rule ID: empty-rules

                            This rule warns when an empty rule is found in the CSS. The following patterns are considered warnings:

                            -
                            .mybox { }
                            -
                            -.mybox {
                            -
                            -}
                            +
                            .mybox { }

                            .mybox {

                            }

                            .mybox {
                            /* a comment */
                            }
                            -.mybox { - /* a comment */ -}
                            + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/fallback-colors.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/fallback-colors.html index 9583636..0a6d16a 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/fallback-colors.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/fallback-colors.html @@ -1,31 +1,25 @@ -

                            Details

                            -

                            In the beginning, there were three ways to specify colors: in hexadecimal format, using either three or six characters, named colors such as red, and rgb(). CSS3 has since added several new color formats including rgba(), hsl(), and hsla(). While these new color formats bring a remarkable amount of flexibility to how developers define colors and the relationships between them, it can also leave older browsers looking worse than expected.

                            +

                            Details

                            + +

                            In the beginning, there were three ways to specify colors: in hexadecimal format, using either three or six characters, named colors such as red, and rgb(). CSS3 has since added several new color formats including rgba(), hsl(), and hsla(). While these new color formats bring a remarkable amount of flexibility to how developers define colors and the relationships between them, it can also leave older browsers looking worse than expected.

                            The problem is that CSS parsers in browsers will skip a property whose name or value is not understood. Older browsers such as Internet Explorer 8 and earlier, do not understand rgba(), hsl(), or hsla(), and as a result will drop any declarations containing them. Consider the following:

                            -
                            .box {
                            -    background: #000;
                            -    color: rgba(100, 100, 200, 0.5);
                            -}
                            +
                            .box {
                            background: #000;
                            color: rgba(100, 100, 200, 0.5);
                            }

                            Supporting browsers will treat this CSS code as described. Non-supporting browsers will completely drop the color property because the value isn't understood. That means the actual color used will be inherited from the surrounding context and might actually end up black (the same as the background). To prevent this, you should always include a fallback color in either hexadecimal, named, or rgb() format, such as:

                            -
                            .box {
                            -    background: #000;
                            -    color: blue;
                            -    color: rgba(100, 100, 200, 0.5);
                            -}
                            +
                            .box {
                            background: #000;
                            color: blue;
                            color: rgba(100, 100, 200, 0.5);
                            }

                            The fallback color should always go before the new color to ensure older browsers see and use it correctly, and that newer browsers continue on to use the newer color format.

                            -Rule Details

                            +Rule Details

                            Rule ID: fallback-colors

                            This rule is aimed at ensuring a proper color is displayed for all browsers. As such, the rule warns when it finds:

                            -
                              +
                              1. A color property with a rgba(), hsl(), or hsla() color without a preceding color property that has an older color format.
                              2. A background property with a rgba(), hsl(), or hsla() color without a preceding background property that has an older color format.
                              3. A background-color property with a rgba(), hsl(), or hsla() color without a preceding background-color property that has an older color format.
                              4. @@ -33,32 +27,10 @@

                                The following patterns are considered warnings:

                                -
                                -/* missing fallback color */
                                -.mybox {
                                -    color: rgba(100, 200, 100, 0.5);
                                -}
                                -
                                -/* missing fallback color */
                                -.mybox {
                                -    background-color: hsla(100, 50%, 100%, 0.5);
                                -}
                                -
                                -/* missing fallback color */
                                -.mybox {
                                -    background: hsla(100, 50%, 100%, 0.5) url(foo.png);
                                -}
                                -
                                -/* fallback color should be before */
                                -.mybox {
                                -    background-color: hsl(100, 50%, 100%);
                                -    background-color: green;
                                -}
                                +
                                /* missing fallback color */
                                .mybox {
                                color: rgba(100, 200, 100, 0.5);
                                }

                                /* missing fallback color */
                                .mybox {
                                background-color: hsla(100, 50%, 100%, 0.5);
                                }

                                /* missing fallback color */
                                .mybox {
                                background: hsla(100, 50%, 100%, 0.5) url(foo.png);
                                }

                                /* fallback color should be before */
                                .mybox {
                                background-color: hsl(100, 50%, 100%);
                                background-color: green;
                                }

                                The following patterns are considered okay and do not cause warnings:

                                -
                                /* fallback color before newer format */
                                -.mybox {
                                -    color: red;
                                -    color: rgba(255, 0, 0, 0.5);
                                -}
                                +
                                /* fallback color before newer format */
                                .mybox {
                                color: red;
                                color: rgba(255, 0, 0, 0.5);
                                }
                                + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/floats.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/floats.html index 443d3b1..74d29d1 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/floats.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/floats.html @@ -1,27 +1,31 @@ -

                                Details

                                -

                                The float property is the most popular method of achieving columnar layouts using CSS. During the course of a project, more and more float elements are used to create ever-different layouts throughout a page or site. This leads to fragile CSS that is easy to break if one aspect of the layout changes.

                                +

                                Details

                                + +

                                The float property is the most popular method of achieving columnar layouts using CSS. During the course of a project, more and more float elements are used to create ever-different layouts throughout a page or site. This leads to fragile CSS that is easy to break if one aspect of the layout changes.

                                Frequently, using too many floats is a sign that your project would benefit from a grid system. CSS grid systems standardize columnar layouts using CSS classes. Some popular grid systems are:

                                -
                                  +

                                  Using one of these grid systems can greatly reduce the amount of CSS code you need to write by hand.

                                  -Rule Details

                                  +Rule Details

                                  Rule ID: floats

                                  This rule is aimed at reducing complexity by watching how many times float is used. It warns when float has been used more than 10 times. This amount of floats usually indicates that there are a lot of columnar layouts being defined and that a grids system would be a better choice for your CSS.

                                  -Additional Reading

                                  +Additional Reading -
                                    + + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/font-faces.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/font-faces.html index 1428db5..271cde2 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/font-faces.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/font-faces.html @@ -1,2 +1,7 @@ -

                                    Details

                                    -

                                    Web fonts are growing in popularity and use of @font-face is on the rise. However, using web fonts comes with performance implications as font files can be quite large and some browsers block rendering while downloading them. For this reason, CSSLint will warn you when there are more than five web fonts in a style sheet.

                                    +

                                    Details

                                    + +

                                    Web fonts are growing in popularity and use of @font-face is on the rise. However, using web fonts comes with performance implications as font files can be quite large and some browsers block rendering while downloading them. For this reason, CSSLint will warn you when there are more than 5 web fonts in a style sheet.

                                    + +

                                    Rule ID: font-faces

                                    + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/font-sizes.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/font-sizes.html index 0a0e34f..1f714b3 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/font-sizes.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/font-sizes.html @@ -1,26 +1,18 @@ -

                                    Details

                                    -

                                    A well-organized site has a small set of font sizes used throughout. These font sizes are often best represented as abstracted classes that can be applied to elements anywhere in the site. When not abstracted, this leads developers to add font-size declarations repeatedly in order to get the right size to appear. This is problematic because font sizes can't be changed in one spot if and when the design changes.

                                    +

                                    Details

                                    -

                                    You can create some standard font size class such as:

                                    - -
                                    .small {
                                    -    font-size: 8px;
                                    -}
                                    +        

                                    A well-organized site has a small set of font sizes used throughout. These font sizes are often best represented as abstracted classes that can be applied to elements anywhere in the site. When not abstracted, this leads developers to add font-size declarations repeatedly in order to get the right size to appear. This is problematic because font sizes can't be changed in one spot if and when the design changes.

                                    -.medium { - font-size: 11px; -} +

                                    You can create some standard font size class such as:

                                    -.large { - font-size: 14px; -}
                                    +
                                    .small {
                                    font-size: 8px;
                                    }

                                    .medium {
                                    font-size: 11px;
                                    }

                                    .large {
                                    font-size: 14px;
                                    }

                                    Using classes such as these in your project allows consistent use of font sizes throughout, and also limits the number of times font-size appears in your CSS. Now there is one place to go to change font sizes instead of multiple.

                                    -Rule Details

                                    +Rule Details

                                    Rule ID: font-sizes

                                    This rule is aimed at pointing out opportunities for abstracting font sizes. The rule warns when 10 or more font-size declarations are found.

                                    + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/gradients.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/gradients.html index c844f0e..a34ab08 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/gradients.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/gradients.html @@ -1,7 +1,8 @@ -

                                    Details

                                    -

                                    As of December 2011, there is still no standard CSS gradient implementation, which means using CSS gradients in a cross-browser way requires using many different vendor-prefixed versions. There are currently five different vendor-prefixed versions of CSS gradient:

                                    +

                                    Details

                                    -
                                      +

                                      As of December 2011, there is still no standard CSS gradient implementation, which means using CSS gradients in a cross-browser way requires using many different vendor-prefixed versions. There are currently five different vendor-prefixed versions of CSS gradient:

                                      + +
                                      • -ms-linear-gradient and -ms-radial-gradient for Internet Explorer 10+
                                      • @@ -16,17 +17,12 @@

                                        Details

                                        Meaning a simple two-color gradient that works across all browsers must look like this:

                                        -
                                        background: -moz-linear-gradient(top,  #1e5799 0%, #7db9e8 100%); /* FF3.6+ */
                                        -background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */
                                        -background: -webkit-linear-gradient(top,  #1e5799 0%,#7db9e8 100%); /* Chrome10+,Safari5.1+ */
                                        -background: -o-linear-gradient(top,  #1e5799 0%,#7db9e8 100%); /* Opera 11.10+ */
                                        -background: -ms-linear-gradient(top,  #1e5799 0%,#7db9e8 100%); /* IE10+ */
                                        -
                                        +
                                        background: -moz-linear-gradient(top,  #1e5799 0%, #7db9e8 100%); /* FF3.6+ */
                                        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */
                                        background: -webkit-linear-gradient(top, #1e5799 0%,#7db9e8 100%); /* Chrome10+,Safari5.1+ */
                                        background: -o-linear-gradient(top, #1e5799 0%,#7db9e8 100%); /* Opera 11.10+ */
                                        background: -ms-linear-gradient(top, #1e5799 0%,#7db9e8 100%); /* IE10+ */

                                        It's easy to forget one or more gradient definitions with all of the various vendor prefix gradients available.

                                        -Rule Details

                                        +Rule Details

                                        Rule ID: gradients

                                        @@ -34,25 +30,10 @@

                                        The following patterns are considered warnings:

                                        -
                                        /* Missing -moz, -ms, and -o */
                                        -.mybox {
                                        -    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(100%,#7db9e8));
                                        -    background: -webkit-linear-gradient(top,  #1e5799 0%,#7db9e8 100%);
                                        -}
                                        -
                                        -/* Missing old and new -webkit */
                                        -.mybox {
                                        -    background: -moz-linear-gradient(top,  #1e5799 0%, #7db9e8 100%); 
                                        -    background: -o-linear-gradient(top,  #1e5799 0%,#7db9e8 100%);
                                        -    background: -ms-linear-gradient(top,  #1e5799 0%,#7db9e8 100%);
                                        -}
                                        +
                                        /* Missing -moz, -ms, and -o */
                                        .mybox {
                                        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(100%,#7db9e8));
                                        background: -webkit-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
                                        }

                                        /* Missing old and new -webkit */
                                        .mybox {
                                        background: -moz-linear-gradient(top, #1e5799 0%, #7db9e8 100%);
                                        background: -o-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
                                        background: -ms-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
                                        }

                                        The following patterns are considered okay and do not cause a warning:

                                        -
                                        .mybox {
                                        -    background: -moz-linear-gradient(top,  #1e5799 0%, #7db9e8 100%);
                                        -    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-   stop(100%,#7db9e8));
                                        -    background: -webkit-linear-gradient(top,  #1e5799 0%,#7db9e8 100%);
                                        -    background: -o-linear-gradient(top,  #1e5799 0%,#7db9e8 100%);
                                        -    background: -ms-linear-gradient(top,  #1e5799 0%,#7db9e8 100%); 
                                        -}
                                        +
                                        .mybox {
                                        background: -moz-linear-gradient(top, #1e5799 0%, #7db9e8 100%);
                                        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(100%,#7db9e8));
                                        background: -webkit-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
                                        background: -o-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
                                        background: -ms-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
                                        }
                                        + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/ids.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/ids.html index 1929ea8..3c4b89f 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/ids.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/ids.html @@ -1,29 +1,23 @@ -

                                        Details

                                        -

                                        For years, developers have treated IDs as the way to say "that thing!" However, IDs have a downside: they are completely unique and therefore cannot be reused. You could potentially style every element on your page with an ID selector but you would lose a lot of the benefit of CSS in the process.

                                        +

                                        Details

                                        + +

                                        For years, developers have treated IDs as the way to say "that thing!" However, IDs have a downside: they are completely unique and therefore cannot be reused. You could potentially style every element on your page with an ID selector but you would lose a lot of the benefit of CSS in the process.

                                        One of CSS's benefits is the ability to reuse style rules in multiple places. When you start out with an ID selector, you're automatically limiting that style to a single element. Suppose you have this:

                                        -
                                        #header a {
                                        -    color: black;
                                        -}
                                        +
                                        #header a {
                                        color: black;
                                        }

                                        This style is only useful within the element with the ID of header. But now suppose that you want another section of the page to be styled the same way, you'll probably end up defining a new class that does the same thing, such as:

                                        -
                                        #header a,
                                        -.callout a {
                                        -    color: black;
                                        -}
                                        +
                                        #header a,
                                        .callout a {
                                        color: black;
                                        }

                                        Once you've gotten to this point, you might as well just use the class and not mention the ID:

                                        -
                                        .callout a {
                                        -    color: black;
                                        -}
                                        +
                                        .callout a {
                                        color: black;
                                        }

                                        Eventually you will end up needing or wanting to reuse the style specified with the ID, and you'll end up defining a class for that purpose. By not using IDs from the start, you allow for the maximum level of reusability with your CSS.

                                        -Rule Details

                                        +Rule Details

                                        Rule ID: ids

                                        @@ -31,18 +25,14 @@

                                        The following patterns are considered warnings:

                                        -
                                        #mybox {
                                        -    display: block;
                                        -}
                                        -
                                        -.mybox #go {
                                        -    color: red;
                                        -}
                                        +
                                        #mybox {
                                        display: block;
                                        }

                                        .mybox #go {
                                        color: red;
                                        }

                                        -Additional Reading

                                        +Additional Reading -
                                          + + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/import.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/import.html index d738428..8e94593 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/import.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/import.html @@ -1,24 +1,20 @@ -

                                          Details

                                          -

                                          The @import command is used to include CSS files within other CSS files, for example:

                                          +

                                          Details

                                          -
                                          @import url(more.css);
                                          -@import url(andmore.css);
                                          +        

                                          The @import command is used to include CSS files within other CSS files, for example:

                                          -a { - color: black; -}
                                          +
                                          @import url(more.css);
                                          @import url(andmore.css);

                                          a {
                                          color: black;
                                          }

                                          This code includes two more style sheets at the beginning of a style sheet. When the browser parses this code, it stops at each @import and starts to download the specified file. The browser doesn't continue downloading other style sheets until this one has finished, eliminating any possible parallel downloads of CSS.

                                          There are two alternatives to using @import:

                                          -
                                            +
                                            1. Use a build system to concatenate CSS files together before deploying.
                                            2. Use multiple <link> tags to include the style sheets you want. These will still be downloaded in parallel.

                                            -Rule Details

                                            +Rule Details

                                            Rule ID: import

                                            @@ -26,11 +22,13 @@

                                            The following pattern is considered a warning:

                                            -
                                            @import url(foo.css);
                                            +
                                            @import url(foo.css);

                                            -Further Reading

                                            +Further Reading - + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/important.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/important.html index a60e0b8..d2467be 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/important.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/important.html @@ -1,8 +1,9 @@ -

                                            Details

                                            -

                                            The !important annotation is used to artificially increase the specificity of a given property value in a rule. This is usually an indication that the specificity of the entire CSS has gotten a bit out of control and needs to be refactored. The more frequently !important is found in CSS, the more likely it is that developers are having trouble styling parts of a page effectively.

                                            +

                                            Details

                                            + +

                                            The !important annotation is used to artificially increase the specificity of a given property value in a rule. This is usually an indication that the specificity of the entire CSS has gotten a bit out of control and needs to be refactored. The more frequently !important is found in CSS, the more likely it is that developers are having trouble styling parts of a page effectively.

                                            -Rule Details

                                            +Rule Details

                                            Rule ID: important

                                            @@ -10,15 +11,15 @@

                                            The following patterns are considered warnings:

                                            -
                                            .mybox {
                                            -    color: red !important;
                                            -}
                                            +
                                            .mybox {
                                            color: red !important;
                                            }

                                            -Further Reading

                                            +Further Reading -
                                              + + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/known-properties.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/known-properties.html index 6851d69..55357ba 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/known-properties.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/known-properties.html @@ -1,8 +1,9 @@ -

                                              Details

                                              -

                                              The list of supported CSS properties is growing quite large, and it's very easy to miss a typo in a single property when the property name isn't checked.

                                              +

                                              Details

                                              + +

                                              The list of supported CSS properties is growing quite large, and it's very easy to miss a typo in a single property when the property name isn't checked.

                                              -Rule Details

                                              +Rule Details

                                              Rule ID: known-properties

                                              @@ -14,20 +15,10 @@

                                              The following patterns are considered warnings:

                                              -
                                              -/* clr isn't a known property */
                                              -a {
                                              -    clr: red;
                                              -}
                                              -
                                              -/* 'foo' isn't a valid color */
                                              -a {
                                              -    color: foo;
                                              -}
                                              +
                                              /* clr isn't a known property */
                                              a {
                                              clr: red;
                                              }

                                              /* 'foo' isn't a valid color */
                                              a {
                                              color: foo;
                                              }

                                              The following pattern is considered okay and does not cause a warning:

                                              -
                                              /* -moz- is a vendor prefix, so ignore */
                                              -a {
                                              -    -moz-foo: bar;
                                              -}
                                              +
                                              /* -moz- is a vendor prefix, so ignore */
                                              a {
                                              -moz-foo: bar;
                                              }
                                              + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/outline-none.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/outline-none.html index 56b689a..de27a4a 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/outline-none.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/outline-none.html @@ -1,35 +1,29 @@ -

                                              Details

                                              -

                                              The CSS outline property is used to define a border around elements. Unlike the border property, the outline property does not alter the size or layout of the element. Because of this, browsers frequently use outline as the specification for an active state. In Internet Explorer and Firefox, the outline of a selected element is a single pixel dotted line when focus has moved to that element.

                                              +

                                              Details

                                              + +

                                              The CSS outline property is used to define a border around elements. Unlike the border property, the outline property does not alter the size or layout of the element. Because of this, browsers frequently use outline as the specification for an active state. In Internet Explorer and Firefox, the outline of a selected element is a single pixel dotted line when focus has moved to that element.

                                              The focus outline is important for accessibility because it gives a visual indication as to where the focus is on the page. For keyboard-only users, tracking the focus on a web page is impossible without the visual indication given by the focus outline. Unfortunately, some consider the focus outline to be "ugly" or unappealing, and remove it using code such as :

                                              -
                                              a {
                                              -    outline: none;
                                              -}
                                              +
                                              a {
                                              outline: none;
                                              }

                                              Or:

                                              -
                                              a {
                                              -    outline: 0;
                                              -}
                                              +
                                              a {
                                              outline: 0;
                                              }

                                              Both of these will remove the outline from an element, so it won't appear even when focus has moved to that element. This is very bad for accessibility.

                                              Of course, there are times when you may want to provide a custom focus decoration for users instead of the default dotted border. In those instances, it's appropriate to remove the outline and add another treatment. The best way to do this is to use :focus and provide the alternate treatment along with resetting outline, such as:

                                              -
                                              a:focus {
                                              -    border: 1px solid red;
                                              -    outline: none;
                                              -}
                                              +
                                              a:focus {
                                              border: 1px solid red;
                                              outline: none;
                                              }

                                              -Rule Details

                                              +Rule Details

                                              Rule ID: outline-none

                                              This rule is aimed at ensuring keyboard-only users have a visual indicator of focus. As such, the rule warns when it finds:

                                              -
                                                +
                                                1. outline: none or outline: 0 in any rule whose selectors doesn't contain :focus
                                                2. @@ -39,34 +33,27 @@

                                                  The following patterns are considered warnings:

                                                  -
                                                  -/* no :focus */
                                                  -a {
                                                  -    outline: none;
                                                  -}
                                                  +
                                                  /* no :focus */
                                                  +a {
                                                  outline: none;
                                                  } -/* no :focus */ -a { - outline: 0; -} +/* no :focus */ +a {
                                                  outline: 0;
                                                  } -/* :focus but missing a replacement treatment */ -a:focus { - outline: 0; +/* :focus but missing a replacement treatment */ +a:focus { + outline: 0; }

                                                  The following pattern is considered okay and does not cause a warning:

                                                  -
                                                  /* :focus with outline: 0 and provides replacement treatment */
                                                  -a:focus {
                                                  -    border: 1px solid red;
                                                  -    outline: 0;
                                                  -}
                                                  +
                                                  /* :focus with outline: 0 and provides replacement treatment */
                                                  a:focus {
                                                  border: 1px solid red;
                                                  outline: 0;
                                                  }

                                                  -Further Reading

                                                  +Further Reading

                                                  -
                                                    + + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/overqualified-elements.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/overqualified-elements.html index 1152628..9ef18c7 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/overqualified-elements.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/overqualified-elements.html @@ -1,10 +1,11 @@ -

                                                    Details

                                                    -

                                                    Writing selectors such as li.active are unnecessary unless the element name causes the class to behave differently. In most cases, it's safe to remove the element name from the selector, both reducing the size of the CSS as well as improving the selector performance (doesn't have to match the element anymore).

                                                    +

                                                    Details

                                                    + +

                                                    Writing selectors such as li.active are unnecessary unless the element name causes the class to behave differently. In most cases, it's safe to remove the element name from the selector, both reducing the size of the CSS as well as improving the selector performance (doesn't have to match the element anymore).

                                                    Removing the element name also loosens the coupling between your CSS and your HTML, allowing you to change the element on which the class is used without also needing to update the CSS.

                                                    -Rule Details

                                                    +Rule Details

                                                    Rule ID: overqualified-elements

                                                    @@ -12,22 +13,10 @@

                                                    The following patterns are considered warnings:

                                                    -
                                                    div.mybox {
                                                    -    color: red;   
                                                    -}
                                                    -
                                                    -.mybox li.active {
                                                    -    background: red;
                                                    -}
                                                    +
                                                    div.mybox {
                                                    color: red;
                                                    }

                                                    .mybox li.active {
                                                    background: red;
                                                    }

                                                    The following patterns are considered okay and do not cause warnings:

                                                    -
                                                    -/* Two different elements in different rules with the same class */
                                                    -li.active {
                                                    -    color: red;
                                                    -}
                                                    +
                                                    /* Two different elements in different rules with the same class */
                                                    li.active {
                                                    color: red;
                                                    }

                                                    p.active {
                                                    color: green;
                                                    }
                                                    -p.active { - color: green; -}
                                                    + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/qualified-headings.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/qualified-headings.html index 8f8a56d..e73e2d7 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/qualified-headings.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/qualified-headings.html @@ -1,12 +1,11 @@ -

                                                    Details

                                                    -

                                                    Heading elements (h1-h6) should be defined as top-level styles and not scoped to particular areas of the page. The headings are considered to be built-in objects in Object-Oriented CSS, and their appearance should be consistent across an entire site. This allows those styles to be reused across your site for better visual consistency and performance and easier maintenance. For example, this is an example of an overqualified heading:

                                                    +

                                                    Details

                                                    -
                                                    .foo h1 {
                                                    -    font-size: 110%;
                                                    -}
                                                    +

                                                    Heading elements (h1-h6) should be defined as top-level styles and not scoped to particular areas of the page. The headings are considered to be built-in objects in Object-Oriented CSS, and their appearance should be consistent across an entire site. This allows those styles to be reused across your site for better visual consistency and performance and easier maintenance. For example, this is an example of an overqualified heading:

                                                    + +
                                                    .foo h1 {
                                                    font-size: 110%;
                                                    }

                                                    -Rule Details

                                                    +Rule Details

                                                    Rule ID: qualified-headings

                                                    @@ -14,26 +13,17 @@

                                                    The following patterns are considered warnings:

                                                    -
                                                    /* qualified heading */
                                                    -.box h3 {
                                                    -    font-weight: normal;
                                                    -}
                                                    -
                                                    -/* qualified heading */
                                                    -.item:hover h3 {
                                                    -    font-weight: bold;
                                                    -}
                                                    +
                                                    /* qualified heading */
                                                    .box h3 {
                                                    font-weight: normal;
                                                    }

                                                    /* qualified heading */
                                                    .item:hover h3 {
                                                    font-weight: bold;
                                                    }

                                                    The following patterns are considered okay and do not cause warnings:

                                                    -
                                                    /* Not qualified */
                                                    -h3 {
                                                    -    font-weight: normal;
                                                    -}
                                                    +
                                                    /* Not qualified */
                                                    h3 {
                                                    font-weight: normal;
                                                    }

                                                    -Further Reading

                                                    +Further Reading - + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/regex-selectors.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/regex-selectors.html index 177ecc7..8c90d0e 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/regex-selectors.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/regex-selectors.html @@ -1,120 +1,85 @@ -

                                                    Details

                                                    -

                                                    CSS3 adds complex attribute selectors that allow you to perform regular expression matches on attribute values. These types of selectors have performance implications, as regular expression matching is slower than simple class-based matching. In many cases, the attribute selectors aren't providing enough value over simply adding an additional class to the element in question. There are several types of attribute selectors to be mindful of.

                                                    +

                                                    Details

                                                    + +

                                                    CSS3 adds complex attribute selectors that allow you to perform regular expression matches on attribute values. These types of selectors have performance implications, as regular expression matching is slower than simple class-based matching. In many cases, the attribute selectors aren't providing enough value over simply adding an additional class to the element in question. There are several types of attribute selectors to be mindful of.

                                                    The first attribute selector is actually not a performance issue as it simply determine if the attribute is present. For example, the following applies only when an href property is specified on an <a> element:

                                                    -
                                                    //OK
                                                    -a[href] {
                                                    -    color: red;
                                                    -}
                                                    +
                                                    //OK
                                                    a[href] {
                                                    color: red;
                                                    }

                                                    This attribute selector is okay to use and shouldn't cause any performance issues.

                                                    The second attribute selector that is okay to use applies the style only when an attribute value matches exactly. For example, the following applies only when the rel attribute of an <a> element is "external":

                                                    -
                                                    //OK
                                                    -a[rel=external] {
                                                    -    color: blue;
                                                    -}
                                                    +
                                                    //OK
                                                    a[rel=external] {
                                                    color: blue;
                                                    }

                                                    After these two, the rest of the attribute selectors cause performance issues. Each of the selectors has the same basic format, using square braces after an element name and a special character preceding the equals sign to perform a type of regular expression.

                                                    -Contains

                                                    +Contains

                                                    The first of the problematic selectors is the contains selector. This selector uses *= and matches an element if the attribute contains the given string. This works similar to the JavaScript indexOf() of method in that it matches anywhere in the string. For example:

                                                    -
                                                    a[href*=yahoo.com] {
                                                    -    color: green;
                                                    -}
                                                    +
                                                    a[href*=yahoo.com] {
                                                    color: green;
                                                    }

                                                    This selector matches any <a> element whose href attribute contains the string "yahoo.com". That means it will match any of the following:

                                                    -
                                                    <a href="http://www.yahoo.com/">Yahoo!</a>
                                                    -
                                                    -<a href="http://www.google.com/redirect=www.yahoo.com">Redirect to Yahoo!</a>
                                                    -
                                                    -<a href="http://login.yahoo.com/">Login to Yahoo!</a>
                                                    +
                                                    <a href="http://www.yahoo.com/">Yahoo!</a>

                                                    <a href="http://www.google.com/redirect=www.yahoo.com">Redirect to Yahoo!</a>

                                                    <a href="http://login.yahoo.com/">Login to Yahoo!</a>

                                                    Note that it doesn't matter whether or not the string has white space on either side, it's just a substring match.

                                                    -Starts With

                                                    +Starts With

                                                    The next selector to avoid is the starts with match. This uses the ^= operator and matches only when the attribute value begins with the given string. For example:

                                                    -
                                                    a[rel^=ext] {
                                                    -    color: red;
                                                    -}
                                                    +
                                                    a[rel^=ext] {
                                                    color: red;
                                                    }

                                                    This rule will match any of the following:

                                                    -
                                                    <a href="http://www.example.com" rel="external">Example</a>
                                                    -
                                                    -<a rel="extra">Extra! Extra!</a>
                                                    -
                                                    -<a rel="extreme">Extreme</a>
                                                    +
                                                    <a href="http://www.example.com" rel="external">Example</a>

                                                    <a rel="extra">Extra! Extra!</a>

                                                    <a rel="extreme">Extreme</a>

                                                    All the selector cares is that the string "ext" appears at the beginning of the attribute value of rel.

                                                    -Ends With

                                                    +Ends With

                                                    The next selector to avoid is the ends with match. This uses the $= operator and matches only when the attribute value ends with the given string. For example:

                                                    -
                                                    a[href$=.html] {
                                                    -    color: blue;
                                                    -}
                                                    +
                                                    a[href$=.html] {
                                                    color: blue;
                                                    }

                                                    This rule matches all <a> elements that have an href attribute value ending in .html. So the following all match:

                                                    -
                                                    <a href="index.html">Home</a>
                                                    -
                                                    -<a href="http://www.example.com/example.html">Example</a>
                                                    +
                                                    <a href="index.html">Home</a>

                                                    <a href="http://www.example.com/example.html">Example</a>

                                                    -Word Match

                                                    +Word Match

                                                    Getting even more complex is the selector that checks for a value separated by white space. The ~= operator is used to specify the attribute value must contain the given word, meaning that it must either be the entire attribute value or part of a space-separated list of values. For example:

                                                    -
                                                    a[rel~=external] {
                                                    -    color: red;
                                                    -}
                                                    +
                                                    a[rel~=external] {
                                                    color: red;
                                                    }

                                                    This rule matches any of the following:

                                                    -
                                                    <a href="http://www.example.com" rel="external">Example</a>
                                                    -
                                                    -<a href="http://www.example.com" rel="external me">Example</a>
                                                    -
                                                    -<a href="http://www.example.com" rel="reference external">Example</a>
                                                    -
                                                    -<a href="http://www.example.com" rel="friend external me">Example</a>
                                                    +
                                                    <a href="http://www.example.com" rel="external">Example</a>

                                                    <a href="http://www.example.com" rel="external me">Example</a>

                                                    <a href="http://www.example.com" rel="reference external">Example</a>

                                                    <a href="http://www.example.com" rel="friend external me">Example</a>

                                                    -Contains With Dashes

                                                    +Contains With Dashes

                                                    The last problematic selector checks to see if the attribute value contains a string separated by dashes. The |= operator is used to find a substring inside of a string with the format xxx-yyy-zzz. For example:

                                                    -
                                                    a[data-info|=name] {
                                                    -    color: red;
                                                    -}
                                                    +
                                                    a[data-info|=name] {
                                                    color: red;
                                                    }

                                                    This matches all of the following:

                                                    -
                                                    <a data-info="name-address-phone">Info</a>
                                                    -
                                                    -<a data-info="address-name-phone">Info</a>
                                                    -
                                                    -<a data-info="address-phone-name">Info</a>
                                                    +
                                                    <a data-info="name-address-phone">Info</a>

                                                    <a data-info="address-name-phone">Info</a>

                                                    <a data-info="address-phone-name">Info</a>

                                                    -Performance Issues

                                                    +Performance Issues

                                                    All of these complex attribute selectors need to perform regular expression matches on attribute values over and over again to ensure the correct visual display is achieved. Doing so slows down the overall page performance as the CSS calculation takes more time.

                                                    -Rule Details

                                                    +Rule Details

                                                    Rule ID: regex-selectors

                                                    @@ -122,39 +87,17 @@

                                                    The following patterns are considered warnings:

                                                    -
                                                    .mybox[class~=xxx]{
                                                    -    color: red;
                                                    -}
                                                    -
                                                    -.mybox[class^=xxx]{
                                                    -    color: red;
                                                    -}
                                                    -
                                                    -.mybox[class|=xxx]{
                                                    -    color: red;
                                                    -}
                                                    -
                                                    -.mybox[class$=xxx]{
                                                    -    color: red;
                                                    -}
                                                    -
                                                    -.mybox[class*=xxx]{
                                                    -    color: red;
                                                    -}
                                                    +
                                                    .mybox[class~=xxx]{
                                                    color: red;
                                                    }

                                                    .mybox[class^=xxx]{
                                                    color: red;
                                                    }

                                                    .mybox[class|=xxx]{
                                                    color: red;
                                                    }

                                                    .mybox[class$=xxx]{
                                                    color: red;
                                                    }

                                                    .mybox[class*=xxx]{
                                                    color: red;
                                                    }

                                                    The following patterns are considered okay and do not cause warnings:

                                                    -
                                                    .mybox[class=xxx]{
                                                    -    color: red;
                                                    -}
                                                    -
                                                    -.mybox[class]{
                                                    -    color: red;
                                                    -}
                                                    +
                                                    .mybox[class=xxx]{
                                                    color: red;
                                                    }

                                                    .mybox[class]{
                                                    color: red;
                                                    }

                                                    -Further Reading

                                                    +Further Reading + + - \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/shorthand.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/shorthand.html index 17a7d7e..dd1a9c7 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/shorthand.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/shorthand.html @@ -1,61 +1,40 @@ -

                                                    Details

                                                    -

                                                    Sometimes when editing a rule you may end up defining multiple properties that can better be represented using shorthand. For example:

                                                    - -
                                                    .mybox {
                                                    -    margin-left: 10px;
                                                    -    margin-right: 10px;
                                                    -    margin-top: 20px;
                                                    -    margin-bottom: 30px;
                                                    -}
                                                    +

                                                    Details

                                                    + +

                                                    Sometimes when editing a rule you may end up defining multiple properties that can better be represented using shorthand. For example:

                                                    + +
                                                    .mybox {
                                                    margin-left: 10px;
                                                    margin-right: 10px;
                                                    margin-top: 20px;
                                                    margin-bottom: 30px;
                                                    }

                                                    These four properties can actually be combined into a single margin property, such as:

                                                    -
                                                    .mybox {
                                                    -    margin: 20px 10px 30px;
                                                    -}
                                                    +
                                                    .mybox {
                                                    margin: 20px 10px 30px;
                                                    }

                                                    Using shorthand properties where possible helps to decrease the overall size of the CSS.

                                                    -Rule Details

                                                    +Rule Details

                                                    Rule ID: shorthand

                                                    This rule is aimed at decreasing file size by finding properties that can be combined into one. As such, it warns in the following cases:

                                                    -
                                                      +
                                                      1. When margin-left, margin-right, margin-top, and margin-bottom are used together in a single rule.
                                                      2. When padding-left, padding-right, padding-top, and padding-bottom are used together in a single rule.

                                                      The following patterns are considered warnings:

                                                      -
                                                      .mybox {
                                                      -    margin-left: 10px;
                                                      -    margin-right: 10px;
                                                      -    margin-top: 20px;
                                                      -    margin-bottom: 30px;
                                                      -}
                                                      +
                                                      .mybox {
                                                      margin-left: 10px;
                                                      margin-right: 10px;
                                                      margin-top: 20px;
                                                      margin-bottom: 30px;
                                                      } .mybox { - padding-left: 10px; - padding-right: 10px; - padding-top: 20px; - padding-bottom: 30px; + padding-left: 10px; + padding-right: 10px; + padding-top: 20px; + padding-bottom: 30px; }

                                                      The following patterns are considered okay and do not cause warnings:

                                                      -
                                                      -/* only two margin properties*/
                                                      -.mybox {
                                                      -    margin-left: 10px;
                                                      -    margin-right: 10px;
                                                      -
                                                      -}
                                                      +
                                                      /* only two margin properties*/
                                                      .mybox {
                                                      margin-left: 10px;
                                                      margin-right: 10px;

                                                      }

                                                      /* only two padding properties */
                                                      .mybox {
                                                      padding-right: 10px;
                                                      padding-top: 20px;
                                                      }
                                                      -/* only two padding properties */ -.mybox { - padding-right: 10px; - padding-top: 20px; -}
                                                      + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/star-property-hack.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/star-property-hack.html index 9279dcd..b96b5e6 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/star-property-hack.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/star-property-hack.html @@ -1,19 +1,15 @@ -

                                                      Details

                                                      -

                                                      The star hack is a famous (or perhaps infamous) technique for applying CSS properties only to Internet Explorer prior to version 8. By placing an asterisk immediately before the property name, older versions of Internet Explorer treated as if the asterisk isn't there while other browsers simply ignore it. For example:

                                                      +

                                                      Details

                                                      -
                                                      .mybox {
                                                      -    border: 1px solid black;
                                                      -    padding: 5px;
                                                      -    width: 100px;
                                                      -    *width: 200px;
                                                      -}
                                                      +

                                                      The star hack is a famous (or perhaps infamous) technique for applying CSS properties only to Internet Explorer prior to version 8. By placing an asterisk immediately before the property name, older versions of Internet Explorer treated as if the asterisk isn't there while other browsers simply ignore it. For example:

                                                      + +
                                                      .mybox {
                                                      border: 1px solid black;
                                                      padding: 5px;
                                                      width: 100px;
                                                      *width: 200px;
                                                      }

                                                      In this example, the *width property is treated as if it were width by Internet Explorer 7 and earlier, so it uses the value of 200px; other browsers skip that property and use the value of 100px.

                                                      Star hack relies on an old CSS parser bug in Internet Explorer, and as such, some prefer not to use it.

                                                      -Rule Details

                                                      +Rule Details

                                                      Rule ID: star-property-hack

                                                      @@ -21,16 +17,14 @@

                                                      The following patterns are considered warnings:

                                                      -
                                                      -.mybox {
                                                      -    border: 1px solid black;
                                                      -    *width: 100px;
                                                      -}
                                                      +
                                                      .mybox {
                                                      border: 1px solid black;
                                                      *width: 100px;
                                                      }

                                                      -Further Reading

                                                      +Further Reading -
                                                        + + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/text-indent.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/text-indent.html index 6e77e4e..886b064 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/text-indent.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/text-indent.html @@ -1,27 +1,21 @@ -

                                                        Details

                                                        -

                                                        Negative text indents are typically used to hide text off-screen for accessibility purposes. Often used as part of an image replacement technique, using a negative text indent ensures that screen readers will read the text even though it appears offscreen. Using visibility: hidden or display: none causes the text to be skipped by screen readers, so a negative text indent has been deemed as better for accessibility.

                                                        +

                                                        Details

                                                        + +

                                                        Negative text indents are typically used to hide text off-screen for accessibility purposes. Often used as part of an image replacement technique, using a negative text indent ensures that screen readers will read the text even though it appears offscreen. Using visibility: hidden or display: none causes the text to be skipped by screen readers, so a negative text indent has been deemed as better for accessibility.

                                                        The technique usually involves a very large negative number such as -999px or -9999px, such as:

                                                        -
                                                        .mybox {
                                                        -    background: url(bg.png) no-repeat;
                                                        -    text-indent: -9999px;
                                                        -}
                                                        +
                                                        .mybox {
                                                        background: url(bg.png) no-repeat;
                                                        text-indent: -9999px;
                                                        }

                                                        The intent of this technique is to allow the background image to show through for sighted users while screen readers receive the inline text instead.

                                                        Negative text indents are also problematic when used in a right-to-left language page, as the effect may cause a long horizontal scrollbar to appear. This problem can be fixed by adding direction: ltr to the rule, such as:

                                                        -
                                                        .mybox {
                                                        -    background: url(bg.png) no-repeat;
                                                        -    direction: ltr;
                                                        -    text-indent: -9999px;
                                                        -}
                                                        +
                                                        .mybox {
                                                        background: url(bg.png) no-repeat;
                                                        direction: ltr;
                                                        text-indent: -9999px;
                                                        }

                                                        There are mixed opinions about whether or not negative text indents affect a page's search ranking. Anecdotal accounts seems to indicate Google treats negative text indents as a spam technique, but this has not been confirmed.

                                                        -Rule Details

                                                        +Rule Details

                                                        Rule ID: text-indent

                                                        @@ -29,42 +23,19 @@

                                                        The following patterns are considered warnings:

                                                        -
                                                        -/* missing direction */
                                                        -.mybox {
                                                        -    text-indent: -999px;
                                                        -}
                                                        -
                                                        -/* missing direction */
                                                        -.mybox {
                                                        -    text-indent: -999em;
                                                        -}
                                                        -
                                                        -/* direction is rtl */
                                                        -.mybox {
                                                        -    direction: rtl;
                                                        -    text-indent: -999em;
                                                        -}
                                                        -
                                                        +
                                                        /* missing direction */
                                                        .mybox {
                                                        text-indent: -999px;
                                                        }

                                                        /* missing direction */
                                                        .mybox {
                                                        text-indent: -999em;
                                                        }

                                                        /* direction is rtl */
                                                        .mybox {
                                                        direction: rtl;
                                                        text-indent: -999em;
                                                        }

                                                        The following patterns are considered okay and do not cause a warning:

                                                        -
                                                        /* direction used */
                                                        -.mybox {
                                                        -    direction: ltr;
                                                        -    text-indent: -999em;
                                                        -}
                                                        -
                                                        -/* Not obviously used to hide text */
                                                        -.mybox {
                                                        -    text-indent: -1em;
                                                        -}
                                                        +
                                                        /* direction used */
                                                        .mybox {
                                                        direction: ltr;
                                                        text-indent: -999em;
                                                        }

                                                        /* Not obviously used to hide text */
                                                        .mybox {
                                                        text-indent: -1em;
                                                        }

                                                        -Further Reading

                                                        +Further Reading -
                                                          + + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/underscore-property-hack.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/underscore-property-hack.html index 0c7a175..834196e 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/underscore-property-hack.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/underscore-property-hack.html @@ -1,19 +1,15 @@ -

                                                          Details

                                                          -

                                                          The underscore hack is a technique for applying CSS properties only to Internet Explorer prior to version 7. By placing an underscore immediately before the property name, older versions of Internet Explorer treated as if the underscore isn't there while other browsers simply ignore it. For example:

                                                          +

                                                          Details

                                                          -
                                                          .mybox {
                                                          -    border: 1px solid black;
                                                          -    padding: 5px;
                                                          -    width: 100px;
                                                          -    _width: 200px;
                                                          -}
                                                          +

                                                          The underscore hack is a technique for applying CSS properties only to Internet Explorer prior to version 7. By placing an underscore immediately before the property name, older versions of Internet Explorer treated as if the underscore isn't there while other browsers simply ignore it. For example:

                                                          + +
                                                          .mybox {
                                                          border: 1px solid black;
                                                          padding: 5px;
                                                          width: 100px;
                                                          _width: 200px;
                                                          }

                                                          In this example, the _width property is treated as if it were width by Internet Explorer 6 and earlier, so it uses the value of 200px; other browsers skip that property and use the value of 100px.

                                                          The underscore hack relies on an old CSS parser bug in Internet Explorer, and as such, some prefer not to use it.

                                                          -Rule Details

                                                          +Rule Details

                                                          Rule ID: underscore-property-hack

                                                          @@ -21,16 +17,14 @@

                                                          The following patterns are considered warnings:

                                                          -
                                                          -.mybox {
                                                          -    border: 1px solid black;
                                                          -    _width: 100px;
                                                          -}
                                                          +
                                                          .mybox {
                                                          border: 1px solid black;
                                                          _width: 100px;
                                                          }

                                                          -Further Reading

                                                          +Further Reading -
                                                            + + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/unique-headings.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/unique-headings.html index da1297b..e7a8901 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/unique-headings.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/unique-headings.html @@ -1,8 +1,9 @@ -

                                                            Details

                                                            -

                                                            Object-Oriented CSS (OOCSS) works by defining reusable objects that can be put into place anywhere on a site and appear exactly the same. The heading elements (h1-h6) are considered to be built-in objects that should look the same regardless of where they appear. As such, each heading should have exactly one rule defining its appearance. Multiple rules defining the same heading appearance can lead to objects that are hard to use because the context defines the appearance rather than being completely atomic.

                                                            +

                                                            Details

                                                            + +

                                                            Object-Oriented CSS (OOCSS) works by defining reusable objects that can be put into place anywhere on a site and appear exactly the same. The heading elements (h1-h6) are considered to be built-in objects that should look the same regardless of where they appear. As such, each heading should have exactly one rule defining its appearance. Multiple rules defining the same heading appearance can lead to objects that are hard to use because the context defines the appearance rather than being completely atomic.

                                                            -Rule Details

                                                            +Rule Details

                                                            Rule ID: unique-headings

                                                            @@ -10,29 +11,17 @@

                                                            The following patterns are considered warnings:

                                                            -
                                                            /* Two rules for h3 */
                                                            -h3 {
                                                            -    font-weight: normal;
                                                            -}
                                                            -
                                                            -.box h3 {
                                                            -    font-weight: bold;
                                                            -}
                                                            +
                                                            /* Two rules for h3 */
                                                            h3 {
                                                            font-weight: normal;
                                                            }

                                                            .box h3 {
                                                            font-weight: bold;
                                                            }

                                                            The following patterns are considered okay and do not cause warnings:

                                                            -
                                                            /* :hover doesn't count */
                                                            -h3 {
                                                            -    font-weight: normal;
                                                            -}
                                                            -
                                                            -h3:hover {
                                                            -    font-weight: bold;
                                                            -}
                                                            +
                                                            /* :hover doesn't count */
                                                            h3 {
                                                            font-weight: normal;
                                                            }

                                                            h3:hover {
                                                            font-weight: bold;
                                                            }

                                                            -Further Reading

                                                            +Further Reading -
                                                              + + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/universal-selector.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/universal-selector.html index 0f5324d..c595c9e 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/universal-selector.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/universal-selector.html @@ -1,16 +1,13 @@ -

                                                              Details

                                                              -

                                                              The universal selector (*) matches all elements. Though convenient for selecting a group of elements at a time, the universal selector causes performance issues when used as the key part (far-right) of a selector. For example, this type of rule should be avoided:

                                                              +

                                                              Details

                                                              -
                                                              .mybox * {
                                                              -    background: #fff;
                                                              -    color: #000;
                                                              -    background: rgba(255, 255, 255, 0.5);
                                                              -}
                                                              +

                                                              The universal selector (*) matches all elements. Though convenient for selecting a group of elements at a time, the universal selector causes performance issues when used as the key part (far-right) of a selector. For example, this type of rule should be avoided:

                                                              + +
                                                              .mybox * {
                                                              background: #fff;
                                                              color: #000;
                                                              background: rgba(255, 255, 255, 0.5);
                                                              }

                                                              Browsers evaluate selectors from right-to-left, so this rule begins by first matching every element in the document. After that, each of those elements must be inspected to see if it matches the next criteria, which is having an ancestor with the class of mybox. The more complex the selector containing *, the slower the evaluation becomes. For this reason, it's recommended to avoid using the universal selector as the key part of a selector.

                                                              -Rule Details

                                                              +Rule Details

                                                              Rule ID: universal-selector

                                                              @@ -18,19 +15,10 @@

                                                              The following patterns are considered warnings:

                                                              -
                                                              * {
                                                              -    color: red;
                                                              -}
                                                              -
                                                              -.selected * {
                                                              -    color: red;
                                                              -}
                                                              +
                                                              * {
                                                              color: red;
                                                              }

                                                              .selected * {
                                                              color: red;
                                                              }

                                                              The following patterns are considered okay and do not cause warnings:

                                                              -
                                                              /* universal selector is not key */
                                                              -.selected * a {
                                                              -    color: red;
                                                              -}
                                                              +
                                                              /* universal selector is not key */
                                                              .selected * a {
                                                              color: red;
                                                              }
                                                              -

                                                      + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/unqualified-attributes.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/unqualified-attributes.html index b33829f..b7a050b 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/unqualified-attributes.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/unqualified-attributes.html @@ -1,16 +1,13 @@ -

                                                      Details

                                                      -

                                                      Unqualified attribute selectors, such as [type=text], match all elements first and then check their attributes. This means unqualified attribute selectors have the same performance characteristics as the universal selector (*). Similar to the universal selector, unqualified attribute selectors cause performance issues when used as the key part (far-right) of a selector. For example, this type of rule should be avoided:

                                                      +

                                                      Details

                                                      -
                                                      .mybox [type=text] {
                                                      -    background: #fff;
                                                      -    color: #000;
                                                      -    background: rgba(255, 255, 255, 0.5);
                                                      -}
                                                      +

                                                      Unqualified attribute selectors, such as [type=text], match all elements first and then check their attributes. This means unqualified attribute selectors have the same performance characteristics as the universal selector (*). Similar to the universal selector, unqualified attribute selectors cause performance issues when used as the key part (far-right) of a selector. For example, this type of rule should be avoided:

                                                      + +
                                                      .mybox [type=text] {
                                                      background: #fff;
                                                      color: #000;
                                                      background: rgba(255, 255, 255, 0.5);
                                                      }

                                                      Browsers evaluate selectors from right-to-left, so this rule begins by first matching every element in the document and then checking the attribute. After that, each of those elements must be inspected to see if it matches the next criteria, which is having an ancestor with the class of mybox. The more complex the selector containing unqualified attributes, the slower the evaluation becomes. For this reason, it's recommended to avoid using the qualified attribute selectors as the key part of a selector.

                                                      -Rule Details

                                                      +Rule Details

                                                      Rule ID: unqualified-attributes

                                                      @@ -18,19 +15,10 @@

                                                      The following patterns are considered warnings:

                                                      -
                                                      [type=text] {
                                                      -    color: red;
                                                      -}
                                                      -
                                                      -.selected [type=text] {
                                                      -    color: red;
                                                      -}
                                                      +
                                                      [type=text] {
                                                      color: red;
                                                      }

                                                      .selected [type=text] {
                                                      color: red;
                                                      }

                                                      The following patterns are considered okay and do not cause warnings:

                                                      -
                                                      /* unqualified attribute selector is not key */
                                                      -.selected [type=text] a {
                                                      -    color: red;
                                                      -}
                                                      +
                                                      /* unqualified attribute selector is not key */
                                                      .selected [type=text] a {
                                                      color: red;
                                                      }
                                                      - + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/vendor-prefix.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/vendor-prefix.html index a02d703..e7c7c7b 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/vendor-prefix.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/vendor-prefix.html @@ -1,52 +1,39 @@ -

                                                      Details

                                                      -

                                                      Vendor-prefixed properties are created by browser vendors to experiment with new CSS features before the standard has been completed. This allows both developers and browser vendors to find bugs and cross-browser compatibility issues without being locked in to a certain behavior in the future. The standard version of the property usually (but not always) has the same name and syntax as the vendor-prefixed version, providing that there are two or more vendor-prefixed versions with the same syntax.

                                                      +

                                                      Details

                                                      + +

                                                      Vendor-prefixed properties are created by browser vendors to experiment with new CSS features before the standard has been completed. This allows both developers and browser vendors to find bugs and cross-browser compatibility issues without being locked in to a certain behavior in the future. The standard version of the property usually (but not always) has the same name and syntax as the vendor-prefixed version, providing that there are two or more vendor-prefixed versions with the same syntax.

                                                      When using vendor-prefixed properties such as -moz-border-radius, you should also include the standard property for future-compatibility. The standard property should come after the vendor-prefixed one to ensure the standard property is used by the browser, such as:

                                                      -
                                                      .mybox {
                                                      -    -moz-border-radius: 5px;
                                                      -    border-radius: 5px;
                                                      -}
                                                      +
                                                      .mybox {
                                                      -moz-border-radius: 5px;
                                                      border-radius: 5px;
                                                      }

                                                      Putting the standard property after the vendor-prefixed property is the best way to ensure your CSS code will continue to work once the standard property is fully adopted (then you can take your time going back and removing the vendor-prefixed properties).

                                                      -Rule Details

                                                      +Rule Details

                                                      Rule ID: vendor-prefix

                                                      This rule is aimed at ensuring standard properties are included whenever vendor-prefixed properties are used. As such, the rule warns when it finds:

                                                      -
                                                        +
                                                        1. A vendor-prefixed property without a standard property after it.
                                                        2. A vendor-prefixed property with a standard property defined before it.

                                                        The following patterns are considered warnings:

                                                        -
                                                        -/* missing standard property */
                                                        -.mybox {
                                                        -    -moz-border-radius: 5px;
                                                        -}
                                                        -
                                                        -/* standard property should come after vendor-prefixed property */
                                                        -.mybox {
                                                        -    border-radius: 5px;
                                                        -    -webkit-border-radius: 5px;
                                                        -}
                                                        +
                                                        /* missing standard property */
                                                        .mybox {
                                                        -moz-border-radius: 5px;
                                                        }

                                                        /* standard property should come after vendor-prefixed property */
                                                        .mybox {
                                                        border-radius: 5px;
                                                        -webkit-border-radius: 5px;
                                                        }

                                                        The following patterns are considered okay and do not cause warnings:

                                                        -
                                                        /* both vendor-prefix and standard property */
                                                        -.mybox {
                                                        -    -moz-border-radius: 5px;
                                                        -    border-radius: 5px;
                                                        -}
                                                        +
                                                        /* both vendor-prefix and standard property */
                                                        +.mybox {
                                                        -moz-border-radius: 5px;
                                                        border-radius: 5px;
                                                        }

                                                        -Further Reading

                                                        +Further Reading -
                                                          + + + \ No newline at end of file diff --git a/sonar-web-frontend-css/src/main/resources/rules/csslint/zero-units.html b/sonar-web-frontend-css/src/main/resources/rules/csslint/zero-units.html index 7caff85..6287306 100644 --- a/sonar-web-frontend-css/src/main/resources/rules/csslint/zero-units.html +++ b/sonar-web-frontend-css/src/main/resources/rules/csslint/zero-units.html @@ -1,35 +1,22 @@ -

                                                          Details

                                                          -

                                                          The value of 0 works without specifying units in all situations where numbers with units or percentages are allowed. There is no difference between 0px, 0em, 0%, or any other zero-value. The units aren't important because the value is still zero. CSS allows you to omit the units for zero values and still remain valid CSS.

                                                          +

                                                          Details

                                                          -

                                                          It's recommended to remove units for all zero values because these units aren't being used by the browser and therefore can be safely removed to save bytes.

                                                          +

                                                          The value of 0 works without specifying units in all situations where numbers with length units or percentages are allowed. There is no difference between 0px, 0em, 0%, or any other zero-value. The units aren't important because the value is still zero. CSS allows you to omit the length units for zero values and still remain valid CSS.

                                                          + +

                                                          It's recommended to remove units for all zero length values because these units aren't being used by the browser and therefore can be safely removed to save bytes.

                                                          -Rule Details

                                                          +Rule Details

                                                          Rule ID: zero-units

                                                          -

                                                          This rule is aimed at flagging zero values that still have units. As such, it warns when 0 is found followed by a unit or a percentage sign.

                                                          +

                                                          This rule is aimed at flagging zero length values that still have units. As such, it warns when 0 is found followed by a unit or a percentage sign.

                                                          The following patterns are considered warnings:

                                                          -
                                                          .mybox {
                                                          -    margin: 0px;
                                                          -}
                                                          -
                                                          -.mybox {
                                                          -    width: 0%;
                                                          -}
                                                          -
                                                          -.mybox {
                                                          -    padding: 10px 0px;
                                                          -}
                                                          +
                                                          .mybox {
                                                          margin: 0px;
                                                          }

                                                          .mybox {
                                                          width: 0%;
                                                          }

                                                          .mybox {
                                                          padding: 10px 0px;
                                                          }

                                                          The following patterns are okay and do not cause warnings:

                                                          -
                                                          .mybox {
                                                          -    margin: 0;
                                                          -}
                                                          +
                                                          .mybox {
                                                          margin: 0;
                                                          }

                                                          .mybox {
                                                          padding: 10px 0;
                                                          }
                                                          -.mybox { - padding: 10px 0; -}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-html/pom.xml b/sonar-web-frontend-html/pom.xml index f02105d..d763c51 100644 --- a/sonar-web-frontend-html/pom.xml +++ b/sonar-web-frontend-html/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 fr.sii.sonar sonar-sii-plugin-parent - 2.0-SNAPSHOT + 2.0.1-SNAPSHOT sonar-web-frontend-html diff --git a/sonar-web-frontend-html/src/main/java/fr/sii/sonar/web/frontend/html/duplication/HtmlDuplicationConstants.java b/sonar-web-frontend-html/src/main/java/fr/sii/sonar/web/frontend/html/duplication/HtmlDuplicationConstants.java index ad510e4..b777703 100644 --- a/sonar-web-frontend-html/src/main/java/fr/sii/sonar/web/frontend/html/duplication/HtmlDuplicationConstants.java +++ b/sonar-web-frontend-html/src/main/java/fr/sii/sonar/web/frontend/html/duplication/HtmlDuplicationConstants.java @@ -8,7 +8,7 @@ public class HtmlDuplicationConstants extends HtmlLanguageConstants implements D public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.duplication.html.file.missing.fail"; public static final String SKIP_DUPLICATION_KEY = "sonar.sii.duplication.html.skip"; public static final String SKIP_DUPLICATION_DEFVAL = "false"; - public static final String REPORT_PATH_DEFVALUE = "/report/html-duplication.xml"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/html-duplication.xml"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String SUB_CATEGORY = "Duplication"; diff --git a/sonar-web-frontend-html/src/main/java/fr/sii/sonar/web/frontend/html/quality/HtmlHintQualityConstants.java b/sonar-web-frontend-html/src/main/java/fr/sii/sonar/web/frontend/html/quality/HtmlHintQualityConstants.java index 5b66500..02ca76a 100644 --- a/sonar-web-frontend-html/src/main/java/fr/sii/sonar/web/frontend/html/quality/HtmlHintQualityConstants.java +++ b/sonar-web-frontend-html/src/main/java/fr/sii/sonar/web/frontend/html/quality/HtmlHintQualityConstants.java @@ -10,7 +10,7 @@ public class HtmlHintQualityConstants extends HtmlLanguageConstants implements Q public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.quality.html.file.missing.fail"; public static final String SKIP_FILE_METRICS_KEY = "sonar.sii.quality.html.file.metrics.skip"; public static final String SKIP_FILE_METRICS_DEFVALUE = "false"; - public static final String REPORT_PATH_DEFVALUE = "/report/htmlhint.json"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/htmlhint.json"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String RULES_PATH = "/rules/htmlhint.json"; public static final String REPOSITORY_NAME = "HTMLHint"; diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint.css b/sonar-web-frontend-html/src/main/resources/rules/htmlhint.css index 157c776..3a3b13c 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint.css +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint.css @@ -1,4 +1,82 @@ -.extended-html-description { +.ehd { margin-top: 20px; margin-bottom: 30px; +} + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + color: #333; + background: #f8f8f8; +} +.hljs-comment, +.hljs-quote { + color: #998; + font-style: italic; +} +.hljs-keyword, +.hljs-selector-tag, +.hljs-subst { + color: #333; + font-weight: bold; +} +.hljs-number, +.hljs-literal, +.hljs-variable, +.hljs-template-variable, +.hljs-tag .hljs-attr { + color: #008080; +} +.hljs-string, +.hljs-doctag { + color: #d14; +} +.hljs-title, +.hljs-section, +.hljs-selector-id { + color: #900; + font-weight: bold; +} +.hljs-subst { + font-weight: normal; +} +.hljs-type, +.hljs-class .hljs-title { + color: #458; + font-weight: bold; +} +.hljs-tag, +.hljs-name, +.hljs-attribute { + color: #000080; + font-weight: normal; +} +.hljs-regexp, +.hljs-link { + color: #009926; +} +.hljs-symbol, +.hljs-bullet { + color: #990073; +} +.hljs-built_in, +.hljs-builtin-name { + color: #0086b3; +} +.hljs-meta { + color: #999; + font-weight: bold; +} +.hljs-deletion { + background: #fdd; +} +.hljs-addition { + background: #dfd; +} +.hljs-emphasis { + font-style: italic; +} +.hljs-strong { + font-weight: bold; } \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint.json b/sonar-web-frontend-html/src/main/resources/rules/htmlhint.json index c1f3d4a..82b7fdd 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint.json +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint.json @@ -1,136 +1,365 @@ -[ - - { - "key":"attr-lowercase", - "name":"Attribute case", - "description":"Attribute name must be lowercase.", - "severity":"MINOR" - }, - { - "key":"attr-no-duplication", - "name":"Attribute duplicated", - "description":"Attribute name can not been duplication.", - "severity":"CRITICAL" - }, - { - "key":"attr-unsafe-chars", - "name":"Attribute contains unsafe chars.", - "description":"Attribute value cant not use unsafe chars.", - "severity":"CRITICAL" - }, - { - "key":"attr-value-double-quotes", - "name":"Use double quotes in attributes", - "description":"Attribute value must closed by double quotes.", - "severity":"MAJOR" - }, - { - "key":"attr-value-not-empty", - "name":"Empty attribute value", - "description":"Attribute must set value.", - "severity":"MINOR" - }, - { - "key":"csslint", - "name":"csslint", - "description":"Scan css with csslint.", - "severity":"INFO" - }, - { - "key":"doctype-first", - "name":"Doctype first", - "description":"Doctype must be first.", - "severity":"CRITICAL" - }, - { - "key":"doctype-html5", - "name":"Doctype html5", - "description":"Doctype must be html5.", - "severity":"MAJOR" - }, - { - "key":"head-script-disabled", - "name":"Script in head", - "description":"The script tag can not be used in head.", - "severity":"MINOR" - }, - { - "key":"href-abs-or-rel", - "name":"Absolute or relative href", - "description":"Href must be absolute or relative.", - "severity":"MAJOR" - }, - { - "key":"id-class-ad-disabled", - "name":"ad keyword", - "description":"Id and class can not use ad keyword, it will blocked by adblock software.", - "severity":"CRITICAL" - }, - { - "key":"id-class-value", - "name":"id and class naming", - "description":"Id and class value must meet some rules.", - "severity":"MAJOR" - }, - { - "key":"id-unique", - "name":"Unique id", - "description":"Id must be unique.", - "severity":"CRITICAL" - }, - { - "key":"img-alt-require", - "name":"Alt required", - "description":"Alt of img tag must be set value.", - "severity":"MAJOR" - }, - { - "key":"jshint", - "name":"jshint", - "description":"Scan script with jshint.", - "severity":"INFO" - }, - { - "key":"space-tab-mixed-disabled", - "name":"Spaces or tabs", - "description":"Spaces and tabs can not mixed in front of line.", - "severity":"INFO" - }, - { - "key":"spec-char-escape", - "name":"Special characters", - "description":"Special characters must be escaped.", - "severity":"CRITICAL" - }, - { - "key":"src-not-empty", - "name":"Empty src", - "description":"Src of img(script,link) must set value.", - "severity":"MAJOR" - }, - { - "key":"style-disabled", - "name":"Style tag", - "description":"Style tag can not be use.", - "severity":"MINOR" - }, - { - "key":"tag-pair", - "name":"Tag pair", - "description":"Tag must be paired.", - "severity":"CRITICAL" - }, - { - "key":"tag-self-close", - "name":"Empty tag self close", - "description":"The empty tag must closed by self.", - "severity":"MAJOR" - }, - { - "key":"tagname-lowercase", - "name":"Tag case", - "description":"Tagname must be lowercase.", - "severity":"MINOR" - } - -] \ No newline at end of file +[ { + "key" : "attr-lowercase", + "name" : "Attribute case", + "description" : "Attribute name must be lowercase.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "htmlhint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "attr-no-duplication", + "name" : "Attribute duplicated", + "description" : "Attribute name can not been duplication.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "htmlhint", "pitfall", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "attr-unsafe-chars", + "name" : "Attribute contains unsafe chars.", + "description" : "Attribute value cant not use unsafe chars.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "htmlhint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "attr-value-double-quotes", + "name" : "Use double quotes in attributes", + "description" : "Attribute value must closed by double quotes.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "htmlhint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "attr-value-not-empty", + "name" : "Empty attribute value", + "description" : "Attribute must set value.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "htmlhint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "csslint", + "name" : "csslint", + "description" : "Scan css with csslint.", + "severity" : "INFO", + "status" : null, + "tags" : [ "htmlhint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "doctype-first", + "name" : "Doctype first", + "description" : "Doctype must be first.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "htmlhint", "convention", "bug", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "doctype-html5", + "name" : "Doctype html5", + "description" : "Doctype must be html5.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "htmlhint", "convention", "obsolete", "html5" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "head-script-disabled", + "name" : "Script in head", + "description" : "The script tag can not be used in head.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "htmlhint", "bad-practice", "pitfall", "user-experience" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "href-abs-or-rel", + "name" : "Absolute or relative href", + "description" : "Href must be absolute or relative.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "htmlhint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_CHANGEABILITY" + } +}, { + "key" : "id-class-ad-disabled", + "name" : "ad keyword", + "description" : "Id and class can not use ad keyword, it will blocked by adblock software.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "htmlhint", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "RESOURCE_RELIABILITY" + } +}, { + "key" : "id-class-value", + "name" : "id and class naming", + "description" : "Id and class value must meet some rules.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "htmlhint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "id-unique", + "name" : "Unique id", + "description" : "Id must be unique.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "htmlhint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "img-alt-require", + "name" : "Alt required", + "description" : "Alt of img tag must be set value.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "htmlhint", "convention", "user-experience", "accessibility" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "USABILITY_ACCESSIBILITY" + } +}, { + "key" : "jshint", + "name" : "jshint", + "description" : "Scan script with jshint.", + "severity" : "INFO", + "status" : null, + "tags" : [ "htmlhint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "space-tab-mixed-disabled", + "name" : "Spaces or tabs", + "description" : "Spaces and tabs can not mixed in front of line.", + "severity" : "INFO", + "status" : null, + "tags" : [ "htmlhint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "spec-char-escape", + "name" : "Special characters", + "description" : "Special characters must be escaped.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "htmlhint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "src-not-empty", + "name" : "Empty src", + "description" : "Src of img(script,link) must set value.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "htmlhint", "convention", "pitfall", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "style-disabled", + "name" : "Style tag disabled", + "description" : "Style tag can not be use.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "htmlhint", "convention", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "tag-pair", + "name" : "Tag pair", + "description" : "Tag must be paired.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "htmlhint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "tag-self-close", + "name" : "Empty tag self close", + "description" : "The empty tag must closed by self.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "htmlhint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "tagname-lowercase", + "name" : "Tagname lowercase", + "description" : "Tagname must be lowercase", + "severity" : "MINOR", + "status" : null, + "tags" : [ "htmlhint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "title-require", + "name" : "title required", + "description" : "title must be present in head", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "htmlhint", "convention", "accessibility", "user-experience" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "USABILITY_EASE_OF_USE" + } +}, { + "key" : "alt-require", + "name" : "alt required", + "description" : "Alt of img must be present and alt of area[href] and input[type=image] must be set value", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "htmlhint", "convention", "user-experience", "accessibility" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "USABILITY_ACCESSIBILITY" + } +}, { + "key" : "inline-style-disabled", + "name" : "inline style disabled", + "description" : "Inline style cannot be used", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "htmlhint", "convention", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "LOGIC_CHANGEABILITY" + } +}, { + "key" : "inline-script-disabled", + "name" : "inline script disabled", + "description" : "Inline script cannot be used", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "htmlhint", "convention", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "LOGIC_CHANGEABILITY" + } +} ] \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/alt-require.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/alt-require.html new file mode 100644 index 0000000..f682171 --- /dev/null +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/alt-require.html @@ -0,0 +1,11 @@ +

                                                          Details

                                                          +

                                                          Alt of img must be present and alt of area[href] and input[type=image] must be set value.

                                                          +

                                                          good:

                                                          +
                                                          <img src="test.png" alt="test">
                                                          <input type="image" alt="test">
                                                          <area shape="circle" coords="180,139,14" href ="test.html" alt="test" />
                                                          +

                                                          bad:

                                                          +
                                                          <img src="test.png">
                                                          <input type="image">
                                                          <area shape="circle" coords="180,139,14" href ="test.html" />
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-lowercase.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-lowercase.html index f82a884..16ac35c 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-lowercase.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-lowercase.html @@ -1,12 +1,11 @@ -

                                                          Details

                                                          -

                                                          Attribute name must be lowercase.

                                                          - -

                                                          good:

                                                          - -
                                                          <img src="test.png" alt="test">
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <img SRC="test.png" ALT="test">
                                                          -
                                                          \ No newline at end of file +

                                                          Details

                                                          +

                                                          Attribute name must be lowercase.

                                                          +

                                                          good:

                                                          +
                                                          <img src="test.png" alt="test">
                                                          +

                                                          bad:

                                                          +
                                                          <img SRC="test.png" ALT="test">
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-no-duplication.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-no-duplication.html index ecbe764..1c48a78 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-no-duplication.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-no-duplication.html @@ -1,12 +1,11 @@ -

                                                          Details

                                                          -

                                                          Attribute name can not been duplicated.

                                                          - -

                                                          good:

                                                          - -
                                                          <img src="a.png" />
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <img src="a.png" src="b.png" />
                                                          -
                                                          +

                                                          Details

                                                          +

                                                          The same attribute can't be specified twice.

                                                          +

                                                          good:

                                                          +
                                                          <img src="a.png" />
                                                          +

                                                          bad:

                                                          +
                                                          <img src="a.png" src="b.png" />
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-unsafe-chars.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-unsafe-chars.html index f9ad47e..c4acf66 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-unsafe-chars.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-unsafe-chars.html @@ -1,14 +1,13 @@ -

                                                          Details

                                                          -

                                                          Attribute value cant not use unsafe chars.

                                                          - -

                                                          good:

                                                          - -
                                                          <li><a href="https://vimeo.com/album/1951235/video/56931059">Sud Web 2012</a></li>
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <li><a href="https://vimeo.com/album/1951235/video/56931059‎">Sud Web 2012</a></li>
                                                          -
                                                          - -

                                                          Tip: The unsafe chars is in the tail of the href attribute.

                                                          +

                                                          Details

                                                          +

                                                          Attribute value cant not use unsafe chars.

                                                          +

                                                          regexp: /[\u0000-\u0009\u000b\u000c\u000e-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/

                                                          +

                                                          good:

                                                          +
                                                          <li><a href="https://vimeo.com/album/1951235/video/56931059">Sud Web 2012</a></li>
                                                          +

                                                          bad:

                                                          +
                                                          <li><a href="https://vimeo.com/album/1951235/video/56931059‎">Sud Web 2012</a></li>
                                                          +

                                                          Tip: The unsafe chars is in the tail of the href attribute.

                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-value-double-quotes.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-value-double-quotes.html index 2983b67..2befe63 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-value-double-quotes.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-value-double-quotes.html @@ -1,12 +1,11 @@ -

                                                          Details

                                                          -

                                                          Attribute value must closed by double quotes.

                                                          - -

                                                          good:

                                                          - -
                                                          <a href="" title="abc">
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <a href='' title=abc>
                                                          -
                                                          \ No newline at end of file +

                                                          Details

                                                          +

                                                          Attribute value must closed by double quotes.

                                                          +

                                                          good:

                                                          +
                                                          <a href="" title="abc">
                                                          +

                                                          bad:

                                                          +
                                                          <a href='' title=abc>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-value-not-empty.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-value-not-empty.html index 40f7297..d65fa01 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-value-not-empty.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/attr-value-not-empty.html @@ -1,12 +1,11 @@ -

                                                          Details

                                                          -

                                                          Attribute must set value.

                                                          - -

                                                          good:

                                                          - -
                                                          <input type="button" disabled="disabled">
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <input type="button" disabled>
                                                          -
                                                          \ No newline at end of file +

                                                          Details

                                                          +

                                                          Attribute must set value.

                                                          +

                                                          good:

                                                          +
                                                          <input type="button" disabled="disabled">
                                                          +

                                                          bad:

                                                          +
                                                          <input type="button" disabled>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/csslint.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/csslint.html index bbff37a..02bc992 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/csslint.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/csslint.html @@ -1,2 +1,3 @@ -

                                                          Details

                                                          -

                                                          All csslint rules: https://github.com/stubbornella/csslint/wiki/Rules

                                                          +

                                                          Details

                                                          +

                                                          Scan css with csslint.

                                                          +

                                                          All csslint rules: https://github.com/stubbornella/csslint/wiki/Rules

                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/doctype-first.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/doctype-first.html index c5a07d1..869a9d1 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/doctype-first.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/doctype-first.html @@ -1,12 +1,11 @@ -

                                                          Details

                                                          -

                                                          Doctype must be first.

                                                          - -

                                                          good:

                                                          - -
                                                          <!DOCTYPE HTML><html>
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <!--comment--><!DOCTYPE HTML><html>
                                                          -
                                                          +

                                                          Details

                                                          +

                                                          Doctype must be first.

                                                          +

                                                          good:

                                                          +
                                                          <!DOCTYPE HTML><html>
                                                          +

                                                          bad:

                                                          +
                                                          <!--comment--><!DOCTYPE HTML><html>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/doctype-html5.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/doctype-html5.html index 8143720..3e78ca5 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/doctype-html5.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/doctype-html5.html @@ -1,7 +1,9 @@ -

                                                          Details

                                                          -

                                                          Doctype must be html5.

                                                          - -

                                                          good:

                                                          - -
                                                          <!DOCTYPE HTML><html>
                                                          -
                                                          +

                                                          Details

                                                          +

                                                          Doctype must be html5.

                                                          +

                                                          good:

                                                          +
                                                          <!DOCTYPE HTML><html>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/head-script-disabled.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/head-script-disabled.html index 6520766..e309945 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/head-script-disabled.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/head-script-disabled.html @@ -1,12 +1,11 @@ -

                                                          Details

                                                          -

                                                          The script tag can not be used in head.

                                                          - -

                                                          good:

                                                          - -
                                                          <body><script type="text/javascript" src="test.js"></script></body>
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <head><script type="text/javascript" src="test.js"></script></head>
                                                          -
                                                          +

                                                          Details

                                                          +

                                                          The script tag can not be used in head.

                                                          +

                                                          good:

                                                          +
                                                          <body><script type="text/javascript" src="test.js"></script></body>
                                                          +

                                                          bad:

                                                          +
                                                          <head><script type="text/javascript" src="test.js"></script></head>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/href-abs-or-rel.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/href-abs-or-rel.html index 0ca3d41..474456c 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/href-abs-or-rel.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/href-abs-or-rel.html @@ -1,8 +1,10 @@ -

                                                          Details

                                                          -

                                                          Href must be absolute or relative.

                                                          - -

                                                          good:

                                                          - -
                                                          abs: <a href="http://www.alibaba.com/">test1</a> <a href="https://www.alipay.com/">test2</a>
                                                          -rel: <a href="test.html">test1</a> <a href="../test.html">test2</a>
                                                          -
                                                          +

                                                          Details

                                                          +

                                                          Href must be absolute or relative.

                                                          +

                                                          good:

                                                          +
                                                          abs: <a href="http://www.alibaba.com/">test1</a> <a href="https://www.alipay.com/">test2</a>
                                                          rel: <a href="test.html">test1</a> <a href="../test.html">test2</a>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. abs: absolute mode
                                                          2. +
                                                          3. rel: relative mode
                                                          4. +
                                                          5. false: disable rule
                                                          6. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/id-class-ad-disabled.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/id-class-ad-disabled.html index 5409e51..2c05d95 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/id-class-ad-disabled.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/id-class-ad-disabled.html @@ -1,13 +1,11 @@ -

                                                          Details

                                                          -

                                                          Id and class can not use ad keyword, it will blocked by adblock software.

                                                          - -

                                                          good:

                                                          - -
                                                          <div id="adcontainer"></div>
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <div id="ad-container"></div>
                                                          -<div id="ad_container"></div>
                                                          -
                                                          \ No newline at end of file +

                                                          Details

                                                          +

                                                          Id and class can not use ad keyword, it will blocked by adblock software.

                                                          +

                                                          good:

                                                          +
                                                          <div id="adcontainer"></div>
                                                          +

                                                          bad:

                                                          +
                                                          <div id="ad-container"></div>
                                                          <div id="ad_container"></div>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/id-class-value.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/id-class-value.html index fd56140..265e983 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/id-class-value.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/id-class-value.html @@ -1,9 +1,11 @@ -

                                                          Details

                                                          -

                                                          Id and class value must meet some rules: underline, dash, hump.

                                                          - -

                                                          good:

                                                          - -
                                                          underline: <div id="aaa_bbb">
                                                          -dash: <div id="aaa-bbb">
                                                          -hump: <div id="aaaBbb">
                                                          -
                                                          +

                                                          Details

                                                          +

                                                          Id and class value must meet some rules: underline, dash, hump.

                                                          +

                                                          good:

                                                          +
                                                          underline: <div id="aaa_bbb">
                                                          dash: <div id="aaa-bbb">
                                                          hump: <div id="aaaBbb">
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. underline: underline mode ( aaa_bb )
                                                          2. +
                                                          3. dash: enable rule ( aaa-bbb )
                                                          4. +
                                                          5. hump: enable rule ( aaaBbb )
                                                          6. +
                                                          7. false: disable rule
                                                          8. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/id-unique.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/id-unique.html index 5258663..619d605 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/id-unique.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/id-unique.html @@ -1,12 +1,11 @@ -

                                                          Details

                                                          -

                                                          Id must be unique.

                                                          - -

                                                          good:

                                                          - -
                                                          <div id="id1"></div><div id="id2"></div>
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <div id="id1"></div><div id="id1"></div>
                                                          -
                                                          +

                                                          Details

                                                          +

                                                          ID attributes must be unique in the document.

                                                          +

                                                          good:

                                                          +
                                                          <div id="id1"></div><div id="id2"></div>
                                                          +

                                                          bad:

                                                          +
                                                          <div id="id1"></div><div id="id1"></div>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/inline-script-disabled.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/inline-script-disabled.html new file mode 100644 index 0000000..0d2fa0a --- /dev/null +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/inline-script-disabled.html @@ -0,0 +1,9 @@ +

                                                          Details

                                                          +

                                                          Inline script cannot be use.

                                                          +

                                                          bad:

                                                          +
                                                          <img src="test.gif" onclick="alert(1);">
                                                          <img src="javascript:alert(1)">
                                                          <a href="javascript:alert(1)">test1</a>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/inline-style-disabled.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/inline-style-disabled.html new file mode 100644 index 0000000..3f44f20 --- /dev/null +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/inline-style-disabled.html @@ -0,0 +1,9 @@ +

                                                          Details

                                                          +

                                                          Inline style cannot be use.

                                                          +

                                                          bad:

                                                          +
                                                          <div style="color:red"></div>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/jshint.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/jshint.html index 141f864..6977da6 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/jshint.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/jshint.html @@ -1,4 +1,3 @@ -

                                                          Details

                                                          -

                                                          Scan script with jshint.

                                                          - -

                                                          All jshint rules: http://jshint.com/docs/#options

                                                          +

                                                          Details

                                                          +

                                                          Scan script with jshint.

                                                          +

                                                          All jshint rules: http://jshint.com/docs/options/

                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/space-tab-mixed-disabled.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/space-tab-mixed-disabled.html index a6b356d..9d1d56c 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/space-tab-mixed-disabled.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/space-tab-mixed-disabled.html @@ -1,17 +1,13 @@ -

                                                          Details

                                                          -

                                                          Spaces and tabs can not mixed in front of line.

                                                          - - -

                                                          good:

                                                          - -
                                                                  <img src="tab.png" />
                                                          -          <img src="space.png" />
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                                   <img src="tab_before_space.png" />
                                                          -    <img src="space_before_tab.png" />
                                                          -
                                                          - -

                                                          Tip: github will replace tab to space, read md file to read raw code.

                                                          +

                                                          Details

                                                          +

                                                          Spaces and tabs can not mixed in front of line.

                                                          +

                                                          good:

                                                          +
                                                             →   →<img src="tab.png" />
                                                          ········<img src="space.png" />
                                                          +

                                                          bad:

                                                          +
                                                             →····<img src="tab_before_space.png" />
                                                          ···· →<img src="space_before_tab.png" />
                                                          +

                                                          Note: in the examples above, spaces and tabs are represented by · and , respectively, to make the difference visible.

                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. space: space mode (only space for indentation)
                                                          2. +
                                                          3. tab: tab mode (only tab for indentation)
                                                          4. +
                                                          5. false: disable rule
                                                          6. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/spec-char-escape.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/spec-char-escape.html index ee10670..9b95ad9 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/spec-char-escape.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/spec-char-escape.html @@ -1,12 +1,11 @@ -

                                                          Details

                                                          -

                                                          Special characters must be escaped.

                                                          - -

                                                          good:

                                                          - -
                                                          <span>aaa&gt;bbb&lt;ccc</span>
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <span>aaa>bbb<ccc</span>
                                                          -
                                                          +

                                                          Details

                                                          +

                                                          Special characters must be escaped.

                                                          +

                                                          good:

                                                          +
                                                          <span>aaa&gt;bbb&lt;ccc</span>
                                                          +

                                                          bad:

                                                          +
                                                          <span>aaa>bbb<ccc</span>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/src-not-empty.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/src-not-empty.html index 4a8e99f..718e26b 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/src-not-empty.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/src-not-empty.html @@ -1,33 +1,12 @@ -

                                                          Details

                                                          -

                                                          Src of img(script,link) must set value.

                                                          - -

                                                          Emtpy of src will visit current page twice.

                                                          - -

                                                          good:

                                                          - -
                                                          <img src="test.png" />
                                                          -<script src="test.js"></script>
                                                          -<link href="test.css" type="text/css" />
                                                          -<embed src="test.swf">
                                                          -<bgsound src="test.mid" />
                                                          -<iframe src="test.html">
                                                          -<object data="test.swf">
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <img src />
                                                          -<script src=""></script>
                                                          -<script src></script>
                                                          -<link href="" type="text/css" />
                                                          -<link href type="text/css" />
                                                          -<embed src="">
                                                          -<embed src>
                                                          -<bgsound src="" />
                                                          -<bgsound src />
                                                          -<iframe src="">
                                                          -<iframe src>
                                                          -<object data="">
                                                          -<object data>
                                                          -
                                                          - +

                                                          Details

                                                          +

                                                          Src of img(script,link) must set value.

                                                          +

                                                          Emtpy of src will visit current page twice.

                                                          +

                                                          good:

                                                          +
                                                          <img src="test.png" />
                                                          <script src="test.js"></script>
                                                          <link href="test.css" type="text/css" />
                                                          <embed src="test.swf">
                                                          <bgsound src="test.mid" />
                                                          <iframe src="test.html">
                                                          <object data="test.swf">
                                                          +

                                                          bad:

                                                          +
                                                          <img src />
                                                          <script src=""></script>
                                                          <script src></script>
                                                          <link href="" type="text/css" />
                                                          <link href type="text/css" />
                                                          <embed src="">
                                                          <embed src>
                                                          <bgsound src="" />
                                                          <bgsound src />
                                                          <iframe src="">
                                                          <iframe src>
                                                          <object data="">
                                                          <object data>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/style-disabled.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/style-disabled.html index 36b7731..72a9de0 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/style-disabled.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/style-disabled.html @@ -1,9 +1,9 @@ -

                                                          Details

                                                          -

                                                          Style tag can not be use.

                                                          - - -

                                                          bad:

                                                          - -
                                                          <head><style type="text/css"></style></head>
                                                          -<body><style type="text/css"></style></body>
                                                          -
                                                          +

                                                          Details

                                                          +

                                                          Style tag can not be use.

                                                          +

                                                          bad:

                                                          +
                                                          <head><style type="text/css"></style></head>
                                                          <body><style type="text/css"></style></body>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/tag-pair.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/tag-pair.html index 1ebacbb..fecf85b 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/tag-pair.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/tag-pair.html @@ -1,13 +1,11 @@ -

                                                          Details

                                                          -

                                                          Tag must be paired.

                                                          - -

                                                          good:

                                                          - -
                                                          <ul><li></li></ul>
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <ul><li></ul>
                                                          -<ul></li></ul>
                                                          -
                                                          +

                                                          Details

                                                          +

                                                          Tag must be paired.

                                                          +

                                                          good:

                                                          +
                                                          <ul><li></li></ul>
                                                          +

                                                          bad:

                                                          +
                                                          <ul><li></ul>
                                                          <ul></li></ul>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/tag-self-close.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/tag-self-close.html index b238dfc..26eca9e 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/tag-self-close.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/tag-self-close.html @@ -1,12 +1,11 @@ -

                                                          Details

                                                          -

                                                          The empty tag must closed by self.

                                                          - -

                                                          good:

                                                          - -
                                                          <br />
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <br>
                                                          -
                                                          +

                                                          Details

                                                          +

                                                          The empty tag must closed by self.

                                                          +

                                                          good:

                                                          +
                                                          <br />
                                                          +

                                                          bad:

                                                          +
                                                          <br>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/tagname-lowercase.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/tagname-lowercase.html index 06fbc3a..e5ee5f8 100644 --- a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/tagname-lowercase.html +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/tagname-lowercase.html @@ -1,12 +1,11 @@ -

                                                          Details

                                                          -

                                                          Tagname must be lowercase.

                                                          - -

                                                          good:

                                                          - -
                                                          <span><div>
                                                          -
                                                          - -

                                                          bad:

                                                          - -
                                                          <SPAN><BR>
                                                          -
                                                          +

                                                          Details

                                                          +

                                                          Tagname must be lowercase.

                                                          +

                                                          good:

                                                          +
                                                          <span><div>
                                                          +

                                                          bad:

                                                          +
                                                          <SPAN><BR>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-html/src/main/resources/rules/htmlhint/title-require.html b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/title-require.html new file mode 100644 index 0000000..612c625 --- /dev/null +++ b/sonar-web-frontend-html/src/main/resources/rules/htmlhint/title-require.html @@ -0,0 +1,11 @@ +

                                                          Details

                                                          +

                                                          <title> must be present in <head> tag.

                                                          +

                                                          good:

                                                          +
                                                          <html><head><title>test</title></head></html>
                                                          +

                                                          bad:

                                                          +
                                                          <html><head></head></html>
                                                          <html><head><title></title></head></html>
                                                          <html><title></title><head></head></html>
                                                          +

                                                          config value:

                                                          +
                                                            +
                                                          1. true: enable rule
                                                          2. +
                                                          3. false: disable rule
                                                          4. +
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-js/pom.xml b/sonar-web-frontend-js/pom.xml index 0a472e1..9eb1ff2 100644 --- a/sonar-web-frontend-js/pom.xml +++ b/sonar-web-frontend-js/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 fr.sii.sonar sonar-sii-plugin-parent - 2.0-SNAPSHOT + 2.0.1-SNAPSHOT sonar-web-frontend-js diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/JsPlugin.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/JsPlugin.java index 0559a7b..73aea58 100644 --- a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/JsPlugin.java +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/JsPlugin.java @@ -16,10 +16,14 @@ import fr.sii.sonar.web.frontend.js.coverage.LcovUnitCoverageSensor; import fr.sii.sonar.web.frontend.js.duplication.JsDuplicationConstants; import fr.sii.sonar.web.frontend.js.duplication.JsDuplicationSensor; -import fr.sii.sonar.web.frontend.js.quality.JsHintQualityConstants; -import fr.sii.sonar.web.frontend.js.quality.JsHintQualitySensor; -import fr.sii.sonar.web.frontend.js.quality.JshintProfileDefinition; -import fr.sii.sonar.web.frontend.js.quality.JshintRulesDefinition; +import fr.sii.sonar.web.frontend.js.quality.eslint.EslintProfileDefinition; +import fr.sii.sonar.web.frontend.js.quality.eslint.EslintQualityConstants; +import fr.sii.sonar.web.frontend.js.quality.eslint.EslintQualitySensor; +import fr.sii.sonar.web.frontend.js.quality.eslint.EslintRulesDefinition; +import fr.sii.sonar.web.frontend.js.quality.jshint.JsHintQualityConstants; +import fr.sii.sonar.web.frontend.js.quality.jshint.JsHintQualitySensor; +import fr.sii.sonar.web.frontend.js.quality.jshint.JshintProfileDefinition; +import fr.sii.sonar.web.frontend.js.quality.jshint.JshintRulesDefinition; import fr.sii.sonar.web.frontend.js.test.JUnitConstants; import fr.sii.sonar.web.frontend.js.test.JUnitIntegrationConstants; import fr.sii.sonar.web.frontend.js.test.JUnitIntegrationReportSensor; @@ -81,6 +85,37 @@ public List getExtensions() { JshintProfileDefinition.class, JsHintQualitySensor.class, + // Quality configuration for ESLint + PropertyDefinition.builder(EslintQualityConstants.REPORT_PATH_KEY) + .defaultValue(EslintQualityConstants.REPORT_PATH_DEFVALUE) + .category(EslintQualityConstants.CATEGORY) + .subCategory(EslintQualityConstants.SUB_CATEGORY) + .name("JavaScript quality report path for ESLint") + .description("The path to the JavaScript report file to load") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(EslintQualityConstants.FAIL_MISSING_FILE_KEY) + .defaultValue(EslintQualityConstants.FAIL_MISSING_FILE_DEFVALUE) + .category(EslintQualityConstants.CATEGORY) + .subCategory(EslintQualityConstants.SUB_CATEGORY) + .name("Fail on missing source file") + .description("True to stop analysis if a source file is not found") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(EslintQualityConstants.SKIP_FILE_METRICS_KEY) + .defaultValue(EslintQualityConstants.SKIP_FILE_METRICS_DEFVALUE) + .category(EslintQualityConstants.CATEGORY) + .subCategory(EslintQualityConstants.SUB_CATEGORY) + .name("Skip save of file metrics") + .description("If you have several plugins that are able to handle JavaScript, you may have an error (Can not add the same measure twice). Set it to true to let the other plugin save the metrics") + .onQualifiers(Qualifiers.PROJECT) + .build(), + + EslintQualityConstants.class, + EslintRulesDefinition.class, + EslintProfileDefinition.class, + EslintQualitySensor.class, + // Unit coverage configuration PropertyDefinition.builder(LcovUnitCoverageConstants.REPORT_PATH_KEY) .defaultValue(LcovUnitCoverageConstants.REPORT_PATH_DEFVALUE) diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/coverage/LcovIntegrationCoverageConstants.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/coverage/LcovIntegrationCoverageConstants.java index c122ee3..6adf0c1 100644 --- a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/coverage/LcovIntegrationCoverageConstants.java +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/coverage/LcovIntegrationCoverageConstants.java @@ -7,7 +7,7 @@ public class LcovIntegrationCoverageConstants extends JsLanguageConstants implements ReportConstants, CoverageConstants { public static final String REPORT_PATH_KEY = "sonar.sii.coverage.it.js.report.path"; public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.coverage.it.js.file.missing.fail"; - public static final String REPORT_PATH_DEFVALUE = "/report/js-it.lcov"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/js-it.lcov"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String SUB_CATEGORY = "Coverage"; diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/coverage/LcovOverallCoverageConstants.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/coverage/LcovOverallCoverageConstants.java index 1b2abe5..83d3b76 100644 --- a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/coverage/LcovOverallCoverageConstants.java +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/coverage/LcovOverallCoverageConstants.java @@ -7,7 +7,7 @@ public class LcovOverallCoverageConstants extends JsLanguageConstants implements ReportConstants, CoverageConstants { public static final String REPORT_PATH_KEY = "sonar.sii.coverage.overall.js.report.path"; public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.coverage.overall.js.file.missing.fail"; - public static final String REPORT_PATH_DEFVALUE = "/report/js-overall.lcov"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/js-overall.lcov"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String SUB_CATEGORY = "Coverage"; diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/coverage/LcovUnitCoverageConstants.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/coverage/LcovUnitCoverageConstants.java index 4d9a03b..60a7514 100644 --- a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/coverage/LcovUnitCoverageConstants.java +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/coverage/LcovUnitCoverageConstants.java @@ -7,7 +7,7 @@ public class LcovUnitCoverageConstants extends JsLanguageConstants implements ReportConstants, CoverageConstants { public static final String REPORT_PATH_KEY = "sonar.sii.coverage.ut.js.report.path"; public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.coverage.ut.js.file.missing.fail"; - public static final String REPORT_PATH_DEFVALUE = "/report/js-ut.lcov"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/js-ut.lcov"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String SUB_CATEGORY = "Coverage"; diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/duplication/JsDuplicationConstants.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/duplication/JsDuplicationConstants.java index 305e3ff..ff798b3 100644 --- a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/duplication/JsDuplicationConstants.java +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/duplication/JsDuplicationConstants.java @@ -8,7 +8,7 @@ public class JsDuplicationConstants extends JsLanguageConstants implements Dupli public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.duplication.js.file.missing.fail"; public static final String SKIP_DUPLICATION_KEY = "sonar.sii.duplication.js.skip"; public static final String SKIP_DUPLICATION_DEFVAL = "false"; - public static final String REPORT_PATH_DEFVALUE = "/report/js-duplication.xml"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/js-duplication.xml"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String SUB_CATEGORY = "Duplication"; diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/eslint/EslintProfileDefinition.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/eslint/EslintProfileDefinition.java new file mode 100644 index 0000000..bb13cc2 --- /dev/null +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/eslint/EslintProfileDefinition.java @@ -0,0 +1,20 @@ +package fr.sii.sonar.web.frontend.js.quality.eslint; + +import org.sonar.api.rules.RuleFinder; + +import fr.sii.sonar.report.core.quality.profile.JsonProfileParser; +import fr.sii.sonar.report.core.quality.profile.ProfileFileDefinition; + +/** + * Just a specific implementation to help dependency injection + * + * @author Aurélien Baudet + * + */ +public class EslintProfileDefinition extends ProfileFileDefinition { + + public EslintProfileDefinition(RuleFinder ruleFinder, EslintQualityConstants constants) { + super(constants.getProfileJsonPath(), new JsonProfileParser(), ruleFinder); + } + +} diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/eslint/EslintQualityConstants.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/eslint/EslintQualityConstants.java new file mode 100644 index 0000000..e1040a3 --- /dev/null +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/eslint/EslintQualityConstants.java @@ -0,0 +1,49 @@ +package fr.sii.sonar.web.frontend.js.quality.eslint; + +import fr.sii.sonar.report.core.common.rules.RulesDefinitionConstants; +import fr.sii.sonar.report.core.quality.ProfileDefinitionConstants; +import fr.sii.sonar.report.core.quality.QualityConstants; +import fr.sii.sonar.web.frontend.js.JsLanguageConstants; + +public class EslintQualityConstants extends JsLanguageConstants implements QualityConstants, RulesDefinitionConstants, ProfileDefinitionConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.quality.js.eslint.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.quality.js.eslint.file.missing.fail"; + public static final String SKIP_FILE_METRICS_KEY = "sonar.sii.quality.js.eslint.file.metrics.skip"; + public static final String SKIP_FILE_METRICS_DEFVALUE = "false"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/eslint.json"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String RULES_PATH = "/rules/eslint.json"; + public static final String REPOSITORY_NAME = "ESLint"; + public static final String REPOSITORY_KEY = "eslint"; + public static final String SUB_CATEGORY = "Quality"; + public static final String PROFILE_PATH = "/profiles/eslint.json"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getRepositoryKey() { + return REPOSITORY_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + + public String getRepositoryName() { + return REPOSITORY_NAME; + } + + public String getRulesJsonPath() { + return RULES_PATH; + } + + public String getProfileJsonPath() { + return PROFILE_PATH; + } + + public String getSkipFileMetricsKey() { + return SKIP_FILE_METRICS_KEY; + } + +} diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/eslint/EslintQualitySensor.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/eslint/EslintQualitySensor.java new file mode 100644 index 0000000..b4bbbbc --- /dev/null +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/eslint/EslintQualitySensor.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.web.frontend.js.quality.eslint; + +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.quality.domain.report.QualityReport; +import fr.sii.sonar.report.core.quality.factory.JsonQualityReportProviderFactory; +import fr.sii.sonar.report.core.quality.factory.QualitySaverFactory; + +/** + * Just a specific implementation to help dependency injection + * + * @author Aurélien Baudet + * + */ +public class EslintQualitySensor extends ReportSensor { + + public EslintQualitySensor(EslintQualityConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new JsonQualityReportProviderFactory(), new QualitySaverFactory()); + } + +} diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/eslint/EslintRulesDefinition.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/eslint/EslintRulesDefinition.java new file mode 100644 index 0000000..a77d9bb --- /dev/null +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/eslint/EslintRulesDefinition.java @@ -0,0 +1,17 @@ +package fr.sii.sonar.web.frontend.js.quality.eslint; + +import fr.sii.sonar.report.core.common.rules.ComposableRulesDefinition; + +/** + * Repository for ESLint rules + * + * @author Aurélien Baudet + * + */ +public class EslintRulesDefinition extends ComposableRulesDefinition { + + public EslintRulesDefinition(EslintQualityConstants constants) { + super(constants); + } + +} \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/JsHintQualityConstants.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/jshint/JsHintQualityConstants.java similarity index 92% rename from sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/JsHintQualityConstants.java rename to sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/jshint/JsHintQualityConstants.java index 73ebfb6..ebb1db0 100644 --- a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/JsHintQualityConstants.java +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/jshint/JsHintQualityConstants.java @@ -1,4 +1,4 @@ -package fr.sii.sonar.web.frontend.js.quality; +package fr.sii.sonar.web.frontend.js.quality.jshint; import fr.sii.sonar.report.core.common.rules.RulesDefinitionConstants; import fr.sii.sonar.report.core.quality.ProfileDefinitionConstants; @@ -10,7 +10,7 @@ public class JsHintQualityConstants extends JsLanguageConstants implements Quali public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.quality.js.file.missing.fail"; public static final String SKIP_FILE_METRICS_KEY = "sonar.sii.quality.js.file.metrics.skip"; public static final String SKIP_FILE_METRICS_DEFVALUE = "false"; - public static final String REPORT_PATH_DEFVALUE = "/report/jshint.json"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/jshint.json"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String RULES_PATH = "/rules/jshint.json"; public static final String REPOSITORY_NAME = "JSHint"; diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/JsHintQualitySensor.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/jshint/JsHintQualitySensor.java similarity index 93% rename from sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/JsHintQualitySensor.java rename to sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/jshint/JsHintQualitySensor.java index db2a6a3..28c0c35 100644 --- a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/JsHintQualitySensor.java +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/jshint/JsHintQualitySensor.java @@ -1,4 +1,4 @@ -package fr.sii.sonar.web.frontend.js.quality; +package fr.sii.sonar.web.frontend.js.quality.jshint; import fr.sii.sonar.report.core.common.PluginDependencies; import fr.sii.sonar.report.core.common.ReportSensor; diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/JshintProfileDefinition.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/jshint/JshintProfileDefinition.java similarity index 90% rename from sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/JshintProfileDefinition.java rename to sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/jshint/JshintProfileDefinition.java index caac4b9..eb16b0a 100644 --- a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/JshintProfileDefinition.java +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/jshint/JshintProfileDefinition.java @@ -1,4 +1,4 @@ -package fr.sii.sonar.web.frontend.js.quality; +package fr.sii.sonar.web.frontend.js.quality.jshint; import org.sonar.api.rules.RuleFinder; diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/JshintRulesDefinition.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/jshint/JshintRulesDefinition.java similarity index 85% rename from sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/JshintRulesDefinition.java rename to sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/jshint/JshintRulesDefinition.java index fc4e20a..0e5f1cb 100644 --- a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/JshintRulesDefinition.java +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/quality/jshint/JshintRulesDefinition.java @@ -1,4 +1,4 @@ -package fr.sii.sonar.web.frontend.js.quality; +package fr.sii.sonar.web.frontend.js.quality.jshint; import fr.sii.sonar.report.core.common.rules.ComposableRulesDefinition; diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/test/JUnitConstants.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/test/JUnitConstants.java index 6bdce88..361dcad 100644 --- a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/test/JUnitConstants.java +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/test/JUnitConstants.java @@ -5,9 +5,9 @@ import fr.sii.sonar.web.frontend.js.JsLanguageConstants; public class JUnitConstants extends JsLanguageConstants implements TestConstants { - public static final String REPORT_PATH_KEY = "sonar.sii.test.unit.js.report.path"; - public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.test.unit.js.file.missing.fail"; - public static final String REPORT_PATH_DEFVALUE = "/report/jasmine.unit.xml"; + public static final String REPORT_PATH_KEY = "sonar.sii.test.ut.js.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.test.ut.js.file.missing.fail"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/js-ut.xml"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String SUB_CATEGORY = "Unit testing"; diff --git a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/test/JUnitIntegrationConstants.java b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/test/JUnitIntegrationConstants.java index c11f3c4..e8e5881 100644 --- a/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/test/JUnitIntegrationConstants.java +++ b/sonar-web-frontend-js/src/main/java/fr/sii/sonar/web/frontend/js/test/JUnitIntegrationConstants.java @@ -7,7 +7,7 @@ public class JUnitIntegrationConstants extends JsLanguageConstants implements TestConstants { public static final String REPORT_PATH_KEY = "sonar.sii.test.it.js.report.path"; public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.test.it.js.file.missing.fail"; - public static final String REPORT_PATH_DEFVALUE = "/report/jasmine.it.xml"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/js-it.xml"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String SUB_CATEGORY = "Integration testing"; diff --git a/sonar-web-frontend-js/src/main/resources/profiles/eslint.json b/sonar-web-frontend-js/src/main/resources/profiles/eslint.json new file mode 100644 index 0000000..450baa3 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/profiles/eslint.json @@ -0,0 +1,12 @@ +{ + "name": "eslint", + "language": "js", + "repositories": [{ + "key": "eslint", + "rules": "/rules/eslint.json" + }], + "rules": [{ + "repositoryKey": "eslint", + "key": "unknown-rule" + }] +} \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint.css b/sonar-web-frontend-js/src/main/resources/rules/eslint.css new file mode 100644 index 0000000..05e10da --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint.css @@ -0,0 +1,188 @@ +.ehd h1:first-child { + margin-top: 20px; +} + +@font-face { + font-family: 'Glyphicons Halflings'; + src: url(static/webfrontend/fonts/glyphicons-halflings-regular.eot); + src: url(static/webfrontend/fonts/glyphicons-halflings-regular.eot?#iefix) format('embedded-opentype'), url(static/webfrontend/fonts/glyphicons-halflings-regular.woff) format('woff'), url(static/webfrontend/fonts/glyphicons-halflings-regular.ttf) format('truetype'), url(static/webfrontend/fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular) format('svg') +} + + +.highlight .hll { background-color: #ffffcc } +.highlight .c { color: #999988; font-style: italic } /* Comment */ +.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ +.highlight .k { color: #000000; font-weight: bold } /* Keyword */ +.highlight .o { color: #000000; font-weight: bold } /* Operator */ +.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #999999; font-weight: bold; font-style: italic } /* Comment.Preproc */ +.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ +.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ +.highlight .ge { color: #000000; font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #aa0000 } /* Generic.Error */ +.highlight .gh { color: #999999 } /* Generic.Heading */ +.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ +.highlight .go { color: #888888 } /* Generic.Output */ +.highlight .gp { color: #555555 } /* Generic.Prompt */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .gu { color: #aaaaaa } /* Generic.Subheading */ +.highlight .gt { color: #aa0000 } /* Generic.Traceback */ +.highlight .kc { color: #000000; font-weight: bold } /* Keyword.Constant */ +.highlight .kd { color: #000000; font-weight: bold } /* Keyword.Declaration */ +.highlight .kn { color: #000000; font-weight: bold } /* Keyword.Namespace */ +.highlight .kp { color: #000000; font-weight: bold } /* Keyword.Pseudo */ +.highlight .kr { color: #000000; font-weight: bold } /* Keyword.Reserved */ +.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */ +.highlight .m { color: #009999 } /* Literal.Number */ +.highlight .s { color: #d01040 } /* Literal.String */ +.highlight .na { color: #008080 } /* Name.Attribute */ +.highlight .nb { color: #0086B3 } /* Name.Builtin */ +.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */ +.highlight .no { color: #008080 } /* Name.Constant */ +.highlight .nd { color: #3c5d5d; font-weight: bold } /* Name.Decorator */ +.highlight .ni { color: #800080 } /* Name.Entity */ +.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */ +.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */ +.highlight .nl { color: #990000; font-weight: bold } /* Name.Label */ +.highlight .nn { color: #555555 } /* Name.Namespace */ +.highlight .nt { color: #000080 } /* Name.Tag */ +.highlight .nv { color: #008080 } /* Name.Variable */ +.highlight .ow { color: #000000; font-weight: bold } /* Operator.Word */ +.highlight .w { color: #bbbbbb } /* Text.Whitespace */ +.highlight .mf { color: #009999 } /* Literal.Number.Float */ +.highlight .mh { color: #009999 } /* Literal.Number.Hex */ +.highlight .mi { color: #009999 } /* Literal.Number.Integer */ +.highlight .mo { color: #009999 } /* Literal.Number.Oct */ +.highlight .sb { color: #d01040 } /* Literal.String.Backtick */ +.highlight .sc { color: #d01040 } /* Literal.String.Char */ +.highlight .sd { color: #d01040 } /* Literal.String.Doc */ +.highlight .s2 { color: #d01040 } /* Literal.String.Double */ +.highlight .se { color: #d01040 } /* Literal.String.Escape */ +.highlight .sh { color: #d01040 } /* Literal.String.Heredoc */ +.highlight .si { color: #d01040 } /* Literal.String.Interpol */ +.highlight .sx { color: #d01040 } /* Literal.String.Other */ +.highlight .sr { color: #009926 } /* Literal.String.Regex */ +.highlight .s1 { color: #d01040 } /* Literal.String.Single */ +.highlight .ss { color: #990073 } /* Literal.String.Symbol */ +.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */ +.highlight .vc { color: #008080 } /* Name.Variable.Class */ +.highlight .vg { color: #008080 } /* Name.Variable.Global */ +.highlight .vi { color: #008080 } /* Name.Variable.Instance */ +.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */ + + +.btn-getting-started { + margin-top: 30px; +} + +/* Prevent long code from wrapping, scroll instead */ +code[data-lang] { + white-space: pre; +} + +main.doc .highlight pre { + overflow-x: auto; + word-wrap: normal; +} + +/* We need to push the content because of the fixed header */ +body { + padding-top: 80px; +} +/* Allow anchors to not be hidden by the fixed header */ +h1:target:before, +h2:target:before, +h3:target:before, +h4:target:before, +h5:target:before, +h6:target:before { + content: ""; + display: block; + margin-top: -80px; + height: 80px; + width: 1px; +} + +/* icon margins for rules page */ +.glyphicon { + margin: 0 2px; +} + +td .glyphicon { + margin: 0; /* within table in rules page */ +} + +th, +td { + padding-left: 0.5em; + min-width: 1em; /* width of glyphicon for a column of empty cells */ +} + +th:first-child, +td:first-child { + padding-left: 0; +} + +tr { + vertical-align: baseline; +} + +p.incorrect + div + div + div > pre, /* vars-on-top */ +p.incorrect + div + div > pre, /* no-continue */ +p.incorrect + div > pre { + background-color: #fff6f6; /* light red hsl(0,100%,98%) */ +} + +p.correct + div + div + div > pre, /* vars-on-top */ +p.correct + div + div > pre, /* no-continue */ +p.correct + div > pre { + background-color: #f6fff6; /* light green hsl(120,100%,98%) */ +} + +p.icon:before { + font-family: "Glyphicons Halflings"; + color: #4d4d4d; /* gray hsl(0,0%,30%) */ + margin-right: 0.5em; +} + +p.recommended:before { + content: "\e013"; /* ok */ +} + +p.removed:before { + content: "\e014"; /* remove */ +} + +p.fixable:before { + content: "\e136"; /* wrench */ +} + +p.incorrect:before { + content: "\e126"; /* thumbs-down */ +} + +p.correct:before { + content: "\e125"; /* thumbs-up */ +} + +@media (min-width: 768px) { + + p.icon:before { + /*position: absolute;*/ + /*left: -20px;*/ + } + + p.icon { + position:relative; + } + +} + +@media (max-width: 767px) { + + code { + white-space: normal; + } + +} \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint.json b/sonar-web-frontend-js/src/main/resources/rules/eslint.json new file mode 100644 index 0000000..7c1aeac --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint.json @@ -0,0 +1,2969 @@ +[ { + "key" : "comma-dangle", + "name" : "Comma dangle", + "description" : "require or disallow trailing commas", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "cross-browser", "ie8" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "no-cond-assign", + "name" : "No cond assign", + "description" : "disallow assignment operators in conditional expressions", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "suspicious", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-console", + "name" : "No console", + "description" : "disallow the use of console", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-constant-condition", + "name" : "No constant condition", + "description" : "disallow constant expressions in conditions", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-control-regex", + "name" : "No control regex", + "description" : "disallow control characters in regular expressions", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "pitfall", "bug", "regexp" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-debugger", + "name" : "No debugger", + "description" : "disallow the use of debugger", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-dupe-args", + "name" : "No dupe args", + "description" : "disallow duplicate arguments in function definitions", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-dupe-keys", + "name" : "No dupe keys", + "description" : "disallow duplicate keys in object literals", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "suspicious", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-duplicate-case", + "name" : "No duplicate case", + "description" : "disallow duplicate case labels", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-empty", + "name" : "No empty", + "description" : "disallow empty block statements", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-empty-character-class", + "name" : "No empty character class", + "description" : "disallow empty character classes in regular expressions", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "pitfall", "regexp" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-ex-assign", + "name" : "No ex assign", + "description" : "disallow reassigning exceptions in catch clauses", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-extra-boolean-cast", + "name" : "No extra boolean cast", + "description" : "disallow unnecessary boolean casts", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "useless" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-extra-parens", + "name" : "No extra parens", + "description" : "disallow unnecessary parentheses", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention", "useless" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-extra-semi", + "name" : "No extra semi", + "description" : "disallow unnecessary semicolons", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-func-assign", + "name" : "No func assign", + "description" : "disallow reassigning function declarations", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "no-inner-declarations", + "name" : "No inner declarations", + "description" : "disallow function or var declarations in nested blocks", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-invalid-regexp", + "name" : "No invalid regexp", + "description" : "disallow invalid regular expression strings in RegExp constructors", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "bug", "regexp" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-irregular-whitespace", + "name" : "No irregular whitespace", + "description" : "disallow irregular whitespace outside of strings and comments", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "RESOURCE_RELIABILITY" + } +}, { + "key" : "no-negated-in-lhs", + "name" : "No negated in lhs", + "description" : "disallow negating the left operand in in expressions", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-obj-calls", + "name" : "No obj calls", + "description" : "disallow calling global object properties as functions", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-regex-spaces", + "name" : "No regex spaces", + "description" : "disallow multiple spaces in regular expression literals", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "regexp" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-sparse-arrays", + "name" : "No sparse arrays", + "description" : "disallow sparse arrays", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-unexpected-multiline", + "name" : "No unexpected multiline", + "description" : "disallow confusing multiline expressions", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-unreachable", + "name" : "No unreachable", + "description" : "disallow unreachable code after return, throw, continue, and break statements", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "dead-code" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-unsafe-finally", + "name" : "No unsafe finally", + "description" : "disallow control flow statements in finally blocks", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "use-isnan", + "name" : "Use isnan", + "description" : "require calls to isNaN() when checking for NaN", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "bad-practice", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "valid-jsdoc", + "name" : "Valid jsdoc", + "description" : "enforce valid JSDoc comments", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "doc" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "valid-typeof", + "name" : "Valid typeof", + "description" : "enforce comparing typeof expressions against valid strings", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "accessor-pairs", + "name" : "Accessor pairs", + "description" : "enforce getter and setter pairs in objects", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "USABILITY_EASE_OF_USE" + } +}, { + "key" : "array-callback-return", + "name" : "Array callback return", + "description" : "enforce return statements in callbacks of array methods", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "block-scoped-var", + "name" : "Block scoped var", + "description" : "enforce the use of variables within the scope they are defined", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "complexity", + "name" : "Complexity", + "description" : "enforce a maximum cyclomatic complexity allowed in a program", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "complexity", "brain-overload" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "consistent-return", + "name" : "Consistent return", + "description" : "require return statements to either always or never specify values", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "curly", + "name" : "Curly", + "description" : "enforce consistent brace style for all control statements", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "default-case", + "name" : "Default case", + "description" : "require default cases in switch statements", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "DATA_CHANGEABILITY" + } +}, { + "key" : "dot-location", + "name" : "Dot location", + "description" : "enforce consistent newlines before and after dots", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "dot-notation", + "name" : "Dot notation", + "description" : "enforce dot notation whenever possible", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "eqeqeq", + "name" : "Eqeqeq", + "description" : "require the use of === and !==", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "guard-for-in", + "name" : "Guard for in", + "description" : "require for-in loops to include an if statement", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "suspicious", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-alert", + "name" : "No alert", + "description" : "disallow the use of alert, confirm, and prompt", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "user-experience" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "USABILITY_COMPLIANCE" + } +}, { + "key" : "no-caller", + "name" : "No caller", + "description" : "disallow the use of arguments.caller or arguments.callee", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "performance", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "CPU_EFFICIENCY" + } +}, { + "key" : "no-case-declarations", + "name" : "No case declarations", + "description" : "disallow lexical declarations in case clauses", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-div-regex", + "name" : "No div regex", + "description" : "disallow division operators explicitly at the beginning of regular expressions", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "pitfall", "regexp" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-else-return", + "name" : "No else return", + "description" : "disallow else blocks after return statements in if statements", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-empty-function", + "name" : "No empty function", + "description" : "disallow empty functions", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-empty-pattern", + "name" : "No empty pattern", + "description" : "disallow empty destructuring patterns", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-eq-null", + "name" : "No eq null", + "description" : "disallow null comparisons without type-checking operators", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-eval", + "name" : "No eval", + "description" : "disallow the use of eval()", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "security" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "API_ABUSE" + } +}, { + "key" : "no-extend-native", + "name" : "No extend native", + "description" : "disallow extending native types", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "no-extra-bind", + "name" : "No extra bind", + "description" : "disallow unnecessary calls to .bind()", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "useless" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-extra-label", + "name" : "No extra label", + "description" : "disallow unnecessary labels", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "useless" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-fallthrough", + "name" : "No fallthrough", + "description" : "disallow fallthrough of case statements", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "pitfall", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-floating-decimal", + "name" : "No floating decimal", + "description" : "disallow leading or trailing decimal points in numeric literals", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-implicit-coercion", + "name" : "No implicit coercion", + "description" : "disallow shorthand type conversions", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-implicit-globals", + "name" : "No implicit globals", + "description" : "disallow var and named function declarations in the global scope", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_CHANGEABILITY" + } +}, { + "key" : "no-implied-eval", + "name" : "No implied eval", + "description" : "disallow the use of eval()-like methods", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "security" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "API_ABUSE" + } +}, { + "key" : "no-invalid-this", + "name" : "No invalid this", + "description" : "disallow this keywords outside of classes or class-like objects", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-iterator", + "name" : "No iterator", + "description" : "disallow the use of the __iterator__ property", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "obsolete", "spidermonkey" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "no-labels", + "name" : "No labels", + "description" : "disallow labeled statements", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-lone-blocks", + "name" : "No lone blocks", + "description" : "disallow unnecessary nested blocks", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-loop-func", + "name" : "No loop func", + "description" : "disallow function declarations and expressions inside loop statements", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-magic-numbers", + "name" : "No magic numbers", + "description" : "disallow magic numbers", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "DATA_CHANGEABILITY" + } +}, { + "key" : "no-multi-spaces", + "name" : "No multi spaces", + "description" : "disallow multiple spaces", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-multi-str", + "name" : "No multi str", + "description" : "disallow multiline strings", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-native-reassign", + "name" : "No native reassign", + "description" : "disallow reassigning native objects", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "no-new", + "name" : "No new", + "description" : "disallow new operators outside of assignments or comparisons", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-new-func", + "name" : "No new func", + "description" : "disallow new operators with the Function object", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-new-wrappers", + "name" : "No new wrappers", + "description" : "disallow new operators with the String, Number, and Boolean objects", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-octal", + "name" : "No octal", + "description" : "disallow octal literals", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-octal-escape", + "name" : "No octal escape", + "description" : "disallow octal escape sequences in string literals", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "obsolete" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "no-param-reassign", + "name" : "No param reassign", + "description" : "disallow reassigning function parameters", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-proto", + "name" : "No proto", + "description" : "disallow the use of the __proto__ property", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "obsolete" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "no-redeclare", + "name" : "No redeclare", + "description" : "disallow var redeclaration", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-return-assign", + "name" : "No return assign", + "description" : "disallow assignment operators in return statements", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-script-url", + "name" : "No script url", + "description" : "disallow javascript: urls", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "performance", "security" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "API_ABUSE" + } +}, { + "key" : "no-self-assign", + "name" : "No self assign", + "description" : "disallow assignments where both sides are exactly the same", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-self-compare", + "name" : "No self compare", + "description" : "disallow comparisons where both sides are exactly the same", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-sequences", + "name" : "No sequences", + "description" : "disallow comma operators", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-throw-literal", + "name" : "No throw literal", + "description" : "disallow throwing literals as exceptions", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "EXCEPTION_HANDLING" + } +}, { + "key" : "no-unmodified-loop-condition", + "name" : "No unmodified loop condition", + "description" : "disallow unmodified loop conditions", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-unused-expressions", + "name" : "No unused expressions", + "description" : "disallow unused expressions", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "suspicious", "bad-practice", "unused" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-unused-labels", + "name" : "No unused labels", + "description" : "disallow unused labels", + "severity" :"MAJOR", + "status" : null, + "tags" : [ "eslint", "suspicious", "bad-practice", "unused" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-useless-call", + "name" : "No useless call", + "description" : "disallow unnecessary calls to .call() and .apply()", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "suspicious", "bad-practice", "unused" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-useless-concat", + "name" : "No useless concat", + "description" : "disallow unnecessary concatenation of literals or template literals", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "suspicious", "bad-practice", "unused" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-useless-escape", + "name" : "No useless escape", + "description" : "disallow unnecessary escape characters", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "suspicious", "bad-practice", "unused" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-void", + "name" : "No void", + "description" : "disallow void operators", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "obsolete" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-warning-comments", + "name" : "No warning comments", + "description" : "disallow specified warning terms in comments", + "severity" : "INFO", + "status" : null, + "tags" : [ "eslint" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-with", + "name" : "No with", + "description" : "disallow with statements", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "performance", "cross-browser", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "radix", + "name" : "Radix", + "description" : "enforce the consistent use of the radix argument when using parseInt()", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "vars-on-top", + "name" : "Vars on top", + "description" : "require var declarations be placed at the top of their containing scope", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "wrap-iife", + "name" : "Wrap iife", + "description" : "require parentheses around immediate function invocations", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "yoda", + "name" : "Yoda", + "description" : "require or disallow “Yoda” conditions", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "strict", + "name" : "Strict", + "description" : "require or disallow strict mode directives", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "init-declarations", + "name" : "Init declarations", + "description" : "require or disallow initialization in var declarations", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention", "consistency" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-catch-shadow", + "name" : "No catch shadow", + "description" : "disallow catch clause parameters from shadowing variables in the outer scope", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-delete-var", + "name" : "No delete var", + "description" : "disallow deleting variables", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "bad-practice", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-label-var", + "name" : "No label var", + "description" : "disallow labels that share a name with a variable", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-restricted-globals", + "name" : "No restricted globals", + "description" : "disallow specified global variables", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "convention", "forbidden" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "no-shadow", + "name" : "No shadow", + "description" : "disallow var declarations from shadowing variables in the outer scope", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-shadow-restricted-names", + "name" : "No shadow restricted names", + "description" : "disallow identifiers from shadowing restricted names", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "no-undef", + "name" : "No undef", + "description" : "disallow the use of undeclared variables unless mentioned in /*global */ comments", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "no-undef-init", + "name" : "No undef init", + "description" : "disallow initializing variables to undefined", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention", "useless" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-undefined", + "name" : "No undefined", + "description" : "disallow the use of undefined as an identifier", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "no-unused-vars", + "name" : "No unused vars", + "description" : "disallow unused variables", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "unused" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-use-before-define", + "name" : "No use before define", + "description" : "disallow the use of variables before they are defined", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "callback-return", + "name" : "Callback return", + "description" : "require return statements after callbacks", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall", "nodejs", "commonjs" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "global-require", + "name" : "Global require", + "description" : "require require() calls to be placed at top-level module scope", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention", "nodejs", "commonjs" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "handle-callback-err", + "name" : "Handle callback err", + "description" : "require error handling in callbacks", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "error-handling", "nodejs", "commonjs" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "EXCEPTION_HANDLING" + } +}, { + "key" : "no-mixed-requires", + "name" : "No mixed requires", + "description" : "disallow require calls to be mixed with regular var declarations", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention", "nodejs", "commonjs" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-new-require", + "name" : "No new require", + "description" : "disallow new operators with calls to require", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "nodejs", "commonjs" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-path-concat", + "name" : "No path concat", + "description" : "disallow string concatenation with __dirname and __filename", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall", "nodejs", "commonjs" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "OS_RELATED_PORTABILITY" + } +}, { + "key" : "no-process-env", + "name" : "No process env", + "description" : "disallow the use of process.env", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "environment", "nodejs", "commonjs" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "no-process-exit", + "name" : "No process exit", + "description" : "disallow the use of process.exit()", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "nodejs", "commonjs" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "FAULT_TOLERANCE" + } +}, { + "key" : "no-restricted-modules", + "name" : "No restricted modules", + "description" : "disallow specified modules when loaded by require", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "forbidden", "nodejs", "commonjs" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "no-sync", + "name" : "No sync", + "description" : "disallow synchronous methods", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "nodejs", "commonjs" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "EFFICIENCY_COMPLIANCE" + } +}, { + "key" : "array-bracket-spacing", + "name" : "Array bracket spacing", + "description" : "enforce consistent spacing inside array brackets", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "block-spacing", + "name" : "Block spacing", + "description" : "enforce consistent spacing inside single-line blocks", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "brace-style", + "name" : "Brace style", + "description" : "enforce consistent brace style for blocks", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "camelcase", + "name" : "Camelcase", + "description" : "enforce camelcase naming convention", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "comma-spacing", + "name" : "Comma spacing", + "description" : "enforce consistent spacing before and after commas", + "severity" :"MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "comma-style", + "name" : "Comma style", + "description" : "enforce consistent comma style", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "computed-property-spacing", + "name" : "Computed property spacing", + "description" : "enforce consistent spacing inside computed property brackets", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "consistent-this", + "name" : "Consistent this", + "description" : "enforce consistent naming when capturing the current execution context", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "eol-last", + "name" : "Eol last", + "description" : "enforce at least one newline at the end of files", + "severity" : "INFO", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "func-names", + "name" : "Func names", + "description" : "enforce named function expressions", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "func-style", + "name" : "Func style", + "description" : "enforce the consistent use of either function declarations or expressions", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "id-blacklist", + "name" : "Id blacklist", + "description" : "disallow specified identifiers", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "convention", "forbidden" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "id-length", + "name" : "Id length", + "description" : "enforce minimum and maximum identifier lengths", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "id-match", + "name" : "Id match", + "description" : "require identifiers to match a specified regular expression", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "indent", + "name" : "Indent", + "description" : "enforce consistent indentation", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "jsx-quotes", + "name" : "Jsx quotes", + "description" : "enforce the consistent use of either double or single quotes in JSX attributes", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention", "consistency" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "key-spacing", + "name" : "Key spacing", + "description" : "enforce consistent spacing between keys and values in object literal properties", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "keyword-spacing", + "name" : "Keyword spacing", + "description" : "enforce consistent spacing before and after keywords", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "linebreak-style", + "name" : "Linebreak style", + "description" : "enforce consistent linebreak style", + "severity" :"MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "lines-around-comment", + "name" : "Lines around comment", + "description" : "require empty lines around comments", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "max-depth", + "name" : "Max depth", + "description" : "enforce a maximum depth that blocks can be nested", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "brain-overload" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "max-len", + "name" : "Max len", + "description" : "enforce a maximum line length", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "max-nested-callbacks", + "name" : "Max nested callbacks", + "description" : "enforce a maximum depth that callbacks can be nested", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "brain-overload" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "max-params", + "name" : "Max params", + "description" : "enforce a maximum number of parameters in function definitions", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "brain-overload" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_CHANGEABILITY" + } +}, { + "key" : "max-statements", + "name" : "Max statements", + "description" : "enforce a maximum number of statements allowed in function blocks", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "brain-overload" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "max-statements-per-line", + "name" : "Max statements per line", + "description" : "enforce a maximum number of statements allowed per line", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "new-cap", + "name" : "New cap", + "description" : "require constructor function names to begin with a capital letter", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "new-parens", + "name" : "New parens", + "description" : "require parentheses when invoking a constructor with no arguments", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "newline-after-var", + "name" : "Newline after var", + "description" : "require or disallow an empty line after var declarations", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "newline-before-return", + "name" : "Newline before return", + "description" : "require an empty line before return statements", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "newline-per-chained-call", + "name" : "Newline per chained call", + "description" : "require a newline after each call in a method chain", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-array-constructor", + "name" : "No array constructor", + "description" : "disallow Array constructors", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-bitwise", + "name" : "No bitwise", + "description" : "disallow bitwise operators", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "suspicious", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-continue", + "name" : "No continue", + "description" : "disallow continue statements", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-inline-comments", + "name" : "No inline comments", + "description" : "disallow inline comments after code", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-lonely-if", + "name" : "No lonely if", + "description" : "disallow if statements as the only statement in else blocks", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-mixed-spaces-and-tabs", + "name" : "No mixed spaces and tabs", + "description" : "disallow mixed spaces and tabs for indentation", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention", "consistency" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-multiple-empty-lines", + "name" : "No multiple empty lines", + "description" : "disallow multiple empty lines", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-negated-condition", + "name" : "No negated condition", + "description" : "disallow negated conditions", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-nested-ternary", + "name" : "No nested ternary", + "description" : "disallow nested ternary expressions", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-new-object", + "name" : "No new object", + "description" : "disallow Object constructors", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-plusplus", + "name" : "No plusplus", + "description" : "disallow the unary operators ++ and --", + "severity" : "INFO", + "status" : null, + "tags" : [ "eslint", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-restricted-syntax", + "name" : "No restricted syntax", + "description" : "disallow specified syntax", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "forbidden" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "no-spaced-func", + "name" : "No spaced func", + "description" : "disallow spacing between function identifiers and their applications", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-ternary", + "name" : "No ternary", + "description" : "disallow ternary operators", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-trailing-spaces", + "name" : "No trailing spaces", + "description" : "disallow trailing whitespace at the end of lines", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-underscore-dangle", + "name" : "No underscore dangle", + "description" : "disallow dangling underscores in identifiers", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-unneeded-ternary", + "name" : "No unneeded ternary", + "description" : "disallow ternary operators when simpler alternatives exist", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-whitespace-before-property", + "name" : "No whitespace before property", + "description" : "disallow whitespace before properties", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "object-curly-spacing", + "name" : "Object curly spacing", + "description" : "enforce consistent spacing inside braces", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "object-property-newline", + "name" : "Object property newline", + "description" : "enforce placing object properties on separate lines", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "one-var", + "name" : "One var", + "description" : "enforce variables to be declared either together or separately in functions", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "one-var-declaration-per-line", + "name" : "One var declaration per line", + "description" : "require or disallow newlines around var declarations", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "operator-assignment", + "name" : "Operator assignment", + "description" : "require or disallow assignment operator shorthand where possible", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "operator-linebreak", + "name" : "Operator linebreak", + "description" : "enforce consistent linebreak style for operators", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "padded-blocks", + "name" : "Padded blocks", + "description" : "require or disallow padding within blocks", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "quote-props", + "name" : "Quote props", + "description" : "require quotes around object literal property names", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "quotes", + "name" : "Quotes", + "description" : "enforce the consistent use of either backticks, double, or single quotes", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention", "consistency" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "require-jsdoc", + "name" : "Require jsdoc", + "description" : "require JSDoc comments", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention", "doc" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "semi", + "name" : "Semi", + "description" : "require or disallow semicolons instead of ASI", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "semi-spacing", + "name" : "Semi spacing", + "description" : "enforce consistent spacing before and after semicolons", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "sort-vars", + "name" : "Sort vars", + "description" : "require variables within the same declaration block to be sorted", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "space-before-blocks", + "name" : "Space before blocks", + "description" : "enforce consistent spacing before blocks", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "space-before-function-paren", + "name" : "Space before function paren", + "description" : "enforce consistent spacing before function definition opening parenthesis", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "space-in-parens", + "name" : "Space in parens", + "description" : "enforce consistent spacing inside parentheses", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "space-infix-ops", + "name" : "Space infix ops", + "description" : "require spacing around operators", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "space-unary-ops", + "name" : "Space unary ops", + "description" : "enforce consistent spacing before or after unary operators", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "spaced-comment", + "name" : "Spaced comment", + "description" : "enforce consistent spacing after the // or /* in a comment", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "wrap-regex", + "name" : "Wrap regex", + "description" : "require parenthesis around regex literals", + "severity" : "INFO", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "arrow-body-style", + "name" : "Arrow body style", + "description" : "require braces around arrow function bodies", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "arrow-parens", + "name" : "Arrow parens", + "description" : "require parentheses around arrow function arguments", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "arrow-spacing", + "name" : "Arrow spacing", + "description" : "enforce consistent spacing before and after the arrow in arrow functions", + "severity" :"MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "constructor-super", + "name" : "Constructor super", + "description" : "require super() calls in constructors", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "generator-star-spacing", + "name" : "Generator star spacing", + "description" : "enforce consistent spacing around * operators in generator functions", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-class-assign", + "name" : "No class assign", + "description" : "disallow reassigning class members", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-confusing-arrow", + "name" : "No confusing arrow", + "description" : "disallow arrow functions where they could be confused with comparisons", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "suspicious", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-const-assign", + "name" : "No const assign", + "description" : "disallow reassigning const variables", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-dupe-class-members", + "name" : "No dupe class members", + "description" : "disallow duplicate class members", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-duplicate-imports", + "name" : "No duplicate imports", + "description" : "disallow duplicate module imports", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "useless", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-new-symbol", + "name" : "No new symbol", + "description" : "disallow new operators with the Symbol object", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "bug", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-restricted-imports", + "name" : "No restricted imports", + "description" : "disallow specified modules when loaded by import", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "eslint", "forbidden", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "no-this-before-super", + "name" : "No this before super", + "description" : "disallow this/super before calling super() in constructors", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "eslint", "bad-practice", "pitfall", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "no-useless-computed-key", + "name" : "No useless computed key", + "description" : "disallow unnecessary computed property keys in object literals", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "useless", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-useless-constructor", + "name" : "No useless constructor", + "description" : "disallow unnecessary constructors", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "useless", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-var", + "name" : "No var", + "description" : "require let or const instead of var", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "object-shorthand", + "name" : "Object shorthand", + "description" : "require or disallow method and property shorthand syntax for object literals", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "prefer-arrow-callback", + "name" : "Prefer arrow callback", + "description" : "require arrow functions as callbacks", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "prefer-const", + "name" : "Prefer const", + "description" : "require const declarations for variables that are never reassigned after declared", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "prefer-reflect", + "name" : "Prefer reflect", + "description" : "require Reflect methods where applicable", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "prefer-rest-params", + "name" : "Prefer rest params", + "description" : "require rest parameters instead of arguments", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "prefer-spread", + "name" : "Prefer spread", + "description" : "require spread operators instead of .apply()", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "prefer-template", + "name" : "Prefer template", + "description" : "require template literals instead of string concatenation", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "convention", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "require-yield", + "name" : "Require yield", + "description" : "require generator functions to contain yield", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "eslint", "bad-practice", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "sort-imports", + "name" : "Sort imports", + "description" : "enforce sorted import declarations within modules", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "template-curly-spacing", + "name" : "Template curly spacing", + "description" : "require or disallow spacing around embedded expressions of template strings", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "yield-star-spacing", + "name" : "Yield star spacing", + "description" : "require or disallow spacing around the * in yield* expressions", + "severity" : "MINOR", + "status" : null, + "tags" : [ "eslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +} ] \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/accessor-pairs.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/accessor-pairs.html new file mode 100644 index 0000000..504689a --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/accessor-pairs.html @@ -0,0 +1,75 @@ + + + +

                                                          Enforces getter/setter pairs in objects (accessor-pairs)

                                                          + +

                                                          It’s a common mistake in JavaScript to create an object with just a setter for a property but never have a corresponding getter defined for it. Without a getter, you cannot read the property, so it ends up not being used.

                                                          + +

                                                          Here are some examples:

                                                          + +
                                                          // Bad
                                                          var o = {
                                                          set a(value) {
                                                          this.val = value;
                                                          }
                                                          };

                                                          // Good
                                                          var o = {
                                                          set a(value) {
                                                          this.val = value;
                                                          },
                                                          get a() {
                                                          return this.val;
                                                          }
                                                          };

                                                          +
                                                          + +

                                                          This rule warns if setters are defined without getters. Using an option getWithoutSet, it will warn if you have a getter without a setter also.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces a style where it requires to have a getter for every property which has a setter defined.

                                                          + +

                                                          By activating the option getWithoutSet it enforces the presence of a setter for every property which has a getter defined.

                                                          + +

                                                          Options

                                                          + +
                                                            +
                                                          • setWithoutGet set to true will warn for setters without getters (Default true).
                                                          • +
                                                          • getWithoutSet set to true will warn for getters without setters (Default false).
                                                          • +
                                                          + +

                                                          setWithoutGet

                                                          + +

                                                          Examples of incorrect code for the default { "setWithoutGet": true } option:

                                                          + +
                                                          /*eslint accessor-pairs: "error"*/

                                                          var o = {
                                                          set a(value) {
                                                          this.val = value;
                                                          }
                                                          };

                                                          var o = {d: 1};
                                                          Object.defineProperty(o, 'c', {
                                                          set: function(value) {
                                                          this.val = value;
                                                          }
                                                          });
                                                          +
                                                          + +

                                                          Examples of correct code for the default { "setWithoutGet": true } option:

                                                          + +
                                                          /*eslint accessor-pairs: "error"*/

                                                          var o = {
                                                          set a(value) {
                                                          this.val = value;
                                                          },
                                                          get a() {
                                                          return this.val;
                                                          }
                                                          };

                                                          var o = {d: 1};
                                                          Object.defineProperty(o, 'c', {
                                                          set: function(value) {
                                                          this.val = value;
                                                          },
                                                          get: function() {
                                                          return this.val;
                                                          }
                                                          });

                                                          +
                                                          + +

                                                          getWithoutSet

                                                          + +

                                                          Examples of incorrect code for the { "getWithoutSet": true } option:

                                                          + +
                                                          /*eslint accessor-pairs: ["error", { "getWithoutSet": true }]*/

                                                          var o = {
                                                          set a(value) {
                                                          this.val = value;
                                                          }
                                                          };

                                                          var o = {
                                                          get a() {
                                                          return this.val;
                                                          }
                                                          };

                                                          var o = {d: 1};
                                                          Object.defineProperty(o, 'c', {
                                                          set: function(value) {
                                                          this.val = value;
                                                          }
                                                          });

                                                          var o = {d: 1};
                                                          Object.defineProperty(o, 'c', {
                                                          get: function() {
                                                          return this.val;
                                                          }
                                                          });
                                                          +
                                                          + +

                                                          Examples of correct code for the { "getWithoutSet": true } option:

                                                          + +
                                                          /*eslint accessor-pairs: ["error", { "getWithoutSet": true }]*/
                                                          var o = {
                                                          set a(value) {
                                                          this.val = value;
                                                          },
                                                          get a() {
                                                          return this.val;
                                                          }
                                                          };

                                                          var o = {d: 1};
                                                          Object.defineProperty(o, 'c', {
                                                          set: function(value) {
                                                          this.val = value;
                                                          },
                                                          get: function() {
                                                          return this.val;
                                                          }
                                                          });

                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with the simultaneous presence of setters and getters on objects.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.22.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/array-bracket-spacing.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/array-bracket-spacing.html new file mode 100644 index 0000000..d06f30c --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/array-bracket-spacing.html @@ -0,0 +1,133 @@ + + + +

                                                          Disallow or enforce spaces inside of brackets (array-bracket-spacing)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          A number of style guides require or disallow spaces between array brackets and other tokens. This rule +applies to both array literals and destructuring assignments (ECMAScript 6).

                                                          + +
                                                          /*eslint-env es6*/

                                                          var arr = [ 'foo', 'bar' ];
                                                          var [ x, y ] = z;

                                                          var arr = ['foo', 'bar'];
                                                          var [x,y] = z;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces consistent spacing inside array brackets.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • "never" (default) disallows spaces inside array brackets
                                                          • +
                                                          • "always" requires one or more spaces or newlines inside array brackets
                                                          • +
                                                          + +

                                                          This rule has an object option for exceptions to the "never" option:

                                                          + +
                                                            +
                                                          • "singleValue": true requires one or more spaces or newlines inside brackets of array literals that contain a single element
                                                          • +
                                                          • "objectsInArrays": true requires one or more spaces or newlines between brackets of array literals and braces of their object literal elements [ { or } ]
                                                          • +
                                                          • "arraysInArrays": true requires one or more spaces or newlines between brackets of array literals and brackets of their array literal elements [ [ or ] ]
                                                          • +
                                                          + +

                                                          This rule has an object option for exceptions to the "always" option:

                                                          + +
                                                            +
                                                          • "singleValue": false disallows spaces inside brackets of array literals that contain a single element
                                                          • +
                                                          • "objectsInArrays": false disallows spaces between brackets of array literals and braces of their object literal elements [{ or }]
                                                          • +
                                                          • "arraysInArrays": false disallows spaces between brackets of array literals and brackets of their array literal elements [[ or ]]
                                                          • +
                                                          + +

                                                          This rule has built-in exceptions:

                                                          + +
                                                            +
                                                          • "never" (and also the exceptions to the "always" option) allows newlines inside array brackets, because this is a common pattern
                                                          • +
                                                          • "always" does not require spaces or newlines in empty array literals []
                                                          • +
                                                          + +

                                                          never

                                                          + +

                                                          Examples of incorrect code for this rule with the default "never" option:

                                                          + +
                                                          /*eslint array-bracket-spacing: ["error", "never"]*/
                                                          /*eslint-env es6*/

                                                          var arr = [ 'foo', 'bar' ];
                                                          var arr = ['foo', 'bar' ];
                                                          var arr = [ ['foo'], 'bar'];
                                                          var arr = [[ 'foo' ], 'bar'];
                                                          var arr = [ 'foo',
                                                          'bar'
                                                          ];
                                                          var [ x, y ] = z;
                                                          var [ x,y ] = z;
                                                          var [ x, ...y ] = z;
                                                          var [ ,,x, ] = z;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "never" option:

                                                          + +
                                                          /*eslint array-bracket-spacing: ["error", "never"]*/
                                                          /*eslint-env es6*/

                                                          var arr = [];
                                                          var arr = ['foo', 'bar', 'baz'];
                                                          var arr = [['foo'], 'bar', 'baz'];
                                                          var arr = [
                                                          'foo',
                                                          'bar',
                                                          'baz'
                                                          ];
                                                          var arr = ['foo',
                                                          'bar'
                                                          ];
                                                          var arr = [
                                                          'foo',
                                                          'bar'];

                                                          var [x, y] = z;
                                                          var [x,y] = z;
                                                          var [x, ...y] = z;
                                                          var [,,x,] = z;
                                                          +
                                                          + +

                                                          always

                                                          + +

                                                          Examples of incorrect code for this rule with the "always" option:

                                                          + +
                                                          /*eslint array-bracket-spacing: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          var arr = ['foo', 'bar'];
                                                          var arr = ['foo', 'bar' ];
                                                          var arr = [ ['foo'], 'bar' ];
                                                          var arr = ['foo',
                                                          'bar'
                                                          ];
                                                          var arr = [
                                                          'foo',
                                                          'bar'];

                                                          var [x, y] = z;
                                                          var [x,y] = z;
                                                          var [x, ...y] = z;
                                                          var [,,x,] = z;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "always" option:

                                                          + +
                                                          /*eslint array-bracket-spacing: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          var arr = [];
                                                          var arr = [ 'foo', 'bar', 'baz' ];
                                                          var arr = [ [ 'foo' ], 'bar', 'baz' ];
                                                          var arr = [ 'foo',
                                                          'bar'
                                                          ];
                                                          var arr = [
                                                          'foo',
                                                          'bar' ];
                                                          var arr = [
                                                          'foo',
                                                          'bar',
                                                          'baz'
                                                          ];

                                                          var [ x, y ] = z;
                                                          var [ x,y ] = z;
                                                          var [ x, ...y ] = z;
                                                          var [ ,,x, ] = z;
                                                          +
                                                          + +

                                                          singleValue

                                                          + +

                                                          Examples of incorrect code for this rule with the "always", { "singleValue": false } options:

                                                          + +
                                                          /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/

                                                          var foo = [ 'foo' ];
                                                          var foo = [ 'foo'];
                                                          var foo = ['foo' ];
                                                          var foo = [ 1 ];
                                                          var foo = [ 1];
                                                          var foo = [1 ];
                                                          var foo = [ [ 1, 2 ] ];
                                                          var foo = [ { 'foo': 'bar' } ];
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "always", { "singleValue": false } options:

                                                          + +
                                                          /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/

                                                          var foo = ['foo'];
                                                          var foo = [1];
                                                          var foo = [[ 1, 1 ]];
                                                          var foo = [{ 'foo': 'bar' }];
                                                          +
                                                          + +

                                                          objectsInArrays

                                                          + +

                                                          Examples of incorrect this rule with the "always", { "objectsInArrays": false } options:

                                                          + +
                                                          /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/

                                                          var arr = [ { 'foo': 'bar' } ];
                                                          var arr = [ {
                                                          'foo': 'bar'
                                                          } ]
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "always", { "objectsInArrays": false } options:

                                                          + +
                                                          /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/

                                                          var arr = [{ 'foo': 'bar' }];
                                                          var arr = [{
                                                          'foo': 'bar'
                                                          }];
                                                          +
                                                          + +

                                                          arraysInArrays

                                                          + +

                                                          Examples of incorrect code for this rule with the "always", { "arraysInArrays": false } options:

                                                          + +
                                                          /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/

                                                          var arr = [ [ 1, 2 ], 2, 3, 4 ];
                                                          var arr = [ [ 1, 2 ], 2, [ 3, 4 ] ];
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "always", { "arraysInArrays": false } options:

                                                          + +
                                                          /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/

                                                          var arr = [[ 1, 2 ], 2, 3, 4 ];
                                                          var arr = [[ 1, 2 ], 2, [ 3, 4 ]];
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with the consistency of spacing between array brackets.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.24.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/array-callback-return.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/array-callback-return.html new file mode 100644 index 0000000..103ba13 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/array-callback-return.html @@ -0,0 +1,61 @@ + + + +

                                                          Enforces return statements in callbacks of array’s methods (array-callback-return)

                                                          + +

                                                          Array has several methods for filtering, mapping, and folding. +If we forget to write return statement in a callback of those, it’s probably a mistake.

                                                          + +
                                                          // example: convert ['a', 'b', 'c'] --> {a: 0, b: 1, c: 2}
                                                          var indexMap = myArray.reduce(function(memo, item, index) {
                                                          memo[item] = index;
                                                          }, {}); // Error: cannot set property 'b' of undefined
                                                          +
                                                          + +

                                                          This rule enforces usage of return statement in callbacks of array’s methods.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule finds callback functions of the following methods, then checks usage of return statement.

                                                          + + + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint array-callback-return: "error"*/

                                                          var indexMap = myArray.reduce(function(memo, item, index) {
                                                          memo[item] = index;
                                                          }, {});

                                                          var foo = Array.from(nodes, function(node) {
                                                          if (node.tagName === "DIV") {
                                                          return true;
                                                          }
                                                          });

                                                          var bar = foo.filter(function(x) {
                                                          if (x) {
                                                          return true;
                                                          } else {
                                                          return;
                                                          }
                                                          });
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint array-callback-return: "error"*/

                                                          var indexMap = myArray.reduce(function(memo, item, index) {
                                                          memo[item] = index;
                                                          return memo;
                                                          }, {});

                                                          var foo = Array.from(nodes, function(node) {
                                                          if (node.tagName === "DIV") {
                                                          return true;
                                                          }
                                                          return false;
                                                          });

                                                          var bar = foo.map(node => node.getAttribute("id"));
                                                          +
                                                          + +

                                                          Known Limitations

                                                          + +

                                                          This rule checks callback functions of methods with the given names, even if the object which has the method is not an array.

                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to warn about usage of return statement in callbacks of array’s methods, then it’s safe to disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-alpha-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/arrow-body-style.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/arrow-body-style.html new file mode 100644 index 0000000..ac9cf25 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/arrow-body-style.html @@ -0,0 +1,59 @@ + + + +

                                                          Require braces in arrow function body (arrow-body-style)

                                                          + +

                                                          Arrow functions can omit braces when there is a single statement in the body. This rule enforces the consistent use of braces in arrow functions.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule can enforce the use of braces around arrow function body.

                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes one option, a string, which can be:

                                                          + +
                                                            +
                                                          • "always" enforces braces around the function body
                                                          • +
                                                          • "as-needed" enforces no braces where they can be omitted (default)
                                                          • +
                                                          + +

                                                          “always”

                                                          + +
                                                          "arrow-body-style": ["error", "always"]
                                                          +
                                                          + +

                                                          When the rule is set to "always" the following patterns are considered problems:

                                                          + +
                                                          /*eslint arrow-body-style: ["error", "always"]*/
                                                          /*eslint-env es6*/
                                                          let foo = () => 0;
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          let foo = () => {
                                                          return 0;
                                                          };
                                                          let foo = (retv, name) => {
                                                          retv[name] = true;
                                                          return retv;
                                                          };
                                                          +
                                                          + +

                                                          “as-needed”

                                                          + +

                                                          When the rule is set to "as-needed" the following patterns are considered problems:

                                                          + +
                                                          /*eslint arrow-body-style: ["error", "as-needed"]*/
                                                          /*eslint-env es6*/

                                                          let foo = () => {
                                                          return 0;
                                                          };
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint arrow-body-style: ["error", "as-needed"]*/
                                                          /*eslint-env es6*/

                                                          let foo = () => 0;
                                                          let foo = (retv, name) => {
                                                          retv[name] = true;
                                                          return retv;
                                                          };
                                                          let foo = () => { bar(); };
                                                          let foo = () => {};
                                                          let foo = () => { /* do nothing */ };
                                                          let foo = () => {
                                                          // do nothing.
                                                          };
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.8.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/arrow-parens.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/arrow-parens.html new file mode 100644 index 0000000..855feb6 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/arrow-parens.html @@ -0,0 +1,96 @@ + + + +

                                                          Require parens in arrow function arguments (arrow-parens)

                                                          + +

                                                          Arrow functions can omit parentheses when they have exactly one parameter. In all other cases the parameter(s) must +be wrapped in parentheses. This rule enforces the consistent use of parentheses in arrow functions.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces parentheses around arrow function parameters regardless of arity. For example:

                                                          + +
                                                          /*eslint-env es6*/

                                                          // Bad
                                                          a => {}

                                                          // Good
                                                          (a) => {}
                                                          +
                                                          + +

                                                          Following this style will help you find arrow functions (=>) which may be mistakenly included in a condition +when a comparison such as >= was the intent.

                                                          + +
                                                          /*eslint-env es6*/

                                                          // Bad
                                                          if (a => 2) {
                                                          }

                                                          // Good
                                                          if (a >= 2) {
                                                          }
                                                          +
                                                          + +

                                                          The rule can also be configured to discourage the use of parens when they are not required:

                                                          + +
                                                          /*eslint-env es6*/

                                                          // Bad
                                                          (a) => {}

                                                          // Good
                                                          a => {}
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes one option, a string, which could be either "always" or "as-needed". The default is "always".

                                                          + +

                                                          You can set the option in configuration like this:

                                                          + +
                                                          "arrow-parens": ["error", "always"]
                                                          +
                                                          + +

                                                          “always”

                                                          + +

                                                          When the rule is set to "always" the following patterns are considered problems:

                                                          + +
                                                          /*eslint arrow-parens: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          a => {};
                                                          a => a;
                                                          a => {'\n'};
                                                          a.then(foo => {});
                                                          a.then(foo => a);
                                                          a(foo => { if (true) {}; });
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint arrow-parens: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          () => {};
                                                          (a) => {};
                                                          (a) => a;
                                                          (a) => {'\n'}
                                                          a.then((foo) => {});
                                                          a.then((foo) => { if (true) {}; });
                                                          +
                                                          + +

                                                          If Statements

                                                          + +

                                                          One benefits of this option is that it prevents the incorrect use of arrow functions in conditionals:

                                                          + +
                                                          /*eslint-env es6*/

                                                          var a = 1;
                                                          var b = 2;
                                                          // ...
                                                          if (a => b) {
                                                          console.log('bigger');
                                                          } else {
                                                          console.log('smaller');
                                                          };
                                                          // outputs 'bigger', not smaller as expected
                                                          +
                                                          + +

                                                          The contents of the if statement is an arrow function, not a comparison. +If the arrow function is intentional, it should be wrapped in parens to remove ambiguity.

                                                          + +
                                                          /*eslint-env es6*/

                                                          var a = 1;
                                                          var b = 0;
                                                          // ...
                                                          if ((a) => b) {
                                                          console.log('truthy value returned');
                                                          } else {
                                                          console.log('falsey value returned');
                                                          };
                                                          // outputs 'falsey value returned'
                                                          +
                                                          + +

                                                          The following is another example of this behavior:

                                                          + +
                                                          /*eslint-env es6*/

                                                          var a = 1, b = 2, c = 3, d = 4;
                                                          var f = a => b ? c: d;
                                                          // f = ?
                                                          +
                                                          + +

                                                          f is an arrow function which takes a as an argument and returns the result of b ? c: d.

                                                          + +

                                                          This should be rewritten like so:

                                                          + +
                                                          /*eslint-env es6*/

                                                          var a = 1, b = 2, c = 3, d = 4;
                                                          var f = (a) => b ? c: d;
                                                          +
                                                          + +

                                                          “as-needed”

                                                          + +

                                                          When the rule is set to "as-needed" the following patterns are considered problems:

                                                          + +
                                                          /*eslint arrow-parens: ["error", "as-needed"]*/
                                                          /*eslint-env es6*/

                                                          (a) => {};
                                                          (a) => a;
                                                          (a) => {'\n'};
                                                          a.then((foo) => {});
                                                          a.then((foo) => a);
                                                          a((foo) => { if (true) {}; });
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint arrow-parens: ["error", "as-needed"]*/
                                                          /*eslint-env es6*/

                                                          () => {};
                                                          a => {};
                                                          a => a;
                                                          a => {'\n'};
                                                          a.then(foo => {});
                                                          a.then(foo => { if (true) {}; });
                                                          (a, b, c) => a;
                                                          (a = 10) => a;
                                                          ([a, b]) => a;
                                                          ({a, b}) => a;
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0-rc-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/arrow-spacing.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/arrow-spacing.html new file mode 100644 index 0000000..0d02f96 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/arrow-spacing.html @@ -0,0 +1,57 @@ + + + +

                                                          Require space before/after arrow function’s arrow (arrow-spacing)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          This rule normalize style of spacing before/after an arrow function’s arrow(=>).

                                                          + +
                                                          /*eslint-env es6*/

                                                          // { "before": true, "after": true }
                                                          (a) => {}

                                                          // { "before": false, "after": false }
                                                          (a)=>{}
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule takes an object argument with before and after properties, each with a Boolean value.

                                                          + +

                                                          The default configuration is { "before": true, "after": true }.

                                                          + +

                                                          true means there should be one or more spaces and false means no spaces.

                                                          + +

                                                          The following patterns are considered problems if { "before": true, "after": true }.

                                                          + +
                                                          /*eslint arrow-spacing: "error"*/
                                                          /*eslint-env es6*/

                                                          ()=> {};
                                                          () =>{};
                                                          (a)=> {};
                                                          (a) =>{};
                                                          a =>a;
                                                          a=> a;
                                                          ()=> {'\n'};
                                                          () =>{'\n'};
                                                          +
                                                          + +

                                                          The following patterns are not considered problems if { "before": true, "after": true }.

                                                          + +
                                                          /*eslint arrow-spacing: "error"*/
                                                          /*eslint-env es6*/

                                                          () => {};
                                                          (a) => {};
                                                          a => a;
                                                          () => {'\n'};
                                                          +
                                                          + +

                                                          The following patterns are not considered problems if { "before": false, "after": false }.

                                                          + +
                                                          /*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
                                                          /*eslint-env es6*/

                                                          ()=>{};
                                                          (a)=>{};
                                                          a=>a;
                                                          ()=>{'\n'};
                                                          +
                                                          + +

                                                          The following patterns are not considered problems if { "before": true, "after": false }.

                                                          + +
                                                          /*eslint arrow-spacing: ["error", { "before": true, "after": false }]*/
                                                          /*eslint-env es6*/

                                                          () =>{};
                                                          (a) =>{};
                                                          a =>a;
                                                          () =>{'\n'};
                                                          +
                                                          + +

                                                          The following patterns are not considered problems if { "before": false, "after": true }.

                                                          + +
                                                          /*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
                                                          /*eslint-env es6*/

                                                          ()=> {};
                                                          (a)=> {};
                                                          a=> a;
                                                          ()=> {'\n'};
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0-rc-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/block-scoped-var.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/block-scoped-var.html new file mode 100644 index 0000000..f714e7e --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/block-scoped-var.html @@ -0,0 +1,40 @@ + + + +

                                                          Treat var as Block Scoped (block-scoped-var)

                                                          + +

                                                          The block-scoped-var rule generates warnings when variables are used outside of the block in which they were defined. This emulates C-style block scope.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to reduce the usage of variables outside of their binding context and emulate traditional block scope from other languages. This is to help newcomers to the language avoid difficult bugs with variable hoisting.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint block-scoped-var: "error"*/

                                                          function doIf() {
                                                          if (true) {
                                                          var build = true;
                                                          }

                                                          console.log(build);
                                                          }

                                                          function doIfElse() {
                                                          if (true) {
                                                          var build = true;
                                                          } else {
                                                          var build = false;
                                                          }
                                                          }

                                                          function doTryCatch() {
                                                          try {
                                                          var build = 1;
                                                          } catch (e) {
                                                          var f = build;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint block-scoped-var: "error"*/

                                                          function doIf() {
                                                          var build;

                                                          if (true) {
                                                          build = true;
                                                          }

                                                          console.log(build);
                                                          }

                                                          function doIfElse() {
                                                          var build;

                                                          if (true) {
                                                          build = true;
                                                          } else {
                                                          build = false;
                                                          }
                                                          }

                                                          function doTryCatch() {
                                                          var build;
                                                          var f;

                                                          try {
                                                          build = 1;
                                                          } catch (e) {
                                                          f = build;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.1.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/block-spacing.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/block-spacing.html new file mode 100644 index 0000000..9a3e972 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/block-spacing.html @@ -0,0 +1,60 @@ + + + +

                                                          Disallow or enforce spaces inside of single line blocks (block-spacing)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces consistent spacing inside single-line blocks.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • "always" (default) requires one or more spaces
                                                          • +
                                                          • "never" disallows spaces
                                                          • +
                                                          + +

                                                          always

                                                          + +

                                                          Examples of incorrect code for this rule with the default "always" option:

                                                          + +
                                                          /*eslint block-spacing: "error"*/

                                                          function foo() {return true;}
                                                          if (foo) { bar = 0;}
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "always" option:

                                                          + +
                                                          /*eslint block-spacing: "error"*/

                                                          function foo() { return true; }
                                                          if (foo) { bar = 0; }
                                                          +
                                                          + +

                                                          never

                                                          + +

                                                          Examples of incorrect code for this rule with the "never" option:

                                                          + +
                                                          /*eslint block-spacing: ["error", "never"]*/

                                                          function foo() { return true; }
                                                          if (foo) { bar = 0;}
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "never" option:

                                                          + +
                                                          /*eslint block-spacing: ["error", "never"]*/

                                                          function foo() {return true;}
                                                          if (foo) {bar = 0;}
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about spacing style inside of blocks, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.2.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/brace-style.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/brace-style.html new file mode 100644 index 0000000..f876499 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/brace-style.html @@ -0,0 +1,117 @@ + + + +

                                                          Require Brace Style (brace-style)

                                                          + +

                                                          Brace style is closely related to indent style in programming and describes the placement of braces relative to their control statement and body. There are probably a dozen, if not more, brace styles in the world.

                                                          + +

                                                          The one true brace style is one of the most common brace styles in JavaScript, in which the opening brace of a block is placed on the same line as its corresponding statement or declaration. For example:

                                                          + +
                                                          if (foo) {
                                                          bar();
                                                          } else {
                                                          baz();
                                                          }
                                                          +
                                                          + +

                                                          One common variant of one true brace style is called Stroustrup, in which the else statements in an if-else construct, as well as catch and finally, must be on its own line after the preceding closing brace. For example:

                                                          + +
                                                          if (foo) {
                                                          bar();
                                                          }
                                                          else {
                                                          baz();
                                                          }
                                                          +
                                                          + +

                                                          Another style is called Allman, in which all the braces are expected to be on their own lines without any extra indentation. For example:

                                                          + +
                                                          if (foo)
                                                          {
                                                          bar();
                                                          }
                                                          else
                                                          {
                                                          baz();
                                                          }
                                                          +
                                                          + +

                                                          While no style is considered better than the other, most developers agree that having a consistent style throughout a project is important for its long-term maintainability.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces consistent brace style for blocks.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • "1tbs" (default) enforces one true brace style
                                                          • +
                                                          • "stroustrup" enforces Stroustrup style
                                                          • +
                                                          • "allman" enforces Allman style
                                                          • +
                                                          + +

                                                          This rule has an object option for an exception:

                                                          + +
                                                            +
                                                          • "allowSingleLine": true (default false) allows the opening and closing braces for a block to be on the same line
                                                          • +
                                                          + +

                                                          1tbs

                                                          + +

                                                          Examples of incorrect code for this rule with the default "1tbs" option:

                                                          + +
                                                          /*eslint brace-style: "error"*/

                                                          function foo()
                                                          {
                                                          return true;
                                                          }

                                                          if (foo)
                                                          {
                                                          bar();
                                                          }

                                                          try
                                                          {
                                                          somethingRisky();
                                                          } catch(e)
                                                          {
                                                          handleError();
                                                          }

                                                          if (foo) {
                                                          bar();
                                                          }
                                                          else {
                                                          baz();
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "1tbs" option:

                                                          + +
                                                          /*eslint brace-style: "error"*/

                                                          function foo() {
                                                          return true;
                                                          }

                                                          if (foo) {
                                                          bar();
                                                          }

                                                          if (foo) {
                                                          bar();
                                                          } else {
                                                          baz();
                                                          }

                                                          try {
                                                          somethingRisky();
                                                          } catch(e) {
                                                          handleError();
                                                          }

                                                          // when there are no braces, there are no problems
                                                          if (foo) bar();
                                                          else if (baz) boom();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "1tbs", { "allowSingleLine": true } options:

                                                          + +
                                                          /*eslint brace-style: ["error", "1tbs", { "allowSingleLine": true }]*/

                                                          function nop() { return; }

                                                          if (foo) { bar(); }

                                                          if (foo) { bar(); } else { baz(); }

                                                          try { somethingRisky(); } catch(e) { handleError(); }
                                                          +
                                                          + +

                                                          stroustrup

                                                          + +

                                                          Examples of incorrect code for this rule with the "stroustrup" option:

                                                          + +
                                                          /*eslint brace-style: ["error", "stroustrup"]*/

                                                          function foo()
                                                          {
                                                          return true;
                                                          }

                                                          if (foo)
                                                          {
                                                          bar();
                                                          }

                                                          try
                                                          {
                                                          somethingRisky();
                                                          } catch(e)
                                                          {
                                                          handleError();
                                                          }

                                                          if (foo) {
                                                          bar();
                                                          } else {
                                                          baz();
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "stroustrup" option:

                                                          + +
                                                          /*eslint brace-style: ["error", "stroustrup"]*/

                                                          function foo() {
                                                          return true;
                                                          }

                                                          if (foo) {
                                                          bar();
                                                          }

                                                          if (foo) {
                                                          bar();
                                                          }
                                                          else {
                                                          baz();
                                                          }

                                                          try {
                                                          somethingRisky();
                                                          }
                                                          catch(e) {
                                                          handleError();
                                                          }

                                                          // when there are no braces, there are no problems
                                                          if (foo) bar();
                                                          else if (baz) boom();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "stroustrup", { "allowSingleLine": true } options:

                                                          + +
                                                          /*eslint brace-style: ["error", "stroustrup", { "allowSingleLine": true }]*/

                                                          function nop() { return; }

                                                          if (foo) { bar(); }

                                                          if (foo) { bar(); }
                                                          else { baz(); }

                                                          try { somethingRisky(); }
                                                          catch(e) { handleError(); }
                                                          +
                                                          + +

                                                          allman

                                                          + +

                                                          Examples of incorrect code for this rule with the "allman" option:

                                                          + +
                                                          /*eslint brace-style: ["error", "allman"]*/

                                                          function foo() {
                                                          return true;
                                                          }

                                                          if (foo)
                                                          {
                                                          bar(); }

                                                          try
                                                          {
                                                          somethingRisky();
                                                          } catch(e)
                                                          {
                                                          handleError();
                                                          }

                                                          if (foo) {
                                                          bar();
                                                          } else {
                                                          baz();
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "allman" option:

                                                          + +
                                                          /*eslint brace-style: ["error", "allman"]*/

                                                          function foo()
                                                          {
                                                          return true;
                                                          }

                                                          if (foo)
                                                          {
                                                          bar();
                                                          }

                                                          if (foo)
                                                          {
                                                          bar();
                                                          }
                                                          else
                                                          {
                                                          baz();
                                                          }

                                                          try
                                                          {
                                                          somethingRisky();
                                                          }
                                                          catch(e)
                                                          {
                                                          handleError();
                                                          }

                                                          // when there are no braces, there are no problems
                                                          if (foo) bar();
                                                          else if (baz) boom();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "allman", { "allowSingleLine": true } options:

                                                          + +
                                                          /*eslint brace-style: ["error", "allman", { "allowSingleLine": true }]*/

                                                          function nop() { return; }

                                                          if (foo) { bar(); }

                                                          if (foo) { bar(); }
                                                          else { baz(); }

                                                          try { somethingRisky(); }
                                                          catch(e) { handleError(); }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If your project will not be using the one true brace style, turn this rule off.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.7.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/callback-return.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/callback-return.html new file mode 100644 index 0000000..2be3c33 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/callback-return.html @@ -0,0 +1,102 @@ + + + +

                                                          Enforce Return After Callback (callback-return)

                                                          + +

                                                          The callback pattern is at the heart of most I/O and event-driven programming + in JavaScript.

                                                          + +
                                                          function doSomething(err, callback) {
                                                          if (err) {
                                                          return callback(err);
                                                          }
                                                          callback();
                                                          }
                                                          +
                                                          + +

                                                          To prevent calling the callback multiple times it is important to return anytime the callback is triggered outside + of the main function body. Neglecting this technique often leads to issues where you do something more than once. + For example, in the case of an HTTP request, you may try to send HTTP headers more than once leading Node.js to throw + a Can't render headers after they are sent to the client. error.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at ensuring that callbacks used outside of the main function block are always part-of or immediately +preceding a return statement. This rule decides what is a callback based on the name of the function being called.

                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes a single option, which is an array of possible callback names. The default callback names are callback, cb, next.

                                                          + +

                                                          Examples of incorrect code for this rule with the default ["callback", "cb", "next"] option:

                                                          + +
                                                          /*eslint callback-return: "error"*/

                                                          function foo() {
                                                          if (err) {
                                                          callback(err);
                                                          }
                                                          callback();
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default ["callback", "cb", "next"] option:

                                                          + +
                                                          /*eslint callback-return: "error"*/

                                                          function foo() {
                                                          if (err) {
                                                          return callback(err);
                                                          }
                                                          callback();
                                                          }
                                                          +
                                                          + +

                                                          Known Limitations

                                                          + +

                                                          Because it is difficult to understand the meaning of a program through static analysis, this rule has limitations:

                                                          + +
                                                            +
                                                          • false negatives when this rule reports correct code, but the program calls the callback more than one time (which is incorrect behavior)
                                                          • +
                                                          • false positives when this rule reports incorrect code, but the program calls the callback only one time (which is correct behavior)
                                                          • +
                                                          + +

                                                          Passing the callback by reference

                                                          + +

                                                          The static analysis of this rule does not detect that the program calls the callback if it is an argument of a function (for example, setTimeout).

                                                          + +

                                                          Example of a false negative when this rule reports correct code:

                                                          + +
                                                          /*eslint callback-return: "error"*/

                                                          function foo(callback) {
                                                          if (err) {
                                                          setTimeout(callback, 0); // this is bad, but WILL NOT warn
                                                          }
                                                          callback();
                                                          }
                                                          +
                                                          + +

                                                          Triggering the callback within a nested function

                                                          + +

                                                          The static analysis of this rule does not detect that the program calls the callback from within a nested function or an immediately-invoked function expression (IIFE).

                                                          + +

                                                          Example of a false negative when this rule reports correct code:

                                                          + +
                                                          /*eslint callback-return: "error"*/

                                                          function foo(callback) {
                                                          if (err) {
                                                          process.nextTick(function() {
                                                          return callback(); // this is bad, but WILL NOT warn
                                                          });
                                                          }
                                                          callback();
                                                          }
                                                          +
                                                          + +

                                                          If/else statements

                                                          + +

                                                          The static analysis of this rule does not detect that the program calls the callback only one time in each branch of an if statement.

                                                          + +

                                                          Example of a false positive when this rule reports incorrect code:

                                                          + +
                                                          /*eslint callback-return: "error"*/

                                                          function foo(callback) {
                                                          if (err) {
                                                          callback(err); // this is fine, but WILL warn
                                                          } else {
                                                          callback(); // this is fine, but WILL warn
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          There are some cases where you might want to call a callback function more than once. In those cases this rule + may lead to incorrect behavior. In those cases you may want to reserve a special name for those callbacks and + not include that in the list of callbacks that trigger warnings.

                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0-rc-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/camelcase.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/camelcase.html new file mode 100644 index 0000000..5a55ff6 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/camelcase.html @@ -0,0 +1,55 @@ + + + +

                                                          Require Camelcase (camelcase)

                                                          + +

                                                          When it comes to naming variables, style guides generally fall into one of two camps: camelcase (variableName) and underscores (variable_name). This rule focuses on using the camelcase approach. If your style guide calls for camelcasing your variable names, then this rule is for you!

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule looks for any underscores (_) located within the source code. It ignores leading and trailing underscores and only checks those in the middle of a variable name. If ESLint decides that the variable is a constant (all uppercase), then no warning will be thrown. Otherwise, a warning will be thrown. This rule only flags definitions and assignments but not function calls.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an object option:

                                                          + +
                                                            +
                                                          • "properties": "always" (default) enforces camelcase style for property names
                                                          • +
                                                          • "properties": "never" does not check property names
                                                          • +
                                                          + +

                                                          always

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "properties": "always" } option:

                                                          + +
                                                          /*eslint camelcase: "error"*/

                                                          var my_favorite_color = "#112C85";

                                                          function do_something() {
                                                          // ...
                                                          }

                                                          obj.do_something = function() {
                                                          // ...
                                                          };

                                                          var obj = {
                                                          my_pref: 1
                                                          };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "properties": "always" } option:

                                                          + +
                                                          /*eslint camelcase: "error"*/

                                                          var myFavoriteColor = "#112C85";
                                                          var _myFavoriteColor = "#112C85";
                                                          var myFavoriteColor_ = "#112C85";
                                                          var MY_FAVORITE_COLOR = "#112C85";
                                                          var foo = bar.baz_boom;
                                                          var foo = { qux: bar.baz_boom };

                                                          obj.do_something();

                                                          var { category_id: category } = query;
                                                          +
                                                          + +

                                                          never

                                                          + +

                                                          Examples of correct code for this rule with the { "properties": "never" } option:

                                                          + +
                                                          /*eslint camelcase: ["error", {properties: "never"}]*/

                                                          var obj = {
                                                          my_pref: 1
                                                          };
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you have established coding standards using a different naming convention (separating words with underscores), turn this rule off.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/comma-dangle.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/comma-dangle.html new file mode 100644 index 0000000..0d6ec25 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/comma-dangle.html @@ -0,0 +1,104 @@ + + + +

                                                          require or disallow trailing commas (comma-dangle)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Trailing commas in object literals are valid according to the ECMAScript 5 (and ECMAScript 3!) spec. However, IE8 (when not in IE8 document mode) and below will throw an error when it encounters trailing commas in JavaScript.

                                                          + +
                                                          var foo = {
                                                          bar: "baz",
                                                          qux: "quux",
                                                          };
                                                          +
                                                          + +

                                                          Trailing commas simplify adding and removing items to objects and arrays, since only the lines you are modifying must be touched. +Another argument in favor of trailing commas is that it improves the clarity of diffs when an item is added or removed from an object or array:

                                                          + +

                                                          Less clear:

                                                          + +
                                                           var foo = {
                                                          - bar: "baz",
                                                          - qux: "quux"
                                                          + bar: "baz"
                                                          };
                                                          +
                                                          + +

                                                          More clear:

                                                          + +
                                                           var foo = {
                                                          bar: "baz",
                                                          - qux: "quux",
                                                          };
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces consistent use of trailing commas in object and array literals.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • "never" (default) disallows trailing commas
                                                          • +
                                                          • "always" requires trailing commas
                                                          • +
                                                          • "always-multiline" requires trailing commas when the last element or property is in a different line than the closing ] or } and disallows trailing commas when the last element or property is on the same line as the closing ] or }
                                                          • +
                                                          • "only-multiline" allows (but does not require) trailing commas when the last element or property is in a different line than the closing ] or } and disallows trailing commas when the last element or property is on the same line as the closing ] or }
                                                          • +
                                                          + +

                                                          never

                                                          + +

                                                          Examples of incorrect code for this rule with the default "never" option:

                                                          + +
                                                          /*eslint comma-dangle: ["error", "never"]*/

                                                          var foo = {
                                                          bar: "baz",
                                                          qux: "quux",
                                                          };

                                                          var arr = [1,2,];

                                                          foo({
                                                          bar: "baz",
                                                          qux: "quux",
                                                          });
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "never" option:

                                                          + +
                                                          /*eslint comma-dangle: ["error", "never"]*/

                                                          var foo = {
                                                          bar: "baz",
                                                          qux: "quux"
                                                          };

                                                          var arr = [1,2];

                                                          foo({
                                                          bar: "baz",
                                                          qux: "quux"
                                                          });
                                                          +
                                                          + +

                                                          always

                                                          + +

                                                          Examples of incorrect code for this rule with the "always" option:

                                                          + +
                                                          /*eslint comma-dangle: ["error", "always"]*/

                                                          var foo = {
                                                          bar: "baz",
                                                          qux: "quux"
                                                          };

                                                          var arr = [1,2];

                                                          foo({
                                                          bar: "baz",
                                                          qux: "quux"
                                                          });
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "always" option:

                                                          + +
                                                          /*eslint comma-dangle: ["error", "always"]*/

                                                          var foo = {
                                                          bar: "baz",
                                                          qux: "quux",
                                                          };

                                                          var arr = [1,2,];

                                                          foo({
                                                          bar: "baz",
                                                          qux: "quux",
                                                          });
                                                          +
                                                          + +

                                                          always-multiline

                                                          + +

                                                          Examples of incorrect code for this rule with the "always-multiline" option:

                                                          + +
                                                          /*eslint comma-dangle: ["error", "always-multiline"]*/

                                                          var foo = {
                                                          bar: "baz",
                                                          qux: "quux"
                                                          };

                                                          var foo = { bar: "baz", qux: "quux", };

                                                          var arr = [1,2,];

                                                          var arr = [1,
                                                          2,];

                                                          var arr = [
                                                          1,
                                                          2
                                                          ];

                                                          foo({
                                                          bar: "baz",
                                                          qux: "quux"
                                                          });
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "always-multiline" option:

                                                          + +
                                                          /*eslint comma-dangle: ["error", "always-multiline"]*/

                                                          var foo = {
                                                          bar: "baz",
                                                          qux: "quux",
                                                          };

                                                          var foo = {bar: "baz", qux: "quux"};
                                                          var arr = [1,2];

                                                          var arr = [1,
                                                          2];

                                                          var arr = [
                                                          1,
                                                          2,
                                                          ];

                                                          foo({
                                                          bar: "baz",
                                                          qux: "quux",
                                                          });
                                                          +
                                                          + +

                                                          only-multiline

                                                          + +

                                                          Examples of incorrect code for this rule with the "only-multiline" option:

                                                          + +
                                                          /*eslint comma-dangle: ["error", "only-multiline"]*/

                                                          var foo = { bar: "baz", qux: "quux", };

                                                          var arr = [1,2,];

                                                          var arr = [1,
                                                          2,];

                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "only-multiline" option:

                                                          + +
                                                          /*eslint comma-dangle: ["error", "only-multiline"]*/

                                                          var foo = {
                                                          bar: "baz",
                                                          qux: "quux",
                                                          };

                                                          var foo = {
                                                          bar: "baz",
                                                          qux: "quux"
                                                          };

                                                          var foo = {bar: "baz", qux: "quux"};
                                                          var arr = [1,2];

                                                          var arr = [1,
                                                          2];

                                                          var arr = [
                                                          1,
                                                          2,
                                                          ];

                                                          var arr = [
                                                          1,
                                                          2
                                                          ];

                                                          foo({
                                                          bar: "baz",
                                                          qux: "quux",
                                                          });

                                                          foo({
                                                          bar: "baz",
                                                          qux: "quux"
                                                          });
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with dangling commas.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.16.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/comma-spacing.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/comma-spacing.html new file mode 100644 index 0000000..8ce7087 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/comma-spacing.html @@ -0,0 +1,104 @@ + + + +

                                                          Enforces spacing around commas (comma-spacing)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Spacing around commas improve readability of a list of items. Although most of the style guidelines for languages prescribe adding a space after a comma and not before it, it is subjective to the preferences of a project.

                                                          + +
                                                          var foo = 1, bar = 2;
                                                          var foo = 1 ,bar = 2;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces consistent spacing before and after commas in variable declarations, array literals, object literals, function parameters, and sequences.

                                                          + +

                                                          This rule does not apply in an ArrayExpression or ArrayPattern in either of the following cases:

                                                          + +
                                                            +
                                                          • adjacent null elements
                                                          • +
                                                          • an initial null element, to avoid conflicts with the array-bracket-spacing rule
                                                          • +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an object option:

                                                          + +
                                                            +
                                                          • "before": false (default) disallows spaces before commas
                                                          • +
                                                          • "before": true requires one or more spaces before commas
                                                          • +
                                                          • "after": true (default) requires one or more spaces after commas
                                                          • +
                                                          • "after": false disallows spaces after commas
                                                          • +
                                                          + +

                                                          after

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "before": false, "after": true } options:

                                                          + +
                                                          /*eslint comma-spacing: ["error", { "before": false, "after": true }]*/

                                                          var foo = 1 ,bar = 2;
                                                          var arr = [1 , 2];
                                                          var obj = {"foo": "bar" ,"baz": "qur"};
                                                          foo(a ,b);
                                                          new Foo(a ,b);
                                                          function foo(a ,b){}
                                                          a ,b
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "before": false, "after": true } options:

                                                          + +
                                                          /*eslint comma-spacing: ["error", { "before": false, "after": true }]*/

                                                          var foo = 1, bar = 2
                                                          , baz = 3;
                                                          var arr = [1, 2];
                                                          var arr = [1,, 3]
                                                          var obj = {"foo": "bar", "baz": "qur"};
                                                          foo(a, b);
                                                          new Foo(a, b);
                                                          function foo(a, b){}
                                                          a, b
                                                          +
                                                          + +

                                                          Example of correct code for this rule with initial null element for the default { "before": false, "after": true } options:

                                                          + +
                                                          /*eslint comma-spacing: ["error", { "before": false, "after": true }]*/
                                                          /*eslint array-bracket-spacing: ["error", "always"]*/

                                                          var arr = [ , 2, 3 ]
                                                          +
                                                          + +

                                                          before

                                                          + +

                                                          Examples of incorrect code for this rule with the { "before": true, "after": false } options:

                                                          + +
                                                          /*eslint comma-spacing: ["error", { "before": true, "after": false }]*/

                                                          var foo = 1, bar = 2;
                                                          var arr = [1 , 2];
                                                          var obj = {"foo": "bar", "baz": "qur"};
                                                          new Foo(a,b);
                                                          function foo(a,b){}
                                                          a, b
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "before": true, "after": false } options:

                                                          + +
                                                          /*eslint comma-spacing: ["error", { "before": true, "after": false }]*/

                                                          var foo = 1 ,bar = 2 ,
                                                          baz = true;
                                                          var arr = [1 ,2];
                                                          var arr = [1 ,,3]
                                                          var obj = {"foo": "bar" ,"baz": "qur"};
                                                          foo(a ,b);
                                                          new Foo(a ,b);
                                                          function foo(a ,b){}
                                                          a ,b
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with initial null element for the { "before": true, "after": false } options:

                                                          + +
                                                          /*eslint comma-spacing: ["error", { "before": true, "after": false }]*/
                                                          /*eslint array-bracket-spacing: ["error", "never"]*/

                                                          var arr = [,2 ,3]
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If your project will not be following a consistent comma-spacing pattern, turn this rule off.

                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.9.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/comma-style.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/comma-style.html new file mode 100644 index 0000000..61a6335 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/comma-style.html @@ -0,0 +1,119 @@ + + + +

                                                          Comma style (comma-style)

                                                          + +

                                                          The Comma Style rule enforces styles for comma-separated lists. There are two comma styles primarily used in JavaScript:

                                                          + +
                                                            +
                                                          • The standard style, in which commas are placed at the end of the current line
                                                          • +
                                                          • Comma First style, in which commas are placed at the start of the next line
                                                          • +
                                                          + +

                                                          One of the justifications for using Comma First style is that it can help track missing and trailing commas. These are problematic because missing commas in variable declarations can lead to the leakage of global variables and trailing commas can lead to errors in older versions of IE.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforce consistent comma style in array literals, object literals, and variable declarations.

                                                          + +

                                                          This rule does not apply in either of the following cases:

                                                          + +
                                                            +
                                                          • comma preceded and followed by linebreak (lone comma)
                                                          • +
                                                          • single-line array literals, object literals, and variable declarations
                                                          • +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • "last" (default) requires a comma after and on the same line as an array element, object property, or variable declaration
                                                          • +
                                                          • "first" requires a comma before and on the same line as an array element, object property, or variable declaration
                                                          • +
                                                          + +

                                                          This rule also accepts an additional exceptions object:

                                                          + +
                                                            +
                                                          • +

                                                            "exceptions" has properties whose names correspond to node types in the abstract syntax tree (AST) of JavaScript code:

                                                            + +
                                                              +
                                                            • "ArrayExpression": true ignores comma style in array literals
                                                            • +
                                                            • "ObjectExpression": true ignores comma style in object literals
                                                            • +
                                                            • "VariableDeclaration": true ignores comma style in variable declarations
                                                            • +
                                                            +
                                                          • +
                                                          + +

                                                          A way to determine the node types as defined by ESTree is to use the online demo.

                                                          + +

                                                          last

                                                          + +

                                                          Examples of incorrect code for this rule with the default "last" option:

                                                          + +
                                                          /*eslint comma-style: ["error", "last"]*/

                                                          var foo = 1
                                                          ,
                                                          bar = 2;

                                                          var foo = 1
                                                          , bar = 2;

                                                          var foo = ["apples"
                                                          , "oranges"];

                                                          function bar() {
                                                          return {
                                                          "a": 1
                                                          ,"b:": 2
                                                          };
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "last" option:

                                                          + +
                                                          /*eslint comma-style: ["error", "last"]*/

                                                          var foo = 1, bar = 2;

                                                          var foo = 1,
                                                          bar = 2;

                                                          var foo = ["apples",
                                                          "oranges"];

                                                          function bar() {
                                                          return {
                                                          "a": 1,
                                                          "b:": 2
                                                          };
                                                          }
                                                          +
                                                          + +

                                                          first

                                                          + +

                                                          Examples of incorrect code for this rule with the "first" option:

                                                          + +
                                                          /*eslint comma-style: ["error", "first"]*/

                                                          var foo = 1,
                                                          bar = 2;

                                                          var foo = ["apples",
                                                          "oranges"];

                                                          function bar() {
                                                          return {
                                                          "a": 1,
                                                          "b:": 2
                                                          };
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "first" option:

                                                          + +
                                                          /*eslint comma-style: ["error", "first"]*/

                                                          var foo = 1, bar = 2;

                                                          var foo = 1
                                                          ,bar = 2;

                                                          var foo = ["apples"
                                                          ,"oranges"];

                                                          function bar() {
                                                          return {
                                                          "a": 1
                                                          ,"b:": 2
                                                          };
                                                          }
                                                          +
                                                          + +

                                                          exceptions

                                                          + +

                                                          An example use case is to enforce comma style only in var statements.

                                                          + +

                                                          Examples of incorrect code for this rule with sample "first", { "exceptions": { … } } options:

                                                          + +
                                                          /*eslint comma-style: ["error", "first", { "exceptions": { "ArrayExpression": true, "ObjectExpression": true } }]*/

                                                          var o = {},
                                                          a = [];
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with sample "first", { "exceptions": { … } } options:

                                                          + +
                                                          /*eslint comma-style: ["error", "first", { "exceptions": { "ArrayExpression": true, "ObjectExpression": true } }]*/

                                                          var o = {fst:1,
                                                          snd: [1,
                                                          2]}
                                                          , a = [];
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          This rule can safely be turned off if your project does not care about enforcing a consistent comma style.

                                                          + +

                                                          Further Reading

                                                          + +

                                                          For more information on the Comma First style:

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.9.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/complexity.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/complexity.html new file mode 100644 index 0000000..4a09fca --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/complexity.html @@ -0,0 +1,71 @@ + + + +

                                                          Limit Cyclomatic Complexity (complexity)

                                                          + +

                                                          Cyclomatic complexity measures the number of linearly independent paths through a program’s source code. This rule allows setting a cyclomatic complexity threshold.

                                                          + +
                                                          function a(x) {
                                                          if (true) {
                                                          return x; // 1st path
                                                          } else if (false) {
                                                          return x+1; // 2nd path
                                                          } else {
                                                          return 4; // 3rd path
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                                                          + +

                                                          Examples of incorrect code for a maximum of 2:

                                                          + +
                                                          /*eslint complexity: ["error", 2]*/

                                                          function a(x) {
                                                          if (true) {
                                                          return x;
                                                          } else if (false) {
                                                          return x+1;
                                                          } else {
                                                          return 4; // 3rd path
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for a maximum of 2:

                                                          + +
                                                          /*eslint complexity: ["error", 2]*/

                                                          function a(x) {
                                                          if (true) {
                                                          return x;
                                                          } else {
                                                          return 4;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          Optionally, you may specify a max object property:

                                                          + +
                                                          "complexity": ["error", 2]
                                                          +
                                                          + +

                                                          is equivalent to

                                                          + +
                                                          "complexity": ["error", { "max": 2 }]
                                                          +
                                                          + +

                                                          Deprecated: the object property maximum is deprecated. Please use the property max instead.

                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you can’t determine an appropriate complexity limit for your code, then it’s best to disable this rule.

                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/computed-property-spacing.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/computed-property-spacing.html new file mode 100644 index 0000000..cd88bb2 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/computed-property-spacing.html @@ -0,0 +1,77 @@ + + + +

                                                          Disallow or enforce spaces inside of computed properties (computed-property-spacing)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          While formatting preferences are very personal, a number of style guides require +or disallow spaces between computed properties in the following situations:

                                                          + +
                                                          /*eslint-env es6*/

                                                          var obj = { prop: "value" };
                                                          var a = "prop";
                                                          var x = obj[a]; // computed property in object member expression

                                                          var a = "prop";
                                                          var obj = {
                                                          [a]: "value" // computed property key in object literal (ECMAScript 6)
                                                          };
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces consistent spacing inside computed property brackets.

                                                          + +

                                                          It either requires or disallows spaces between the brackets and the values inside of them. +This rule does not apply to brackets that are separated from the adjacent value by a newline.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • "never" (default) disallows spaces inside computed property brackets
                                                          • +
                                                          • "always" requires one or more spaces inside computed property brackets
                                                          • +
                                                          + +

                                                          never

                                                          + +

                                                          Examples of incorrect code for this rule with the default "never" option:

                                                          + +
                                                          /*eslint computed-property-spacing: ["error", "never"]*/
                                                          /*eslint-env es6*/

                                                          obj[foo ]
                                                          obj[ 'foo']
                                                          var x = {[ b ]: a}
                                                          obj[foo[ bar ]]
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "never" option:

                                                          + +
                                                          /*eslint computed-property-spacing: ["error", "never"]*/
                                                          /*eslint-env es6*/

                                                          obj[foo]
                                                          obj['foo']
                                                          var x = {[b]: a}
                                                          obj[foo[bar]]
                                                          +
                                                          + +

                                                          always

                                                          + +

                                                          Examples of incorrect code for this rule with the "always" option:

                                                          + +
                                                          /*eslint computed-property-spacing: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          obj[foo]
                                                          var x = {[b]: a}
                                                          obj[ foo]
                                                          obj['foo' ]
                                                          obj[foo[ bar ]]
                                                          var x = {[ b]: a}
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "always" option:

                                                          + +
                                                          /*eslint computed-property-spacing: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          obj[ foo ]
                                                          obj[ 'foo' ]
                                                          var x = {[ b ]: a}
                                                          obj[ foo[ bar ] ]
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with the consistency of computed properties.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.23.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/consistent-return.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/consistent-return.html new file mode 100644 index 0000000..519e1db --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/consistent-return.html @@ -0,0 +1,46 @@ + + + +

                                                          Require Consistent Returns (consistent-return)

                                                          + +

                                                          One of the confusing aspects of JavaScript is that any function may or may not return a value at any point in time. When a function exits without any return statement executing, the function returns undefined. Similarly, calling return without specifying any value will cause the function to return undefined. Only when return is called with a value is there a change in the function’s return value.

                                                          + +

                                                          Unlike statically-typed languages that will catch when a function doesn’t return the type of data expected, JavaScript has no such checks, meaning that it’s easy to make mistakes such as this:

                                                          + +
                                                          function doSomething(condition) {

                                                          if (condition) {
                                                          return true;
                                                          } else {
                                                          return;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Here, one branch of the function returns true, a Boolean value, while the other exits without specifying any value (and so returns undefined). This may be an indicator of a coding error, especially if this pattern is found in larger functions.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at ensuring all return statements either specify a value or don’t specify a value.

                                                          + +

                                                          It excludes constructors which, when invoked with the new operator, return the instantiated object if another object is not explicitly returned. This rule treats a function as a constructor if its name starts with an uppercase letter.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint consistent-return: "error"*/

                                                          function doSomething(condition) {

                                                          if (condition) {
                                                          return true;
                                                          } else {
                                                          return;
                                                          }
                                                          }

                                                          function doSomething(condition) {

                                                          if (condition) {
                                                          return;
                                                          } else {
                                                          return true;
                                                          }
                                                          }

                                                          function doSomething(condition) {

                                                          if (condition) {
                                                          return true;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint consistent-return: "error"*/

                                                          function doSomething(condition) {

                                                          if (condition) {
                                                          return true;
                                                          } else {
                                                          return false;
                                                          }
                                                          }

                                                          function Foo() {
                                                          if (!(this instanceof Foo)) {
                                                          return new Foo();
                                                          }

                                                          this.a = 0;
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to allow functions to have different return behavior depending on code branching, then it is safe to disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/consistent-this.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/consistent-this.html new file mode 100644 index 0000000..3c94bf0 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/consistent-this.html @@ -0,0 +1,65 @@ + + + +

                                                          Require Consistent This (consistent-this)

                                                          + +

                                                          It is often necessary to capture the current execution context in order to make it available subsequently. A prominent example of this are jQuery callbacks:

                                                          + +
                                                          var that = this;
                                                          jQuery('li').click(function (event) {
                                                          // here, "this" is the HTMLElement where the click event occurred
                                                          that.setFoo(42);
                                                          });
                                                          +
                                                          + +

                                                          There are many commonly used aliases for this such as that, self or me. It is desirable to ensure that whichever alias the team agrees upon is used consistently throughout the application.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces two things about variables with the designated alias names for this:

                                                          + +
                                                            +
                                                          • If a variable with a designated name is declared, it must be either initialized (in the declaration) or assigned (in the same scope as the declaration) the value this.
                                                          • +
                                                          • If a variable is initialized or assigned the value this, the name of the variable must be a designated alias.
                                                          • +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has one or more string options:

                                                          + +
                                                            +
                                                          • designated alias names for this (default "that")
                                                          • +
                                                          + +

                                                          Examples of incorrect code for this rule with the default "that" option:

                                                          + +
                                                          /*eslint consistent-this: ["error", "that"]*/

                                                          var that = 42;

                                                          var self = this;

                                                          that = 42;

                                                          self = this;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "that" option:

                                                          + +
                                                          /*eslint consistent-this: ["error", "that"]*/

                                                          var that = this;

                                                          var self = 42;

                                                          var self;

                                                          that = this;

                                                          foo.bar = this;
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with the default "that" option, if the variable is not initialized:

                                                          + +
                                                          /*eslint consistent-this: ["error", "that"]*/

                                                          var that;
                                                          function f() {
                                                          that = this;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "that" option, if the variable is not initialized:

                                                          + +
                                                          /*eslint consistent-this: ["error", "that"]*/

                                                          var that;
                                                          that = this;

                                                          var foo, that;
                                                          foo = 42;
                                                          that = this;
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you need to capture nested context, consistent-this is going to be problematic. Code of that nature is usually difficult to read and maintain and you should consider refactoring it.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/constructor-super.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/constructor-super.html new file mode 100644 index 0000000..d569435 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/constructor-super.html @@ -0,0 +1,41 @@ + + + +

                                                          Verify calls of super() in constructors (constructor-super)

                                                          + +

                                                          Constructors of derived classes must call super(). +Constructors of non derived classes must not call super(). +If this is not observed, the javascript engine will raise a runtime error.

                                                          + +

                                                          This rule checks whether or not there is a valid super() call.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed to flag invalid/missing super() calls.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint constructor-super: "error"*/
                                                          /*eslint-env es6*/

                                                          class A {
                                                          constructor() {
                                                          super(); // This is a SyntaxError.
                                                          }
                                                          }

                                                          class A extends B {
                                                          constructor() { } // Would throw a ReferenceError.
                                                          }

                                                          // Classes which inherits from a non constructor are always problems.
                                                          class A extends null {
                                                          constructor() {
                                                          super(); // Would throw a TypeError.
                                                          }
                                                          }

                                                          class A extends null {
                                                          constructor() { } // Would throw a ReferenceError.
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint constructor-super: "error"*/
                                                          /*eslint-env es6*/

                                                          class A {
                                                          constructor() { }
                                                          }

                                                          class A extends B {
                                                          constructor() {
                                                          super();
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about invalid/missing super() callings in constructors, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.24.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/curly.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/curly.html new file mode 100644 index 0000000..799dc02 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/curly.html @@ -0,0 +1,108 @@ + + + +

                                                          Require Following Curly Brace Conventions (curly)

                                                          + +

                                                          JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

                                                          + +
                                                          if (foo) foo++;
                                                          +
                                                          + +

                                                          Can be rewritten as:

                                                          + +
                                                          if (foo) {
                                                          foo++;
                                                          }
                                                          +
                                                          + +

                                                          There are, however, some who prefer to only use braces when there is more than one statement to be executed.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

                                                          + +

                                                          Options

                                                          + +

                                                          all

                                                          + +

                                                          Examples of incorrect code for the default "all" option:

                                                          + +
                                                          /*eslint curly: "error"*/

                                                          if (foo) foo++;

                                                          while (bar)
                                                          baz();

                                                          if (foo) {
                                                          baz();
                                                          } else qux();
                                                          +
                                                          + +

                                                          Examples of correct code for the default "all" option:

                                                          + +
                                                          /*eslint curly: "error"*/

                                                          if (foo) {
                                                          foo++;
                                                          }

                                                          while (bar) {
                                                          baz();
                                                          }

                                                          if (foo) {
                                                          baz();
                                                          } else {
                                                          qux();
                                                          }
                                                          +
                                                          + +

                                                          multi

                                                          + +

                                                          By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

                                                          + +

                                                          Examples of incorrect code for the "multi" option:

                                                          + +
                                                          /*eslint curly: ["error", "multi"]*/

                                                          if (foo) {
                                                          foo++;
                                                          }

                                                          if (foo) bar();
                                                          else {
                                                          foo++;
                                                          }

                                                          while (true) {
                                                          doSomething();
                                                          }

                                                          for (var i=0; i < items.length; i++) {
                                                          doSomething();
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for the "multi" option:

                                                          + +
                                                          /*eslint curly: ["error", "multi"]*/

                                                          if (foo) foo++;

                                                          else foo();

                                                          while (true) {
                                                          doSomething();
                                                          doSomethingElse();
                                                          }
                                                          +
                                                          + +

                                                          multi-line

                                                          + +

                                                          Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

                                                          + +

                                                          Examples of incorrect code for the "multi-line" option:

                                                          + +
                                                          /*eslint curly: ["error", "multi-line"]*/

                                                          if (foo)
                                                          doSomething();
                                                          else
                                                          doSomethingElse();

                                                          if (foo) foo(
                                                          bar,
                                                          baz);
                                                          +
                                                          + +

                                                          Examples of correct code for the "multi-line" option:

                                                          + +
                                                          /*eslint curly: ["error", "multi-line"]*/

                                                          if (foo) foo++; else doSomething();

                                                          if (foo) foo++;
                                                          else if (bar) baz()
                                                          else doSomething();

                                                          do something();
                                                          while (foo);

                                                          while (foo
                                                          && bar) baz();

                                                          if (foo) {
                                                          foo++;
                                                          }

                                                          if (foo) { foo++; }

                                                          while (true) {
                                                          doSomething();
                                                          doSomethingElse();
                                                          }
                                                          +
                                                          + +

                                                          multi-or-nest

                                                          + +

                                                          You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

                                                          + +

                                                          Examples of incorrect code for the "multi-or-nest" option:

                                                          + +
                                                          /*eslint curly: ["error", "multi-or-nest"]*/

                                                          if (!foo)
                                                          foo = {
                                                          bar: baz,
                                                          qux: foo
                                                          };

                                                          while (true)
                                                          if(foo)
                                                          doSomething();
                                                          else
                                                          doSomethingElse();

                                                          if (foo) {
                                                          foo++;
                                                          }

                                                          while (true) {
                                                          doSomething();
                                                          }

                                                          for (var i = 0; foo; i++) {
                                                          doSomething();
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for the "multi-or-nest" option:

                                                          + +
                                                          /*eslint curly: ["error", "multi-or-nest"]*/

                                                          if (!foo) {
                                                          foo = {
                                                          bar: baz,
                                                          qux: foo
                                                          };
                                                          }

                                                          while (true) {
                                                          if(foo)
                                                          doSomething();
                                                          else
                                                          doSomethingElse();
                                                          }

                                                          if (foo)
                                                          foo++;

                                                          while (true)
                                                          doSomething();

                                                          for (var i = 0; foo; i++)
                                                          doSomething();
                                                          +
                                                          + +

                                                          consistent

                                                          + +

                                                          When using any of the multi* options, you can add an option to enforce all bodies of a if, +else if and else chain to be with or without braces.

                                                          + +

                                                          Examples of incorrect code for the "multi", "consistent" options:

                                                          + +
                                                          /*eslint curly: ["error", "multi", "consistent"]*/

                                                          if (foo) {
                                                          bar();
                                                          baz();
                                                          } else
                                                          buz();

                                                          if (foo)
                                                          bar();
                                                          else if (faa)
                                                          bor();
                                                          else {
                                                          other();
                                                          things();
                                                          }

                                                          if (true)
                                                          foo();
                                                          else {
                                                          baz();
                                                          }

                                                          if (foo) {
                                                          foo++;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for the "multi", "consistent" options:

                                                          + +
                                                          /*eslint curly: ["error", "multi", "consistent"]*/

                                                          if (foo) {
                                                          bar();
                                                          baz();
                                                          } else {
                                                          buz();
                                                          }

                                                          if (foo) {
                                                          bar();
                                                          } else if (faa) {
                                                          bor();
                                                          } else {
                                                          other();
                                                          things();
                                                          }

                                                          if (true)
                                                          foo();
                                                          else
                                                          baz();

                                                          if (foo)
                                                          foo++;

                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/default-case.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/default-case.html new file mode 100644 index 0000000..9938dde --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/default-case.html @@ -0,0 +1,70 @@ + + + +

                                                          Require Default Case in Switch Statements (default-case)

                                                          + +

                                                          Some code conventions require that all switch statements have a default case, even if the default case is empty, such as:

                                                          + +
                                                          switch (foo) {
                                                          case 1:
                                                          doSomething();
                                                          break;

                                                          case 2:
                                                          doSomething();
                                                          break;

                                                          default:
                                                          // do nothing
                                                          }
                                                          +
                                                          + +

                                                          The thinking is that it’s better to always explicitly state what the default behavior should be so that it’s clear whether or not the developer forgot to include the default behavior by mistake.

                                                          + +

                                                          Other code conventions allow you to skip the default case so long as there is a comment indicating the omission is intentional, such as:

                                                          + +
                                                          switch (foo) {
                                                          case 1:
                                                          doSomething();
                                                          break;

                                                          case 2:
                                                          doSomething();
                                                          break;

                                                          // no default
                                                          }
                                                          +
                                                          + +

                                                          Once again, the intent here is to show that the developer intended for there to be no default behavior.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to require default case in switch statements. You may optionally include a // no default after the last case if there is no default case.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint default-case: "error"*/

                                                          switch (a) {
                                                          case 1:
                                                          /* code */
                                                          break;
                                                          }

                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint default-case: "error"*/

                                                          switch (a) {
                                                          case 1:
                                                          /* code */
                                                          break;

                                                          default:
                                                          /* code */
                                                          break;
                                                          }


                                                          switch (a) {
                                                          case 1:
                                                          /* code */
                                                          break;

                                                          // no default
                                                          }

                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule accepts a single options argument:

                                                          + +
                                                            +
                                                          • Set the commentPattern option to a regular expression string to change the default ^no default$ comment test pattern
                                                          • +
                                                          + +

                                                          commentPattern

                                                          + +

                                                          Examples of correct code for the { "commentPattern": "^skip\\sdefault" } option:

                                                          + +
                                                          /*eslint default-case: ["error", { "commentPattern": "^skip\\sdefault" }]*/

                                                          switch(a) {
                                                          case 1:
                                                          /* code */
                                                          break;

                                                          // skip default
                                                          }

                                                          switch(a) {
                                                          case 1:
                                                          /* code */
                                                          break;

                                                          // skip default case
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to enforce a default case for switch statements, you can safely disable this rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.6.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/dot-location.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/dot-location.html new file mode 100644 index 0000000..eb6c7ae --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/dot-location.html @@ -0,0 +1,76 @@ + + + +

                                                          Enforce newline before and after dot (dot-location)

                                                          + +

                                                          JavaScript allows you to place newlines before or after a dot in a member expression.

                                                          + +

                                                          Consistency in placing a newline before or after the dot can greatly increase readability.

                                                          + +
                                                          var a = universe.
                                                          galaxy;

                                                          var b = universe
                                                          .galaxy;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to enforce newline consistency in member expressions. This rule prevents the use of mixed newlines around the dot in a member expression.

                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes one option, a string:

                                                          + +
                                                            +
                                                          • If it is "object", the dot in a member expression should be on the same line as the object portion. The default is "object".
                                                          • +
                                                          • If it is "property", the dot in a member expression should be on the same line as the property portion.
                                                          • +
                                                          + +

                                                          object

                                                          + +

                                                          The default "object" option requires the dot to be on the same line as the object.

                                                          + +

                                                          Examples of incorrect code for the default "object" option:

                                                          + +
                                                          /*eslint dot-location: ["error", "object"]*/

                                                          var foo = object
                                                          .property;
                                                          +
                                                          + +

                                                          Examples of correct code for the default "object" option:

                                                          + +
                                                          /*eslint dot-location: ["error", "object"]*/

                                                          var foo = object.
                                                          property;
                                                          var bar = object.property;
                                                          +
                                                          + +

                                                          property

                                                          + +

                                                          The "property" option requires the dot to be on the same line as the property.

                                                          + +

                                                          Examples of incorrect code for the "property" option:

                                                          + +
                                                          /*eslint dot-location: ["error", "property"]*/

                                                          var foo = object.
                                                          property;
                                                          +
                                                          + +

                                                          Examples of correct code for the "property" option:

                                                          + +
                                                          /*eslint dot-location: ["error", "property"]*/

                                                          var foo = object
                                                          .property;
                                                          var bar = object.property;
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with the consistency of newlines before or after dots in member expressions.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.21.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/dot-notation.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/dot-notation.html new file mode 100644 index 0000000..6fb9f05 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/dot-notation.html @@ -0,0 +1,61 @@ + + + +

                                                          Require Dot Notation (dot-notation)

                                                          + +

                                                          In JavaScript, one can access properties using the dot notation (foo.bar) or square-bracket notation (foo["bar"]). However, the dot notation is often preferred because it is easier to read, less verbose, and works better with aggressive JavaScript minimizers.

                                                          + +
                                                          foo["bar"];
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at maintaining code consistency and improving code readability by encouraging use of the dot notation style whenever possible. As such, it will warn when it encounters an unnecessary use of square-bracket notation.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint dot-notation: "error"*/

                                                          var x = foo["bar"];
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint dot-notation: "error"*/

                                                          var x = foo.bar;

                                                          var x = foo[bar]; // Property name is a variable, square-bracket notation required
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule accepts a single options argument:

                                                          + +
                                                            +
                                                          • Set the allowKeywords option to false (default is true) to follow ECMAScript version 3 compatible style, avoiding dot notation for reserved word properties.
                                                          • +
                                                          • Set the allowPattern option to a regular expression string to allow bracket notation for property names that match a pattern (by default, no pattern is tested).
                                                          • +
                                                          + +

                                                          allowKeywords

                                                          + +

                                                          Examples of correct code for the { "allowKeywords": false } option:

                                                          + +
                                                          /*eslint dot-notation: ["error", { "allowKeywords": false }]*/

                                                          var foo = { "class": "CS 101" }
                                                          var x = foo["class"]; // Property name is a reserved word, square-bracket notation required
                                                          +
                                                          + +

                                                          allowPattern

                                                          + +

                                                          For example, when preparing data to be sent to an external API, it is often required to use property names that include underscores. If the camelcase rule is in effect, these snake case properties would not be allowed. By providing an allowPattern to the dot-notation rule, these snake case properties can be accessed with bracket notation.

                                                          + +

                                                          Examples of correct code for the sample { "allowPattern": "^[a-z]+(_[a-z]+)+$" } option:

                                                          + +
                                                          /*eslint camelcase: "error"*/
                                                          /*eslint dot-notation: ["error", { "allowPattern": "^[a-z]+(_[a-z]+)+$" }]*/

                                                          var data = {};
                                                          data.foo_bar = 42;

                                                          var data = {};
                                                          data["fooBar"] = 42;

                                                          var data = {};
                                                          data["foo_bar"] = 42; // no warning
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.7.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/eol-last.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/eol-last.html new file mode 100644 index 0000000..226c987 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/eol-last.html @@ -0,0 +1,51 @@ + + + +

                                                          Require file to end with single newline (eol-last)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Trailing newlines in non-empty files are a common UNIX idiom. Benefits of +trailing newlines include the ability to concatenate or append to files as well +as output files to the terminal without interfering with shell prompts.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule requires at least one newline at the end of non-empty files.

                                                          + +

                                                          Prior to v0.16.0 this rule also enforced that there was only a single line at +the end of the file. If you still want this behaviour, consider enabling +no-multiple-empty-lines with maxEOF and/or +no-trailing-spaces.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint eol-last: "error"*/

                                                          function doSmth() {
                                                          var foo = 2;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint eol-last: "error"*/

                                                          function doSmth() {
                                                          var foo = 2;
                                                          }

                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • "unix" (default) enforces line feed (LF) as newline
                                                          • +
                                                          • "windows" enforces carriage return line feed (CRLF) as newline
                                                          • +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.7.1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/eqeqeq.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/eqeqeq.html new file mode 100644 index 0000000..294d5a9 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/eqeqeq.html @@ -0,0 +1,79 @@ + + + +

                                                          Require === and !== (eqeqeq)

                                                          + +

                                                          It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

                                                          + +

                                                          The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. +For instance, the following statements are all considered true:

                                                          + +
                                                            +
                                                          • [] == false
                                                          • +
                                                          • [] == ![]
                                                          • +
                                                          • 3 == "03"
                                                          • +
                                                          + +

                                                          If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at eliminating the type-unsafe equality operators.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint eqeqeq: "error"*/

                                                          if (x == 42) { }

                                                          if ("" == text) { }

                                                          if (obj.getStuff() != undefined) { }
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          smart

                                                          + +

                                                          The "smart" option enforces the use of === and !== except for these cases:

                                                          + +
                                                            +
                                                          • Comparing two literal values
                                                          • +
                                                          • Evaluating the value of typeof
                                                          • +
                                                          • Comparing against null
                                                          • +
                                                          + +

                                                          Examples of incorrect code for the "smart" option:

                                                          + +
                                                          /*eslint eqeqeq: ["error", "smart"]*/

                                                          // comparing two variables requires ===
                                                          a == b

                                                          // only one side is a literal
                                                          foo == true
                                                          bananas != 1

                                                          // comparing to undefined requires ===
                                                          value == undefined
                                                          +
                                                          + +

                                                          Examples of correct code for the "smart" option:

                                                          + +
                                                          /*eslint eqeqeq: ["error", "smart"]*/

                                                          typeof foo == 'undefined'
                                                          'hello' != 'world'
                                                          0 == 0
                                                          true == true
                                                          foo == null
                                                          +
                                                          + +

                                                          allow-null

                                                          + +

                                                          The "allow-null" option will enforce === and !== in your code with one exception - it permits comparing to null to check for null or undefined in a single expression.

                                                          + +

                                                          Examples of incorrect code for the "allow-null" option:

                                                          + +
                                                          /*eslint eqeqeq: ["error", "allow-null"]*/

                                                          bananas != 1
                                                          typeof foo == 'undefined'
                                                          'hello' != 'world'
                                                          0 == 0
                                                          foo == undefined
                                                          +
                                                          + +

                                                          Examples of correct code for the "allow-null" option:

                                                          + +
                                                          /*eslint eqeqeq: ["error", "allow-null"]*/

                                                          foo == null
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to enforce a style for using equality operators, then it’s safe to disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/func-names.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/func-names.html new file mode 100644 index 0000000..2176004 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/func-names.html @@ -0,0 +1,42 @@ + + + +

                                                          Require Function Expressions to have a Name (func-names)

                                                          + +

                                                          A pattern that’s becoming more common is to give function expressions names to aid in debugging. For example:

                                                          + +
                                                          Foo.prototype.bar = function bar() {};
                                                          +
                                                          + +

                                                          Adding the second bar in the above example is optional. If you leave off the function name then when the function throws an exception you are likely to get something similar to anonymous function in the stack trace. If you provide the optional name for a function expression then you will get the name of the function expression in the stack trace.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint func-names: "error"*/

                                                          Foo.prototype.bar = function() {};

                                                          (function() {
                                                          // ...
                                                          }())
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint func-names: "error"*/

                                                          Foo.prototype.bar = function bar() {};

                                                          (function bar() {
                                                          // ...
                                                          }())
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/func-style.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/func-style.html new file mode 100644 index 0000000..8f78e2b --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/func-style.html @@ -0,0 +1,103 @@ + + + +

                                                          enforce the consistent use of either function declarations or expressions (func-style)

                                                          + +

                                                          There are two ways of defining functions in JavaScript: function declarations and function expressions. Declarations contain the function keyword first, followed by a name and then its arguments and the function body, for example:

                                                          + +
                                                          function doSomething() {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Equivalent function expressions begin with the var keyword, followed by a name and then the function itself, such as:

                                                          + +
                                                          var doSomething = function() {
                                                          // ...
                                                          };
                                                          +
                                                          + +

                                                          The primary difference between function declarations and function expressions is that declarations are hoisted to the top of the scope in which they are defined, which allows you to write code that uses the function before its declaration. For example:

                                                          + +
                                                          doSomething();

                                                          function doSomething() {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Although this code might seem like an error, it actually works fine because JavaScript engines hoist the function declarations to the top of the scope. That means this code is treated as if the declaration came before the invocation.

                                                          + +

                                                          For function expressions, you must define the function before it is used, otherwise it causes an error. Example:

                                                          + +
                                                          doSomething();  // error!

                                                          var doSomething = function() {
                                                          // ...
                                                          };
                                                          +
                                                          + +

                                                          In this case, doSomething() is undefined at the time of invocation and so causes a runtime error.

                                                          + +

                                                          Due to these different behaviors, it is common to have guidelines as to which style of function should be used. There is really no correct or incorrect choice here, it is just a preference.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces a particular type of function style throughout a JavaScript file, either declarations or expressions. You can specify which you prefer in the configuration.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • "expression" (default) requires the use of function expressions instead of function declarations
                                                          • +
                                                          • "declaration" requires the use of function declarations instead of function expressions
                                                          • +
                                                          + +

                                                          This rule has an object option for an exception:

                                                          + +
                                                            +
                                                          • "allowArrowFunctions": true (default false) allows the use of arrow functions
                                                          • +
                                                          + +

                                                          expression

                                                          + +

                                                          Examples of incorrect code for this rule with the default "expression" option:

                                                          + +
                                                          /*eslint func-style: ["error", "expression"]*/

                                                          function foo() {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "expression" option:

                                                          + +
                                                          /*eslint func-style: ["error", "expression"]*/

                                                          var foo = function() {
                                                          // ...
                                                          };
                                                          +
                                                          + +

                                                          declaration

                                                          + +

                                                          Examples of incorrect code for this rule with the "declaration" option:

                                                          + +
                                                          /*eslint func-style: ["error", "declaration"]*/

                                                          var foo = function() {
                                                          // ...
                                                          };

                                                          var foo = () => {};
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "declaration" option:

                                                          + +
                                                          /*eslint func-style: ["error", "declaration"]*/

                                                          function foo() {
                                                          // ...
                                                          }

                                                          // Methods (functions assigned to objects) are not checked by this rule
                                                          SomeObject.foo = function() {
                                                          // ...
                                                          };
                                                          +
                                                          + +

                                                          allowArrowFunctions

                                                          + +

                                                          Examples of additional correct code for this rule with the "declaration", { "allowArrowFunctions": true } options:

                                                          + +
                                                          /*eslint func-style: ["error", "declaration", { "allowArrowFunctions": true }]*/

                                                          var foo = () => {};
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to allow developers to each decide how they want to write functions on their own, then you can disable this rule.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.2.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/generator-star-spacing.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/generator-star-spacing.html new file mode 100644 index 0000000..75c2d88 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/generator-star-spacing.html @@ -0,0 +1,105 @@ + + + +

                                                          Enforce spacing around the * in generator functions (generator-star-spacing)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Generators are a new type of function in ECMAScript 6 that can return multiple values over time. +These special functions are indicated by placing an * after the function keyword.

                                                          + +

                                                          Here is an example of a generator function:

                                                          + +
                                                          /*eslint-env es6*/

                                                          function* generator() {
                                                          yield "44";
                                                          yield "55";
                                                          }
                                                          +
                                                          + +

                                                          This is also valid:

                                                          + +
                                                          /*eslint-env es6*/

                                                          function *generator() {
                                                          yield "44";
                                                          yield "55";
                                                          }
                                                          +
                                                          + +

                                                          This is valid as well:

                                                          + +
                                                          /*eslint-env es6*/

                                                          function * generator() {
                                                          yield "44";
                                                          yield "55";
                                                          }
                                                          +
                                                          + +

                                                          To keep a sense of consistency when using generators this rule enforces a single position for the *.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to enforce spacing around the * of generator functions.

                                                          + +

                                                          The rule takes one option, an object, which has two keys before and after having boolean values true or false.

                                                          + +
                                                            +
                                                          • +

                                                            before enforces spacing between the * and the function keyword. +If it is true, a space is required, otherwise spaces are disallowed.

                                                            + +

                                                            In object literal shorthand methods, spacing before the * is not checked, as they lack a function keyword.

                                                            +
                                                          • +
                                                          • +

                                                            after enforces spacing between the * and the function name (or the opening parenthesis for anonymous generator functions). +If it is true, a space is required, otherwise spaces are disallowed.

                                                            +
                                                          • +
                                                          + +

                                                          The default is {"before": true, "after": false}.

                                                          + +
                                                          "generator-star-spacing": ["error", {"before": false, "after": true}]
                                                          +
                                                          + +

                                                          And the option has shorthand as a string keyword:

                                                          + +
                                                            +
                                                          • {"before": true, "after": false}"before"
                                                          • +
                                                          • {"before": false, "after": true}"after"
                                                          • +
                                                          • {"before": true, "after": true}"both"
                                                          • +
                                                          • {"before": false, "after": false}"neither"
                                                          • +
                                                          + +
                                                          "generator-star-spacing": ["error", "after"]
                                                          +
                                                          + +

                                                          When using {"before": true, "after": false} this placement will be enforced:

                                                          + +
                                                          /*eslint generator-star-spacing: ["error", {"before": true, "after": false}]*/
                                                          /*eslint-env es6*/

                                                          function *generator() {}

                                                          var anonymous = function *() {};

                                                          var shorthand = { *generator() {} };
                                                          +
                                                          + +

                                                          When using {"before": false, "after": true} this placement will be enforced:

                                                          + +
                                                          /*eslint generator-star-spacing: ["error", {"before": false, "after": true}]*/
                                                          /*eslint-env es6*/

                                                          function* generator() {}

                                                          var anonymous = function* () {};

                                                          var shorthand = { * generator() {} };
                                                          +
                                                          + +

                                                          When using {"before": true, "after": true} this placement will be enforced:

                                                          + +
                                                          /*eslint generator-star-spacing: ["error", {"before": true, "after": true}]*/
                                                          /*eslint-env es6*/

                                                          function * generator() {}

                                                          var anonymous = function * () {};

                                                          var shorthand = { * generator() {} };
                                                          +
                                                          + +

                                                          When using {"before": false, "after": false} this placement will be enforced:

                                                          + +
                                                          /*eslint generator-star-spacing: ["error", {"before": false, "after": false}]*/
                                                          /*eslint-env es6*/

                                                          function*generator() {}

                                                          var anonymous = function*() {};

                                                          var shorthand = { *generator() {} };
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If your project will not be using generators or you are not concerned with spacing consistency, you do not need this rule.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.17.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/global-require.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/global-require.html new file mode 100644 index 0000000..eecb849 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/global-require.html @@ -0,0 +1,49 @@ + + + +

                                                          Enforce require() on the top-level module scope (global-require)

                                                          + +

                                                          In Node.js, module dependencies are included using the require() function, such as:

                                                          + +
                                                          var fs = require("fs");
                                                          +
                                                          + +

                                                          While require() may be called anywhere in code, some style guides prescribe that it should be called only in the top level of a module to make it easier to identify dependencies. For instance, it’s arguably harder to identify dependencies when they are deeply nested inside of functions and other statements:

                                                          + +
                                                          function foo() {

                                                          if (condition) {
                                                          var fs = require("fs");
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Since require() does a synchronous load, it can cause performance problems when used in other locations.

                                                          + +

                                                          Further, ES6 modules mandate that import and export statements can only occur in the top level of the module’s body.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule requires all calls to require() to be at the top level of the module, similar to ES6 import and export statements, which also can occur only at the top level.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint global-require: "error"*/
                                                          /*eslint-env es6*/

                                                          // calling require() inside of a function is not allowed
                                                          function readFile(filename, callback) {
                                                          var fs = require('fs');
                                                          fs.readFile(filename, callback)
                                                          }

                                                          // conditional requires like this are also not allowed
                                                          if (DEBUG) { require('debug'); }

                                                          // a require() in a switch statement is also flagged
                                                          switch(x) { case '1': require('1'); break; }

                                                          // you may not require() inside an arrow function body
                                                          var getModule = (name) => require(name);

                                                          // you may not require() inside of a function body as well
                                                          function getModule(name) { return require(name); }

                                                          // you may not require() inside of a try/catch block
                                                          try {
                                                          require(unsafeModule);
                                                          } catch(e) {
                                                          console.log(e);
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint global-require: "error"*/

                                                          // all these variations of require() are ok
                                                          require('x');
                                                          var y = require('y');
                                                          var z;
                                                          z = require('z').initialize();

                                                          // requiring a module and using it in a function is ok
                                                          var fs = require('fs');
                                                          function readFile(filename, callback) {
                                                          fs.readFile(filename, callback)
                                                          }

                                                          // you can use a ternary to determine which module to require
                                                          var logger = DEBUG ? require('dev-logger') : require('logger');

                                                          // if you want you can require() at the end of your module
                                                          function doSomethingA() {}
                                                          function doSomethingB() {}
                                                          var x = require("x"),
                                                          z = require("z");
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you have a module that must be initialized with information that comes from the file-system or if a module is only used in very rare situations and will cause significant overhead to load it may make sense to disable the rule. If you need to require() an optional dependency inside of a try/catch, you can disable this rule for just that dependency using the // eslint-disable-line global-require comment.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/guard-for-in.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/guard-for-in.html new file mode 100644 index 0000000..392c6d0 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/guard-for-in.html @@ -0,0 +1,43 @@ + + + +

                                                          Require Guarding for-in (guard-for-in)

                                                          + +

                                                          Looping over objects with a for in loop will include properties that are inherited through the prototype chain. This behavior can lead to unexpected items in your for loop.

                                                          + +
                                                          for (key in foo) {
                                                          doSomething(key);
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at preventing unexpected behavior that could arise from using a for in loop without filtering the results in the loop. As such, it will warn when for in loops do not filter their results with an if statement.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint guard-for-in: "error"*/

                                                          for (key in foo) {
                                                          doSomething(key);
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint guard-for-in: "error"*/

                                                          for (key in foo) {
                                                          if ({}.hasOwnProperty.call(foo, key)) {
                                                          doSomething(key);
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.6.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/handle-callback-err.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/handle-callback-err.html new file mode 100644 index 0000000..dc1f29b --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/handle-callback-err.html @@ -0,0 +1,72 @@ + + + +

                                                          Enforce Callback Error Handling (handle-callback-err)

                                                          + +

                                                          In Node.js, a common pattern for dealing with asynchronous behavior is called the callback pattern. +This pattern expects an Error object or null as the first argument of the callback. +Forgetting to handle these errors can lead to some really strange behavior in your application.

                                                          + +
                                                          function loadData (err, data) {
                                                          doSomething(); // forgot to handle error
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule expects that when you’re using the callback pattern in Node.js you’ll handle the error.

                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes a single string option: the name of the error parameter. The default is "err".

                                                          + +

                                                          Examples of incorrect code for this rule with the default "err" parameter name:

                                                          + +
                                                          /*eslint handle-callback-err: "error"*/

                                                          function loadData (err, data) {
                                                          doSomething();
                                                          }

                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "err" parameter name:

                                                          + +
                                                          /*eslint handle-callback-err: "error"*/

                                                          function loadData (err, data) {
                                                          if (err) {
                                                          console.log(err.stack);
                                                          }
                                                          doSomething();
                                                          }

                                                          function generateError (err) {
                                                          if (err) {}
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with a sample "error" parameter name:

                                                          + +
                                                          /*eslint handle-callback-err: ["error", "error"]*/

                                                          function loadData (error, data) {
                                                          if (error) {
                                                          console.log(error.stack);
                                                          }
                                                          doSomething();
                                                          }
                                                          +
                                                          + +

                                                          regular expression

                                                          + +

                                                          Sometimes (especially in big projects) the name of the error variable is not consistent across the project, +so you need a more flexible configuration to ensure that the rule reports all unhandled errors.

                                                          + +

                                                          If the configured name of the error variable begins with a ^ it is considered to be a regexp pattern.

                                                          + +
                                                            +
                                                          • If the option is "^(err|error|anySpecificError)$", the rule reports unhandled errors where the parameter name can be err, error or anySpecificError.
                                                          • +
                                                          • If the option is "^.+Error$", the rule reports unhandled errors where the parameter name ends with Error (for example, connectionError or validationError will match).
                                                          • +
                                                          • If the option is "^.*(e|E)rr", the rule reports unhandled errors where the parameter name matches any string that contains err or Err (for example, err, error, anyError, some_err will match).
                                                          • +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          There are cases where it may be safe for your application to ignore errors, however only ignore errors if you are +confident that some other form of monitoring will help you catch the problem.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.5.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/id-blacklist.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/id-blacklist.html new file mode 100644 index 0000000..097a934 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/id-blacklist.html @@ -0,0 +1,65 @@ + + + +

                                                          disallow specified identifiers (id-blacklist)

                                                          + +
                                                          +

                                                          “There are only two hard things in Computer Science: cache invalidation and naming things.” — Phil Karlton

                                                          +
                                                          + +

                                                          Bad names can lead to hard-to-decipher code. Generic names, such as data, don’t infer much about the code and the values it receives. This rule allows you to configure a blacklist of bad identifier names, that you don’t want to see in your code.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows specified identifiers in assignments and function definitions.

                                                          + +

                                                          This rule will catch blacklisted identifiers that are:

                                                          + +
                                                            +
                                                          • variable declarations
                                                          • +
                                                          • function declarations
                                                          • +
                                                          • object properties assigned to during object creation
                                                          • +
                                                          + +

                                                          It will not catch blacklisted identifiers that are:

                                                          + +
                                                            +
                                                          • function calls (so you can still use functions you do not have control over)
                                                          • +
                                                          • object properties (so you can still use objects you do not have control over)
                                                          • +
                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes one or more strings as options: the names of restricted identifiers.

                                                          + +

                                                          For example, to restrict the use of common generic identifiers:

                                                          + +
                                                          {
                                                          "id-blacklist": ["error", "data", "err", "e", "cb", "callback"]
                                                          }
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with sample "data", "callback" restricted identifiers:

                                                          + +
                                                          /*eslint id-blacklist: ["error", "data", "callback"] */

                                                          var data = {...};

                                                          function callback() {
                                                          // ...
                                                          }

                                                          element.callback = function() {
                                                          // ...
                                                          };

                                                          var itemSet = {
                                                          data: [...]
                                                          };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with sample "data", "callback" restricted identifiers:

                                                          + +
                                                          /*eslint id-blacklist: ["error", "data", "callback"] */

                                                          var encodingOptions = {...};

                                                          function processFileResult() {
                                                          // ...
                                                          }

                                                          element.successHandler = function() {
                                                          // ...
                                                          };

                                                          var itemSet = {
                                                          entities: [...]
                                                          };

                                                          callback(); // all function calls are ignored

                                                          foo.callback(); // all function calls are ignored

                                                          foo.data; // all property names that are not assignments are ignored
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are happy for identifiers to be named freely.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-beta.2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/id-length.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/id-length.html new file mode 100644 index 0000000..f973984 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/id-length.html @@ -0,0 +1,107 @@ + + + +

                                                          enforce minimum and maximum identifier lengths (id-length)

                                                          + +

                                                          Very short identifier names like e, x, _t or very long ones like hashGeneratorResultOutputContainerObject can make code harder to read and potentially less maintainable. To prevent this, one may enforce a minimum and/or maximum identifier length.

                                                          + +
                                                          var x = 5; // too short; difficult to understand its purpose without context
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces a minimum and/or maximum identifier length convention.

                                                          + +

                                                          Options

                                                          + +

                                                          Examples of incorrect code for this rule with the default options:

                                                          + +
                                                          /*eslint id-length: "error"*/     // default is minimum 2-chars ({ "min": 2 })
                                                          /*eslint-env es6*/

                                                          var x = 5;
                                                          obj.e = document.body;
                                                          var foo = function (e) { };
                                                          try {
                                                          dangerousStuff();
                                                          } catch (e) {
                                                          // ignore as many do
                                                          }
                                                          var myObj = { a: 1 };
                                                          (a) => { a * a };
                                                          class x { }
                                                          class Foo { x() {} }
                                                          function foo(...x) { }
                                                          var { x } = {};
                                                          var { x: a} = {};
                                                          var { a: [x]} = {};
                                                          ({ prop: obj.x }) = {};
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default options:

                                                          + +
                                                          /*eslint id-length: "error"*/     // default is minimum 2-chars ({ "min": 2 })
                                                          /*eslint-env es6*/

                                                          var num = 5;
                                                          function _f() { return 42; }
                                                          function _func() { return 42; }
                                                          obj.el = document.body;
                                                          var foo = function (evt) { /* do stuff */ };
                                                          try {
                                                          dangerousStuff();
                                                          } catch (error) {
                                                          // ignore as many do
                                                          }
                                                          var myObj = { apple: 1 };
                                                          (num) => { num * num };
                                                          function foo(num = 0) { }
                                                          class MyClass { }
                                                          class Foo { method() {} }
                                                          function foo(...args) { }
                                                          var { prop } = {};
                                                          var { prop: a } = {};
                                                          var { prop: [x] } = {};
                                                          ({ prop: obj.longName }) = {};
                                                          var data = { "x": 1 }; // excused because of quotes
                                                          data["y"] = 3; // excused because of calculated property access
                                                          +
                                                          + +

                                                          This rule has an shorthand integer option for the "min" object property.

                                                          + +

                                                          Examples of incorrect code for this rule with a minimum of 4:

                                                          + +
                                                          /*eslint id-length: ["error", 4]*/
                                                          /*eslint-env es6*/

                                                          var val = 5;
                                                          obj.e = document.body;
                                                          function (e) { };
                                                          try {
                                                          dangerousStuff();
                                                          } catch (e) {
                                                          // ignore as many do
                                                          }
                                                          var myObj = { a: 1 };
                                                          (val) => { val * val };
                                                          class x { }
                                                          class Foo { x() {} }
                                                          function foo(...x) { }
                                                          var { x } = {};
                                                          var { x: a} = {};
                                                          var { a: [x]} = {};
                                                          ({ prop: obj.x }) = {};
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with a minimum of 4:

                                                          + +
                                                          /*eslint id-length: ["error", 4]*/
                                                          /*eslint-env es6*/

                                                          var value = 5;
                                                          function func() { return 42; }
                                                          obj.element = document.body;
                                                          var foo = function (event) { /* do stuff */ };
                                                          try {
                                                          dangerousStuff();
                                                          } catch (error) {
                                                          // ignore as many do
                                                          }
                                                          var myObj = { apple: 1 };
                                                          (value) => { value * value };
                                                          function foobar(value = 0) { }
                                                          class MyClass { }
                                                          class Foobar { method() {} }
                                                          function foobar(...args) { }
                                                          var { prop } = {};
                                                          var { prop: a } = {};
                                                          var { prop: [x] } = {};
                                                          ({ prop: obj.name }) = {};
                                                          var data = { "x": 1 }; // excused because of quotes
                                                          data["y"] = 3; // excused because of calculated property access
                                                          +
                                                          + +

                                                          This rule has an object option:

                                                          + +
                                                            +
                                                          • "min" (default: 2) enforces a minimum identifier length
                                                          • +
                                                          • "max" (default: Infinity) enforces a maximum identifier length
                                                          • +
                                                          • "properties": always (default) enforces identifier length convention for property names
                                                          • +
                                                          • "properties": never ignores identifier length convention for property names
                                                          • +
                                                          • "exceptions" allows an array of specified identifier names
                                                          • +
                                                          + +

                                                          min

                                                          + +

                                                          Examples of incorrect code for this rule with the { "min": 4 } option:

                                                          + +
                                                          /*eslint id-length: ["error", { "min": 4 }]*/
                                                          /*eslint-env es6*/

                                                          var val = 5;
                                                          obj.e = document.body;
                                                          function (e) { };
                                                          try {
                                                          dangerousStuff();
                                                          } catch (e) {
                                                          // ignore as many do
                                                          }
                                                          var myObj = { a: 1 };
                                                          (val) => { val * val };
                                                          class x { }
                                                          class Foo { x() {} }
                                                          function foo(...x) { }
                                                          var { x } = {};
                                                          var { x: a} = {};
                                                          var { a: [x]} = {};
                                                          ({ prop: obj.x }) = {};
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "min": 4 } option:

                                                          + +
                                                          /*eslint id-length: ["error", { "min": 4 }]*/
                                                          /*eslint-env es6*/

                                                          var value = 5;
                                                          function func() { return 42; }
                                                          obj.element = document.body;
                                                          var foo = function (event) { /* do stuff */ };
                                                          try {
                                                          dangerousStuff();
                                                          } catch (error) {
                                                          // ignore as many do
                                                          }
                                                          var myObj = { apple: 1 };
                                                          (value) => { value * value };
                                                          function foobar(value = 0) { }
                                                          class MyClass { }
                                                          class Foobar { method() {} }
                                                          function foobar(...args) { }
                                                          var { prop } = {};
                                                          var { prop: a } = {};
                                                          var { prop: [x] } = {};
                                                          ({ prop: obj.name }) = {};
                                                          var data = { "x": 1 }; // excused because of quotes
                                                          data["y"] = 3; // excused because of calculated property access
                                                          +
                                                          + +

                                                          max

                                                          + +

                                                          Examples of incorrect code for this rule with the { "max": 10 } option:

                                                          + +
                                                          /*eslint id-length: ["error", { "max": "10" }]*/
                                                          /*eslint-env es6*/

                                                          var reallyLongVarName = 5;
                                                          function reallyLongFuncName() { return 42; }
                                                          obj.reallyLongPropName = document.body;
                                                          var foo = function (reallyLongArgName) { /* do stuff */ };
                                                          try {
                                                          dangerousStuff();
                                                          } catch (reallyLongErrorName) {
                                                          // ignore as many do
                                                          }
                                                          (reallyLongArgName) => { return !reallyLongArgName; };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "max": 10 } option:

                                                          + +
                                                          /*eslint id-length: ["error", { "max": "10" }]*/
                                                          /*eslint-env es6*/

                                                          var varName = 5;
                                                          function funcName() { return 42; }
                                                          obj.propName = document.body;
                                                          var foo = function (arg) { /* do stuff */ };
                                                          try {
                                                          dangerousStuff();
                                                          } catch (error) {
                                                          // ignore as many do
                                                          }
                                                          (arg) => { return !arg; };
                                                          +
                                                          + +

                                                          properties

                                                          + +

                                                          Examples of correct code for this rule with the { "properties": "never" } option:

                                                          + +
                                                          /*eslint id-length: ["error", { "properties": "never" }]*/
                                                          /*eslint-env es6*/

                                                          var myObj = { a: 1 };
                                                          ({ a: obj.x.y.z }) = {};
                                                          ({ prop: obj.i }) = {};
                                                          +
                                                          + +

                                                          exceptions

                                                          + +

                                                          Examples of additional correct code for this rule with the { "exceptions": "x" } option:

                                                          + +
                                                          /*eslint id-length: ["error", { "max": "10" }]*/
                                                          /*eslint-env es6*/

                                                          var x = 5;
                                                          function x() { return 42; }
                                                          obj.x = document.body;
                                                          var foo = function (x) { /* do stuff */ };
                                                          try {
                                                          dangerousStuff();
                                                          } catch (x) {
                                                          // ignore as many do
                                                          }
                                                          (x) => { return x * x; };
                                                          +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/id-match.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/id-match.html new file mode 100644 index 0000000..f630e02 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/id-match.html @@ -0,0 +1,74 @@ + + + +

                                                          require identifiers to match a specified regular expression (id-match)

                                                          + +
                                                          +

                                                          “There are only two hard things in Computer Science: cache invalidation and naming things.” — Phil Karlton

                                                          +
                                                          + +

                                                          Naming things consistently in a project is an often underestimated aspect of code creation. +When done correctly, it can save your team hours of unnecessary head scratching and misdirections. +This rule allows you to precisely define and enforce the variables and function names on your team should use. +No more limiting yourself to camelCase, snake_case, PascalCase or oHungarianNotation. Id-match has all your needs covered!

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule requires identifiers in assignments and function definitions to match a specified regular expression.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option for the specified regular expression.

                                                          + +

                                                          For example, to enforce a camelcase naming convention:

                                                          + +
                                                          {
                                                          "id-match": ["error", "^[a-z]+([A-Z][a-z]+)*$"]
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "^[a-z]+([A-Z][a-z]+)*$" option:

                                                          + +
                                                          /*eslint id-match: ["error", "^[a-z]+([A-Z][a-z]+)*$"]*/

                                                          var myFavoriteColor = "#112C85";
                                                          var foo = bar.baz_boom;
                                                          var foo = { qux: bar.baz_boom };
                                                          do_something();
                                                          var obj = {
                                                          my_pref: 1
                                                          };
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with the "^[a-z]+([A-Z][a-z]+)*$" option:

                                                          + +
                                                          /*eslint id-match: ["error", "^[a-z]+([A-Z][a-z]+)*$"]*/

                                                          var my_favorite_color = "#112C85";
                                                          var _myFavoriteColor = "#112C85";
                                                          var myFavoriteColor_ = "#112C85";
                                                          var MY_FAVORITE_COLOR = "#112C85";
                                                          function do_something() {
                                                          // ...
                                                          }
                                                          obj.do_something = function() {
                                                          // ...
                                                          };
                                                          +
                                                          + +

                                                          This rule has an object option:

                                                          + +
                                                            +
                                                          • "properties": true requires object properties to match the specified regular expression
                                                          • +
                                                          • "onlyDeclarations": true requires only var, function, and class declarations to match the specified regular expression
                                                          • +
                                                          + +

                                                          properties

                                                          + +

                                                          Examples of incorrect code for this rule with the "^[a-z]+([A-Z][a-z]+)*$", { "properties": true } options:

                                                          + +
                                                          /*eslint id-match: ["error", "^[a-z]+([A-Z][a-z]+)*$", { "properties": true }]*/

                                                          var obj = {
                                                          my_pref: 1
                                                          };
                                                          +
                                                          + +

                                                          onlyDeclarations

                                                          + +

                                                          Examples of correct code for this rule with the "^[a-z]+([A-Z][a-z]+)*$", { "onlyDeclarations": true } options:

                                                          + +
                                                          /*eslint id-match: [2, "^[a-z]+([A-Z][a-z]+)*$", { "onlyDeclarations": true }]*/

                                                          do_something(__dirname);
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If your rules are too complex, it is possible that you encounter performance issues due to the nature of the job.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/indent.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/indent.html new file mode 100644 index 0000000..2113f45 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/indent.html @@ -0,0 +1,132 @@ + + + +

                                                          enforce consistent indentation (indent)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          There are several common guidelines which require specific indentation of nested blocks and statements, like:

                                                          + +
                                                          function hello(indentSize, type) {
                                                          if (indentSize === 4 && type !== 'tab') {
                                                          console.log('Each next indentation will increase on 4 spaces');
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          These are the most common scenarios recommended in different style guides:

                                                          + +
                                                            +
                                                          • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
                                                          • +
                                                          • Tabs: jQuery
                                                          • +
                                                          • Four spaces: Crockford
                                                          • +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces a consistent indentation style. The default style is 4 spaces.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a mixed option:

                                                          + +

                                                          For example, for 2-space indentation:

                                                          + +
                                                          {
                                                          "indent": ["error", 2]
                                                          }
                                                          +
                                                          + +

                                                          Or for tabbed indentation:

                                                          + +
                                                          {
                                                          "indent": ["error", "tab"]
                                                          }
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with the default options:

                                                          + +
                                                          /*eslint indent: "error"*/

                                                          if (a) {
                                                          b=c;
                                                          function foo(d) {
                                                          e=f;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default options:

                                                          + +
                                                          /*eslint indent: "error"*/

                                                          if (a) {
                                                          b=c;
                                                          function foo(d) {
                                                          e=f;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          This rule has an object option:

                                                          + +
                                                            +
                                                          • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
                                                          • +
                                                          • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
                                                          • +
                                                          + +

                                                          Level of indentation denotes the multiple of the indent specified. Example:

                                                          + +
                                                            +
                                                          • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
                                                          • +
                                                          • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
                                                          • +
                                                          • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
                                                          • +
                                                          • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
                                                          • +
                                                          • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
                                                          • +
                                                          • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
                                                          • +
                                                          • Indent of tabs with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
                                                          • +
                                                          + +

                                                          tab

                                                          + +

                                                          Examples of incorrect code for this rule with the "tab" option:

                                                          + +
                                                          /*eslint indent: ["error", "tab"]*/

                                                          if (a) {
                                                          b=c;
                                                          function foo(d) {
                                                          e=f;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "tab" option:

                                                          + +
                                                          /*eslint indent: ["error", "tab"]*/

                                                          if (a) {
                                                          /*tab*/b=c;
                                                          /*tab*/function foo(d) {
                                                          /*tab*//*tab*/e=f;
                                                          /*tab*/}
                                                          }
                                                          +
                                                          + +

                                                          SwitchCase

                                                          + +

                                                          Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

                                                          + +
                                                          /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/

                                                          switch(a){
                                                          case "a":
                                                          break;
                                                          case "b":
                                                          break;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

                                                          + +
                                                          /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/

                                                          switch(a){
                                                          case "a":
                                                          break;
                                                          case "b":
                                                          break;
                                                          }
                                                          +
                                                          + +

                                                          VariableDeclarator

                                                          + +

                                                          Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

                                                          + +
                                                          /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
                                                          /*eslint-env es6*/

                                                          var a,
                                                          b,
                                                          c;
                                                          let a,
                                                          b,
                                                          c;
                                                          const a = 1,
                                                          b = 2,
                                                          c = 3;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

                                                          + +
                                                          /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
                                                          /*eslint-env es6*/

                                                          var a,
                                                          b,
                                                          c;
                                                          let a,
                                                          b,
                                                          c;
                                                          const a = 1,
                                                          b = 2,
                                                          c = 3;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

                                                          + +
                                                          /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
                                                          /*eslint-env es6*/

                                                          var a,
                                                          b,
                                                          c;
                                                          let a,
                                                          b,
                                                          c;
                                                          const a = 1,
                                                          b = 2,
                                                          c = 3;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

                                                          + +
                                                          /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
                                                          /*eslint-env es6*/

                                                          var a,
                                                          b,
                                                          c;
                                                          let a,
                                                          b,
                                                          c;
                                                          const a = 1,
                                                          b = 2,
                                                          c = 3;
                                                          +
                                                          + +

                                                          Compatibility

                                                          + +
                                                            +
                                                          • JSHint: indent
                                                          • +
                                                          • JSCS: validateIndentation
                                                          • +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.14.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/init-declarations.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/init-declarations.html new file mode 100644 index 0000000..46a5470 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/init-declarations.html @@ -0,0 +1,94 @@ + + + +

                                                          Enforce/Disallow Variable Initializations (init-declarations)

                                                          + +

                                                          In JavaScript, variables can be assigned during declaration, or at any point afterwards using an assignment statement. For example, in the following code, foo is initialized during declaration, while bar is initialized later.

                                                          + +
                                                          var foo = 1;
                                                          var bar;

                                                          if (foo) {
                                                          bar = 1;
                                                          } else {
                                                          bar = 2;
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at enforcing or eliminating variable initializations during declaration. For example, in the following code, foo is initialized during declaration, while bar is not.

                                                          + +
                                                          var foo = 1;
                                                          var bar;

                                                          bar = 2;
                                                          +
                                                          + +

                                                          This rule aims to bring consistency to variable initializations and declarations.

                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes two options:

                                                          + +
                                                            +
                                                          1. A string which must be either "always" (the default), to enforce initialization at declaration, or "never" to disallow initialization during declaration. This rule applies to var, let, and const variables, however "never" is ignored for const variables, as unassigned consts generate a parse error.
                                                          2. +
                                                          3. An object that further controls the behavior of this rule. Currently, the only available parameter is ignoreForLoopInit, which indicates if initialization at declaration is allowed in for loops when "never" is set, since it is a very typical use case.
                                                          4. +
                                                          + +

                                                          You can configure the rule as follows:

                                                          + +

                                                          Variables must be initialized at declaration (default)

                                                          + +
                                                          {
                                                          "init-declarations": ["error", "always"],
                                                          }
                                                          +
                                                          + +

                                                          Variables must not be initialized at declaration

                                                          + +
                                                          {
                                                          "init-declarations": ["error", "never"]
                                                          }
                                                          +
                                                          + +

                                                          Variables must not be initialized at declaration, except in for loops, where it is allowed

                                                          + +
                                                          {
                                                          "init-declarations": ["error", "never", { "ignoreForLoopInit": true }]
                                                          }
                                                          +
                                                          + +

                                                          always

                                                          + +

                                                          Examples of incorrect code for the default "always" option:

                                                          + +
                                                          /*eslint init-declarations: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          var bar;
                                                          let baz;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for the default "always" option:

                                                          + +
                                                          /*eslint init-declarations: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          var bar = 1;
                                                          let baz = 2;
                                                          const qux = 3;
                                                          }
                                                          +
                                                          + +

                                                          never

                                                          + +

                                                          Examples of incorrect code for the "never" option:

                                                          + +
                                                          /*eslint init-declarations: ["error", "never"]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          var bar = 1;
                                                          let baz = 2;

                                                          for (var i = 0; i < 1; i++) {}
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for the "never" option:

                                                          + +
                                                          /*eslint init-declarations: ["error", "never"]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          var bar;
                                                          let baz;
                                                          const buzz = 1;
                                                          }
                                                          +
                                                          + +

                                                          The "never" option ignores const variable initializations.

                                                          + +

                                                          ignoreForLoopInit

                                                          + +

                                                          Examples of correct code for the "never", { "ignoreForLoopInit": true } options:

                                                          + +
                                                          /*eslint init-declarations: ["error", "never", { "ignoreForLoopInit": true }]*/
                                                          for (var i = 0; i < 1; i++) {}
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          When you are indifferent as to how your variables are initialized.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0-rc-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/jsx-quotes.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/jsx-quotes.html new file mode 100644 index 0000000..82d74dd --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/jsx-quotes.html @@ -0,0 +1,77 @@ + + + +

                                                          enforce the consistent use of either double or single quotes in JSX attributes (jsx-quotes)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          JSX attribute values can contain string literals, which are delimited with single or double quotes.

                                                          + +
                                                          <a b='c' />
                                                          <a b="c" />
                                                          +
                                                          + +

                                                          Unlike string literals in JavaScript, string literals within JSX attributes can’t contain escaped quotes. +If you want to have e.g. a double quote within a JSX attribute value, you have to use single quotes as string delimiter.

                                                          + +
                                                          <a b="'" />
                                                          <a b='"' />
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces the consistent use of either double or single quotes in JSX attributes.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • "prefer-double" (default) enforces the use of double quotes for all JSX attribute values that don’t contain a double quote.
                                                          • +
                                                          • "prefer-single" enforces the use of single quotes for all JSX attribute values that don’t contain a single quote.
                                                          • +
                                                          + +

                                                          prefer-double

                                                          + +

                                                          Examples of incorrect code for this rule with the default "prefer-double" option:

                                                          + +
                                                          /*eslint jsx-quotes: ["error", "prefer-double"]*/

                                                          <a b='c' />
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "prefer-double" option:

                                                          + +
                                                          /*eslint jsx-quotes: ["error", "prefer-double"]*/

                                                          <a b="c" />
                                                          <a b='"' />
                                                          +
                                                          + +

                                                          prefer-single

                                                          + +

                                                          Examples of incorrect code for this rule with the "prefer-single" option:

                                                          + +
                                                          /*eslint jsx-quotes: ["error", "prefer-single"]*/

                                                          <a b="c" />
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "prefer-single" option:

                                                          + +
                                                          /*eslint jsx-quotes: ["error", "prefer-single"]*/

                                                          <a b='c' />
                                                          <a b="'" />
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you don’t use JSX or if you aren’t concerned with a consistent usage of quotes within JSX attributes.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/key-spacing.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/key-spacing.html new file mode 100644 index 0000000..2bb5a62 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/key-spacing.html @@ -0,0 +1,136 @@ + + + +

                                                          enforce consistent spacing between keys and values in object literal properties (key-spacing)

                                                          + +

                                                          This rule enforces spacing around the colon in object literal properties. It can verify each property individually, or it can ensure horizontal alignment of adjacent properties in an object literal.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces consistent spacing between keys and values in object literal properties. In the case of long lines, it is acceptable to add a new line wherever whitespace is allowed.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an object option:

                                                          + +
                                                            +
                                                          • "beforeColon": false (default) disallows spaces between the key and the colon in object literals
                                                          • +
                                                          • "beforeColon": true requires at least one space between the key and the colon in object literals
                                                          • +
                                                          • "afterColon": true (default) requires at least one space between the colon and the value in object literals
                                                          • +
                                                          • "afterColon": false disallows spaces between the colon and the value in object literals
                                                          • +
                                                          • "mode": strict (default) enforces exactly one space before or after colons in object literals
                                                          • +
                                                          • "mode": minimum enforces one or more spaces before or after colons in object literals
                                                          • +
                                                          • "align": "value" enforces horizontal alignment of values in object literals
                                                          • +
                                                          • "align": "colon" enforces horizontal alignment of both colons and values in object literals.
                                                          • +
                                                          • "singleLine" specifies a spacing style for single-line object literals
                                                          • +
                                                          • "multiLine" specifies a spacing style for multi-line object literals
                                                          • +
                                                          + +

                                                          Please note that you can either use the top-level options or the grouped options (singleLine and multiLine) but not both.

                                                          + +

                                                          beforeColon

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "beforeColon": false } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "beforeColon": false }]*/

                                                          var obj = { "foo" : 42 };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "beforeColon": false } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "beforeColon": false }]*/

                                                          var obj = { "foo": 42 };
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with the { "beforeColon": true } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "beforeColon": true }]*/

                                                          var obj = { "foo": 42 };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "beforeColon": true } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "beforeColon": true }]*/

                                                          var obj = { "foo" : 42 };
                                                          +
                                                          + +

                                                          afterColon

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "afterColon": true } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "afterColon": true }]*/

                                                          var obj = { "foo":42 };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "afterColon": true } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "afterColon": true }]*/

                                                          var obj = { "foo": 42 };
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with the { "afterColon": false } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "afterColon": false }]*/

                                                          var obj = { "foo": 42 };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "afterColon": false } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "afterColon": false }]*/

                                                          var obj = { "foo":42 };
                                                          +
                                                          + +

                                                          mode

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "mode": "strict" } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "mode": "strict" }]*/

                                                          call({
                                                          foobar: 42,
                                                          bat: 2 * 2
                                                          });
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "mode": "strict" } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "mode": "strict" }]*/

                                                          call({
                                                          foobar: 42,
                                                          bat: 2 * 2
                                                          });
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "mode": "minimum" } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "mode": "minimum" }]*/

                                                          call({
                                                          foobar: 42,
                                                          bat: 2 * 2
                                                          });
                                                          +
                                                          + +

                                                          align

                                                          + +

                                                          Examples of incorrect code for this rule with the { "align": "value" } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "align": "value" }]*/

                                                          var obj = {
                                                          a: value,
                                                          bcde: 42,
                                                          fg : foo()
                                                          };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "align": "value" } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "align": "value" }]*/

                                                          var obj = {
                                                          a: value,
                                                          bcde: 42,

                                                          fg: foo(),
                                                          h: function() {
                                                          return this.a;
                                                          },
                                                          ijkl: 'Non-consecutive lines form a new group'
                                                          };

                                                          var obj = { a: "foo", longPropertyName: "bar" };
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with the { "align": "colon" } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "align": "colon" }]*/

                                                          call({
                                                          foobar: 42,
                                                          bat: 2 * 2
                                                          });
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "align": "colon" } option:

                                                          + +
                                                          /*eslint key-spacing: ["error", { "align": "colon" }]*/

                                                          call({
                                                          foobar: 42,
                                                          bat : 2 * 2
                                                          });
                                                          +
                                                          + +

                                                          singleLine and multiLine

                                                          + +

                                                          Examples of correct code for this rule with sample { "singleLine": { }, "multiLine": { } } options:

                                                          + +
                                                          /*eslint "key-spacing": [2, {
                                                          "singleLine": {
                                                          "beforeColon": false,
                                                          "afterColon": true
                                                          },
                                                          "multiLine": {
                                                          "beforeColon": true,
                                                          "afterColon": true,
                                                          "align": "colon"
                                                          }
                                                          }]*/

                                                          var obj = { one: 1, "two": 2, three: 3 };
                                                          var obj2 = {
                                                          "two" : 2,
                                                          three : 3
                                                          };
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you have another convention for property spacing that might not be consistent with the available options, or if you want to permit multiple styles concurrently you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.9.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/keyword-spacing.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/keyword-spacing.html new file mode 100644 index 0000000..ca19846 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/keyword-spacing.html @@ -0,0 +1,100 @@ + + + +

                                                          enforce consistent spacing before and after keywords (keyword-spacing)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Keywords are syntax elements of JavaScript, such as function and if. +These identifiers have special meaning to the language and so often appear in a different color in code editors. +As an important part of the language, style guides often refer to the spacing that should be used around keywords. +For example, you might have a style guide that says keywords should be always surrounded by spaces, which would mean if-else statements must look like this:

                                                          + +
                                                          if (foo) {
                                                          // ...
                                                          } else {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Of course, you could also have a style guide that disallows spaces around keywords.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces consistent spacing around keywords and keyword-like tokens: as (in module declarations), break, case, catch, class, const, continue, debugger, default, delete, do, else, export, extends, finally, for, from (in module declarations), function, get (of getters), if, import, in, instanceof, let, new, of (in for-of statements), return, set (of setters), static, super, switch, this, throw, try, typeof, var, void, while, with, and yield. This rule is designed carefully not to conflict with other spacing rules: it does not apply to spacing where other rules report problems.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an object option:

                                                          + +
                                                            +
                                                          • "before": true (default) requires at least one space before keywords
                                                          • +
                                                          • "before": false disallows spaces before keywords
                                                          • +
                                                          • "after": true (default) requires at least one space after keywords
                                                          • +
                                                          • "after": false disallows spaces after keywords
                                                          • +
                                                          • "overrides" allows overriding spacing style for specified keywords
                                                          • +
                                                          + +

                                                          before

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "before": true } option:

                                                          + +
                                                          /*eslint keyword-spacing: ["error", { "before": true }]*/

                                                          if (foo) {
                                                          //...
                                                          }else if (bar) {
                                                          //...
                                                          }else {
                                                          //...
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "before": true } option:

                                                          + +
                                                          /*eslint keyword-spacing: ["error", { "before": true }]*/
                                                          /*eslint-env es6*/

                                                          if (foo) {
                                                          //...
                                                          } else if (bar) {
                                                          //...
                                                          } else {
                                                          //...
                                                          }

                                                          // no conflict with `array-bracket-spacing`
                                                          let a = [this];
                                                          let b = [function() {}];

                                                          // no conflict with `arrow-spacing`
                                                          let a = ()=> this.foo;

                                                          // no conflict with `block-spacing`
                                                          {function foo() {}}

                                                          // no conflict with `comma-spacing`
                                                          let a = [100,this.foo, this.bar];

                                                          // not conflict with `computed-property-spacing`
                                                          obj[this.foo] = 0;

                                                          // no conflict with `generator-star-spacing`
                                                          function *foo() {}

                                                          // no conflict with `key-spacing`
                                                          let obj = {
                                                          foo:function() {}
                                                          };

                                                          // no conflict with `object-curly-spacing`
                                                          let obj = {foo: this};

                                                          // no conflict with `semi-spacing`
                                                          let a = this;function foo() {}

                                                          // no conflict with `space-in-parens`
                                                          (function () {})();

                                                          // no conflict with `space-infix-ops`
                                                          if ("foo"in {foo: 0}) {}
                                                          if (10+this.foo<= this.bar) {}

                                                          // no conflict with `jsx-curly-spacing`
                                                          let a = <A foo={this.foo} bar={function(){}} />
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with the { "before": false } option:

                                                          + +
                                                          /*eslint keyword-spacing: ["error", { "before": false }]*/

                                                          if (foo) {
                                                          //...
                                                          } else if (bar) {
                                                          //...
                                                          } else {
                                                          //...
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "before": false } option:

                                                          + +
                                                          /*eslint keyword-spacing: ["error", { "before": false }]*/

                                                          if (foo) {
                                                          //...
                                                          }else if (bar) {
                                                          //...
                                                          }else {
                                                          //...
                                                          }
                                                          +
                                                          + +

                                                          after

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "after": true } option:

                                                          + +
                                                          /*eslint keyword-spacing: ["error", { "after": true }]*/

                                                          if(foo) {
                                                          //...
                                                          } else if(bar) {
                                                          //...
                                                          } else{
                                                          //...
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "after": true } option:

                                                          + +
                                                          /*eslint keyword-spacing: ["error", { "after": true }]*/

                                                          if (foo) {
                                                          //...
                                                          } else if (bar) {
                                                          //...
                                                          } else {
                                                          //...
                                                          }

                                                          // not conflict with `array-bracket-spacing`
                                                          let a = [this];

                                                          // not conflict with `arrow-spacing`
                                                          let a = ()=> this.foo;

                                                          // not conflict with `comma-spacing`
                                                          let a = [100, this.foo, this.bar];

                                                          // not conflict with `computed-property-spacing`
                                                          obj[this.foo] = 0;

                                                          // not conflict with `generator-star-spacing`
                                                          function* foo() {}

                                                          // not conflict with `key-spacing`
                                                          let obj = {
                                                          foo:function() {}
                                                          };

                                                          // not conflict with `no-spaced-func`
                                                          class A {
                                                          constructor() {
                                                          super();
                                                          }
                                                          }

                                                          // not conflict with `object-curly-spacing`
                                                          let obj = {foo: this};

                                                          // not conflict with `semi-spacing`
                                                          let a = this;function foo() {}

                                                          // not conflict with `space-before-function-paren`
                                                          function() {}

                                                          // no conflict with `space-infix-ops`
                                                          if ("foo"in{foo: 0}) {}
                                                          if (10+this.foo<= this.bar) {}

                                                          // no conflict with `space-unary-ops`
                                                          function* foo(a) {
                                                          return yield+a;
                                                          }

                                                          // no conflict with `yield-star-spacing`
                                                          function* foo(a) {
                                                          return yield* a;
                                                          }

                                                          // no conflict with `jsx-curly-spacing`
                                                          let a = <A foo={this.foo} bar={function(){}} />
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with the { "after": false } option:

                                                          + +
                                                          /*eslint keyword-spacing: ["error", { "after": false }]*/

                                                          if (foo) {
                                                          //...
                                                          } else if (bar) {
                                                          //...
                                                          } else {
                                                          //...
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "after": false } option:

                                                          + +
                                                          /*eslint keyword-spacing: ["error", { "after": false }]*/

                                                          if(foo) {
                                                          //...
                                                          } else if(bar) {
                                                          //...
                                                          } else{
                                                          //...
                                                          }
                                                          +
                                                          + +

                                                          overrides

                                                          + +

                                                          Examples of correct code for this rule with the { "overrides": { "if": { "after": false }, "for": { "after": false }, "while": { "after": false } } } option:

                                                          + +
                                                          /*eslint keyword-spacing: ["error", { "overrides": {
                                                          "if": { "after": false },
                                                          "for": { "after": false },
                                                          "while": { "after": false }
                                                          } }]*/


                                                          if(foo) {
                                                          //...
                                                          } else if(bar) {
                                                          //...
                                                          } else {
                                                          //...
                                                          }

                                                          for(;;);

                                                          while(true) {
                                                          //...
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to enforce consistency on keyword spacing, then it’s safe to disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-beta.1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/linebreak-style.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/linebreak-style.html new file mode 100644 index 0000000..e36eaf1 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/linebreak-style.html @@ -0,0 +1,74 @@ + + + +

                                                          enforce consistent linebreak style (linebreak-style)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that +different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).

                                                          + +

                                                          The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF) +whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n" (for LF) and "\r\n" for (CRLF).

                                                          + +

                                                          Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • "unix" (default) enforces the usage of Unix line endings: \n for LF.
                                                          • +
                                                          • "windows" enforces the usage of Windows line endings: \r\n for CRLF.
                                                          • +
                                                          + +

                                                          unix

                                                          + +

                                                          Examples of incorrect code for this rule with the default "unix" option:

                                                          + +
                                                          /*eslint linebreak-style: ["error", "unix"]*/

                                                          var a = 'a'; // \r\n

                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "unix" option:

                                                          + +
                                                          /*eslint linebreak-style: ["error", "unix"]*/

                                                          var a = 'a', // \n
                                                          b = 'b'; // \n
                                                          // \n
                                                          function foo(params) { // \n
                                                          // do stuff \n
                                                          }// \n
                                                          +
                                                          + +

                                                          windows

                                                          + +

                                                          Examples of incorrect code for this rule with the "windows" option:

                                                          + +
                                                          /*eslint linebreak-style: ["error", "windows"]*/

                                                          var a = 'a'; // \n
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "windows" option:

                                                          + +
                                                          /*eslint linebreak-style: ["error", "windows"]*/

                                                          var a = 'a', // \r\n
                                                          b = 'b'; // \r\n
                                                          // \r\n
                                                          function foo(params) { // \r\n
                                                          // do stuff \r\n
                                                          } // \r\n
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you aren’t concerned about having different line endings within you code, then you can safely turn this rule off.

                                                          + +

                                                          Compatibility

                                                          + +
                                                            +
                                                          • JSCS: validateLineBreaks
                                                          • +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.21.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/lines-around-comment.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/lines-around-comment.html new file mode 100644 index 0000000..306ca54 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/lines-around-comment.html @@ -0,0 +1,173 @@ + + + +

                                                          require empty lines around comments (lines-around-comment)

                                                          + +

                                                          Many style guides require empty lines before or after comments. The primary goal +of these rules is to make the comments easier to read and improve readability of the code.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule requires empty lines before and/or after comments. It can be enabled separately for both block (/*) and line (//) comments. This rule does not apply to comments that appear on the same line as code and does not require empty lines at the beginning or end of a file. Empty lines are also not required at the beginning or end of a file.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an object option:

                                                          + +
                                                            +
                                                          • "beforeBlockComment": true (default) requires an empty line before block comments
                                                          • +
                                                          • "beforeBlockComment": false disallows an empty line before block comments
                                                          • +
                                                          • "afterBlockComment": true requires an empty line after block comments
                                                          • +
                                                          • "beforeLineComment": true requires an empty line before line comments
                                                          • +
                                                          • "afterLineComment": true requires an empty line after line comments
                                                          • +
                                                          • "allowBlockStart": true allows comments to appear at the start of block statements
                                                          • +
                                                          • "allowBlockEnd": true allows comments to appear at the end of block statements
                                                          • +
                                                          • "allowObjectStart": true allows comments to appear at the start of object literals
                                                          • +
                                                          • "allowObjectEnd": true allows comments to appear at the end of object literals
                                                          • +
                                                          • "allowArrayStart": true allows comments to appear at the start of array literals
                                                          • +
                                                          • "allowArrayEnd": true allows comments to appear at the end of array literals
                                                          • +
                                                          + +

                                                          beforeBlockComment

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "beforeBlockComment": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "beforeBlockComment": true }]*/

                                                          var night = "long";
                                                          /* what a great and wonderful day */
                                                          var day = "great"
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "beforeBlockComment": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "beforeBlockComment": true }]*/

                                                          var night = "long";

                                                          /* what a great and wonderful day */
                                                          var day = "great"
                                                          +
                                                          + +

                                                          afterBlockComment

                                                          + +

                                                          Examples of incorrect code for this rule with the { "afterBlockComment": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "afterBlockComment": true }]*/

                                                          var night = "long";

                                                          /* what a great and wonderful day */
                                                          var day = "great"
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "afterBlockComment": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "afterBlockComment": true }]*/

                                                          var night = "long";

                                                          /* what a great and wonderful day */

                                                          var day = "great"
                                                          +
                                                          + +

                                                          beforeLineComment

                                                          + +

                                                          Examples of incorrect code for this rule with the { "beforeLineComment": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "beforeLineComment": true }]*/

                                                          var night = "long";
                                                          // what a great and wonderful day
                                                          var day = "great"
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "beforeLineComment": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "beforeLineComment": true }]*/

                                                          var night = "long";

                                                          // what a great and wonderful day
                                                          var day = "great"
                                                          +
                                                          + +

                                                          afterLineComment

                                                          + +

                                                          Examples of incorrect code for this rule with the { "afterLineComment": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "afterLineComment": true }]*/

                                                          var night = "long";
                                                          // what a great and wonderful day
                                                          var day = "great"
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "afterLineComment": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "afterLineComment": true }]*/

                                                          var night = "long";
                                                          // what a great and wonderful day

                                                          var day = "great"
                                                          +
                                                          + +

                                                          allowBlockStart

                                                          + +

                                                          Examples of correct code for this rule with the { "beforeLineComment": true, "allowBlockStart": true } options:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "beforeLineComment": true, "allowBlockStart": true }]*/

                                                          function foo(){
                                                          // what a great and wonderful day
                                                          var day = "great"
                                                          return day;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "beforeBlockComment": true, "allowBlockStart": true } options:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "beforeBlockComment": true, "allowBlockStart": true }]*/

                                                          function foo(){
                                                          /* what a great and wonderful day */
                                                          var day = "great"
                                                          return day;
                                                          }
                                                          +
                                                          + +

                                                          allowBlockEnd

                                                          + +

                                                          Examples of correct code for this rule with the { "afterLineComment": true, "allowBlockEnd": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "afterLineComment": true, "allowBlockEnd": true }]*/

                                                          function foo(){
                                                          var day = "great"
                                                          return day;
                                                          // what a great and wonderful day
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "afterBlockComment": true, "allowBlockEnd": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "afterBlockComment": true, "allowBlockEnd": true }]*/

                                                          function foo(){
                                                          var day = "great"
                                                          return day;

                                                          /* what a great and wonderful day */
                                                          }
                                                          +
                                                          + +

                                                          allowObjectStart

                                                          + +

                                                          Examples of correct code for this rule with the { "beforeLineComment": true, "allowObjectStart": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "beforeLineComment": true, "allowObjectStart": true }]*/

                                                          var foo = {
                                                          // what a great and wonderful day
                                                          day: "great"
                                                          };

                                                          const {
                                                          // what a great and wonderful day
                                                          foo: someDay
                                                          } = {foo: "great"};

                                                          const {
                                                          // what a great and wonderful day
                                                          day
                                                          } = {day: "great"};
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "beforeBlockComment": true, "allowObjectStart": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "beforeBlockComment": true, "allowObjectStart": true }]*/

                                                          var foo = {
                                                          /* what a great and wonderful day */
                                                          day: "great"
                                                          };

                                                          const {
                                                          /* what a great and wonderful day */
                                                          foo: someDay
                                                          } = {foo: "great"};

                                                          const {
                                                          /* what a great and wonderful day */
                                                          day
                                                          } = {day: "great"};
                                                          +
                                                          + +

                                                          allowObjectEnd

                                                          + +

                                                          Examples of correct code for this rule with the { "afterLineComment": true, "allowObjectEnd": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "afterLineComment": true, "allowObjectEnd": true }]*/

                                                          var foo = {
                                                          day: "great"
                                                          // what a great and wonderful day
                                                          };

                                                          const {
                                                          foo: someDay
                                                          // what a great and wonderful day
                                                          } = {foo: "great"};

                                                          const {
                                                          day
                                                          // what a great and wonderful day
                                                          } = {day: "great"};
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "afterBlockComment": true, "allowObjectEnd": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "afterBlockComment": true, "allowObjectEnd": true }]*/

                                                          var foo = {
                                                          day: "great"

                                                          /* what a great and wonderful day */
                                                          };

                                                          const {
                                                          foo: someDay

                                                          /* what a great and wonderful day */
                                                          } = {foo: "great"};

                                                          const {
                                                          day

                                                          /* what a great and wonderful day */
                                                          } = {day: "great"};
                                                          +
                                                          + +

                                                          allowArrayStart

                                                          + +

                                                          Examples of correct code for this rule with the { "beforeLineComment": true, "allowArrayStart": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "beforeLineComment": true, "allowArrayStart": true }]*/

                                                          var day = [
                                                          // what a great and wonderful day
                                                          "great",
                                                          "wonderful"
                                                          ];

                                                          const [
                                                          // what a great and wonderful day
                                                          someDay
                                                          ] = ["great", "not great"];
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "beforeBlockComment": true, "allowArrayStart": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "beforeBlockComment": true, "allowArrayStart": true }]*/

                                                          var day = [
                                                          /* what a great and wonderful day */
                                                          "great",
                                                          "wonderful"
                                                          ];

                                                          const [
                                                          /* what a great and wonderful day */
                                                          someDay
                                                          ] = ["great", "not great"];
                                                          +
                                                          + +

                                                          allowArrayEnd

                                                          + +

                                                          Examples of correct code for this rule with the { "afterLineComment": true, "allowArrayEnd": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "afterLineComment": true, "allowArrayEnd": true }]*/

                                                          var day = [
                                                          "great",
                                                          "wonderful"
                                                          // what a great and wonderful day
                                                          ];

                                                          const [
                                                          someDay
                                                          // what a great and wonderful day
                                                          ] = ["great", "not great"];
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "afterBlockComment": true, "allowArrayEnd": true } option:

                                                          + +
                                                          /*eslint lines-around-comment: ["error", { "afterBlockComment": true, "allowArrayEnd": true }]*/

                                                          var day = [
                                                          "great",
                                                          "wonderful"

                                                          /* what a great and wonderful day */
                                                          ];

                                                          const [
                                                          someDay

                                                          /* what a great and wonderful day */
                                                          ] = ["great", "not great"];
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          Many people enjoy a terser code style and don’t mind comments bumping up against code. If you fall into that category this rule is not for you.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.22.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/max-depth.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/max-depth.html new file mode 100644 index 0000000..453c6a2 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/max-depth.html @@ -0,0 +1,55 @@ + + + +

                                                          enforce a maximum depth that blocks can be nested (max-depth)

                                                          + +

                                                          Many developers consider code difficult to read if blocks are nested beyond a certain depth.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces a maximum depth that blocks can be nested to reduce code complexity.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a number or object option:

                                                          + +
                                                            +
                                                          • "max" (default 4) enforces a maximum depth that blocks can be nested
                                                          • +
                                                          + +

                                                          Deprecated: The object property maximum is deprecated; please use the object property max instead.

                                                          + +

                                                          max

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "max": 4 } option:

                                                          + +
                                                          /*eslint max-depth: ["error", 4]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          for (;;) { // Nested 1 deep
                                                          let val = () => (param) => { // Nested 2 deep
                                                          if (true) { // Nested 3 deep
                                                          if (true) { // Nested 4 deep
                                                          if (true) { // Nested 5 deep
                                                          }
                                                          }
                                                          }
                                                          };
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "max": 4 } option:

                                                          + +
                                                          /*eslint max-depth: ["error", 4]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          for (;;) { // Nested 1 deep
                                                          let val = () => (param) => { // Nested 2 deep
                                                          if (true) { // Nested 3 deep
                                                          if (true) { // Nested 4 deep
                                                          }
                                                          }
                                                          };
                                                          }
                                                          }
                                                          +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/max-len.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/max-len.html new file mode 100644 index 0000000..b0dc7ac --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/max-len.html @@ -0,0 +1,111 @@ + + + +

                                                          enforce a maximum line length (max-len)

                                                          + +

                                                          Very long lines of code in any language can be difficult to read. In order to aid in readability and maintainability many coders have developed a convention to limit lines of code to X number of characters (traditionally 80 characters).

                                                          + +
                                                          var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" }; // very long
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces a maximum line length to increase code readability and maintainability.

                                                          + +

                                                          Note: This rule calculates the length of a line via code points, not characters. That means if you use a double-byte character in your code, it will count as 2 code points instead of 1, and 2 will be used to calculate line length. This is a technical limitation of JavaScript that is made easier with ES2015, and we will look to update this when ES2015 is available in Node.js.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a number or object option:

                                                          + +
                                                            +
                                                          • "code" (default 80) enforces a maximum line length
                                                          • +
                                                          • "tabWidth" (default 4) specifies the character width for tab characters
                                                          • +
                                                          • "comments" enforces a maximum line length for comments; defaults to value of code
                                                          • +
                                                          • "ignorePattern" ignores lines matching a regular expression; can only match a single line and need to be double escaped when written in YAML or JSON
                                                          • +
                                                          • "ignoreComments": true ignores all trailing comments and comments on their own line
                                                          • +
                                                          • "ignoreTrailingComments": true ignores only trailing comments
                                                          • +
                                                          • "ignoreUrls": true ignores lines that contain a URL
                                                          • +
                                                          + +

                                                          code

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "code": 80 } option:

                                                          + +
                                                          /*eslint max-len: ["error", 80]*/

                                                          var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "code": 80 } option:

                                                          + +
                                                          /*eslint max-len: ["error", 80]*/

                                                          var foo = {
                                                          "bar": "This is a bar.",
                                                          "baz": { "qux": "This is a qux" },
                                                          "easier": "to read"
                                                          };
                                                          +
                                                          + +

                                                          tabWidth

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "tabWidth": 4 } option:

                                                          + +
                                                          /*eslint max-len: ["error", 80, 4]*/

                                                          \t \t var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" } };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "tabWidth": 4 } option:

                                                          + +
                                                          /*eslint max-len: ["error", 80, 4]*/

                                                          \t \t var foo = {
                                                          \t \t \t \t "bar": "This is a bar.",
                                                          \t \t \t \t "baz": { "qux": "This is a qux" }
                                                          \t \t };
                                                          +
                                                          + +

                                                          comments

                                                          + +

                                                          Examples of incorrect code for this rule with the { "comments": 65 } option:

                                                          + +
                                                          /*eslint max-len: ["error", { "comments": 65 }]*/

                                                          /**
                                                          * This is a comment that violates the maximum line length we have specified
                                                          **/

                                                          +
                                                          + +

                                                          ignoreComments

                                                          + +

                                                          Examples of correct code for this rule with the { "ignoreComments": true } option:

                                                          + +
                                                          /*eslint max-len: ["error", { "ignoreComments": true }]*/

                                                          /**
                                                          * This is a really really really really really really really really really long comment
                                                          **/

                                                          +
                                                          + +

                                                          ignoreTrailingComments

                                                          + +

                                                          Examples of correct code for this rule with the { "ignoreTrailingComments": true } option:

                                                          + +
                                                          /*eslint max-len: ["error", { "ignoreTrailingComments": true }]*/

                                                          var foo = 'bar'; // This is a really really really really really really really long comment
                                                          +
                                                          + +

                                                          ignoreUrls

                                                          + +

                                                          Examples of correct code for this rule with the { "ignoreUrls": true } option:

                                                          + +
                                                          /*eslint max-len: ["error", { "ignoreUrls": true }]*/

                                                          var url = 'https://www.example.com/really/really/really/really/really/really/really/long';
                                                          +
                                                          + +

                                                          ignorePattern

                                                          + +

                                                          Examples of correct code for this rule with the { "ignorePattern": true } option:

                                                          + +
                                                          /*eslint max-len: ["error", { "ignorePattern": "^\\s*var\\s.+=\\s*require\\s*\\(/" }]*/

                                                          var dep = require('really/really/really/really/really/really/really/really/long/module');
                                                          +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/max-nested-callbacks.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/max-nested-callbacks.html new file mode 100644 index 0000000..5480498 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/max-nested-callbacks.html @@ -0,0 +1,66 @@ + + + +

                                                          enforce a maximum depth that callbacks can be nested (max-nested-callbacks)

                                                          + +

                                                          Many JavaScript libraries use the callback pattern to manage asynchronous operations. A program of any complexity will most likely need to manage several asynchronous operations at various levels of concurrency. A common pitfall that is easy to fall into is nesting callbacks, which makes code more difficult to read the deeper the callbacks are nested.

                                                          + +
                                                          foo(function () {
                                                          bar(function () {
                                                          baz(function() {
                                                          qux(function () {

                                                          });
                                                          });
                                                          });
                                                          });
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces a maximum depth that callbacks can be nested to increase code clarity.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a number or object option:

                                                          + +
                                                            +
                                                          • "max" (default 10) enforces a maximum depth that callbacks can be nested
                                                          • +
                                                          + +

                                                          Deprecated: The object property maximum is deprecated; please use the object property max instead.

                                                          + +

                                                          max

                                                          + +

                                                          Examples of incorrect code for this rule with the { "max": 3 } option:

                                                          + +
                                                          /*eslint max-nested-callbacks: ["error", 3]*/

                                                          foo1(function() {
                                                          foo2(function() {
                                                          foo3(function() {
                                                          foo4(function() {
                                                          // Do something
                                                          });
                                                          });
                                                          });
                                                          });
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "max": 3 } option:

                                                          + +
                                                          /*eslint max-nested-callbacks: ["error", 3]*/

                                                          foo1(handleFoo1);

                                                          function handleFoo1() {
                                                          foo2(handleFoo2);
                                                          }

                                                          function handleFoo2() {
                                                          foo3(handleFoo3);
                                                          }

                                                          function handleFoo3() {
                                                          foo4(handleFoo4);
                                                          }

                                                          function handleFoo4() {
                                                          foo5();
                                                          }
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.2.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/max-params.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/max-params.html new file mode 100644 index 0000000..4fd3f64 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/max-params.html @@ -0,0 +1,58 @@ + + + +

                                                          enforce a maximum number of parameters in function definitions (max-params)

                                                          + +

                                                          Functions that take numerous parameters can be difficult to read and write because it requires the memorization of what each parameter is, its type, and the order they should appear in. As a result, many coders adhere to a convention that caps the number of parameters a function can take.

                                                          + +
                                                          function foo (bar, baz, qux, qxx) { // four parameters, may be too many
                                                          doSomething();
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces a maximum number of parameters allowed in function definitions.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a number or object option:

                                                          + +
                                                            +
                                                          • "max" (default 3) enforces a maximum number of parameters in function definitions
                                                          • +
                                                          + +

                                                          Deprecated: The object property maximum is deprecated; please use the object property max instead.

                                                          + +

                                                          max

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "max": 3 } option:

                                                          + +
                                                          /*eslint max-params: ["error", 3]*/
                                                          /*eslint-env es6*/

                                                          function foo (bar, baz, qux, qxx) {
                                                          doSomething();
                                                          }

                                                          let foo = (bar, baz, qux, qxx) => {
                                                          doSomething();
                                                          };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "max": 4 } option:

                                                          + +
                                                          /*eslint max-params: ["error", 3]*/
                                                          /*eslint-env es6*/

                                                          function foo (bar, baz, qux) {
                                                          doSomething();
                                                          }

                                                          let foo = (bar, baz, qux) => {
                                                          doSomething();
                                                          };
                                                          +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/max-statements-per-line.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/max-statements-per-line.html new file mode 100644 index 0000000..0202b6e --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/max-statements-per-line.html @@ -0,0 +1,66 @@ + + + +

                                                          enforce a maximum number of statements allowed per line (max-statements-per-line)

                                                          + +

                                                          A line of code containing too many statements can be difficult to read. Code is generally read from the top down, especially when scanning, so limiting the number of statements allowed on a single line can be very beneficial for readability and maintainability.

                                                          + +
                                                          function () { var bar; if (condition) { bar = 1; } else { bar = 2; } return true; } // too many statements
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces a maximum number of statements allowed per line.

                                                          + +

                                                          Options

                                                          + +

                                                          max

                                                          + +

                                                          The “max” object property is optional (default: 1).

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "max": 1 } option:

                                                          + +
                                                          /*eslint max-statements-per-line: ["error", { "max": 1 }]*/

                                                          var bar; var baz;
                                                          if (condition) { bar = 1; }
                                                          for (var i = 0; i < length; ++i) { bar = 1; }
                                                          switch (discriminant) { default: break; }
                                                          function foo() { bar = 1; }
                                                          var foo = function foo() { bar = 1; };
                                                          (function foo() { bar = 1; })();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "max": 1 } option:

                                                          + +
                                                          /*eslint max-statements-per-line: ["error", { "max": 1 }]*/

                                                          var bar, baz;
                                                          if (condition) bar = 1;
                                                          for (var i = 0; i < length; ++i);
                                                          switch (discriminant) { default: }
                                                          function foo() { }
                                                          var foo = function foo() { };
                                                          (function foo() { })();
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with the { "max": 2 } option:

                                                          + +
                                                          /*eslint max-statements-per-line: ["error", { "max": 2 }]*/

                                                          var bar; var baz; var qux;
                                                          if (condition) { bar = 1; } else { baz = 2; }
                                                          for (var i = 0; i < length; ++i) { bar = 1; baz = 2; }
                                                          switch (discriminant) { case 'test': break; default: break; }
                                                          function foo() { bar = 1; baz = 2; }
                                                          var foo = function foo() { bar = 1; };
                                                          (function foo() { bar = 1; baz = 2; })();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "max": 2 } option:

                                                          + +
                                                          /*eslint max-statements-per-line: ["error", { "max": 2 }]*/

                                                          var bar; var baz;
                                                          if (condition) bar = 1; if (condition) baz = 2;
                                                          for (var i = 0; i < length; ++i) { bar = 1; }
                                                          switch (discriminant) { default: break; }
                                                          function foo() { bar = 1; }
                                                          var foo = function foo() { bar = 1; };
                                                          (function foo() { var bar = 1; })();
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with the number of statements on each line.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.5.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/max-statements.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/max-statements.html new file mode 100644 index 0000000..abe97d6 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/max-statements.html @@ -0,0 +1,71 @@ + + + +

                                                          enforce a maximum number of statements allowed in function blocks (max-statements)

                                                          + +

                                                          The max-statements rule allows you to specify the maximum number of statements allowed in a function.

                                                          + +
                                                          function foo() {
                                                          var bar = 1; // one statement
                                                          var baz = 2; // two statements
                                                          var qux = 3; // three statements
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces a maximum number of statements allowed in function blocks.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a number or object option:

                                                          + +
                                                            +
                                                          • "max" (default 10) enforces a maximum number of statements allows in function blocks
                                                          • +
                                                          + +

                                                          Deprecated: The object property maximum is deprecated; please use the object property max instead.

                                                          + +

                                                          This rule has an object option:

                                                          + +
                                                            +
                                                          • "ignoreTopLevelFunctions": true ignores top-level functions
                                                          • +
                                                          + +

                                                          max

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "max": 10 } option:

                                                          + +
                                                          /*eslint max-statements: ["error", 10]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          var foo1 = 1;
                                                          var foo2 = 2;
                                                          var foo3 = 3;
                                                          var foo4 = 4;
                                                          var foo5 = 5;
                                                          var foo6 = 6;
                                                          var foo7 = 7;
                                                          var foo8 = 8;
                                                          var foo9 = 9;
                                                          var foo10 = 10;

                                                          var foo11 = 11; // Too many.
                                                          }

                                                          let foo = () => {
                                                          var foo1 = 1;
                                                          var foo2 = 2;
                                                          var foo3 = 3;
                                                          var foo4 = 4;
                                                          var foo5 = 5;
                                                          var foo6 = 6;
                                                          var foo7 = 7;
                                                          var foo8 = 8;
                                                          var foo9 = 9;
                                                          var foo10 = 10;

                                                          var foo11 = 11; // Too many.
                                                          };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "max": 10 } option:

                                                          + +
                                                          /*eslint max-statements: ["error", 10]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          var foo1 = 1;
                                                          var foo2 = 2;
                                                          var foo3 = 3;
                                                          var foo4 = 4;
                                                          var foo5 = 5;
                                                          var foo6 = 6;
                                                          var foo7 = 7;
                                                          var foo8 = 8;
                                                          var foo9 = 9;
                                                          var foo10 = 10;
                                                          return function () {

                                                          // The number of statements in the inner function does not count toward the
                                                          // statement maximum.

                                                          return 42;
                                                          };
                                                          }

                                                          let foo = () => {
                                                          var foo1 = 1;
                                                          var foo2 = 2;
                                                          var foo3 = 3;
                                                          var foo4 = 4;
                                                          var foo5 = 5;
                                                          var foo6 = 6;
                                                          var foo7 = 7;
                                                          var foo8 = 8;
                                                          var foo9 = 9;
                                                          var foo10 = 10;
                                                          return function () {

                                                          // The number of statements in the inner function does not count toward the
                                                          // statement maximum.

                                                          return 42;
                                                          };
                                                          }
                                                          +
                                                          + +

                                                          ignoreTopLevelFunctions

                                                          + +

                                                          Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

                                                          + +
                                                          /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/

                                                          function foo() {
                                                          var foo1 = 1;
                                                          var foo2 = 2;
                                                          var foo3 = 3;
                                                          var foo4 = 4;
                                                          var foo5 = 5;
                                                          var foo6 = 6;
                                                          var foo7 = 7;
                                                          var foo8 = 8;
                                                          var foo9 = 9;
                                                          var foo10 = 10;
                                                          var foo11 = 11;
                                                          }
                                                          +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/new-cap.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/new-cap.html new file mode 100644 index 0000000..9df5139 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/new-cap.html @@ -0,0 +1,128 @@ + + + +

                                                          require constructor function names to begin with a capital letter (new-cap)

                                                          + +

                                                          The new operator in JavaScript creates a new instance of a particular type of object. That type of object is represented by a constructor function. Since constructor functions are just regular functions, the only defining characteristic is that new is being used as part of the call. Native JavaScript functions begin with an uppercase letter to distinguish those functions that are to be used as constructors from functions that are not. Many style guides recommend following this pattern to more easily determine which functions are to be used as constructors.

                                                          + +
                                                          var friend = new Person();
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule requires constructor names to begin with a capital letter. Certain built-in identifiers are exempt from this rule. These identifiers are:

                                                          + +
                                                            +
                                                          • Array
                                                          • +
                                                          • Boolean
                                                          • +
                                                          • Date
                                                          • +
                                                          • Error
                                                          • +
                                                          • Function
                                                          • +
                                                          • Number
                                                          • +
                                                          • Object
                                                          • +
                                                          • RegExp
                                                          • +
                                                          • String
                                                          • +
                                                          • Symbol
                                                          • +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint new-cap: "error"*/

                                                          function foo(arg) {
                                                          return Boolean(arg);
                                                          }
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an object option:

                                                          + +
                                                            +
                                                          • "newIsCap": true (default) requires all new operators to be called with uppercase-started functions.
                                                          • +
                                                          • "newIsCap": false allows new operators to be called with lowercase-started or uppercase-started functions.
                                                          • +
                                                          • "capIsNew": true (default) requires all uppercase-started functions to be called with new operators.
                                                          • +
                                                          • "capIsNew": false allows uppercase-started functions to be called without new operators.
                                                          • +
                                                          • "newIsCapExceptions" allows specified lowercase-started function names to be called with the new operator.
                                                          • +
                                                          • "capIsNewExceptions" allows specified uppercase-started function names to be called without the new operator.
                                                          • +
                                                          • "properties": true (default) enables checks on object properties
                                                          • +
                                                          • "properties": false disables checks on object properties
                                                          • +
                                                          + +

                                                          newIsCap

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "newIsCap": true } option:

                                                          + +
                                                          /*eslint new-cap: ["error", { "newIsCap": true }]*/

                                                          var friend = new person();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "newIsCap": true } option:

                                                          + +
                                                          /*eslint new-cap: ["error", { "newIsCap": true }]*/

                                                          var friend = new Person();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "newIsCap": false } option:

                                                          + +
                                                          /*eslint new-cap: ["error", { "newIsCap": false }]*/

                                                          var friend = new person();
                                                          +
                                                          + +

                                                          capIsNew

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "capIsNew": true } option:

                                                          + +
                                                          /*eslint new-cap: ["error", { "capIsNew": true }]*/

                                                          var colleague = Person();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "capIsNew": true } option:

                                                          + +
                                                          /*eslint new-cap: ["error", { "capIsNew": true }]*/

                                                          var colleague = new Person();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "capIsNew": false } option:

                                                          + +
                                                          /*eslint new-cap: ["error", { "capIsNew": false }]*/

                                                          var colleague = Person();
                                                          +
                                                          + +

                                                          newIsCapExceptions

                                                          + +

                                                          Examples of additional correct code for this rule with the { "newIsCapExceptions": ["events"] } option:

                                                          + +
                                                          /*eslint new-cap: ["error", { "newIsCapExceptions": ["events"] }]*/

                                                          var events = require('events');

                                                          var emitter = new events();
                                                          +
                                                          + +

                                                          capIsNewExceptions

                                                          + +

                                                          Examples of additional correct code for this rule with the { "capIsNewExceptions": ["Person"] } option:

                                                          + +
                                                          /*eslint new-cap: ["error", { "capIsNewExceptions": ["Person"] }]*/

                                                          function foo(arg) {
                                                          return Person(arg);
                                                          }
                                                          +
                                                          + +

                                                          properties

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "properties": true } option:

                                                          + +
                                                          /*eslint new-cap: ["error", { "properties": true }]*/

                                                          var friend = new person.acquaintance();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "properties": true } option:

                                                          + +
                                                          /*eslint new-cap: ["error", { "properties": true }]*/

                                                          var friend = new person.Acquaintance();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "properties": false } option:

                                                          + +
                                                          /*eslint new-cap: ["error", { "properties": false }]*/

                                                          var friend = new person.acquaintance();
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you have conventions that don’t require an uppercase letter for constructors, or don’t require capitalized functions be only used as constructors, turn this rule off.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.3-0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/new-parens.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/new-parens.html new file mode 100644 index 0000000..4a92c9e --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/new-parens.html @@ -0,0 +1,36 @@ + + + +

                                                          require parentheses when invoking a constructor with no arguments (new-parens)

                                                          + +

                                                          JavaScript allows the omission of parentheses when invoking a function via the new keyword and the constructor has no arguments. However, some coders believe that omitting the parentheses is inconsistent with the rest of the language and thus makes code less clear.

                                                          + +
                                                          var person = new Person;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule requires parentheses when invoking a constructor with no arguments using the new keyword in order to increase code clarity.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint new-parens: "error"*/

                                                          var person = new Person;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint new-parens: "error"*/

                                                          var person = new Person();
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.6.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/newline-after-var.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/newline-after-var.html new file mode 100644 index 0000000..2661931 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/newline-after-var.html @@ -0,0 +1,72 @@ + + + +

                                                          require or disallow an empty line after var declarations (newline-after-var)

                                                          + +

                                                          As of today there is no consistency in separating variable declarations from the rest of the code. Some developers leave an empty line between var statements and the rest of the code like:

                                                          + +
                                                          var foo;

                                                          // do something with foo
                                                          +
                                                          + +

                                                          Whereas others don’t leave any empty newlines at all.

                                                          + +
                                                          var foo;
                                                          // do something with foo
                                                          +
                                                          + +

                                                          The problem is when these developers work together in a project. This rule enforces a coding style where empty newlines are allowed or disallowed after var, let, or const statements. It helps the code to look consistent across the entire project.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces a coding style where empty lines are required or disallowed after var, let, or const statements to achieve a consistent coding style across the project.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • +

                                                            "always" (default) requires an empty line after var, let, or const

                                                            + +

                                                            Comments on a line directly after var statements are treated like additional var statements.

                                                            +
                                                          • +
                                                          • +

                                                            "never" disallows empty lines after var, let, or const

                                                            +
                                                          • +
                                                          + +

                                                          always

                                                          + +

                                                          Examples of incorrect code for this rule with the default "always" option:

                                                          + +
                                                          /*eslint newline-after-var: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          var greet = "hello,",
                                                          name = "world";
                                                          console.log(greet, name);

                                                          let greet = "hello,",
                                                          name = "world";
                                                          console.log(greet, name);

                                                          var greet = "hello,";
                                                          const NAME = "world";
                                                          console.log(greet, NAME);

                                                          var greet = "hello,";
                                                          var name = "world";
                                                          // var name = require("world");
                                                          console.log(greet, name);
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "always" option:

                                                          + +
                                                          /*eslint newline-after-var: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          var greet = "hello,",
                                                          name = "world";

                                                          console.log(greet, name);

                                                          let greet = "hello,",
                                                          name = "world";

                                                          console.log(greet, name);

                                                          var greet = "hello,";
                                                          const NAME = "world";

                                                          console.log(greet, NAME);

                                                          var greet = "hello,";
                                                          var name = "world";
                                                          // var name = require("world");

                                                          console.log(greet, name);
                                                          +
                                                          + +

                                                          never

                                                          + +

                                                          Examples of incorrect code for this rule with the default "never" option:

                                                          + +
                                                          /*eslint newline-after-var: ["error", "never"]*/
                                                          /*eslint-env es6*/

                                                          var greet = "hello,",
                                                          name = "world";

                                                          console.log(greet, name);

                                                          let greet = "hello,",
                                                          name = "world";

                                                          console.log(greet, name);

                                                          var greet = "hello,";
                                                          const NAME = "world";

                                                          console.log(greet, NAME);

                                                          var greet = "hello,";
                                                          var name = "world";
                                                          // var name = require("world");

                                                          console.log(greet, name);
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "never" option:

                                                          + +
                                                          /*eslint newline-after-var: ["error", "never"]*/
                                                          /*eslint-env es6*/

                                                          var greet = "hello,",
                                                          name = "world";
                                                          console.log(greet, name);

                                                          let greet = "hello,",
                                                          name = "world";
                                                          console.log(greet, name);

                                                          var greet = "hello,";
                                                          const NAME = "world";
                                                          console.log(greet, NAME);

                                                          var greet = "hello,";
                                                          var name = "world";
                                                          // var name = require("world");
                                                          console.log(greet, name);
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.18.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/newline-before-return.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/newline-before-return.html new file mode 100644 index 0000000..0bf4dbd --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/newline-before-return.html @@ -0,0 +1,51 @@ + + + +

                                                          require an empty line before return statements (newline-before-return)

                                                          + +

                                                          There is no hardfast rule about whether empty lines should precede return statements in JavaScript. However, clearly delineating where a function is returning can greatly increase the readability and clarity of the code. For example:

                                                          + +
                                                          function foo(bar) {
                                                          var baz = 'baz';
                                                          if (!bar) {
                                                          bar = baz;
                                                          return bar;
                                                          }
                                                          return bar;
                                                          }
                                                          +
                                                          + +

                                                          Adding newlines visibly separates the return statements from the previous lines, making it clear where the function exits and what value it returns:

                                                          + +
                                                          function foo(bar) {
                                                          var baz = 'baz';

                                                          if (!bar) {
                                                          bar = baz;

                                                          return bar;
                                                          }

                                                          return bar;
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule requires an empty line before return statements to increase code clarity, except when the return is alone inside a statement group (such as an if statement). In the latter case, the return statement does not need to be delineated by virtue of it being alone. Comments are ignored and do not count as empty lines.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint newline-before-return: "error"*/

                                                          function foo() {

                                                          return;
                                                          }

                                                          function foo(bar) {
                                                          if (!bar) {

                                                          return;
                                                          }
                                                          }

                                                          function foo(bar) {
                                                          if (!bar) {
                                                          return;
                                                          }
                                                          return bar;
                                                          }

                                                          function foo() {

                                                          // comment
                                                          return;
                                                          }

                                                          function foo(bar) {
                                                          if (!bar) {
                                                          return;
                                                          }
                                                          /* multi-line
                                                          comment */

                                                          return bar;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint newline-before-return: "error"*/

                                                          function foo() {
                                                          return;
                                                          }

                                                          function foo(bar) {
                                                          if (!bar) return;
                                                          }

                                                          function foo(bar) {
                                                          if (!bar) { return };
                                                          }

                                                          function foo(bar) {
                                                          if (!bar) {
                                                          return;
                                                          }
                                                          }

                                                          function foo(bar) {
                                                          if (!bar) {
                                                          return;
                                                          }

                                                          return bar;
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can safely disable this rule if you do not have any strict conventions about whitespace before return statements.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.3.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/newline-per-chained-call.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/newline-per-chained-call.html new file mode 100644 index 0000000..df0bf0c --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/newline-per-chained-call.html @@ -0,0 +1,69 @@ + + + +

                                                          require a newline after each call in a method chain (newline-per-chained-call)

                                                          + +

                                                          Chained method calls on a single line without line breaks are harder to read, so some developers place a newline character after each method call in the chain to make it more readable and easy to maintain.

                                                          + +

                                                          Let’s look at the following perfectly valid (but single line) code.

                                                          + +
                                                          d3.select("body").selectAll("p").data([4, 8, 15, 16, 23, 42 ]).enter().append("p").text(function(d) { return "I'm number " + d + "!"; });
                                                          +
                                                          + +

                                                          However, with appropriate new lines, it becomes easy to read and understand. Look at the same code written below with line breaks after each call.

                                                          + +
                                                          d3
                                                          .select("body")
                                                          .selectAll("p")
                                                          .data([
                                                          4,
                                                          8,
                                                          15,
                                                          16,
                                                          23,
                                                          42
                                                          ])
                                                          .enter()
                                                          .append("p")
                                                          .text(function (d) {
                                                          return "I'm number " + d + "!";
                                                          });
                                                          +
                                                          + +

                                                          Another argument in favor of this style is that it improves the clarity of diffs when something in the method chain is changed:

                                                          + +

                                                          Less clear:

                                                          + +
                                                          -d3.select("body").selectAll("p").style("color", "white");
                                                          +d3.select("body").selectAll("p").style("color", "blue");
                                                          +
                                                          + +

                                                          More clear:

                                                          + +
                                                          d3
                                                          .select("body")
                                                          .selectAll("p")
                                                          - .style("color", "white");
                                                          + .style("color", "blue");
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule requires a newline after each call in a method chain or deep member access. Computed property accesses such as instance[something] are excluded.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an object option:

                                                          + +
                                                            +
                                                          • "ignoreChainWithDepth" (default: 2) allows chains up to a specified depth.
                                                          • +
                                                          + +

                                                          ignoreChainWithDepth

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "ignoreChainWithDepth": 2 } option:

                                                          + +
                                                          /*eslint newline-per-chained-call: ["error", { "ignoreChainWithDepth": 2 }]*/

                                                          _.chain({}).map(foo).filter(bar).value();

                                                          // Or
                                                          _.chain({}).map(foo).filter(bar);

                                                          // Or
                                                          _
                                                          .chain({}).map(foo)
                                                          .filter(bar);

                                                          // Or
                                                          obj.method().method2().method3();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "ignoreChainWithDepth": 2 } option:

                                                          + +
                                                          /*eslint newline-per-chained-call: ["error", { "ignoreChainWithDepth": 2 }]*/

                                                          _
                                                          .chain({})
                                                          .map(foo)
                                                          .filter(bar)
                                                          .value();

                                                          // Or
                                                          _
                                                          .chain({})
                                                          .map(foo)
                                                          .filter(bar);

                                                          // Or
                                                          _.chain({})
                                                          .map(foo)
                                                          .filter(bar);

                                                          // Or
                                                          obj
                                                          .prop
                                                          .method().prop;

                                                          // Or
                                                          obj
                                                          .prop.method()
                                                          .method2()
                                                          .method3().prop;
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you have conflicting rules or when you are fine with chained calls on one line, you can safely turn this rule off.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-rc.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-alert.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-alert.html new file mode 100644 index 0000000..9aa485b --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-alert.html @@ -0,0 +1,43 @@ + + + +

                                                          Disallow Use of Alert (no-alert)

                                                          + +

                                                          JavaScripts’ alert, confirm, and prompt functions are widely considered to be obtrusive as UI elements and should be replaced by a more appropriate custom UI implementation. Furthermore, alert is often used while debugging code, which should be removed before deployment to production.

                                                          + +
                                                          alert("here!");
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at catching debugging code that should be removed and popup UI elements that should be replaced with less obtrusive, custom UIs. As such, it will warn when it encounters alert, prompt, and confirm function calls which are not shadowed.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-alert: "error"*/

                                                          alert("here!");

                                                          confirm("Are you sure?");

                                                          prompt("What's your name?", "John Doe");
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-alert: "error"*/

                                                          customAlert("Something happened!");

                                                          customConfirm("Are you sure?");

                                                          customPrompt("Who are you?");

                                                          function foo() {
                                                          var alert = myCustomLib.customAlert;
                                                          alert();
                                                          }
                                                          +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.5.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-array-constructor.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-array-constructor.html new file mode 100644 index 0000000..9abca21 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-array-constructor.html @@ -0,0 +1,55 @@ + + + +

                                                          disallow Array constructors (no-array-constructor)

                                                          + +

                                                          Use of the Array constructor to construct a new array is generally +discouraged in favour of array literal notation because of the single-argument +pitfall and because the Array global may be redefined. The exception is when +the Array constructor is used to intentionally create sparse arrays of a +specified size by giving the constructor a single numeric argument.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows Array constructors.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-array-constructor: "error"*/

                                                          Array(0, 1, 2)
                                                          +
                                                          + +
                                                          /*eslint no-array-constructor: "error"*/

                                                          new Array(0, 1, 2)
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-array-constructor: "error"*/

                                                          Array(500)
                                                          +
                                                          + +
                                                          /*eslint no-array-constructor: "error"*/

                                                          new Array(someOtherArray.length)
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          This rule enforces a nearly universal stylistic concern. That being said, this +rule may be disabled if the constructor style is preferred.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-bitwise.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-bitwise.html new file mode 100644 index 0000000..0b990fe --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-bitwise.html @@ -0,0 +1,59 @@ + + + +

                                                          disallow bitwise operators (no-bitwise)

                                                          + +

                                                          The use of bitwise operators in JavaScript is very rare and often & or | is simply a mistyped && or ||, which will lead to unexpected behavior.

                                                          + +
                                                          var x = y | z;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows bitwise operators.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-bitwise: "error"*/

                                                          var x = y | z;

                                                          var x = y & z;

                                                          var x = y ^ z;

                                                          var x = ~ z;

                                                          var x = y << z;

                                                          var x = y >> z;

                                                          var x = y >>> z;

                                                          x |= y;

                                                          x &= y;

                                                          x ^= y;

                                                          x <<= y;

                                                          x >>= y;

                                                          x >>>= y;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-bitwise: "error"*/

                                                          var x = y || z;

                                                          var x = y && z;

                                                          var x = y > z;

                                                          var x = y < z;

                                                          x += y;
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an object option:

                                                          + +
                                                            +
                                                          • "allow": Allows a list of bitwise operators to be used as exceptions.
                                                          • +
                                                          • "int32Hint": Allows the use of bitwise OR in |0 pattern for type casting.
                                                          • +
                                                          + +

                                                          allow

                                                          + +

                                                          Examples of correct code for this rule with the { "allow": ["~"] } option:

                                                          + +
                                                          /*eslint no-bitwise: ["error", { "allow": ["~"] }] */

                                                          ~[1,2,3].indexOf(1) === -1;
                                                          +
                                                          + +

                                                          int32Hint

                                                          + +

                                                          Examples of correct code for this rule with the { "int32Hint": true } option:

                                                          + +
                                                          /*eslint no-bitwise: ["error", { "int32Hint": true }] */

                                                          var b = a|0;
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-caller.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-caller.html new file mode 100644 index 0000000..7ae3988 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-caller.html @@ -0,0 +1,36 @@ + + + +

                                                          Disallow Use of caller/callee (no-caller)

                                                          + +

                                                          The use of arguments.caller and arguments.callee make several code optimizations impossible. They have been deprecated in future versions of JavaScript and their use is forbidden in ECMAScript 5 while in strict mode.

                                                          + +
                                                          function foo() {
                                                          var callee = arguments.callee;
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at discouraging the use of deprecated and sub-optimal code, but disallowing the use of arguments.caller and arguments.callee. As such, it will warn when arguments.caller and arguments.callee are used.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-caller: "error"*/

                                                          function foo(n) {
                                                          if (n <= 0) {
                                                          return;
                                                          }

                                                          arguments.callee(n - 1);
                                                          }

                                                          [1,2,3,4,5].map(function(n) {
                                                          return !(n > 1) ? 1 : arguments.callee(n - 1) * n;
                                                          });
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-caller: "error"*/

                                                          function foo(n) {
                                                          if (n <= 0) {
                                                          return;
                                                          }

                                                          foo(n - 1);
                                                          }

                                                          [1,2,3,4,5].map(function factorial(n) {
                                                          return !(n > 1) ? 1 : factorial(n - 1) * n;
                                                          });
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.6.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-case-declarations.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-case-declarations.html new file mode 100644 index 0000000..b4f03fc --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-case-declarations.html @@ -0,0 +1,49 @@ + + + +

                                                          Disallow lexical declarations in case/default clauses (no-case-declarations)

                                                          + +

                                                          This rule disallows lexical declarations (let, const, function and class) +in case/default clauses. The reason is that the lexical declaration is visible +in the entire switch block but it only gets initialized when it is assigned, which +will only happen if the case where it is defined is reached.

                                                          + +

                                                          To ensure that the lexical declaration only applies to the current case clause +wrap your clauses in blocks.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to prevent access to uninitialized lexical bindings as well as accessing hoisted functions across case clauses.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-case-declarations: "error"*/
                                                          /*eslint-env es6*/

                                                          switch (foo) {
                                                          case 1:
                                                          let x = 1;
                                                          break;
                                                          case 2:
                                                          const y = 2;
                                                          break;
                                                          case 3:
                                                          function f() {}
                                                          break;
                                                          default:
                                                          class C {}
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-case-declarations: "error"*/
                                                          /*eslint-env es6*/

                                                          switch (foo) {
                                                          case 1: {
                                                          let x = 1;
                                                          break;
                                                          }
                                                          case 2: {
                                                          const y = 2;
                                                          break;
                                                          }
                                                          case 3: {
                                                          function f() {}
                                                          break;
                                                          }
                                                          default: {
                                                          class C {}
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you depend on fall through behavior and want access to bindings introduced in the case block.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.9.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-catch-shadow.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-catch-shadow.html new file mode 100644 index 0000000..7348346 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-catch-shadow.html @@ -0,0 +1,40 @@ + + + +

                                                          Disallow Shadowing of Variables Inside of catch (no-catch-shadow)

                                                          + +

                                                          In IE 8 and earlier, the catch clause parameter can overwrite the value of a variable in the outer scope, if that variable has the same name as the catch clause parameter.

                                                          + +
                                                          var err = "x";

                                                          try {
                                                          throw "problem";
                                                          } catch (err) {

                                                          }

                                                          console.log(err) // err is 'problem', not 'x'
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at preventing unexpected behavior in your program that may arise from a bug in IE 8 and earlier, in which the catch clause parameter can leak into outer scopes. This rule will warn whenever it encounters a catch clause parameter that has the same name as a variable in an outer scope.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-catch-shadow: "error"*/

                                                          var err = "x";

                                                          try {
                                                          throw "problem";
                                                          } catch (err) {

                                                          }

                                                          function err() {
                                                          // ...
                                                          };

                                                          try {
                                                          throw "problem";
                                                          } catch (err) {

                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-catch-shadow: "error"*/

                                                          var err = "x";

                                                          try {
                                                          throw "problem";
                                                          } catch (e) {

                                                          }

                                                          function err() {
                                                          // ...
                                                          };

                                                          try {
                                                          throw "problem";
                                                          } catch (e) {

                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you do not need to support IE 8 and earlier, you should turn this rule off.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-class-assign.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-class-assign.html new file mode 100644 index 0000000..bc8677e --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-class-assign.html @@ -0,0 +1,57 @@ + + + +

                                                          Disallow modifying variables of class declarations (no-class-assign)

                                                          + +

                                                          ClassDeclaration creates a variable, and we can modify the variable.

                                                          + +
                                                          /*eslint-env es6*/

                                                          class A { }
                                                          A = 0;
                                                          +
                                                          + +

                                                          But the modification is a mistake in most cases.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed to flag modifying variables of class declarations.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-class-assign: "error"*/
                                                          /*eslint-env es6*/

                                                          class A { }
                                                          A = 0;
                                                          +
                                                          + +
                                                          /*eslint no-class-assign: "error"*/
                                                          /*eslint-env es6*/

                                                          A = 0;
                                                          class A { }
                                                          +
                                                          + +
                                                          /*eslint no-class-assign: "error"*/
                                                          /*eslint-env es6*/

                                                          class A {
                                                          b() {
                                                          A = 0;
                                                          }
                                                          }
                                                          +
                                                          + +
                                                          /*eslint no-class-assign: "error"*/
                                                          /*eslint-env es6*/

                                                          let A = class A {
                                                          b() {
                                                          A = 0;
                                                          // `let A` is shadowed by the class name.
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-class-assign: "error"*/
                                                          /*eslint-env es6*/

                                                          let A = class A { }
                                                          A = 0; // A is a variable.
                                                          +
                                                          + +
                                                          /*eslint no-class-assign: "error"*/
                                                          /*eslint-env es6*/

                                                          let A = class {
                                                          b() {
                                                          A = 0; // A is a variable.
                                                          }
                                                          }
                                                          +
                                                          + +
                                                          /*eslint no-class-assign: 2*/
                                                          /*eslint-env es6*/

                                                          class A {
                                                          b(A) {
                                                          A = 0; // A is a parameter.
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about modifying variables of class declarations, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0-rc-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-cond-assign.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-cond-assign.html new file mode 100644 index 0000000..60e1e91 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-cond-assign.html @@ -0,0 +1,73 @@ + + + +

                                                          disallow assignment operators in conditional statements (no-cond-assign)

                                                          + +

                                                          In conditional statements, it is very easy to mistype a comparison operator (such as ==) as an assignment operator (such as =). For example:

                                                          + +
                                                          // Check the user's job title
                                                          if (user.jobTitle = "manager") {
                                                          // user.jobTitle is now incorrect
                                                          }
                                                          +
                                                          + +

                                                          There are valid reasons to use assignment operators in conditional statements. However, it can be difficult to tell whether a specific assignment was intentional.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows ambiguous assignment operators in test conditions of if, for, while, and do...while statements.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • "except-parens" (default) allows assignments in test conditions only if they are enclosed in parentheses (for example, to allow reassigning a variable in the test of a while or do...while loop)
                                                          • +
                                                          • "always" disallows all assignments in test conditions
                                                          • +
                                                          + +

                                                          except-parens

                                                          + +

                                                          Examples of incorrect code for this rule with the default "except-parens" option:

                                                          + +
                                                          /*eslint no-cond-assign: "error"*/

                                                          // Unintentional assignment
                                                          var x;
                                                          if (x = 0) {
                                                          var b = 1;
                                                          }

                                                          // Practical example that is similar to an error
                                                          function setHeight(someNode) {
                                                          "use strict";
                                                          do {
                                                          someNode.height = "100px";
                                                          } while (someNode = someNode.parentNode);
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "except-parens" option:

                                                          + +
                                                          /*eslint no-cond-assign: "error"*/

                                                          // Assignment replaced by comparison
                                                          var x;
                                                          if (x === 0) {
                                                          var b = 1;
                                                          }

                                                          // Practical example that wraps the assignment in parentheses
                                                          function setHeight(someNode) {
                                                          "use strict";
                                                          do {
                                                          someNode.height = "100px";
                                                          } while ((someNode = someNode.parentNode));
                                                          }

                                                          // Practical example that wraps the assignment and tests for 'null'
                                                          function setHeight(someNode) {
                                                          "use strict";
                                                          do {
                                                          someNode.height = "100px";
                                                          } while ((someNode = someNode.parentNode) !== null);
                                                          }
                                                          +
                                                          + +

                                                          always

                                                          + +

                                                          Examples of incorrect code for this rule with the "always" option:

                                                          + +
                                                          /*eslint no-cond-assign: ["error", "always"]*/

                                                          // Unintentional assignment
                                                          var x;
                                                          if (x = 0) {
                                                          var b = 1;
                                                          }

                                                          // Practical example that is similar to an error
                                                          function setHeight(someNode) {
                                                          "use strict";
                                                          do {
                                                          someNode.height = "100px";
                                                          } while (someNode = someNode.parentNode);
                                                          }

                                                          // Practical example that wraps the assignment in parentheses
                                                          function setHeight(someNode) {
                                                          "use strict";
                                                          do {
                                                          someNode.height = "100px";
                                                          } while ((someNode = someNode.parentNode));
                                                          }

                                                          // Practical example that wraps the assignment and tests for 'null'
                                                          function setHeight(someNode) {
                                                          "use strict";
                                                          do {
                                                          someNode.height = "100px";
                                                          } while ((someNode = someNode.parentNode) !== null);
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "always" option:

                                                          + +
                                                          /*eslint no-cond-assign: ["error", "always"]*/

                                                          // Assignment replaced by comparison
                                                          var x;
                                                          if (x === 0) {
                                                          var b = 1;
                                                          }
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-confusing-arrow.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-confusing-arrow.html new file mode 100644 index 0000000..9c40cce --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-confusing-arrow.html @@ -0,0 +1,62 @@ + + + +

                                                          Disallow arrow functions where they could be confused with comparisons (no-confusing-arrow)

                                                          + +

                                                          Arrow functions (=>) are similar in syntax to some comparison operators (>, <, <=, and >=). This rule warns against using the arrow function syntax in places where it could be confused with a comparison operator. Even if the arguments of the arrow function are wrapped with parens, this rule still warns about it unless allowParens is set to true.

                                                          + +

                                                          Here’s an example where the usage of => could be confusing:

                                                          + +
                                                          // The intent is not clear
                                                          var x = a => 1 ? 2 : 3;
                                                          // Did the author mean this
                                                          var x = function (a) { return 1 ? 2 : 3 };
                                                          // Or this
                                                          var x = a <= 1 ? 2 : 3;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          The following patterns are considered warnings:

                                                          + +
                                                          /*eslint no-confusing-arrow: "error"*/
                                                          /*eslint-env es6*/

                                                          var x = a => 1 ? 2 : 3;
                                                          var x = (a) => 1 ? 2 : 3;
                                                          var x = (a) => (1 ? 2 : 3);
                                                          +
                                                          + +

                                                          The following patterns are not considered warnings:

                                                          + +
                                                          /*eslint no-confusing-arrow: "error"*/
                                                          /*eslint-env es6*/

                                                          var x = a => { return 1 ? 2 : 3; };
                                                          var x = (a) => { return 1 ? 2 : 3; };
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule accepts a single options argument with the following defaults:

                                                          + +
                                                          {
                                                          "rules": {
                                                          "no-confusing-arrow": ["error", {"allowParens": false}]
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          allowParens is a boolean setting that can be true or false:

                                                          + +
                                                            +
                                                          1. true relaxes the rule and accepts parenthesis as a valid “confusion-preventing” syntax.
                                                          2. +
                                                          3. false warns even if the expression is wrapped in parenthesis
                                                          4. +
                                                          + +

                                                          When allowParens is set to true following patterns are no longer considered as warnings:

                                                          + +
                                                          /*eslint no-confusing-arrow: ["error", {allowParens: true}]*/
                                                          /*eslint-env es6*/
                                                          var x = a => (1 ? 2 : 3);
                                                          var x = (a) => (1 ? 2 : 3);
                                                          +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-alpha-2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-console.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-console.html new file mode 100644 index 0000000..b7b5589 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-console.html @@ -0,0 +1,60 @@ + + + +

                                                          disallow the use of console (no-console)

                                                          + +

                                                          In JavaScript that is designed to be executed in the browser, it’s considered a best practice to avoid using methods on console. Such messages are considered to be for debugging purposes and therefore not suitable to ship to the client. In general, calls using console should be stripped before being pushed to production.

                                                          + +
                                                          console.log("Made it here.");
                                                          console.error("That shouldn't have happened.");
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows calls to methods of the console object.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-console: "error"*/

                                                          console.log("Log a debug level message.");
                                                          console.warn("Log a warn level message.");
                                                          console.error("Log an error level message.");
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-console: "error"*/

                                                          // custom console
                                                          Console.log("Hello world!");
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an object option for exceptions:

                                                          + +
                                                            +
                                                          • "allow" has an array of strings which are allowed methods of the console object
                                                          • +
                                                          + +

                                                          Examples of additional correct code for this rule with a sample { "allow": ["warn", "error"] } option:

                                                          + +
                                                          /*eslint no-console: ["error", { allow: ["warn", "error"] }] */

                                                          console.warn("Log a warn level message.");
                                                          console.error("Log an error level message.");
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you’re using Node.js, however, console is used to output information to the user and so is not strictly used for debugging purposes. If you are developing for Node.js then you most likely do not want this rule enabled.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-const-assign.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-const-assign.html new file mode 100644 index 0000000..9b71263 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-const-assign.html @@ -0,0 +1,52 @@ + + + +

                                                          Disallow modifying variables that are declared using const (no-const-assign)

                                                          + +

                                                          We cannot modify variables that are declared using const keyword. +It will raise a runtime error.

                                                          + +

                                                          Under non ES2015 environment, it might be ignored merely.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed to flag modifying variables that are declared using const keyword.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-const-assign: "error"*/
                                                          /*eslint-env es6*/

                                                          const a = 0;
                                                          a = 1;
                                                          +
                                                          + +
                                                          /*eslint no-const-assign: "error"*/
                                                          /*eslint-env es6*/

                                                          const a = 0;
                                                          a += 1;
                                                          +
                                                          + +
                                                          /*eslint no-const-assign: "error"*/
                                                          /*eslint-env es6*/

                                                          const a = 0;
                                                          ++a;
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-const-assign: "error"*/
                                                          /*eslint-env es6*/

                                                          const a = 0;
                                                          console.log(a);
                                                          +
                                                          + +
                                                          /*eslint no-const-assign: "error"*/
                                                          /*eslint-env es6*/

                                                          for (const a in [1, 2, 3]) { // `a` is re-defined (not modified) on each loop step.
                                                          console.log(a);
                                                          }
                                                          +
                                                          + +
                                                          /*eslint no-const-assign: "error"*/
                                                          /*eslint-env es6*/

                                                          for (const a of [1, 2, 3]) { // `a` is re-defined (not modified) on each loop step.
                                                          console.log(a);
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about modifying variables that are declared using const keyword, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0-rc-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-constant-condition.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-constant-condition.html new file mode 100644 index 0000000..3500c38 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-constant-condition.html @@ -0,0 +1,41 @@ + + + +

                                                          disallow constant expressions in conditions (no-constant-condition)

                                                          + +

                                                          A constant expression (for example, a literal) as a test condition might be a typo or development trigger for a specific behavior. For example, the following code looks as if it is not ready for production.

                                                          + +
                                                          if (false) {
                                                          doSomethingUnfinished();
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows constant expressions in the test condition of:

                                                          + +
                                                            +
                                                          • if, for, while, or do...while statement
                                                          • +
                                                          • ?: ternary expression
                                                          • +
                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-constant-condition: "error"*/

                                                          if (false) {
                                                          doSomethingUnfinished();
                                                          }

                                                          for (;-2;) {
                                                          doSomethingForever();
                                                          }

                                                          while (typeof x) {
                                                          doSomethingForever();
                                                          }

                                                          do{
                                                          doSomethingForever();
                                                          } while (x = -1);

                                                          var result = 0 ? a : b;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-constant-condition: "error"*/

                                                          if (x === 0) {
                                                          doSomething();
                                                          }

                                                          for (;;) {
                                                          doSomethingForever();
                                                          }

                                                          while (typeof x === "undefined") {
                                                          doSomething();
                                                          }

                                                          do{
                                                          doSomething();
                                                          } while (x);

                                                          var result = x !== 0 ? a : b;
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-continue.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-continue.html new file mode 100644 index 0000000..eae6cdf --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-continue.html @@ -0,0 +1,45 @@ + + + +

                                                          disallow continue statements (no-continue)

                                                          + +

                                                          The continue statement terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration. When used incorrectly it makes code less testable, less readable and less maintainable. Structured control flow statements such as if should be used instead.

                                                          + +
                                                          var sum = 0,
                                                          i;

                                                          for(i = 0; i < 10; i++) {
                                                          if(i >= 5) {
                                                          continue;
                                                          }

                                                          a += i;
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows continue statements.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-continue: "error"*/

                                                          var sum = 0,
                                                          i;

                                                          for(i = 0; i < 10; i++) {
                                                          if(i >= 5) {
                                                          continue;
                                                          }

                                                          a += i;
                                                          }
                                                          +
                                                          + +
                                                          /*eslint no-continue: "error"*/

                                                          var sum = 0,
                                                          i;

                                                          labeledLoop: for(i = 0; i < 10; i++) {
                                                          if(i >= 5) {
                                                          continue labeledLoop;
                                                          }

                                                          a += i;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-continue: "error"*/

                                                          var sum = 0,
                                                          i;

                                                          for(i = 0; i < 10; i++) {
                                                          if(i < 5) {
                                                          a += i;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Compatibility

                                                          + +
                                                            +
                                                          • JSLint: continue
                                                          • +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.19.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-control-regex.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-control-regex.html new file mode 100644 index 0000000..ca31b4e --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-control-regex.html @@ -0,0 +1,44 @@ + + + +

                                                          disallow control characters in regular expressions (no-control-regex)

                                                          + +

                                                          Control characters are special, invisible characters in the ASCII range 0-31. These characters are rarely used in JavaScript strings so a regular expression containing these characters is most likely a mistake.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows control characters in regular expressions.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-control-regex: "error"*/

                                                          var pattern1 = /\x1f/;
                                                          var pattern2 = new RegExp("\x1f");
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-control-regex: "error"*/

                                                          var pattern1 = /\x20/;
                                                          var pattern2 = new RegExp("\x20");
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you need to use control character pattern matching, then you should turn this rule off.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.1.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-debugger.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-debugger.html new file mode 100644 index 0000000..f81a987 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-debugger.html @@ -0,0 +1,50 @@ + + + +

                                                          disallow the use of debugger (no-debugger)

                                                          + +

                                                          The debugger statement is used to tell the executing JavaScript environment to stop execution and start up a debugger at the current point in the code. This has fallen out of favor as a good practice with the advent of modern debugging and development tools. Production code should definitely not contain debugger, as it will cause the browser to stop executing code and open an appropriate debugger.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows debugger statements.

                                                          + +

                                                          Example of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-debugger: "error"*/

                                                          function isTruthy(x) {
                                                          debugger;
                                                          return Boolean(x);
                                                          }
                                                          +
                                                          + +

                                                          Example of correct code for this rule:

                                                          + +
                                                          /*eslint no-debugger: "error"*/

                                                          function isTruthy(x) {
                                                          return Boolean(x); // set a breakpoint at this line
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If your code is still very much in development and don’t want to worry about stripping about debugger statements, then turn this rule off. You’ll generally want to turn it back on when testing code prior to deployment.

                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-delete-var.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-delete-var.html new file mode 100644 index 0000000..e9ba79a --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-delete-var.html @@ -0,0 +1,36 @@ + + + +

                                                          disallow deleting variables (no-delete-var)

                                                          + +

                                                          The purpose of the delete operator is to remove a property from an object. Using the delete operator on a variable might lead to unexpected behavior.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows the use of the delete operator on variables.

                                                          + +

                                                          If ESLint parses code in strict mode, the parser (instead of this rule) reports the error.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-delete-var: "error"*/

                                                          var x;
                                                          delete x;
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-div-regex.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-div-regex.html new file mode 100644 index 0000000..52a63c6 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-div-regex.html @@ -0,0 +1,43 @@ + + + +

                                                          Disallow Regexs That Look Like Division (no-div-regex)

                                                          + +

                                                          Require regex literals to escape division operators.

                                                          + +
                                                          function bar() { return /=foo/; }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This is used to disambiguate the division operator to not confuse users.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-div-regex: "error"*/

                                                          function bar() { return /=foo/; }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-div-regex: "error"*/

                                                          function bar() { return /\=foo/; }
                                                          +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.1.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-dupe-args.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-dupe-args.html new file mode 100644 index 0000000..8689cb8 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-dupe-args.html @@ -0,0 +1,35 @@ + + + +

                                                          disallow duplicate arguments in function definitions (no-dupe-args)

                                                          + +

                                                          If more than one parameter has the same name in a function definition, the last occurrence “shadows” the preceding occurrences. A duplicated name might be a typing error.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows duplicate parameter names in function declarations or expressions. It does not apply to arrow functions or class methods, because the parser reports the error.

                                                          + +

                                                          If ESLint parses code in strict mode, the parser (instead of this rule) reports the error.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-dupe-args: "error"*/

                                                          function foo(a, b, a) {
                                                          console.log("value of the second a:", a);
                                                          }

                                                          var bar = function (a, b, a) {
                                                          console.log("value of the second a:", a);
                                                          };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-dupe-args: "error"*/

                                                          function foo(a, b, c) {
                                                          console.log(a, b, c);
                                                          }

                                                          var bar = function (a, b, c) {
                                                          console.log(a, b, c);
                                                          };
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.16.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-dupe-class-members.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-dupe-class-members.html new file mode 100644 index 0000000..b210ebe --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-dupe-class-members.html @@ -0,0 +1,43 @@ + + + +

                                                          Disallow duplicate name in class members (no-dupe-class-members)

                                                          + +

                                                          If there are declarations of the same name in class members, the last declaration overwrites other declarations silently. +It can cause unexpected behaviors.

                                                          + +
                                                          /*eslint-env es6*/

                                                          class Foo {
                                                          bar() { console.log("hello"); }
                                                          bar() { console.log("goodbye"); }
                                                          }

                                                          var foo = new Foo();
                                                          foo.bar(); // goodbye
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed to flag the use of duplicate names in class members.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-dupe-class-members: "error"*/
                                                          /*eslint-env es6*/

                                                          class Foo {
                                                          bar() { }
                                                          bar() { }
                                                          }

                                                          class Foo {
                                                          bar() { }
                                                          get bar() { }
                                                          }

                                                          class Foo {
                                                          static bar() { }
                                                          static bar() { }
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-dupe-class-members: "error"*/
                                                          /*eslint-env es6*/

                                                          class Foo {
                                                          bar() { }
                                                          qux() { }
                                                          }

                                                          class Foo {
                                                          get bar() { }
                                                          set bar(value) { }
                                                          }

                                                          class Foo {
                                                          static bar() { }
                                                          bar() { }
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          This rule should not be used in ES3/5 environments.

                                                          + +

                                                          In ES2015 (ES6) or later, if you don’t want to be notified about duplicate names in class members, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.2.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-dupe-keys.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-dupe-keys.html new file mode 100644 index 0000000..20fd73b --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-dupe-keys.html @@ -0,0 +1,36 @@ + + + +

                                                          disallow duplicate keys in object literals (no-dupe-keys)

                                                          + +

                                                          Multiple properties with the same key in object literals can cause unexpected behavior in your application.

                                                          + +
                                                          var foo = {
                                                          bar: "baz",
                                                          bar: "qux"
                                                          };
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows duplicate keys in object literals.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-dupe-keys: "error"*/

                                                          var foo = {
                                                          bar: "baz",
                                                          bar: "qux"
                                                          };

                                                          var foo = {
                                                          "bar": "baz",
                                                          bar: "qux"
                                                          };

                                                          var foo = {
                                                          0x1: "baz",
                                                          1: "qux"
                                                          };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-dupe-keys: "error"*/

                                                          var foo = {
                                                          bar: "baz",
                                                          quxx: "qux"
                                                          };
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-duplicate-case.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-duplicate-case.html new file mode 100644 index 0000000..09b08d8 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-duplicate-case.html @@ -0,0 +1,33 @@ + + + +

                                                          Rule to disallow a duplicate case label (no-duplicate-case)

                                                          + +

                                                          If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows duplicate test expressions in case clauses of switch statements.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-duplicate-case: "error"*/

                                                          var a = 1,
                                                          one = 1;

                                                          switch (a) {
                                                          case 1:
                                                          break;
                                                          case 2:
                                                          break;
                                                          case 1: // duplicate test expression
                                                          break;
                                                          default:
                                                          break;
                                                          }

                                                          switch (a) {
                                                          case one:
                                                          break;
                                                          case 2:
                                                          break;
                                                          case one: // duplicate test expression
                                                          break;
                                                          default:
                                                          break;
                                                          }

                                                          switch (a) {
                                                          case "1":
                                                          break;
                                                          case "2":
                                                          break;
                                                          case "1": // duplicate test expression
                                                          break;
                                                          default:
                                                          break;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-duplicate-case: "error"*/

                                                          var a = 1,
                                                          one = 1;

                                                          switch (a) {
                                                          case 1:
                                                          break;
                                                          case 2:
                                                          break;
                                                          case 3:
                                                          break;
                                                          default:
                                                          break;
                                                          }

                                                          switch (a) {
                                                          case one:
                                                          break;
                                                          case 2:
                                                          break;
                                                          case 3:
                                                          break;
                                                          default:
                                                          break;
                                                          }

                                                          switch (a) {
                                                          case "1":
                                                          break;
                                                          case "2":
                                                          break;
                                                          case "3":
                                                          break;
                                                          default:
                                                          break;
                                                          }
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.17.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-duplicate-imports.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-duplicate-imports.html new file mode 100644 index 0000000..2b62d66 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-duplicate-imports.html @@ -0,0 +1,52 @@ + + + +

                                                          Disallow duplicate imports (no-duplicate-imports)

                                                          + +

                                                          An ES6/ES2015 import can be spread over multiple lines, but this takes up unneeded whitespace. This rules validates that all imports from a single module exists in a single import statement.

                                                          + +

                                                          In the following example the module import on line 1 is repeated on line 3. These can be combined to make the list of imports more succinct.

                                                          + +
                                                          import { merge } from 'module';
                                                          import path from 'another-module';
                                                          import { find } from 'module';
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This inspection reports any duplicated module in an import statement.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-duplicate-imports: "error"*/

                                                          import { merge } from 'module';
                                                          import path from 'another-module';
                                                          import { find } from 'module';


                                                          import { merge } from 'module';
                                                          import _, { find } from 'module';
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-duplicate-imports: "error"*/

                                                          import { merge, find } from 'module';
                                                          import path from 'another-module';
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule takes one optional argument, an object with a single key, includeExports which is a boolean. It defaults to false.

                                                          + +

                                                          With this option set to true, the following patterns are considered problems:

                                                          + +
                                                          /*eslint no-duplicate-imports: ["error", { includeExports: true }]*/

                                                          import { merge } from 'module';
                                                          import path from 'another-module';

                                                          export { find } from 'module';


                                                          import _ from 'module';
                                                          const find = _.find;

                                                          export { find as lodashFind } from 'module';
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-duplicate-imports: ["error", { includeExports: true }]*/

                                                          import { merge, find } from 'module';

                                                          export { merge };
                                                          export { find as lodashFind };
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.5.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-else-return.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-else-return.html new file mode 100644 index 0000000..706745f --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-else-return.html @@ -0,0 +1,36 @@ + + + +

                                                          Disallow return before else (no-else-return)

                                                          + +

                                                          If an if block contains a return statement, the else block becomes unnecessary. Its contents can be placed outside of the block.

                                                          + +
                                                          function foo() {
                                                          if (x) {
                                                          return y;
                                                          } else {
                                                          return z;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at highlighting an unnecessary block of code following an if containing a return statement. As such, it will warn when it encounters an else following a chain of ifs, all of them containing a return statement.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-else-return: "error"*/

                                                          function foo() {
                                                          if (x) {
                                                          return y;
                                                          } else {
                                                          return z;
                                                          }
                                                          }

                                                          function foo() {
                                                          if (x) {
                                                          return y;
                                                          } else if (z) {
                                                          return w;
                                                          } else {
                                                          return t;
                                                          }
                                                          }

                                                          function foo() {
                                                          if (x) {
                                                          return y;
                                                          } else {
                                                          var t = "foo";
                                                          }

                                                          return t;
                                                          }

                                                          // Two warnings for nested occurrences
                                                          function foo() {
                                                          if (x) {
                                                          if (y) {
                                                          return y;
                                                          } else {
                                                          return x;
                                                          }
                                                          } else {
                                                          return z;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-else-return: "error"*/

                                                          function foo() {
                                                          if (x) {
                                                          return y;
                                                          }

                                                          return z;
                                                          }

                                                          function foo() {
                                                          if (x) {
                                                          return y;
                                                          } else if (z) {
                                                          var t = "foo";
                                                          } else {
                                                          return w;
                                                          }
                                                          }

                                                          function foo() {
                                                          if (x) {
                                                          if (z) {
                                                          return y;
                                                          }
                                                          } else {
                                                          return z;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-empty-character-class.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-empty-character-class.html new file mode 100644 index 0000000..8bcbef4 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-empty-character-class.html @@ -0,0 +1,45 @@ + + + +

                                                          disallow empty character classes in regular expressions (no-empty-character-class)

                                                          + +

                                                          Because empty character classes in regular expressions do not match anything, they might be typing mistakes.

                                                          + +
                                                          var foo = /^abc[]/;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows empty character classes in regular expressions.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-empty-character-class: "error"*/

                                                          /^abc[]/.test("abcdefg"); // false
                                                          "abcdefg".match(/^abc[]/); // null
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-empty-character-class: "error"*/

                                                          /^abc/.test("abcdefg"); // true
                                                          "abcdefg".match(/^abc/); // ["abc"]

                                                          /^abc[a-z]/.test("abcdefg"); // true
                                                          "abcdefg".match(/^abc[a-z]/); // ["abcd"]
                                                          +
                                                          + +

                                                          Known Limitations

                                                          + +

                                                          This rule does not report empty character classes in the string argument of calls to the RegExp constructor.

                                                          + +

                                                          Example of a false negative when this rule reports correct code:

                                                          + +
                                                          /*eslint no-empty-character-class: "error"*/

                                                          var abcNeverMatches = new RegExp("^abc[]");
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.22.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-empty-function.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-empty-function.html new file mode 100644 index 0000000..2deef18 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-empty-function.html @@ -0,0 +1,129 @@ + + + +

                                                          Disallow empty functions (no-empty-function)

                                                          + +

                                                          Empty functions can reduce readability because readers need to guess whether it’s intentional or not. +So writing a clear comment for empty functions is a good practice.

                                                          + +
                                                          function foo() {
                                                          // do nothing.
                                                          }
                                                          +
                                                          + +

                                                          Especially, the empty block of arrow functions might be confusing developers. +It’s very similar to an empty object literal.

                                                          + +
                                                          list.map(() => {});   // This is a block, would return undefined.
                                                          list.map(() => ({})); // This is an empty object.
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at eliminating empty functions. +A function will not be considered a problem if it contains a comment.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-empty-function: "error"*/
                                                          /*eslint-env es6*/

                                                          function foo() {}

                                                          var foo = function() {};

                                                          var foo = () => {};

                                                          function* foo() {}

                                                          var foo = function*() {};

                                                          var obj = {
                                                          foo: function() {},

                                                          foo: function*() {},

                                                          foo() {},

                                                          *foo() {},

                                                          get foo() {},

                                                          set foo(value) {}
                                                          };

                                                          class A {
                                                          constructor() {}

                                                          foo() {}

                                                          *foo() {}

                                                          get foo() {}

                                                          set foo(value) {}

                                                          static foo() {}

                                                          static *foo() {}

                                                          static get foo() {}

                                                          static set foo(value) {}
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-empty-function: "error"*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          // do nothing.
                                                          }

                                                          var foo = function() {
                                                          // any clear comments.
                                                          };

                                                          var foo = () => {
                                                          bar();
                                                          };

                                                          function* foo() {
                                                          // do nothing.
                                                          }

                                                          var foo = function*() {
                                                          // do nothing.
                                                          };

                                                          var obj = {
                                                          foo: function() {
                                                          // do nothing.
                                                          },

                                                          foo: function*() {
                                                          // do nothing.
                                                          },

                                                          foo() {
                                                          // do nothing.
                                                          },

                                                          *foo() {
                                                          // do nothing.
                                                          },

                                                          get foo() {
                                                          // do nothing.
                                                          },

                                                          set foo(value) {
                                                          // do nothing.
                                                          }
                                                          };

                                                          class A {
                                                          constructor() {
                                                          // do nothing.
                                                          }

                                                          foo() {
                                                          // do nothing.
                                                          }

                                                          *foo() {
                                                          // do nothing.
                                                          }

                                                          get foo() {
                                                          // do nothing.
                                                          }

                                                          set foo(value) {
                                                          // do nothing.
                                                          }

                                                          static foo() {
                                                          // do nothing.
                                                          }

                                                          static *foo() {
                                                          // do nothing.
                                                          }

                                                          static get foo() {
                                                          // do nothing.
                                                          }

                                                          static set foo(value) {
                                                          // do nothing.
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an option to allow specific kinds of functions to be empty.

                                                          + +
                                                            +
                                                          • allow (string[]) - A list of kind to allow empty functions. List items are some of the following strings. An empty array ([]) by default. +
                                                              +
                                                            • "functions" - Normal functions.
                                                            • +
                                                            • "arrowFunctions" - Arrow functions.
                                                            • +
                                                            • "generatorFunctions" - Generator functions.
                                                            • +
                                                            • "methods" - Class methods and method shorthands of object literals.
                                                            • +
                                                            • "generatorMethods" - Class methods and method shorthands of object literals with generator.
                                                            • +
                                                            • "getters" - Getters.
                                                            • +
                                                            • "setters" - Setters.
                                                            • +
                                                            • "constructors" - Class constructors.
                                                            • +
                                                            +
                                                          • +
                                                          + +

                                                          allow: functions

                                                          + +

                                                          Examples of correct code for the { "allow": ["functions"] } option:

                                                          + +
                                                          /*eslint no-empty-function: ["error", { "allow": ["functions"] }]*/

                                                          function foo() {}

                                                          var foo = function() {};

                                                          var obj = {
                                                          foo: function() {}
                                                          };
                                                          +
                                                          + +

                                                          allow: arrowFunctions

                                                          + +

                                                          Examples of correct code for the { "allow": ["arrowFunctions"] } option:

                                                          + +
                                                          /*eslint no-empty-function: ["error", { "allow": ["arrowFunctions"] }]*/
                                                          /*eslint-env es6*/

                                                          var foo = () => {};
                                                          +
                                                          + +

                                                          allow: generatorFunctions

                                                          + +

                                                          Examples of correct code for the { "allow": ["generatorFunctions"] } option:

                                                          + +
                                                          /*eslint no-empty-function: ["error", { "allow": ["generatorFunctions"] }]*/
                                                          /*eslint-env es6*/

                                                          function* foo() {}

                                                          var foo = function*() {};

                                                          var obj = {
                                                          foo: function*() {}
                                                          };
                                                          +
                                                          + +

                                                          allow: methods

                                                          + +

                                                          Examples of correct code for the { "allow": ["methods"] } option:

                                                          + +
                                                          /*eslint no-empty-function: ["error", { "allow": ["methods"] }]*/
                                                          /*eslint-env es6*/

                                                          var obj = {
                                                          foo() {}
                                                          };

                                                          class A {
                                                          foo() {}
                                                          static foo() {}
                                                          }
                                                          +
                                                          + +

                                                          allow: generatorMethods

                                                          + +

                                                          Examples of correct code for the { "allow": ["generatorMethods"] } option:

                                                          + +
                                                          /*eslint no-empty-function: ["error", { "allow": ["generatorMethods"] }]*/
                                                          /*eslint-env es6*/

                                                          var obj = {
                                                          *foo() {}
                                                          };

                                                          class A {
                                                          *foo() {}
                                                          static *foo() {}
                                                          }
                                                          +
                                                          + +

                                                          allow: getters

                                                          + +

                                                          Examples of correct code for the { "allow": ["getters"] } option:

                                                          + +
                                                          /*eslint no-empty-function: ["error", { "allow": ["getters"] }]*/
                                                          /*eslint-env es6*/

                                                          var obj = {
                                                          get foo() {}
                                                          };

                                                          class A {
                                                          get foo() {}
                                                          static get foo() {}
                                                          }
                                                          +
                                                          + +

                                                          allow: setters

                                                          + +

                                                          Examples of correct code for the { "allow": ["setters"] } option:

                                                          + +
                                                          /*eslint no-empty-function: ["error", { "allow": ["setters"] }]*/
                                                          /*eslint-env es6*/

                                                          var obj = {
                                                          set foo(value) {}
                                                          };

                                                          class A {
                                                          set foo(value) {}
                                                          static set foo(value) {}
                                                          }
                                                          +
                                                          + +

                                                          allow: constructors

                                                          + +

                                                          Examples of correct code for the { "allow": ["constructors"] } option:

                                                          + +
                                                          /*eslint no-empty-function: ["error", { "allow": ["constructors"] }]*/
                                                          /*eslint-env es6*/

                                                          class A {
                                                          constructor() {}
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about empty functions, then it’s safe to disable this rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-empty-pattern.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-empty-pattern.html new file mode 100644 index 0000000..5f5cdf4 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-empty-pattern.html @@ -0,0 +1,48 @@ + + + +

                                                          Disallow empty destructuring patterns (no-empty-pattern)

                                                          + +

                                                          When using destructuring, it’s possible to create a pattern that has no effect. This happens when empty curly braces are used to the right of an embedded object destructuring pattern, such as:

                                                          + +
                                                          // doesn't create any variables
                                                          var {a: {}} = foo;
                                                          +
                                                          + +

                                                          In this code, no new variables are created because a is just a location helper while the {} is expected to contain the variables to create, such as:

                                                          + +
                                                          // creates variable b
                                                          var {a: { b }} = foo;
                                                          +
                                                          + +

                                                          In many cases, the empty object pattern is a mistake where the author intended to use a default value instead, such as:

                                                          + +
                                                          // creates variable a
                                                          var {a = {}} = foo;
                                                          +
                                                          + +

                                                          The difference between these two patterns is subtle, especially because the problematic empty pattern looks just like an object literal.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to flag any empty patterns in destructured objects and arrays, and as such, will report a problem whenever one is encountered.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-empty-pattern: "error"*/

                                                          var {} = foo;
                                                          var [] = foo;
                                                          var {a: {}} = foo;
                                                          var {a: []} = foo;
                                                          function foo({}) {}
                                                          function foo([]) {}
                                                          function foo({a: {}}) {}
                                                          function foo({a: []}) {}
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-empty-pattern: "error"*/

                                                          var {a = {}} = foo;
                                                          var {a = []} = foo;
                                                          function foo({a = {}}) {}
                                                          function foo({a = []}) {}
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.7.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-empty.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-empty.html new file mode 100644 index 0000000..b43d976 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-empty.html @@ -0,0 +1,58 @@ + + + +

                                                          disallow empty block statements (no-empty)

                                                          + +

                                                          Empty block statements, while not technically errors, usually occur due to refactoring that wasn’t completed. They can cause confusion when reading code.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows empty block statements. This rule ignores block statements which contain a comment (for example, in an empty catch or finally block of a try statement to indicate that execution should continue regardless of errors).

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-empty: "error"*/

                                                          if (foo) {
                                                          }

                                                          while (foo) {
                                                          }

                                                          switch(foo) {
                                                          }

                                                          try {
                                                          doSomething();
                                                          } catch(ex) {

                                                          } finally {

                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-empty: "error"*/

                                                          if (foo) {
                                                          // empty
                                                          }

                                                          while (foo) {
                                                          /* empty */
                                                          }

                                                          try {
                                                          doSomething();
                                                          } catch (ex) {
                                                          // continue regardless of error
                                                          }

                                                          try {
                                                          doSomething();
                                                          } finally {
                                                          /* continue regardless of error */
                                                          }
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an object option for exceptions:

                                                          + +
                                                            +
                                                          • "allowEmptyCatch": true allows empty catch clauses (that is, which do not contain a comment)
                                                          • +
                                                          + +

                                                          allowEmptyCatch

                                                          + +

                                                          Examples of additional correct code for this rule with the { "allowEmptyCatch": true } option:

                                                          + +
                                                          /* eslint no-empty: ["error", { "allowEmptyCatch": true }] */
                                                          try {
                                                          doSomething();
                                                          } catch (ex) {}

                                                          try {
                                                          doSomething();
                                                          }
                                                          catch (ex) {}
                                                          finally {
                                                          /* continue regardless of error */
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you intentionally use empty block statements then you can disable this rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-eq-null.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-eq-null.html new file mode 100644 index 0000000..8c41e3f --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-eq-null.html @@ -0,0 +1,36 @@ + + + +

                                                          Disallow Null Comparisons (no-eq-null)

                                                          + +

                                                          Comparing to null without a type-checking operator (== or !=), can have unintended results as the comparison will evaluate to true when comparing to not just a null, but also an undefined value.

                                                          + +
                                                          if (foo == null) {
                                                          bar();
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          The no-eq-null rule aims reduce potential bug and unwanted behavior by ensuring that comparisons to null only match null, and not also undefined. As such it will flag comparisons to null when using == and !=.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-eq-null: "error"*/

                                                          if (foo == null) {
                                                          bar();
                                                          }

                                                          while (qux != null) {
                                                          baz();
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-eq-null: "error"*/

                                                          if (foo === null) {
                                                          bar();
                                                          }

                                                          while (qux !== null) {
                                                          baz();
                                                          }
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-eval.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-eval.html new file mode 100644 index 0000000..afbf416 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-eval.html @@ -0,0 +1,101 @@ + + + +

                                                          Disallow eval() (no-eval)

                                                          + +

                                                          JavaScript’s eval() function is potentially dangerous and is often misused. Using eval() on untrusted code can open a program up to several different injection attacks. The use of eval() in most contexts can be substituted for a better, alternative approach to a problem.

                                                          + +
                                                          var obj = { x: "foo" },
                                                          key = "x",
                                                          value = eval("obj." + key);
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at preventing potentially dangerous, unnecessary, and slow code by disallowing the use of the eval() function. As such, it will warn whenever the eval() function is used.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-eval: "error"*/

                                                          var obj = { x: "foo" },
                                                          key = "x",
                                                          value = eval("obj." + key);

                                                          (0, eval)("var a = 0");

                                                          var foo = eval;
                                                          foo("var a = 0");

                                                          // This `this` is the global object.
                                                          this.eval("var a = 0");
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with browser environment:

                                                          + +
                                                          /*eslint no-eval: "error"*/
                                                          /*eslint-env browser*/

                                                          window.eval("var a = 0");
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with node environment:

                                                          + +
                                                          /*eslint no-eval: "error"*/
                                                          /*eslint-env node*/

                                                          global.eval("var a = 0");
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-eval: "error"*/
                                                          /*eslint-env es6*/

                                                          var obj = { x: "foo" },
                                                          key = "x",
                                                          value = obj[key];

                                                          class A {
                                                          foo() {
                                                          // This is a user-defined method.
                                                          this.eval("var a = 0");
                                                          }

                                                          eval() {
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an option to allow indirect calls to eval. +Indirect calls to eval are less dangerous than direct calls to eval because they cannot dynamically change the scope. Because of this, they also will not negatively impact performance to the degree of direct eval.

                                                          + +
                                                          {
                                                          "no-eval": ["error", {"allowIndirect": true}] // default is false
                                                          }
                                                          +
                                                          + +

                                                          With this option the following patterns are considered problems:

                                                          + +
                                                          /*eslint no-eval: "error"*/

                                                          var obj = { x: "foo" },
                                                          key = "x",
                                                          value = eval("obj." + key);
                                                          +
                                                          + +

                                                          With this option the following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-eval: "error"*/

                                                          (0, eval)("var a = 0");

                                                          var foo = eval;
                                                          foo("var a = 0");

                                                          this.eval("var a = 0");
                                                          +
                                                          + +
                                                          /*eslint no-eval: "error"*/
                                                          /*eslint-env browser*/

                                                          window.eval("var a = 0");
                                                          +
                                                          + +
                                                          /*eslint no-eval: "error"*/
                                                          /*eslint-env node*/

                                                          global.eval("var a = 0");
                                                          +
                                                          + +

                                                          Known Limitations

                                                          + +
                                                            +
                                                          • +

                                                            This rule is warning every eval() even if the eval is not global’s. +This behavior is in order to detect calls of direct eval. Such as:

                                                            + +
                                                            module.exports = function(eval) {
                                                            // If the value of this `eval` is built-in `eval` function, this is a
                                                            // call of direct `eval`.
                                                            eval("var a = 0");
                                                            };
                                                            +
                                                            +
                                                          • +
                                                          • +

                                                            This rule cannot catch renaming the global object. Such as:

                                                            + +
                                                            var foo = window;
                                                            foo.eval("var a = 0");
                                                            +
                                                            +
                                                          • +
                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-ex-assign.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-ex-assign.html new file mode 100644 index 0000000..e75bfe8 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-ex-assign.html @@ -0,0 +1,41 @@ + + + +

                                                          disallow reassigning exceptions in catch clauses (no-ex-assign)

                                                          + +

                                                          If a catch clause in a try statement accidentally (or purposely) assigns another value to the exception parameter, it impossible to refer to the error from that point on. +Since there is no arguments object to offer alternative access to this data, assignment of the parameter is absolutely destructive.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows reassigning exceptions in catch clauses.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-ex-assign: "error"*/

                                                          try {
                                                          // code
                                                          } catch (e) {
                                                          e = 10;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-ex-assign: "error"*/

                                                          try {
                                                          // code
                                                          } catch (e) {
                                                          var foo = 10;
                                                          }
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extend-native.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extend-native.html new file mode 100644 index 0000000..de69af9 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extend-native.html @@ -0,0 +1,63 @@ + + + +

                                                          Disallow Extending of Native Objects (no-extend-native)

                                                          + +

                                                          In JavaScript, you can extend any object, including builtin or “native” objects. Sometimes people change the behavior of these native objects in ways that break the assumptions made about them in other parts of the code.

                                                          + +

                                                          For example here we are overriding a builtin method that will then affect all Objects, even other builtins.

                                                          + +
                                                          // seems harmless
                                                          Object.prototype.extra = 55;

                                                          // loop through some userIds
                                                          var users = {
                                                          "123": "Stan",
                                                          "456": "David"
                                                          };

                                                          // not what you'd expect
                                                          for (var id in users) {
                                                          console.log(id); // "123", "456", "extra"
                                                          }
                                                          +
                                                          + +

                                                          A common suggestion to avoid this problem would be to wrap the inside of the for loop with users.hasOwnProperty(id). However, if this rule is strictly enforced throughout your codebase you won’t need to take that step.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          Disallows directly modifying the prototype of builtin objects.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-extend-native: "error"*/

                                                          Object.prototype.a = "a";
                                                          Object.defineProperty(Array.prototype, "times", { value: 999 });
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule accepts an exceptions option, which can be used to specify a list of builtins for which extensions will be allowed.

                                                          + +

                                                          exceptions

                                                          + +

                                                          Examples of correct code for the sample { "exceptions": ["Object"] } option:

                                                          + +
                                                          /*eslint no-extend-native: ["error", { "exceptions": ["Object"] }]*/

                                                          Object.prototype.a = "a";
                                                          +
                                                          + +

                                                          Known Limitations

                                                          + +

                                                          This rule does not report any of the following less obvious approaches to modify the prototype of builtin objects:

                                                          + +
                                                          var x = Object;
                                                          x.prototype.thing = a;

                                                          eval("Array.prototype.forEach = 'muhahaha'");

                                                          with(Array) {
                                                          prototype.thing = 'thing';
                                                          };

                                                          window.Function.prototype.bind = 'tight';
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You may want to disable this rule when working with polyfills that try to patch older versions of JavaScript with the latest spec, such as those that might Function.prototype.bind or Array.prototype.forEach in a future-friendly way.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.1.4.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-bind.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-bind.html new file mode 100644 index 0000000..7097006 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-bind.html @@ -0,0 +1,58 @@ + + + +

                                                          Disallow unnecessary function binding (no-extra-bind)

                                                          + +

                                                          The bind() method is used to create functions with specific this values and, optionally, binds arguments to specific values. When used to specify the value of this, it’s important that the function actually use this in its function body. For example:

                                                          + +
                                                          var boundGetName = (function getName() {
                                                          return this.name;
                                                          }).bind({ name: "ESLint" });

                                                          console.log(boundGetName()); // "ESLint"
                                                          +
                                                          + +

                                                          This code is an example of a good use of bind() for setting the value of this.

                                                          + +

                                                          Sometimes during the course of code maintenance, the this value is removed from the function body. In that case, you can end up with a call to bind() that doesn’t accomplish anything:

                                                          + +
                                                          // useless bind
                                                          var boundGetName = (function getName() {
                                                          return "ESLint";
                                                          }).bind({ name: "ESLint" });

                                                          console.log(boundGetName()); // "ESLint"
                                                          +
                                                          + +

                                                          In this code, the reference to this has been removed but bind() is still used. In this case, the bind() is unnecessary overhead (and a performance hit) and can be safely removed.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at avoiding the unnecessary use of bind() and as such will warn whenever an immediately-invoked function expression (IIFE) is using bind() and doesn’t have an appropriate this value. This rule won’t flag usage of bind() that includes function argument binding.

                                                          + +

                                                          Note: Arrow functions can never have their this value set using bind(). This rule flags all uses of bind() with arrow functions as a problem

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-extra-bind: "error"*/
                                                          /*eslint-env es6*/

                                                          var x = function () {
                                                          foo();
                                                          }.bind(bar);

                                                          var x = (() => {
                                                          foo();
                                                          }).bind(bar);

                                                          var x = (() => {
                                                          this.foo();
                                                          }).bind(bar);

                                                          var x = function () {
                                                          (function () {
                                                          this.foo();
                                                          }());
                                                          }.bind(bar);

                                                          var x = function () {
                                                          function foo() {
                                                          this.bar();
                                                          }
                                                          }.bind(baz);
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-extra-bind: "error"*/

                                                          var x = function () {
                                                          this.foo();
                                                          }.bind(bar);

                                                          var x = function (a) {
                                                          return a + 1;
                                                          }.bind(foo, bar);
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you are not concerned about unnecessary calls to bind(), you can safely disable this rule.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.8.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-boolean-cast.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-boolean-cast.html new file mode 100644 index 0000000..c477e59 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-boolean-cast.html @@ -0,0 +1,36 @@ + + + +

                                                          disallow unnecessary boolean casts (no-extra-boolean-cast)

                                                          + +

                                                          In contexts such as an if statement’s test where the result of the expression will already be coerced to a Boolean, casting to a Boolean via double negation (!!) or a Boolean call is unnecessary. For example, these if statements are equivalent:

                                                          + +
                                                          if (!!foo) {
                                                          // ...
                                                          }

                                                          if (Boolean(foo)) {
                                                          // ...
                                                          }

                                                          if (foo) {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows unnecessary boolean casts.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-extra-boolean-cast: "error"*/

                                                          var foo = !!!bar;

                                                          var foo = !!bar ? baz : bat;

                                                          var foo = Boolean(!!bar);

                                                          var foo = new Boolean(!!bar);

                                                          if (!!foo) {
                                                          // ...
                                                          }

                                                          if (Boolean(foo)) {
                                                          // ...
                                                          }

                                                          while (!!foo) {
                                                          // ...
                                                          }

                                                          do {
                                                          // ...
                                                          } while (Boolean(foo));

                                                          for (; !!foo; ) {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-extra-boolean-cast: "error"*/

                                                          var foo = !!bar;
                                                          var foo = Boolean(bar);

                                                          function foo() {
                                                          return !!bar;
                                                          }

                                                          var foo = bar ? !!baz : !!bat;
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-label.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-label.html new file mode 100644 index 0000000..dfffb5d --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-label.html @@ -0,0 +1,51 @@ + + + +

                                                          Disallow Unnecessary Labels (no-extra-label)

                                                          + +

                                                          If a loop contains no nested loops or switches, labeling the loop is unnecessary.

                                                          + +
                                                          A: while (a) {
                                                          break A;
                                                          }
                                                          +
                                                          + +

                                                          You can achieve the same result by removing the label and using break or continue without a label. +Probably those labels would confuse developers because they expect labels to jump to further.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at eliminating unnecessary labels.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-extra-label: "error"*/

                                                          A: while (a) {
                                                          break A;
                                                          }

                                                          B: for (let i = 0; i < 10; ++i) {
                                                          break B;
                                                          }

                                                          C: switch (a) {
                                                          case 0:
                                                          break C;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-extra-label: "error"*/

                                                          while (a) {
                                                          break;
                                                          }

                                                          for (let i = 0; i < 10; ++i) {
                                                          break;
                                                          }

                                                          switch (a) {
                                                          case 0:
                                                          break;
                                                          }

                                                          A: {
                                                          break A;
                                                          }

                                                          B: while (a) {
                                                          while (b) {
                                                          break B;
                                                          }
                                                          }

                                                          C: switch (a) {
                                                          case 0:
                                                          while (b) {
                                                          break C;
                                                          }
                                                          break;
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about usage of labels, then it’s safe to disable this rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-rc.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-parens.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-parens.html new file mode 100644 index 0000000..2fa2f3e --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-parens.html @@ -0,0 +1,103 @@ + + + +

                                                          disallow unnecessary parentheses (no-extra-parens)

                                                          + +

                                                          This rule restricts the use of parentheses to only where they are necessary.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule always ignores extra parentheses around the following:

                                                          + +
                                                            +
                                                          • RegExp literals such as (/abc/).test(var) to avoid conflicts with the wrap-regex rule
                                                          • +
                                                          • immediately-invokes function expressions (also known as IIFEs) such as var x = (function () {})(); and ((function foo() {return 1;})()) to avoid conflicts with the wrap-iife rule
                                                          • +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • "all" (default) disallows unnecessary parentheses around any expression
                                                          • +
                                                          • "functions" disallows unnecessary parentheses only around function expressions
                                                          • +
                                                          + +

                                                          This rule has an object option for exceptions to the "all" option:

                                                          + +
                                                            +
                                                          • "conditionalAssign": false allows extra parentheses around assignments in conditional test expressions
                                                          • +
                                                          • "returnAssign": false allows extra parentheses around assignments in return statements
                                                          • +
                                                          • "nestedBinaryExpressions": false allows extra parentheses in nested binary expressions
                                                          • +
                                                          + +

                                                          all

                                                          + +

                                                          Examples of incorrect code for this rule with the default "all" option:

                                                          + +
                                                          /* eslint no-extra-parens: "error" */

                                                          a = (b * c);

                                                          (a * b) + c;

                                                          typeof (a);

                                                          (function(){} ? a() : b());
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "all" option:

                                                          + +
                                                          /* eslint no-extra-parens: "error" */

                                                          (0).toString();

                                                          ({}.toString.call());

                                                          (function(){}) ? a() : b();

                                                          (/^a$/).test(x);
                                                          +
                                                          + +

                                                          conditionalAssign

                                                          + +

                                                          Examples of correct code for this rule with the "all" and { "conditionalAssign": false } options:

                                                          + +
                                                          /* eslint no-extra-parens: ["error", "all", { "conditionalAssign": false }] */

                                                          while ((foo = bar())) {}

                                                          if ((foo = bar())) {}

                                                          do; while ((foo = bar()))

                                                          for (;(a = b););
                                                          +
                                                          + +

                                                          returnAssign

                                                          + +

                                                          Examples of correct code for this rule with the "all" and { "returnAssign": false } options:

                                                          + +
                                                          /* eslint no-extra-parens: ["error", "all", { "returnAssign": false }] */

                                                          function a(b) {
                                                          return (b = 1);
                                                          }

                                                          function a(b) {
                                                          return b ? (c = d) : (c = e);
                                                          }

                                                          b => (b = 1);

                                                          b => b ? (c = d) : (c = e);
                                                          +
                                                          + +

                                                          nestedBinaryExpressions

                                                          + +

                                                          Examples of correct for this rule with the "all" and { "nestedBinaryExpressions": false } options:

                                                          + +
                                                          /* eslint no-extra-parens: ["error", "all", { "nestedBinaryExpressions": false }] */

                                                          x = a || (b && c);
                                                          x = a + (b * c);
                                                          x = (a * b) / c;
                                                          +
                                                          + +

                                                          functions

                                                          + +

                                                          Examples of incorrect code for this rule with the "functions" option:

                                                          + +
                                                          /* eslint no-extra-parens: ["error", "functions"] */

                                                          ((function foo() {}))();

                                                          var y = (function () {return 1;});
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "functions" option:

                                                          + +
                                                          /* eslint no-extra-parens: ["error", "functions"] */

                                                          (0).toString();

                                                          ({}.toString.call());

                                                          (function(){} ? a() : b());

                                                          (/^a$/).test(x);

                                                          a = (b * c);

                                                          (a * b) + c;

                                                          typeof (a);
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.1.4.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-semi.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-semi.html new file mode 100644 index 0000000..5c4c430 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-extra-semi.html @@ -0,0 +1,46 @@ + + + +

                                                          disallow unnecessary semicolons (no-extra-semi)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows unnecessary semicolons.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-extra-semi: "error"*/

                                                          var x = 5;;

                                                          function foo() {
                                                          // code
                                                          };

                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-extra-semi: "error"*/

                                                          var x = 5;

                                                          var foo = function() {
                                                          // code
                                                          };

                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you intentionally use extra semicolons then you can disable this rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-fallthrough.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-fallthrough.html new file mode 100644 index 0000000..9da0fa3 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-fallthrough.html @@ -0,0 +1,75 @@ + + + +

                                                          Disallow Case Statement Fallthrough (no-fallthrough)

                                                          + +

                                                          The switch statement in JavaScript is one of the more error-prone constructs of the language thanks in part to the ability to “fall through” from one case to the next. For example:

                                                          + +
                                                          switch(foo) {
                                                          case 1:
                                                          doSomething();

                                                          case 2:
                                                          doSomethingElse();
                                                          }
                                                          +
                                                          + +

                                                          In this example, if foo is 1, then execution will flow through both cases, as the first falls through to the second. You can prevent this by using break, as in this example:

                                                          + +
                                                          switch(foo) {
                                                          case 1:
                                                          doSomething();
                                                          break;

                                                          case 2:
                                                          doSomethingElse();
                                                          }
                                                          +
                                                          + +

                                                          That works fine when you don’t want a fallthrough, but what if the fallthrough is intentional, there is no way to indicate that in the language. It’s considered a best practice to always indicate when a fallthrough is intentional using a comment which matches the /falls?\s?through/i regular expression:

                                                          + +
                                                          switch(foo) {
                                                          case 1:
                                                          doSomething();
                                                          // falls through

                                                          case 2:
                                                          doSomethingElse();
                                                          }

                                                          switch(foo) {
                                                          case 1:
                                                          doSomething();
                                                          // fall through

                                                          case 2:
                                                          doSomethingElse();
                                                          }

                                                          switch(foo) {
                                                          case 1:
                                                          doSomething();
                                                          // fallsthrough

                                                          case 2:
                                                          doSomethingElse();
                                                          }
                                                          +
                                                          + +

                                                          In this example, there is no confusion as to the expected behavior. It is clear that the first case is meant to fall through to the second case.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at eliminating unintentional fallthrough of one case to the other. As such, it flags and fallthrough scenarios that are not marked by a comment.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-fallthrough: "error"*/

                                                          switch(foo) {
                                                          case 1:
                                                          doSomething();

                                                          case 2:
                                                          doSomething();
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-fallthrough: "error"*/

                                                          switch(foo) {
                                                          case 1:
                                                          doSomething();
                                                          break;

                                                          case 2:
                                                          doSomething();
                                                          }

                                                          function bar(foo) {
                                                          switch(foo) {
                                                          case 1:
                                                          doSomething();
                                                          return;

                                                          case 2:
                                                          doSomething();
                                                          }
                                                          }

                                                          switch(foo) {
                                                          case 1:
                                                          doSomething();
                                                          throw new Error("Boo!");

                                                          case 2:
                                                          doSomething();
                                                          }

                                                          switch(foo) {
                                                          case 1:
                                                          case 2:
                                                          doSomething();
                                                          }

                                                          switch(foo) {
                                                          case 1:
                                                          doSomething();
                                                          // falls through

                                                          case 2:
                                                          doSomething();
                                                          }
                                                          +
                                                          + +

                                                          Note that the last case statement in these examples does not cause a warning because there is nothing to fall through into.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule accepts a single options argument:

                                                          + +
                                                            +
                                                          • Set the commentPattern option to a regular expression string to change the test for intentional fallthrough comment
                                                          • +
                                                          + +

                                                          commentPattern

                                                          + +

                                                          Examples of correct code for the { "commentPattern": "break[\\s\\w]*omitted" } option:

                                                          + +
                                                          /*eslint no-fallthrough: ["error", { "commentPattern": "break[\\s\\w]*omitted" }]*/

                                                          switch(foo) {
                                                          case 1:
                                                          doSomething();
                                                          // break omitted

                                                          case 2:
                                                          doSomething();
                                                          }

                                                          switch(foo) {
                                                          case 1:
                                                          doSomething();
                                                          // caution: break is omitted intentionally

                                                          default:
                                                          doSomething();
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to enforce that each case statement should end with a throw, return, break, or comment, then you can safely turn this rule off.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.7.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-floating-decimal.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-floating-decimal.html new file mode 100644 index 0000000..742b8f5 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-floating-decimal.html @@ -0,0 +1,54 @@ + + + +

                                                          Disallow Floating Decimals (no-floating-decimal)

                                                          + +

                                                          Float values in JavaScript contain a decimal point, and there is no requirement that the decimal point be preceded or followed by a number. For example, the following are all valid JavaScript numbers:

                                                          + +
                                                          var num = .5;
                                                          var num = 2.;
                                                          var num = -.7;
                                                          +
                                                          + +

                                                          Although not a syntax error, this format for numbers can make it difficult to distinguish between true decimal numbers and the dot operator. For this reason, some recommend that you should always include a number before and after a decimal point to make it clear the intent is to create a decimal number.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at eliminating floating decimal points and will warn whenever a numeric value has a decimal point but is missing a number either before or after it.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-floating-decimal: "error"*/

                                                          var num = .5;
                                                          var num = 2.;
                                                          var num = -.7;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-floating-decimal: "error"*/

                                                          var num = 0.5;
                                                          var num = 2.0;
                                                          var num = -0.7;
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you aren’t concerned about misinterpreting floating decimal point values, then you can safely turn this rule off.

                                                          + +

                                                          Compatibility

                                                          + +
                                                            +
                                                          • JSHint: W008
                                                          • +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.6.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-func-assign.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-func-assign.html new file mode 100644 index 0000000..cf11f91 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-func-assign.html @@ -0,0 +1,41 @@ + + + +

                                                          disallow reassigning function declarations (no-func-assign)

                                                          + +

                                                          JavaScript functions can be written as a FunctionDeclaration function foo() { ... } or as a FunctionExpression var foo = function() { ... };. While a JavaScript interpreter might tolerate it, overwriting/reassigning a function written as a FunctionDeclaration is often indicative of a mistake or issue.

                                                          + +
                                                          function foo() {}
                                                          foo = bar;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows reassigning function declarations.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-func-assign: "error"*/

                                                          function foo() {}
                                                          foo = bar;

                                                          function foo() {
                                                          foo = bar;
                                                          }
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule, unlike the corresponding rule in JSHint:

                                                          + +
                                                          /*eslint no-func-assign: "error"*/

                                                          foo = bar;
                                                          function foo() {}
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-func-assign: "error"*/

                                                          var foo = function () {}
                                                          foo = bar;

                                                          function foo(foo) { // `foo` is shadowed.
                                                          foo = bar;
                                                          }

                                                          function foo() {
                                                          var foo = bar; // `foo` is shadowed.
                                                          }
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-implicit-coercion.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-implicit-coercion.html new file mode 100644 index 0000000..3ea75aa --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-implicit-coercion.html @@ -0,0 +1,96 @@ + + + +

                                                          Disallow the type conversion with shorter notations. (no-implicit-coercion)

                                                          + +

                                                          In JavaScript, there are a lot of different ways to convert value types. +Some of them might be hard to read and understand.

                                                          + +

                                                          Such as:

                                                          + +
                                                          var b = !!foo;
                                                          var b = ~foo.indexOf(".");
                                                          var n = +foo;
                                                          var n = 1 * foo;
                                                          var s = "" + foo;
                                                          foo += "";
                                                          +
                                                          + +

                                                          Those can be replaced with the following code:

                                                          + +
                                                          var b = Boolean(foo);
                                                          var b = foo.indexOf(".") !== -1;
                                                          var n = Number(foo);
                                                          var n = Number(foo);
                                                          var s = String(foo);
                                                          foo = String(foo);
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed to flag shorter notations for the type conversion, then suggest a more self-explanatory notation.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has three main options and one override option to allow some coercions as required.

                                                          + +
                                                            +
                                                          • "boolean" (true by default) - When this is true, this rule warns shorter type conversions for boolean type.
                                                          • +
                                                          • "number" (true by default) - When this is true, this rule warns shorter type conversions for number type.
                                                          • +
                                                          • "string" (true by default) - When this is true, this rule warns shorter type conversions for string type.
                                                          • +
                                                          • "allow" (empty by default) - Each entry in this array can be one of ~, !!, + or * that are to be allowed.
                                                          • +
                                                          + +

                                                          Note that operator + in allow list would allow +foo (number coercion) as well as "" + foo (string coercion).

                                                          + +

                                                          boolean

                                                          + +

                                                          Examples of incorrect code for the default { "boolean": true } option:

                                                          + +
                                                          /*eslint no-implicit-coercion: "error"*/

                                                          var b = !!foo;
                                                          var b = ~foo.indexOf(".");
                                                          // bitwise not is incorrect only with `indexOf`/`lastIndexOf` method calling.
                                                          +
                                                          + +

                                                          Examples of correct code for the default { "boolean": true } option:

                                                          + +
                                                          /*eslint no-implicit-coercion: "error"*/

                                                          var b = Boolean(foo);
                                                          var b = foo.indexOf(".") !== -1;

                                                          var n = ~foo; // This is a just bitwise not.
                                                          +
                                                          + +

                                                          number

                                                          + +

                                                          Examples of incorrect code for the default { "number": true } option:

                                                          + +
                                                          /*eslint no-implicit-coercion: "error"*/

                                                          var n = +foo;
                                                          var n = 1 * foo;
                                                          +
                                                          + +

                                                          Examples of correct code for the default { "number": true } option:

                                                          + +
                                                          /*eslint no-implicit-coercion: "error"*/

                                                          var n = Number(foo);
                                                          var n = parseFloat(foo);
                                                          var n = parseInt(foo, 10);
                                                          +
                                                          + +

                                                          string

                                                          + +

                                                          Examples of incorrect code for the default { "string": true } option:

                                                          + +
                                                          /*eslint no-implicit-coercion: "error"*/

                                                          var s = "" + foo;
                                                          foo += "";
                                                          +
                                                          + +

                                                          Examples of correct code for the default { "string": true } option:

                                                          + +
                                                          /*eslint no-implicit-coercion: "error"*/

                                                          var s = String(foo);
                                                          +
                                                          + +

                                                          allow

                                                          + +

                                                          Using allow list, we can override and allow specific operators.

                                                          + +

                                                          Examples of correct code for the sample { "allow": ["!!", "~"] } option:

                                                          + +
                                                          /*eslint no-implicit-coercion: [2, { "allow": ["!!", "~"] } ]*/

                                                          var b = !!foo;
                                                          var b = ~foo.indexOf(".");
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about shorter notations for the type conversion, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0-rc-2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-implicit-globals.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-implicit-globals.html new file mode 100644 index 0000000..dcc855e --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-implicit-globals.html @@ -0,0 +1,48 @@ + + + +

                                                          Disallow var and Named Functions in Global Scope (no-implicit-globals)

                                                          + +

                                                          When working with browser scripts, developers often forget that variable and function declarations at the top-level scope become global variables on the window object. As opposed to modules which have their own scope. Globals should be explicitly assigned to window or self if that is the intent. Otherwise variables intended to be local to the script should be wrapped in an IIFE.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows var and named function declarations at the top-level script scope. This does not apply to ES and CommonJS modules since they have a module scope.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-implicit-globals: "error"*/

                                                          var foo = 1;

                                                          function bar() {}
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-implicit-globals: "error"*/

                                                          // explicitly set on window
                                                          window.foo = 1;
                                                          window.bar = function() {};

                                                          // intended to be scope to this file
                                                          (function() {
                                                          var foo = 1;

                                                          function bar() {}
                                                          })();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with "parserOptions": { "sourceType": "module" } in the ESLint configuration:

                                                          + +
                                                          /*eslint no-implicit-globals: 2*/

                                                          // foo and bar are local to module
                                                          var foo = 1;
                                                          function bar() {}
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to be able to declare variables and functions in the global scope you can safely disable this rule. Or if you are always using module scoped files, this rule will never apply.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-alpha-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-implied-eval.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-implied-eval.html new file mode 100644 index 0000000..e2dc1ed --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-implied-eval.html @@ -0,0 +1,62 @@ + + + +

                                                          Disallow Implied eval() (no-implied-eval)

                                                          + +

                                                          It’s considered a good practice to avoid using eval() in JavaScript. There are security and performance implications involved with doing so, which is why many linters (including ESLint) recommend disallowing eval(). However, there are some other ways to pass a string and have it interpreted as JavaScript code that have similar concerns.

                                                          + +

                                                          The first is using setTimeout(), setInterval() or execScript() (Internet Explorer only), both of which can accept a string of JavaScript code as their first argument. For example:

                                                          + +
                                                          setTimeout("alert('Hi!');", 100);
                                                          +
                                                          + +

                                                          This is considered an implied eval() because a string of JavaScript code is + passed in to be interpreted. The same can be done with setInterval() and execScript(). Both interpret the JavaScript code in the global scope. For both setTimeout() and setInterval(), the first argument can also be a function, and that is considered safer and is more performant:

                                                          + +
                                                          setTimeout(function() {
                                                          alert("Hi!");
                                                          }, 100);
                                                          +
                                                          + +

                                                          The best practice is to always use a function for the first argument of setTimeout() and setInterval() (and avoid execScript()).

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to eliminate implied eval() through the use of setTimeout(), setInterval() or execScript(). As such, it will warn when either function is used with a string as the first argument.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-implied-eval: "error"*/

                                                          setTimeout("alert('Hi!');", 100);

                                                          setInterval("alert('Hi!');", 100);

                                                          execScript("alert('Hi!')");

                                                          window.setTimeout("count = 5", 10);

                                                          window.setInterval("foo = bar", 10);
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-implied-eval: "error"*/

                                                          setTimeout(function() {
                                                          alert("Hi!");
                                                          }, 100);

                                                          setInterval(function() {
                                                          alert("Hi!");
                                                          }, 100);
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to allow setTimeout() and setInterval() with string arguments, then you can safely disable this rule.

                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.7.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-inline-comments.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-inline-comments.html new file mode 100644 index 0000000..06d436c --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-inline-comments.html @@ -0,0 +1,34 @@ + + + +

                                                          disallow inline comments after code (no-inline-comments)

                                                          + +

                                                          Some style guides disallow comments on the same line as code. Code can become difficult to read if comments immediately follow the code on the same line. +On the other hand, it is sometimes faster and more obvious to put comments immediately following code.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows comments on the same line as code.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-inline-comments: "error"*/

                                                          var a = 1; // declaring a to 1

                                                          function getRandomNumber(){
                                                          return 4; // chosen by fair dice roll.
                                                          // guaranteed to be random.
                                                          }

                                                          /* A block comment before code */ var b = 2;

                                                          var c = 3; /* A block comment after code */
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-inline-comments: "error"*/

                                                          // This is a comment above a line of code
                                                          var foo = 5;

                                                          var bar = 5;
                                                          //This is a comment below a line of code
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.10.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-inner-declarations.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-inner-declarations.html new file mode 100644 index 0000000..a8fdac1 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-inner-declarations.html @@ -0,0 +1,68 @@ + + + +

                                                          disallow function or var declarations in nested blocks (no-inner-declarations)

                                                          + +

                                                          In JavaScript, prior to ES6, a function declaration is only allowed in the first level of a program or the body of another function, though parsers sometimes erroneously accept them elsewhere. This only applies to function declarations; named or anonymous function expressions can occur anywhere an expression is permitted.

                                                          + +
                                                          // Good
                                                          function doSomething() { }

                                                          // Bad
                                                          if (test) {
                                                          function doSomethingElse () { }
                                                          }

                                                          function anotherThing() {
                                                          var fn;

                                                          if (test) {

                                                          // Good
                                                          fn = function expression() { };

                                                          // Bad
                                                          function declaration() { }
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          A variable declaration is permitted anywhere a statement can go, even nested deeply inside other blocks. This is often undesirable due to variable hoisting, and moving declarations to the root of the program or function body can increase clarity. Note that block bindings (let, const) are not hoisted and therefore they are not affected by this rule.

                                                          + +
                                                          /*eslint-env es6*/

                                                          // Good
                                                          var foo = 42;

                                                          // Good
                                                          if (foo) {
                                                          let bar1;
                                                          }

                                                          // Bad
                                                          while (test) {
                                                          var bar2;
                                                          }

                                                          function doSomething() {
                                                          // Good
                                                          var baz = true;

                                                          // Bad
                                                          if (baz) {
                                                          var quux;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule requires that function declarations and, optionally, variable declarations be in the root of a program or the body of a function.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has a string option:

                                                          + +
                                                            +
                                                          • "functions" (default) disallows function declarations in nested blocks
                                                          • +
                                                          • "both" disallows function and var declarations in nested blocks
                                                          • +
                                                          + +

                                                          functions

                                                          + +

                                                          Examples of incorrect code for this rule with the default "functions" option:

                                                          + +
                                                          /*eslint no-inner-declarations: "error"*/

                                                          if (test) {
                                                          function doSomething() { }
                                                          }

                                                          function doSomethingElse() {
                                                          if (test) {
                                                          function doAnotherThing() { }
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default "functions" option:

                                                          + +
                                                          /*eslint no-inner-declarations: "error"*/

                                                          function doSomething() { }

                                                          function doSomethingElse() {
                                                          function doAnotherThing() { }
                                                          }

                                                          if (test) {
                                                          asyncCall(id, function (err, data) { });
                                                          }

                                                          var fn;
                                                          if (test) {
                                                          fn = function fnExpression() { };
                                                          }
                                                          +
                                                          + +

                                                          both

                                                          + +

                                                          Examples of incorrect code for this rule with the "both" option:

                                                          + +
                                                          /*eslint no-inner-declarations: ["error", "both"]*/

                                                          if (test) {
                                                          var foo = 42;
                                                          }

                                                          function doAnotherThing() {
                                                          if (test) {
                                                          var bar = 81;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "both" option:

                                                          + +
                                                          /*eslint no-inner-declarations: "error"*/
                                                          /*eslint-env es6*/

                                                          var bar = 42;

                                                          if (test) {
                                                          let baz = 43;
                                                          }

                                                          function doAnotherThing() {
                                                          var baz = 81;
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          The function declaration portion rule will be rendered obsolete when block-scoped functions land in ES6, but until then, it should be left on to enforce valid constructions. Disable checking variable declarations when using block-scoped-var or if declaring variables in nested blocks is acceptable despite hoisting.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.6.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-invalid-regexp.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-invalid-regexp.html new file mode 100644 index 0000000..0517772 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-invalid-regexp.html @@ -0,0 +1,67 @@ + + + +

                                                          disallow invalid regular expression strings in RegExp constructors (no-invalid-regexp)

                                                          + +

                                                          An invalid pattern in a regular expression literal is a SyntaxError when the code is parsed, but an invalid string in RegExp constructors throws a SyntaxError only when the code is executed.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows invalid regular expression strings in RegExp constructors.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-invalid-regexp: "error"*/

                                                          RegExp('[')

                                                          RegExp('.', 'z')

                                                          new RegExp('\\')
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-invalid-regexp: "error"*/

                                                          RegExp('.')

                                                          new RegExp

                                                          this.RegExp('[')
                                                          +
                                                          + +

                                                          Environments

                                                          + +

                                                          ECMAScript 6 adds the following flag arguments to the RegExp constructor:

                                                          + + + +

                                                          You can enable these to be recognized as valid by setting the ECMAScript version to 6 in your ESLint configuration.

                                                          + +

                                                          If you want to allow additional constructor flags for any reason, you can specify them using an allowConstructorFlags option in .eslintrc. These flags will then be ignored by the rule regardless of the ecmaVersion setting.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an object option for exceptions:

                                                          + +
                                                            +
                                                          • "allowConstructorFlags" is an array of flags
                                                          • +
                                                          + +

                                                          allowConstructorFlags

                                                          + +

                                                          Examples of correct code for this rule with the { "allowConstructorFlags": ["u", "y"] } option:

                                                          + +
                                                          /*eslint no-invalid-regexp: ["error", { "allowConstructorFlags": ["u", "y"] }]*/

                                                          new RegExp('.', 'y')

                                                          new RegExp('.', 'yu')
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.1.4.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-invalid-this.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-invalid-this.html new file mode 100644 index 0000000..485065a --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-invalid-this.html @@ -0,0 +1,67 @@ + + + +

                                                          Disallow this keywords outside of classes or class-like objects. (no-invalid-this)

                                                          + +

                                                          Under the strict mode, this keywords outside of classes or class-like objects might be undefined and raise a TypeError.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to flag usage of this keywords outside of classes or class-like objects.

                                                          + +

                                                          Basically this rule checks whether or not a function which are containing this keywords is a constructor or a method.

                                                          + +

                                                          This rule judges from following conditions whether or not the function is a constructor:

                                                          + +
                                                            +
                                                          • The name of the function starts with uppercase.
                                                          • +
                                                          • The function is a constructor of ES2015 Classes.
                                                          • +
                                                          + +

                                                          This rule judges from following conditions whether or not the function is a method:

                                                          + +
                                                            +
                                                          • The function is on an object literal.
                                                          • +
                                                          • The function assigns to a property.
                                                          • +
                                                          • The function is a method/getter/setter of ES2015 Classes. (excepts static methods)
                                                          • +
                                                          + +

                                                          And this rule allows this keywords in functions below:

                                                          + +
                                                            +
                                                          • The call/apply/bind method of the function is called directly.
                                                          • +
                                                          • The function is a callback of array methods (such as .forEach()) if thisArg is given.
                                                          • +
                                                          • The function has @this tag in its JSDoc comment.
                                                          • +
                                                          + +

                                                          Otherwise are considered problems.

                                                          + +

                                                          This rule applies only in strict mode. +With "parserOptions": { "sourceType": "module" } in the ESLint configuration, your code is in strict mode even without a "use strict" directive.

                                                          + +

                                                          Examples of incorrect code for this rule in strict mode:

                                                          + +
                                                          /*eslint no-invalid-this: "error"*/
                                                          /*eslint-env es6*/

                                                          "use strict";

                                                          this.a = 0;
                                                          baz(() => this);

                                                          (function() {
                                                          this.a = 0;
                                                          baz(() => this);
                                                          })();

                                                          function foo() {
                                                          this.a = 0;
                                                          baz(() => this);
                                                          }

                                                          var foo = function() {
                                                          this.a = 0;
                                                          baz(() => this);
                                                          };

                                                          foo(function() {
                                                          this.a = 0;
                                                          baz(() => this);
                                                          });

                                                          obj.foo = () => {
                                                          // `this` of arrow functions is the outer scope's.
                                                          this.a = 0;
                                                          };

                                                          var obj = {
                                                          aaa: function() {
                                                          return function foo() {
                                                          // There is in a method `aaa`, but `foo` is not a method.
                                                          this.a = 0;
                                                          baz(() => this);
                                                          };
                                                          }
                                                          };

                                                          foo.forEach(function() {
                                                          this.a = 0;
                                                          baz(() => this);
                                                          });
                                                          +
                                                          + +

                                                          Examples of correct code for this rule in strict mode:

                                                          + +
                                                          /*eslint no-invalid-this: "error"*/
                                                          /*eslint-env es6*/

                                                          "use strict";

                                                          function Foo() {
                                                          // OK, this is in a legacy style constructor.
                                                          this.a = 0;
                                                          baz(() => this);
                                                          }

                                                          class Foo {
                                                          constructor() {
                                                          // OK, this is in a constructor.
                                                          this.a = 0;
                                                          baz(() => this);
                                                          }
                                                          }

                                                          var obj = {
                                                          foo: function foo() {
                                                          // OK, this is in a method (this function is on object literal).
                                                          this.a = 0;
                                                          }
                                                          };

                                                          var obj = {
                                                          foo() {
                                                          // OK, this is in a method (this function is on object literal).
                                                          this.a = 0;
                                                          }
                                                          };

                                                          var obj = {
                                                          get foo() {
                                                          // OK, this is in a method (this function is on object literal).
                                                          return this.a;
                                                          }
                                                          };

                                                          var obj = Object.create(null, {
                                                          foo: {value: function foo() {
                                                          // OK, this is in a method (this function is on object literal).
                                                          this.a = 0;
                                                          }}
                                                          });

                                                          Object.defineProperty(obj, "foo", {
                                                          value: function foo() {
                                                          // OK, this is in a method (this function is on object literal).
                                                          this.a = 0;
                                                          }
                                                          });

                                                          Object.defineProperties(obj, {
                                                          foo: {value: function foo() {
                                                          // OK, this is in a method (this function is on object literal).
                                                          this.a = 0;
                                                          }}
                                                          });

                                                          function Foo() {
                                                          this.foo = function foo() {
                                                          // OK, this is in a method (this function assigns to a property).
                                                          this.a = 0;
                                                          baz(() => this);
                                                          };
                                                          }

                                                          obj.foo = function foo() {
                                                          // OK, this is in a method (this function assigns to a property).
                                                          this.a = 0;
                                                          };

                                                          Foo.prototype.foo = function foo() {
                                                          // OK, this is in a method (this function assigns to a property).
                                                          this.a = 0;
                                                          };

                                                          class Foo {
                                                          foo() {
                                                          // OK, this is in a method.
                                                          this.a = 0;
                                                          baz(() => this);
                                                          }

                                                          static foo() {
                                                          // OK, this is in a method (static methods also have valid this).
                                                          this.a = 0;
                                                          baz(() => this);
                                                          }
                                                          }

                                                          var foo = (function foo() {
                                                          // OK, the `bind` method of this function is called directly.
                                                          this.a = 0;
                                                          }).bind(obj);

                                                          foo.forEach(function() {
                                                          // OK, `thisArg` of `.forEach()` is given.
                                                          this.a = 0;
                                                          baz(() => this);
                                                          }, thisArg);

                                                          /** @this Foo */
                                                          function foo() {
                                                          // OK, this function has a `@this` tag in its JSDoc comment.
                                                          this.a = 0;
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about usage of this keyword outside of classes or class-like objects, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0-rc-2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-irregular-whitespace.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-irregular-whitespace.html new file mode 100644 index 0000000..869a7b4 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-irregular-whitespace.html @@ -0,0 +1,101 @@ + + + +

                                                          disallow irregular whitespace (no-irregular-whitespace)

                                                          + +

                                                          Invalid or irregular whitespace causes issues with ECMAScript 5 parsers and also makes code harder to debug in a similar nature to mixed tabs and spaces.

                                                          + +

                                                          Various whitespace characters can be inputted by programmers by mistake for example from copying or keyboard shortcuts. Pressing Alt + Space on OS X adds in a non breaking space character for example.

                                                          + +

                                                          Known issues these spaces cause:

                                                          + +
                                                            +
                                                          • Zero Width Space +
                                                              +
                                                            • Is NOT considered a separator for tokens and is often parsed as an Unexpected token ILLEGAL
                                                            • +
                                                            • Is NOT shown in modern browsers making code repository software expected to resolve the visualisation
                                                            • +
                                                            +
                                                          • +
                                                          • Line Separator +
                                                              +
                                                            • Is NOT a valid character within JSON which would cause parse errors
                                                            • +
                                                            +
                                                          • +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at catching invalid whitespace that is not a normal tab and space. Some of these characters may cause issues in modern browsers and others will be a debugging issue to spot.

                                                          + +

                                                          This rule disallows the following characters except where the options allow:

                                                          + +
                                                          \u000B - Line Tabulation (\v) - <VT>
                                                          \u000C - Form Feed (\f) - <FF>
                                                          \u00A0 - No-Break Space - <NBSP>
                                                          \u0085 - Next Line
                                                          \u1680 - Ogham Space Mark
                                                          \u180E - Mongolian Vowel Separator - <MVS>
                                                          \ufeff - Zero Width No-Break Space - <BOM>
                                                          \u2000 - En Quad
                                                          \u2001 - Em Quad
                                                          \u2002 - En Space - <ENSP>
                                                          \u2003 - Em Space - <EMSP>
                                                          \u2004 - Tree-Per-Em
                                                          \u2005 - Four-Per-Em
                                                          \u2006 - Six-Per-Em
                                                          \u2007 - Figure Space
                                                          \u2008 - Punctuation Space - <PUNCSP>
                                                          \u2009 - Thin Space
                                                          \u200A - Hair Space
                                                          \u200B - Zero Width Space - <ZWSP>
                                                          \u2028 - Line Separator
                                                          \u2029 - Paragraph Separator
                                                          \u202F - Narrow No-Break Space
                                                          \u205f - Medium Mathematical Space
                                                          \u3000 - Ideographic Space
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an object option for exceptions:

                                                          + +
                                                            +
                                                          • "skipStrings": true (default) allows any whitespace characters in string literals
                                                          • +
                                                          • "skipComments": true allows any whitespace characters in comments
                                                          • +
                                                          • "skipRegExps": true allows any whitespace characters in regular expression literals
                                                          • +
                                                          • "skipTemplates": true allows any whitespace characters in template literals
                                                          • +
                                                          + +

                                                          skipStrings

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "skipStrings": true } option:

                                                          + +
                                                          /*eslint no-irregular-whitespace: "error"*/

                                                          function thing() /*<NBSP>*/{
                                                          return 'test';
                                                          }

                                                          function thing( /*<NBSP>*/){
                                                          return 'test';
                                                          }

                                                          function thing /*<NBSP>*/(){
                                                          return 'test';
                                                          }

                                                          function thing/*<MVS>*/(){
                                                          return 'test';
                                                          }

                                                          function thing() {
                                                          return 'test';/*<ENSP>*/
                                                          }

                                                          function thing() {
                                                          return 'test'; /*<NBSP>*/
                                                          }

                                                          function thing() {
                                                          // Description <NBSP>: some descriptive text
                                                          }

                                                          /*
                                                          Description <NBSP>: some descriptive text
                                                          */


                                                          function thing() {
                                                          return / <NBSP>regexp/;
                                                          }

                                                          /*eslint-env es6*/
                                                          function thing() {
                                                          return `template<NBSP>string`;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "skipStrings": true } option:

                                                          + +
                                                          /*eslint no-irregular-whitespace: "error"*/

                                                          function thing() {
                                                          return ' <NBSP>thing';
                                                          }

                                                          function thing() {
                                                          return '​<ZWSP>thing';
                                                          }

                                                          function thing() {
                                                          return 'th <NBSP>ing';
                                                          }
                                                          +
                                                          + +

                                                          skipComments

                                                          + +

                                                          Examples of additional correct code for this rule with the { "skipComments": true } option:

                                                          + +
                                                          /*eslint no-irregular-whitespace: ["error", { "skipComments": true }]*/

                                                          function thing() {
                                                          // Description <NBSP>: some descriptive text
                                                          }

                                                          /*
                                                          Description <NBSP>: some descriptive text
                                                          */

                                                          +
                                                          + +

                                                          skipRegExps

                                                          + +

                                                          Examples of additional correct code for this rule with the { "skipRegExps": true } option:

                                                          + +
                                                          /*eslint no-irregular-whitespace: ["error", { "skipRegExps": true }]*/

                                                          function thing() {
                                                          return / <NBSP>regexp/;
                                                          }
                                                          +
                                                          + +

                                                          skipTemplates

                                                          + +

                                                          Examples of additional correct code for this rule with the { "skipTemplates": true } option:

                                                          + +
                                                          /*eslint no-irregular-whitespace: ["error", { "skipTemplates": true }]*/
                                                          /*eslint-env es6*/

                                                          function thing() {
                                                          return `template<NBSP>string`;
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you decide that you wish to use whitespace other than tabs and spaces outside of strings in your application.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.9.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-iterator.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-iterator.html new file mode 100644 index 0000000..36e03f3 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-iterator.html @@ -0,0 +1,46 @@ + + + +

                                                          Disallow Iterator (no-iterator)

                                                          + +

                                                          The __iterator__ property was a SpiderMonkey extension to JavaScript that could be used to create custom iterators that are compatible with JavaScript’s for in and for each constructs. However, this property is now obsolete, so it should not be used. Here’s an example of how this used to work:

                                                          + +
                                                          Foo.prototype.__iterator__ = function() {
                                                          return new FooIterator(this);
                                                          }
                                                          +
                                                          + +

                                                          You should use ECMAScript 6 iterators and generators instead.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at preventing errors that may arise from using the __iterator__ property, which is not implemented in several browsers. As such, it will warn whenever it encounters the __iterator__ property.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-iterator: "error"*/

                                                          Foo.prototype.__iterator__ = function() {
                                                          return new FooIterator(this);
                                                          };

                                                          foo.__iterator__ = function () {};

                                                          foo["__iterator__"] = function () {};

                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-iterator: "error"*/

                                                          var __iterator__ = foo; // Not using the `__iterator__` property.
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-label-var.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-label-var.html new file mode 100644 index 0000000..ee639a1 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-label-var.html @@ -0,0 +1,49 @@ + + + +

                                                          Disallow Labels That Are Variables Names (no-label-var)

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to create clearer code by disallowing the bad practice of creating a label that shares a name with a variable that is in scope.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-label-var: "error"*/

                                                          var x = foo;
                                                          function bar() {
                                                          x:
                                                          for (;;) {
                                                          break x;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-label-var: "error"*/

                                                          // The variable that has the same name as the label is not in scope.

                                                          function foo() {
                                                          var q = t;
                                                          }

                                                          function bar() {
                                                          q:
                                                          for(;;) {
                                                          break q;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about usage of labels, then it’s safe to disable this rule.

                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-labels.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-labels.html new file mode 100644 index 0000000..eebf3f4 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-labels.html @@ -0,0 +1,78 @@ + + + +

                                                          Disallow Labeled Statements (no-labels)

                                                          + +

                                                          Labeled statements in JavaScript are used in conjunction with break and continue to control flow around multiple loops. For example:

                                                          + +
                                                          outer:
                                                          while (true) {

                                                          while (true) {
                                                          break outer;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          The break outer statement ensures that this code will not result in an infinite loop because control is returned to the next statement after the outer label was applied. If this statement was changed to be just break, control would flow back to the outer while statement and an infinite loop would result.

                                                          + +

                                                          While convenient in some cases, labels tend to be used only rarely and are frowned upon by some as a remedial form of flow control that is more error prone and harder to understand.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to eliminate the use of labeled statements in JavaScript. It will warn whenever a labeled statement is encountered and whenever break or continue are used with a label.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-labels: "error"*/

                                                          label:
                                                          while(true) {
                                                          // ...
                                                          }

                                                          label:
                                                          while(true) {
                                                          break label;
                                                          }

                                                          label:
                                                          while(true) {
                                                          continue label;
                                                          }

                                                          label:
                                                          switch (a) {
                                                          case 0:
                                                          break label;
                                                          }

                                                          label:
                                                          {
                                                          break label;
                                                          }

                                                          label:
                                                          if (a) {
                                                          break label;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-labels: "error"*/

                                                          var f = {
                                                          label: "foo"
                                                          };

                                                          while (true) {
                                                          break;
                                                          }

                                                          while (true) {
                                                          continue;
                                                          }
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          The options allow labels with loop or switch statements:

                                                          + +
                                                            +
                                                          • "allowLoop" (boolean, default is false) - If this option was set true, this rule ignores labels which are sticking to loop statements.
                                                          • +
                                                          • "allowSwitch" (boolean, default is false) - If this option was set true, this rule ignores labels which are sticking to switch statements.
                                                          • +
                                                          + +

                                                          Actually labeled statements in JavaScript can be used with other than loop and switch statements. +However, this way is ultra rare, not well-known, so this would be confusing developers.

                                                          + +

                                                          allowLoop

                                                          + +

                                                          Examples of correct code for the { “allowLoop”: true } option:

                                                          + +
                                                          /*eslint no-labels: ["error", { "allowLoop": true }]*/

                                                          label:
                                                          while (true) {
                                                          break label;
                                                          }
                                                          +
                                                          + +

                                                          allowSwitch

                                                          + +

                                                          Examples of correct code for the { “allowSwitch”: true } option:

                                                          + +
                                                          /*eslint no-labels: ["error", { "allowSwitch": true }]*/

                                                          label:
                                                          switch (a) {
                                                          case 0:
                                                          break label;
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you need to use labeled statements everywhere, then you can safely disable this rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-lone-blocks.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-lone-blocks.html new file mode 100644 index 0000000..a93e97a --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-lone-blocks.html @@ -0,0 +1,43 @@ + + + +

                                                          Disallow Unnecessary Nested Blocks (no-lone-blocks)

                                                          + +

                                                          In JavaScript, prior to ES6, standalone code blocks delimited by curly braces do not create a new scope and have no use. For example, these curly braces do nothing to foo:

                                                          + +
                                                          {
                                                          var foo = bar();
                                                          }
                                                          +
                                                          + +

                                                          In ES6, code blocks may create a new scope if a block-level binding (let and const), a class declaration or a function declaration (in strict mode) are present. A block is not considered redundant in these cases.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to eliminate unnecessary and potentially confusing blocks at the top level of a script or within other blocks.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-lone-blocks: "error"*/

                                                          {}

                                                          if (foo) {
                                                          bar();
                                                          {
                                                          baz();
                                                          }
                                                          }

                                                          function bar() {
                                                          {
                                                          baz();
                                                          }
                                                          }

                                                          {
                                                          function foo() {}
                                                          }

                                                          {
                                                          aLabel: {
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with es6 environment:

                                                          + +
                                                          /*eslint no-lone-blocks: "error"*/
                                                          /*eslint-env es6*/

                                                          while (foo) {
                                                          bar();
                                                          }

                                                          if (foo) {
                                                          if (bar) {
                                                          baz();
                                                          }
                                                          }

                                                          function bar() {
                                                          baz();
                                                          }

                                                          {
                                                          let x = 1;
                                                          }

                                                          {
                                                          const y = 1;
                                                          }

                                                          {
                                                          class Foo {}
                                                          }

                                                          aLabel: {
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with es6 environment and strict mode via "parserOptions": { "sourceType": "module" } in the ESLint configuration or "use strict" directive in the code:

                                                          + +
                                                          /*eslint no-lone-blocks: "error"*/
                                                          /*eslint-env es6*/

                                                          "use strict";

                                                          {
                                                          function foo() {}
                                                          }
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-lonely-if.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-lonely-if.html new file mode 100644 index 0000000..47b8076 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-lonely-if.html @@ -0,0 +1,45 @@ + + + +

                                                          Disallow if as the Only Statement in an else Block (no-lonely-if)

                                                          + +

                                                          If an if statement is the only statement in the else block of a parent if statement, it is often clearer to combine the two to using else if form.

                                                          + +
                                                          if (foo) {
                                                          // ...
                                                          } else {
                                                          if (bar) {
                                                          // ...
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          should be rewritten as

                                                          + +
                                                          if (foo) {
                                                          // ...
                                                          } else if (bar) {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule warns when an if statement’s else block contains only another if statement.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-lonely-if: "error"*/

                                                          if (condition) {
                                                          // ...
                                                          } else {
                                                          if (anotherCondition) {
                                                          // ...
                                                          }
                                                          }

                                                          if (condition) {
                                                          // ...
                                                          } else {
                                                          if (anotherCondition) {
                                                          // ...
                                                          } else {
                                                          // ...
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-lonely-if: "error"*/

                                                          if (condition) {
                                                          // ...
                                                          } else if (anotherCondition) {
                                                          // ...
                                                          }

                                                          if (condition) {
                                                          // ...
                                                          } else if (anotherCondition) {
                                                          // ...
                                                          } else {
                                                          // ...
                                                          }

                                                          if (condition) {
                                                          // ...
                                                          } else {
                                                          if (anotherCondition) {
                                                          // ...
                                                          }
                                                          doSomething();
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          Disable this rule if the code is clearer without requiring the else if form.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.6.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-loop-func.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-loop-func.html new file mode 100644 index 0000000..ed3f3cf --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-loop-func.html @@ -0,0 +1,51 @@ + + + +

                                                          Disallow Functions in Loops (no-loop-func)

                                                          + +

                                                          Writing functions within loops tends to result in errors due to the way the function creates a closure around the loop. For example:

                                                          + +
                                                          for (var i = 0; i < 10; i++) {
                                                          funcs[i] = function() {
                                                          return i;
                                                          };
                                                          }
                                                          +
                                                          + +

                                                          In this case, you would expect each function created within the loop to return a different number. In reality, each function returns 10, because that was the last value of i in the scope.

                                                          + +

                                                          let or const mitigate this problem.

                                                          + +
                                                          /*eslint-env es6*/

                                                          for (let i = 0; i < 10; i++) {
                                                          funcs[i] = function() {
                                                          return i;
                                                          };
                                                          }
                                                          +
                                                          + +

                                                          In this case, each function created within the loop returns a different number as expected.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This error is raised to highlight a piece of code that may not work as you expect it to and could also indicate a misunderstanding of how the language works. Your code may run without any problems if you do not fix this error, but in some situations it could behave unexpectedly.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-loop-func: "error"*/
                                                          /*eslint-env es6*/

                                                          for (var i=10; i; i--) {
                                                          (function() { return i; })();
                                                          }

                                                          while(i) {
                                                          var a = function() { return i; };
                                                          a();
                                                          }

                                                          do {
                                                          function a() { return i; };
                                                          a();
                                                          } while (i);

                                                          let foo = 0;
                                                          for (let i=10; i; i--) {
                                                          // Bad, function is referencing block scoped variable in the outer scope.
                                                          var a = function() { return foo; };
                                                          a();
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-loop-func: "error"*/
                                                          /*eslint-env es6*/

                                                          var a = function() {};

                                                          for (var i=10; i; i--) {
                                                          a();
                                                          }

                                                          for (var i=10; i; i--) {
                                                          var a = function() {}; // OK, no references to variables in the outer scopes.
                                                          a();
                                                          }

                                                          for (let i=10; i; i--) {
                                                          var a = function() { return i; }; // OK, all references are referring to block scoped variables in the loop.
                                                          a();
                                                          }

                                                          var foo = 100;
                                                          for (let i=10; i; i--) {
                                                          var a = function() { return foo; }; // OK, all references are referring to never modified variables.
                                                          a();
                                                          }
                                                          //... no modifications of foo after this loop ...
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-magic-numbers.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-magic-numbers.html new file mode 100644 index 0000000..cbb1937 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-magic-numbers.html @@ -0,0 +1,85 @@ + + + +

                                                          Disallow Magic Numbers (no-magic-numbers)

                                                          + +

                                                          ‘Magic numbers’ are numbers that occur multiple time in code without an explicit meaning. +They should preferably be replaced by named constants.

                                                          + +
                                                          var now = Date.now(),
                                                          inOneHour = now + (60 * 60 * 1000);
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          The no-magic-numbers rule aims to make code more readable and refactoring easier by ensuring that special numbers +are declared as constants to make their meaning explicit.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-magic-numbers: "error"*/

                                                          var dutyFreePrice = 100,
                                                          finalPrice = dutyFreePrice + (dutyFreePrice * 0.25);
                                                          +
                                                          + +
                                                          /*eslint no-magic-numbers: "error"*/

                                                          var data = ['foo', 'bar', 'baz'];

                                                          var dataLast = data[2];
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-magic-numbers: "error"*/

                                                          var TAX = 0.25;

                                                          var dutyFreePrice = 100,
                                                          finalPrice = dutyFreePrice + (dutyFreePrice * TAX);
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          ignore

                                                          + +

                                                          An array of numbers to ignore. It’s set to [] by default. +If provided, it must be an Array.

                                                          + +

                                                          Examples of correct code for the sample { “ignore”: [1] } option:

                                                          + +
                                                          /*eslint no-magic-numbers: ["error", { "ignore": [1] }]*/

                                                          var data = ['foo', 'bar', 'baz'];
                                                          var dataLast = data.length && data[data.length - 1];
                                                          +
                                                          + +

                                                          ignoreArrayIndexes

                                                          + +

                                                          A boolean to specify if numbers used as array indexes are considered okay. false by default.

                                                          + +

                                                          Examples of correct code for the { “ignoreArrayIndexes”: true } option:

                                                          + +
                                                          /*eslint no-magic-numbers: ["error", { "ignoreArrayIndexes": true }]*/

                                                          var data = ['foo', 'bar', 'baz'];
                                                          var dataLast = data[2];
                                                          +
                                                          + +

                                                          enforceConst

                                                          + +

                                                          A boolean to specify if we should check for the const keyword in variable declaration of numbers. false by default.

                                                          + +

                                                          Examples of incorrect code for the { “enforceConst”: true } option:

                                                          + +
                                                          /*eslint no-magic-numbers: ["error", { "enforceConst": true }]*/

                                                          var TAX = 0.25;

                                                          var dutyFreePrice = 100,
                                                          finalPrice = dutyFreePrice + (dutyFreePrice * TAX);
                                                          +
                                                          + +

                                                          detectObjects

                                                          + +

                                                          A boolean to specify if we should detect numbers when setting object properties for example. false by default.

                                                          + +

                                                          Examples of incorrect code for the { “detectObjects”: true } option:

                                                          + +
                                                          /*eslint no-magic-numbers: ["error", { "detectObjects": true }]*/

                                                          var magic = {
                                                          tax: 0.25
                                                          };

                                                          var dutyFreePrice = 100,
                                                          finalPrice = dutyFreePrice + (dutyFreePrice * magic.tax);
                                                          +
                                                          + +

                                                          Examples of correct code for the { “detectObjects”: true } option:

                                                          + +
                                                          /*eslint no-magic-numbers: ["error", { "detectObjects": true }]*/

                                                          var TAX = 0.25;

                                                          var magic = {
                                                          tax: TAX
                                                          };

                                                          var dutyFreePrice = 100,
                                                          finalPrice = dutyFreePrice + (dutyFreePrice * magic.tax);
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.7.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-mixed-requires.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-mixed-requires.html new file mode 100644 index 0000000..29eeacd --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-mixed-requires.html @@ -0,0 +1,95 @@ + + + +

                                                          Disallow Mixed Requires (no-mixed-requires)

                                                          + +

                                                          In the Node.js community it is often customary to separate initializations with calls to require modules from other variable declarations, sometimes also grouping them by the type of module. This rule helps you enforce this convention.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          When this rule is enabled, each var statement must satisfy the following conditions:

                                                          + +
                                                            +
                                                          • either none or all variable declarations must be require declarations (default)
                                                          • +
                                                          • all require declarations must be of the same type (grouping)
                                                          • +
                                                          + +

                                                          This rule distinguishes between six kinds of variable declaration types:

                                                          + +
                                                            +
                                                          • core: declaration of a required core module
                                                          • +
                                                          • file: declaration of a required file module
                                                          • +
                                                          • module: declaration of a required module from the node_modules folder
                                                          • +
                                                          • computed: declaration of a required module whose type could not be determined (either because it is computed or because require was called without an argument)
                                                          • +
                                                          • uninitialized: a declaration that is not initialized
                                                          • +
                                                          • other: any other kind of declaration
                                                          • +
                                                          + +

                                                          In this document, the first four types are summed up under the term require declaration.

                                                          + +
                                                          var fs = require('fs'),        // "core"     \
                                                          async = require('async'), // "module" |- these are "require declaration"s
                                                          foo = require('./foo'), // "file" |
                                                          bar = require(getName()), // "computed" /
                                                          baz = 42, // "other"
                                                          bam; // "uninitialized"
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule can have an object literal option whose two properties have false values by default.

                                                          + +

                                                          Configuring this rule with one boolean option true is deprecated.

                                                          + +

                                                          Examples of incorrect code for this rule with the default { "grouping": false, "allowCall": false } options:

                                                          + +
                                                          /*eslint no-mixed-requires: "error"*/

                                                          var fs = require('fs'),
                                                          i = 0;

                                                          var async = require('async'),
                                                          debug = require('diagnostics').someFunction('my-module'),
                                                          eslint = require('eslint');
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the default { "grouping": false, "allowCall": false } options:

                                                          + +
                                                          /*eslint no-mixed-requires: "error"*/

                                                          // only require declarations (grouping off)
                                                          var eventEmitter = require('events').EventEmitter,
                                                          myUtils = require('./utils'),
                                                          util = require('util'),
                                                          bar = require(getBarModuleName());

                                                          // only non-require declarations
                                                          var foo = 42,
                                                          bar = 'baz';

                                                          // always valid regardless of grouping because all declarations are of the same type
                                                          var foo = require('foo' + VERSION),
                                                          bar = require(getBarModuleName()),
                                                          baz = require();
                                                          +
                                                          + +

                                                          grouping

                                                          + +

                                                          Examples of incorrect code for this rule with the { "grouping": true } option:

                                                          + +
                                                          /*eslint no-mixed-requires: ["error", { "grouping": true }]*/

                                                          // invalid because of mixed types "core" and "file"
                                                          var fs = require('fs'),
                                                          async = require('async');

                                                          // invalid because of mixed types "file" and "unknown"
                                                          var foo = require('foo'),
                                                          bar = require(getBarModuleName());
                                                          +
                                                          + +

                                                          allowCall

                                                          + +

                                                          Examples of incorrect code for this rule with the { "allowCall": true } option:

                                                          + +
                                                          /*eslint no-mixed-requires: ["error", { "allowCall": true }]*/

                                                          var async = require('async'),
                                                          debug = require('diagnostics').someFunction('my-module'), /* allowCall doesn't allow calling any function */
                                                          eslint = require('eslint');
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the { "allowCall": true } option:

                                                          + +
                                                          /*eslint no-mixed-requires: ["error", { "allowCall": true }]*/

                                                          var async = require('async'),
                                                          debug = require('diagnostics')('my-module'),
                                                          eslint = require('eslint');
                                                          +
                                                          + +

                                                          Known Limitations

                                                          + +
                                                            +
                                                          • +

                                                            The implementation is not aware of any local functions with the name require that may shadow Node.js’ global require.

                                                            +
                                                          • +
                                                          • +

                                                            Internally, the list of core modules is retrieved via require("repl")._builtinLibs. If you use different versions of Node.js for ESLint and your application, the list of core modules for each version may be different. +The above mentioned _builtinLibs property became available in 0.8, for earlier versions a hardcoded list of module names is used as a fallback. If your version of Node.js is older than 0.6 that list may be inaccurate.

                                                            +
                                                          • +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you use a pattern such as UMD where the required modules are not loaded in variable declarations, this rule will obviously do nothing for you.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-mixed-spaces-and-tabs.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-mixed-spaces-and-tabs.html new file mode 100644 index 0000000..af00152 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-mixed-spaces-and-tabs.html @@ -0,0 +1,55 @@ + + + +

                                                          Disallow mixed spaces and tabs for indentation (no-mixed-spaces-and-tabs)

                                                          + +

                                                          Most code conventions require either tabs or spaces be used for indentation. As such, it’s usually an error if a single line of code is indented with both tabs and spaces.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          The no-mixed-spaces-and-tabs rule is aimed at flagging any lines of code that are indented with a mixture of tabs and spaces.

                                                          + +

                                                          Options

                                                          + +

                                                          smart-tabs

                                                          + +

                                                          This option suppresses warnings about mixed tabs and spaces when the latter are used for alignment only. This technique is called SmartTabs. The option is turned off by default.

                                                          + +

                                                          You can enable this option by using the following configuration:

                                                          + +
                                                          "no-mixed-spaces-and-tabs": ["error", "smart-tabs"]
                                                          +
                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-mixed-spaces-and-tabs: "error"*/

                                                          function add(x, y) {
                                                          // --->..return x + y;

                                                          return x + y;
                                                          }

                                                          function main() {
                                                          // --->var x = 5,
                                                          // --->....y = 7;

                                                          var x = 5,
                                                          y = 7;
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-mixed-spaces-and-tabs: "error"*/

                                                          function add(x, y) {
                                                          // --->return x + y;
                                                          return x + y;
                                                          }
                                                          +
                                                          + +

                                                          When the SmartTabs option is enabled the following does not produce a warning:

                                                          + +
                                                          /*eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/

                                                          function main() {
                                                          // --->var x = 5,
                                                          // --->....y = 7;

                                                          var x = 5,
                                                          y = 7;
                                                          }
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.7.1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-multi-spaces.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-multi-spaces.html new file mode 100644 index 0000000..085530a --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-multi-spaces.html @@ -0,0 +1,94 @@ + + + +

                                                          Disallow multiple spaces (no-multi-spaces)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Multiple spaces in a row that are not used for indentation are typically mistakes. For example:

                                                          + +

                                                          if(foo === "bar") {}

                                                          +
                                                          + +

                                                          It’s hard to tell, but there are two spaces between foo and ===. Multiple spaces such as this are generally frowned upon in favor of single spaces:

                                                          + +

                                                          if(foo === "bar") {}

                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to disallow multiple whitespace around logical expressions, conditional expressions, declarations, array elements, object properties, sequences and function parameters.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-multi-spaces: "error"*/

                                                          var a = 1;

                                                          if(foo === "bar") {}

                                                          a << b

                                                          var arr = [1, 2];

                                                          a ? b: c
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-multi-spaces: "error"*/

                                                          var a = 1;

                                                          if(foo === "bar") {}

                                                          a << b

                                                          var arr = [1, 2];

                                                          a ? b: c
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          To avoid contradictions if some other rules require multiple spaces, this rule has an option to ignore certain node types in the abstract syntax tree (AST) of JavaScript code.

                                                          + +

                                                          exceptions

                                                          + +

                                                          The exceptions object expects property names to be AST node types as defined by ESTree. The easiest way to determine the node types for exceptions is to use the online demo.

                                                          + +

                                                          Only the Property node type is ignored by default, because for the key-spacing rule some alignment options require multiple spaces in properties of object literals.

                                                          + +

                                                          Examples of correct code for the default "exceptions": { "Property": true } option:

                                                          + +
                                                          /*eslint no-multi-spaces: "error"*/
                                                          /*eslint key-spacing: ["error", { align: "value" }]*/

                                                          var obj = {
                                                          first: "first",
                                                          second: "second"
                                                          };
                                                          +
                                                          + +

                                                          Examples of incorrect code for the "exceptions": { "Property": false } option:

                                                          + +
                                                          /*eslint no-multi-spaces: ["error", { exceptions: { "Property": false } }]*/
                                                          /*eslint key-spacing: ["error", { align: "value" }]*/

                                                          var obj = {
                                                          first: "first",
                                                          second: "second"
                                                          };
                                                          +
                                                          + +

                                                          Examples of correct code for the "exceptions": { "BinaryExpression": true } option:

                                                          + +
                                                          /*eslint no-multi-spaces: ["error", { exceptions: { "BinaryExpression": true } }]*/

                                                          var a = 1 * 2;
                                                          +
                                                          + +

                                                          Examples of correct code for the "exceptions": { "VariableDeclarator": true } option:

                                                          + +
                                                          /*eslint no-multi-spaces: ["error", { exceptions: { "VariableDeclarator": true } }]*/

                                                          var someVar = 'foo';
                                                          var someOtherVar = 'barBaz';
                                                          +
                                                          + +

                                                          Examples of correct code for the "exceptions": { "ImportDeclaration": true } option:

                                                          + +
                                                          /*eslint no-multi-spaces: ["error", { exceptions: { "ImportDeclaration": true } }]*/

                                                          import mod from 'mod';
                                                          import someOtherMod from 'some-other-mod';
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to check and disallow multiple spaces, then you should turn this rule off.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.9.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-multi-str.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-multi-str.html new file mode 100644 index 0000000..78f868b --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-multi-str.html @@ -0,0 +1,44 @@ + + + +

                                                          Disallow Multiline Strings (no-multi-str)

                                                          + +

                                                          It’s possible to create multiline strings in JavaScript by using a slash before a newline, such as:

                                                          + +
                                                          var x = "Line 1 \
                                                          Line 2"
                                                          ;
                                                          +
                                                          + +

                                                          Some consider this to be a bad practice as it was an undocumented feature of JavaScript that was only formalized later.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at preventing the use of multiline strings.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-multi-str: "error"*/
                                                          var x = "Line 1 \
                                                          Line 2"
                                                          ;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-multi-str: "error"*/

                                                          var x = "Line 1\n" +
                                                          "Line 2";
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-multiple-empty-lines.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-multiple-empty-lines.html new file mode 100644 index 0000000..99a7951 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-multiple-empty-lines.html @@ -0,0 +1,88 @@ + + + +

                                                          Disallows multiple blank lines (no-multiple-empty-lines)

                                                          + +

                                                          Some developers prefer to have multiple blank lines removed, while others feel that it helps improve readability. Whitespace is useful for separating logical sections of code, but excess whitespace takes up more of the screen.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to reduce the scrolling required when reading through your code. It will warn when the maximum amount of empty lines has been exceeded.

                                                          + +

                                                          Options

                                                          + +

                                                          The second argument can be used to configure this rule:

                                                          + +
                                                            +
                                                          • max sets the maximum number of consecutive blank lines.
                                                          • +
                                                          • maxEOF can be used to set a different number for the end of file. The last +blank lines will then be treated differently. If omitted, the max option is +applied at the end of the file.
                                                          • +
                                                          • maxBOF can be used to set a different number for the beginning of the file. +If omitted, the ‘max’ option is applied at the beginning of the file.
                                                          • +
                                                          + +

                                                          max

                                                          + +

                                                          In the following example, the error is the severity of the rule, and the +max property is the maximum number of empty lines (2 in this example).

                                                          + +
                                                          "no-multiple-empty-lines": ["error", {"max": 2}]
                                                          +
                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-multiple-empty-lines: ["error", {max: 2}]*/


                                                          var foo = 5;



                                                          var bar = 3;


                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-multiple-empty-lines: ["error", {max: 2}]*/


                                                          var foo = 5;


                                                          var bar = 3;


                                                          +
                                                          + +

                                                          maxEOF

                                                          + +
                                                          "no-multiple-empty-lines": ["error", {"max": 2, "maxEOF": 1}]
                                                          +
                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-multiple-empty-lines: ["error", {max: 2, maxEOF: 1}]*/


                                                          var foo = 5;


                                                          var bar = 3;


                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-multiple-empty-lines: ["error", {max: 2, maxEOF: 1}]*/


                                                          var foo = 5;


                                                          var bar = 3;

                                                          +
                                                          + +

                                                          maxBOF

                                                          + +
                                                          "no-multiple-empty-lines": ["error", {"max": 2, "maxBOF": 0}]
                                                          +
                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-multiple-empty-lines: ["error", {max: 2, maxBOF: 0}]*/


                                                          var foo = 5;


                                                          var bar = 3;


                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-multiple-empty-lines: ["error", {max: 2, maxBOF: 0}]*/
                                                          var foo = 5;


                                                          var bar = 3;


                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you do not care about extra blank lines, turn this off.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.9.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-native-reassign.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-native-reassign.html new file mode 100644 index 0000000..d8f9274 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-native-reassign.html @@ -0,0 +1,50 @@ + + + +

                                                          Disallow Reassignment of Native Objects (no-native-reassign)

                                                          + +

                                                          Reports an error when they encounter an attempt to assign a value to built-in native object.

                                                          + +
                                                          String = "hello world";
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          The native objects reported by this rule are the builtin variables from globals.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-native-reassign: "error"*/

                                                          String = new Object();
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule accepts an exceptions option, which can be used to specify a list of builtins for which reassignments will be allowed:

                                                          + +
                                                          {
                                                          "rules": {
                                                          "no-native-reassign": ["error", {"exceptions": ["Object"]}]
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you are trying to override one of the native objects.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-negated-condition.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-negated-condition.html new file mode 100644 index 0000000..01fcf50 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-negated-condition.html @@ -0,0 +1,43 @@ + + + +

                                                          Disallow use of negated expressions in conditions (no-negated-condition)

                                                          + +

                                                          Checks against the use of a negated expression in an if condition when the else branch is not empty or in a ternary operator. Negated conditions are more difficult to understand. Code can be made more readable by inverting the condition instead.

                                                          + +

                                                          For example:

                                                          + +
                                                          if (!a) {
                                                          doSomething();
                                                          }
                                                          else {
                                                          doSomethingElse();
                                                          }
                                                          +
                                                          + +

                                                          should instead be written as:

                                                          + +
                                                          if (a) {
                                                          doSomethingElse();
                                                          }
                                                          else {
                                                          doSomething();
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          The rule is aimed at preventing the use of a negated expression in a condition.

                                                          + +

                                                          The following patterns are considered warnings:

                                                          + +
                                                          /*eslint no-negated-condition: "error"*/

                                                          if (!a) {
                                                          doSomething();
                                                          } else {
                                                          doSomethingElse();
                                                          }

                                                          if (a != b) {
                                                          doSomething();
                                                          } else {
                                                          doSomethingElse();
                                                          }

                                                          if (a !== b) {
                                                          doSomething();
                                                          } else {
                                                          doSomethingElse();
                                                          }


                                                          !a ? b : c

                                                          +
                                                          + +

                                                          The following patterns are not warnings:

                                                          + +
                                                          /*eslint no-negated-condition: "error"*/

                                                          if (!a) {
                                                          doSomething();
                                                          }

                                                          if (!a) {
                                                          doSomething();
                                                          } else if (b) {
                                                          doSomething();
                                                          }

                                                          if (a != b) {
                                                          doSomething();
                                                          }

                                                          a ? b : c

                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.6.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-negated-in-lhs.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-negated-in-lhs.html new file mode 100644 index 0000000..3f342c0 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-negated-in-lhs.html @@ -0,0 +1,39 @@ + + + +

                                                          disallow negating the left operand in in expressions (no-negated-in-lhs)

                                                          + +

                                                          Rule Details

                                                          + +

                                                          Just as developers might type -a + b when they mean -(a + b) for the negative of a sum, they might type !key in object by mistake when they almost certainly mean !(key in object) to test that a key is not in an object.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows negating the left operand in in expressions.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-negated-in-lhs: "error"*/

                                                          if(!key in object) {
                                                          // operator precedence makes it equivalent to (!key) in object
                                                          // and type conversion makes it equivalent to (key ? "false" : "true") in object
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-negated-in-lhs: "error"*/

                                                          if(!(key in object)) {
                                                          // key is not in object
                                                          }

                                                          if(('' + !key) in object) {
                                                          // make operator precedence and type conversion explicit
                                                          // in a rare situation when that is the intended meaning
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          Never.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.1.2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-nested-ternary.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-nested-ternary.html new file mode 100644 index 0000000..6eff7e9 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-nested-ternary.html @@ -0,0 +1,43 @@ + + + +

                                                          Disallow Nested Ternaries (no-nested-ternary)

                                                          + +

                                                          Nesting ternary expressions makes code unclear. The no-nested-ternary rule disallows the use of nested ternary expressions.

                                                          + +
                                                          var foo = bar ? baz : qux === quxx ? bing : bam;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          The no-nested-ternary rule aims to increase the clarity and readability of code by disallowing the use of nested ternary expressions.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-nested-ternary: "error"*/

                                                          var thing = foo ? bar : baz === qux ? quxx : foobar;

                                                          foo ? baz === qux ? quxx() : foobar() : bar();
                                                          +
                                                          + +

                                                          The following patterns are considered okay and could be used alternatively:

                                                          + +
                                                          /*eslint no-nested-ternary: "error"*/

                                                          var thing;

                                                          if (foo) {
                                                          thing = bar;
                                                          } else if (baz === qux) {
                                                          thing = quxx;
                                                          } else {
                                                          thing = foobar;
                                                          }
                                                          +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.2.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-func.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-func.html new file mode 100644 index 0000000..3eead9e --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-func.html @@ -0,0 +1,48 @@ + + + +

                                                          Disallow Function Constructor (no-new-func)

                                                          + +

                                                          It’s possible to create functions in JavaScript using the Function constructor, such as:

                                                          + +
                                                          var x = new Function("a", "b", "return a + b");
                                                          +
                                                          + +

                                                          This is considered by many to be a bad practice due to the difficulty in debugging and reading these types of functions.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This error is raised to highlight the use of a bad practice. By passing a string to the Function constructor, you are requiring the engine to parse that string much in the way it has to when you call the eval function.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-new-func: "error"*/

                                                          var x = new Function("a", "b", "return a + b");
                                                          var x = Function("a", "b", "return a + b");
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-new-func: "error"*/

                                                          var x = function (a, b) {
                                                          return a + b;
                                                          };
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          In more advanced cases where you really need to use the Function constructor.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.7.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-object.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-object.html new file mode 100644 index 0000000..6c4626e --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-object.html @@ -0,0 +1,56 @@ + + + +

                                                          Disallow the use of the Object constructor (no-new-object)

                                                          + +

                                                          The Object constructor is used to create new generic objects in JavaScript, such as:

                                                          + +
                                                          var myObject = new Object();
                                                          +
                                                          + +

                                                          However, this is no different from using the more concise object literal syntax:

                                                          + +
                                                          var myObject = {};
                                                          +
                                                          + +

                                                          For this reason, many prefer to always use the object literal syntax and never use the Object constructor.

                                                          + +

                                                          While there are no performance differences between the two approaches, the byte savings and conciseness of the object literal form is what has made it the de facto way of creating new objects.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to eliminate use of the Object constructor. As such, it warns whenever new Object is found in code.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-new-object: "error"*/

                                                          var myObject = new Object();

                                                          var myObject = new Object;
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-new-object: "error"*/

                                                          var myObject = new CustomObject();

                                                          var myObject = {};
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you wish to allow the use of the Object constructor, you can safely turn this rule off.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-require.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-require.html new file mode 100644 index 0000000..4efc78d --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-require.html @@ -0,0 +1,52 @@ + + + +

                                                          Disallow new require (no-new-require)

                                                          + +

                                                          The require function is used to include modules that exist in separate files, such as:

                                                          + +
                                                          var appHeader = require('app-header');
                                                          +
                                                          + +

                                                          Some modules return a constructor which can potentially lead to code such as:

                                                          + +
                                                          var appHeader = new require('app-header');
                                                          +
                                                          + +

                                                          Unfortunately, this introduces a high potential for confusion since the code author likely meant to write:

                                                          + +
                                                          var appHeader = new (require('app-header'));
                                                          +
                                                          + +

                                                          For this reason, it is usually best to disallow this particular expression.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to eliminate use of the new require expression.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-new-require: "error"*/

                                                          var appHeader = new require('app-header');
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-new-require: "error"*/

                                                          var AppHeader = require('app-header');
                                                          var appHeader = new AppHeader();
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you are using a custom implementation of require and your code will never be used in projects where a standard require (CommonJS, Node.js, AMD) is expected, you can safely turn this rule off.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.6.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-symbol.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-symbol.html new file mode 100644 index 0000000..1a7261f --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-symbol.html @@ -0,0 +1,48 @@ + + + +

                                                          Disallow Symbol Constructor (no-new-symbol)

                                                          + +

                                                          The Symbol constructor is not intended to be used with the new operator, but to be called as a function.

                                                          + +
                                                          var foo = new Symbol("foo");
                                                          +
                                                          + +

                                                          This throws a TypeError exception.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at preventing the accidental calling of Symbol with the new operator.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-new-symbol: "error"*/
                                                          /*eslint-env es6*/

                                                          var foo = new Symbol('foo');
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-new-symbol: "error"*/
                                                          /*eslint-env es6*/

                                                          var foo = Symbol('foo');


                                                          // Ignores shadowed Symbol.
                                                          function bar(Symbol) {
                                                          const baz = new Symbol("baz");
                                                          }

                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          This rule should not be used in ES3/5 environments.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-beta.1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-wrappers.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-wrappers.html new file mode 100644 index 0000000..5b6fa36 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new-wrappers.html @@ -0,0 +1,69 @@ + + + +

                                                          Disallow Primitive Wrapper Instances (no-new-wrappers)

                                                          + +

                                                          There are three primitive types in JavaScript that have wrapper objects: string, number, and boolean. These are represented by the constructors String, Number, and Boolean, respectively. The primitive wrapper types are used whenever one of these primitive values is read, providing them with object-like capabilities such as methods. Behind the scenes, an object of the associated wrapper type is created and then destroyed, which is why you can call methods on primitive values, such as:

                                                          + +
                                                          var text = "Hello world".substring(2);
                                                          +
                                                          + +

                                                          Behind the scenes in this example, a String object is constructed. The substring() method exists on String.prototype and so is accessible to the string instance.

                                                          + +

                                                          It’s also possible to manually create a new wrapper instance:

                                                          + +
                                                          var stringObject = new String("Hello world");
                                                          var numberObject = new Number(33);
                                                          var booleanObject = new Boolean(false);
                                                          +
                                                          + +

                                                          Although possible, there aren’t any good reasons to use these primitive wrappers as constructors. They tend to confuse other developers more than anything else because they seem like they should act as primitives, but they do not. For example:

                                                          + +
                                                          var stringObject = new String("Hello world");
                                                          console.log(typeof stringObject); // "object"

                                                          var text = "Hello world";
                                                          console.log(typeof text); // "string"

                                                          var booleanObject = new Boolean(false);
                                                          if (booleanObject) { // all objects are truthy!
                                                          console.log("This executes");
                                                          }
                                                          +
                                                          + +

                                                          The first problem is that primitive wrapper objects are, in fact, objects. That means typeof will return "object" instead of "string", "number", or "boolean". The second problem comes with boolean objects. Every object is truthy, that means an instance of Boolean always resolves to true even when its actual value is false.

                                                          + +

                                                          For these reasons, it’s considered a best practice to avoid using primitive wrapper types with new.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to eliminate the use of String, Number, and Boolean with the new operator. As such, it warns whenever it sees new String, new Number, or new Boolean.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-new-wrappers: "error"*/

                                                          var stringObject = new String("Hello world");
                                                          var numberObject = new Number(33);
                                                          var booleanObject = new Boolean(false);

                                                          var stringObject = new String;
                                                          var numberObject = new Number;
                                                          var booleanObject = new Boolean;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-new-wrappers: "error"*/

                                                          var text = String(someValue);
                                                          var num = Number(someValue);

                                                          var object = new MyString();
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to allow the use of primitive wrapper objects, then you can safely disable this rule.

                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.6.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new.html new file mode 100644 index 0000000..2a239b5 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-new.html @@ -0,0 +1,43 @@ + + + +

                                                          Disallow new For Side Effects (no-new)

                                                          + +

                                                          The goal of using new with a constructor is typically to create an object of a particular type and store that object in a variable, such as:

                                                          + +
                                                          var person = new Person();
                                                          +
                                                          + +

                                                          It’s less common to use new and not store the result, such as:

                                                          + +
                                                          new Person();
                                                          +
                                                          + +

                                                          In this case, the created object is thrown away because its reference isn’t stored anywhere, and in many cases, this means that the constructor should be replaced with a function that doesn’t require new to be used.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at maintaining consistency and convention by disallowing constructor calls using the new keyword that do not assign the resulting object to a variable.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-new: "error"*/

                                                          new Thing();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-new: "error"*/

                                                          var thing = new Thing();

                                                          Thing();
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.7.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-obj-calls.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-obj-calls.html new file mode 100644 index 0000000..9171026 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-obj-calls.html @@ -0,0 +1,46 @@ + + + +

                                                          disallow calling global object properties as functions (no-obj-calls)

                                                          + +

                                                          ECMAScript provides several global objects that are intended to be used as-is. Some of these objects look as if they could be constructors due their capitalization (such as Math and JSON) but will throw an error if you try to execute them as functions.

                                                          + +

                                                          The ECMAScript 5 specification makes it clear that both Math and JSON cannot be invoked:

                                                          + +
                                                          +

                                                          The Math object does not have a [[Call]] internal property; it is not possible to invoke the Math object as a function.

                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows calling the Math and JSON objects as functions.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-obj-calls: "error"*/

                                                          var math = Math();
                                                          var json = JSON();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-obj-calls: "error"*/

                                                          function area(r) {
                                                          return Math.PI * r * r;
                                                          }
                                                          var object = JSON.parse("{}");
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-octal-escape.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-octal-escape.html new file mode 100644 index 0000000..def0010 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-octal-escape.html @@ -0,0 +1,38 @@ + + + +

                                                          disallow octal escape sequences in string literals (no-octal-escape)

                                                          + +

                                                          As of the ECMAScript 5 specification, octal escape sequences in string literals are deprecated and should not be used. Unicode escape sequences should be used instead.

                                                          + +
                                                          var foo = "Copyright \251";
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows octal escape sequences in string literals.

                                                          + +

                                                          If ESLint parses code in strict mode, the parser (instead of this rule) reports the error.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-octal-escape: "error"*/

                                                          var foo = "Copyright \251";
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-octal-escape: "error"*/

                                                          var foo = "Copyright \u00A9"; // unicode

                                                          var foo = "Copyright \xA9"; // hexadecimal
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-octal.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-octal.html new file mode 100644 index 0000000..24d0266 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-octal.html @@ -0,0 +1,52 @@ + + + +

                                                          disallow octal literals (no-octal)

                                                          + +

                                                          Octal literals are numerals that begin with a leading zero, such as:

                                                          + +
                                                          var num = 071;      // 57
                                                          +
                                                          + +

                                                          Because the leading zero which identifies an octal literal has been a source of confusion and error in JavaScript code, ECMAScript 5 deprecates the use of octal numeric literals.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          The rule disallows octal literals.

                                                          + +

                                                          If ESLint parses code in strict mode, the parser (instead of this rule) reports the error.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-octal: "error"*/

                                                          var num = 071;
                                                          var result = 5 + 07;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-octal: "error"*/

                                                          var num = "071";
                                                          +
                                                          + +

                                                          Compatibility

                                                          + +
                                                            +
                                                          • JSHint: W115
                                                          • +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.6.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-param-reassign.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-param-reassign.html new file mode 100644 index 0000000..5206ff0 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-param-reassign.html @@ -0,0 +1,61 @@ + + + +

                                                          Disallow Reassignment of Function Parameters (no-param-reassign)

                                                          + +

                                                          Assignment to variables declared as function parameters can be misleading and lead to confusing behavior, as modifying function parameters will also mutate the arguments object. Often, assignment to function parameters is unintended and indicative of a mistake or programmer error.

                                                          + +

                                                          This rule can be also configured to fail when function parameters are modified. Side effects on parameters can cause counter-intuitive execution flow and make errors difficult to track down.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-param-reassign: "error"*/

                                                          function foo(bar) {
                                                          bar = 13;
                                                          }

                                                          function foo(bar) {
                                                          bar++;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-param-reassign: "error"*/

                                                          function foo(bar) {
                                                          var baz = bar;
                                                          }
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule takes one option, an object, with a boolean property "props". It is false by default. If it is set to true, this rule warns against the modification of parameter properties.

                                                          + +

                                                          props

                                                          + +

                                                          Examples of correct code for the default { "props": false } option:

                                                          + +
                                                          /*eslint no-param-reassign: ["error", { "props": false }]*/

                                                          function foo(bar) {
                                                          bar.prop = "value";
                                                          }

                                                          function foo(bar) {
                                                          delete bar.aaa;
                                                          }

                                                          function foo(bar) {
                                                          bar.aaa++;
                                                          }
                                                          +
                                                          + +

                                                          Examples of incorrect code for the { "props": true } option:

                                                          + +
                                                          /*eslint no-param-reassign: ["error", { "props": true }]*/

                                                          function foo(bar) {
                                                          bar.prop = "value";
                                                          }

                                                          function foo(bar) {
                                                          delete bar.aaa;
                                                          }

                                                          function foo(bar) {
                                                          bar.aaa++;
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to allow assignment to function parameters, then you can safely disable this rule.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.18.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-path-concat.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-path-concat.html new file mode 100644 index 0000000..b2e4193 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-path-concat.html @@ -0,0 +1,54 @@ + + + +

                                                          Disallow string concatenation when using __dirname and __filename (no-path-concat)

                                                          + +

                                                          In Node.js, the __dirname and __filename global variables contain the directory path and the file path of the currently executing script file, respectively. Sometimes, developers try to use these variables to create paths to other files, such as:

                                                          + +
                                                          var fullPath = __dirname + "/foo.js";
                                                          +
                                                          + +

                                                          However, there are a few problems with this. First, you can’t be sure what type of system the script is running on. Node.js can be run on any computer, including Windows, which uses a different path separator. It’s very easy, therefore, to create an invalid path using string concatenation and assuming Unix-style separators. There’s also the possibility of having double separators, or otherwise ending up with an invalid path.

                                                          + +

                                                          In order to avoid any confusion as to how to create the correct path, Node.js provides the path module. This module uses system-specific information to always return the correct value. So you can rewrite the previous example as:

                                                          + +
                                                          var fullPath = path.join(__dirname, "foo.js");
                                                          +
                                                          + +

                                                          This example doesn’t need to include separators as path.join() will do it in the most appropriate manner. Alternately, you can use path.resolve() to retrieve the fully-qualified path:

                                                          + +
                                                          var fullPath = path.resolve(__dirname, "foo.js");
                                                          +
                                                          + +

                                                          Both path.join() and path.resolve() are suitable replacements for string concatenation wherever file or directory paths are being created.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to prevent string concatenation of directory paths in Node.js

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-path-concat: "error"*/

                                                          var fullPath = __dirname + "/foo.js";

                                                          var fullPath = __filename + "/foo.js";

                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-path-concat: "error"*/

                                                          var fullPath = dirname + "/foo.js";
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to allow string concatenation of path names.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-plusplus.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-plusplus.html new file mode 100644 index 0000000..10e2ec8 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-plusplus.html @@ -0,0 +1,57 @@ + + + +

                                                          Disallow ++ and – (no-plusplus)

                                                          + +

                                                          The no-plusplus rule flags the use of unary operators, ++ and --.

                                                          + +
                                                          var foo = 0;
                                                          foo++;
                                                          +
                                                          + +

                                                          The ++ and -- operators are subject to automatic semicolon insertion. When their use is allowed, introducing whitespace may change semantics of source code. Enabling the rule may prevent this kind of errors.

                                                          + +
                                                          var i = 10;
                                                          var j = 20;

                                                          i ++
                                                          j
                                                          // i = 11, j = 20
                                                          +
                                                          + +
                                                          var i = 10;
                                                          var j = 20;

                                                          i
                                                          ++
                                                          j
                                                          // i = 10, j = 21
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at flagging the use of ++ and --. Some believe that the use of these unary operators reduces code quality and clarity. There are some programming languages that completely exclude these operators.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

                                                          + +
                                                            +
                                                          • allowForLoopAfterthoughts set to true will allow you to use the unary operators ++ and -- in the afterthought (final expression) of a for loop.
                                                          • +
                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-plusplus: "error"*/

                                                          var foo = 0;
                                                          foo++;

                                                          var bar = 42;
                                                          bar--;

                                                          for (i = 0; i < l; i++) {
                                                          return;
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-plusplus: "error"*/

                                                          var foo = 0;
                                                          foo += 1;

                                                          var bar = 42;
                                                          bar -= 1;

                                                          for (i = 0; i < l; i += 1) {
                                                          return;
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems if allowForLoopAfterthoughts is set to true:

                                                          + +
                                                          /*eslint no-plusplus: ["error", { allowForLoopAfterthoughts: true }]*/

                                                          for (i = 0; i < l; i++) {
                                                          return;
                                                          }

                                                          for (i = 0; i < l; i--) {
                                                          return;
                                                          }
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-process-env.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-process-env.html new file mode 100644 index 0000000..f3b24f1 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-process-env.html @@ -0,0 +1,44 @@ + + + +

                                                          Disallow process.env (no-process-env)

                                                          + +

                                                          The process.env object in Node.js is used to store deployment/configuration parameters. Littering it through out a project could lead to maintenance issues as it’s another kind of global dependency. As such, it could lead to merge conflicts in a multi-user setup and deployment issues in a multi-server setup. Instead, one of the best practices is to define all those parameters in a single configuration/settings file which could be accessed throughout the project.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at discouraging use of process.env to avoid global dependencies. As such, it will warn whenever process.env is used.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-process-env: "error"*/

                                                          if(process.env.NODE_ENV === "development") {
                                                          //...
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-process-env: "error"*/

                                                          var config = require("./config");

                                                          if(config.env === "development") {
                                                          //...
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If prefer to use process.env throughout your project to retrieve values from environment variables, then you can safely disable this rule.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.9.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-process-exit.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-process-exit.html new file mode 100644 index 0000000..16a94d1 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-process-exit.html @@ -0,0 +1,47 @@ + + + +

                                                          Disallow process.exit() (no-process-exit)

                                                          + +

                                                          The process.exit() method in Node.js is used to immediately stop the Node.js process and exit. This is a dangerous operation because it can occur in any method at any point in time, potentially stopping a Node.js application completely when an error occurs. For example:

                                                          + +
                                                          if (somethingBadHappened) {
                                                          console.error("Something bad happened!");
                                                          process.exit(1);
                                                          }
                                                          +
                                                          + +

                                                          This code could appear in any module and will stop the entire application when somethingBadHappened is truthy. This doesn’t give the application any chance to respond to the error. It’s usually better to throw an error and allow the application to handle it appropriately:

                                                          + +
                                                          if (somethingBadHappened) {
                                                          throw new Error("Something bad happened!");
                                                          }
                                                          +
                                                          + +

                                                          By throwing an error in this way, other parts of the application have an opportunity to handle the error rather than stopping the application altogether. If the error bubbles all the way up to the process without being handled, then the process will exit and a non-zero exit code will returned, so the end result is the same.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to prevent the use of process.exit() in Node.js JavaScript. As such, it warns whenever process.exit() is found in code.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-process-exit: "error"*/

                                                          process.exit(1);
                                                          process.exit(0);
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-process-exit: "error"*/

                                                          Process.exit();
                                                          var exit = process.exit;
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          There may be a part of a Node.js application that is responsible for determining the correct exit code to return upon exiting. In that case, you should turn this rule off to allow proper handling of the exit code.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-proto.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-proto.html new file mode 100644 index 0000000..7d1b323 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-proto.html @@ -0,0 +1,43 @@ + + + +

                                                          Disallow Use of __proto__ (no-proto)

                                                          + +

                                                          __proto__ property has been deprecated as of ECMAScript 3.1 and shouldn’t be used in the code. Use getPrototypeOf method instead.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          When an object is created __proto__ is set to the original prototype property of the object’s constructor function. getPrototypeOf is the preferred method of getting “the prototype”.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-proto: "error"*/

                                                          var a = obj.__proto__;

                                                          var a = obj["__proto__"];
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-proto: "error"*/

                                                          var a = Object.getPrototypeOf(obj);
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you need to support legacy browsers, you might want to turn this rule off, since support for getPrototypeOf is not yet universal.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-redeclare.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-redeclare.html new file mode 100644 index 0000000..e6dbdcb --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-redeclare.html @@ -0,0 +1,52 @@ + + + +

                                                          Disallow Redeclaring Variables (no-redeclare)

                                                          + +

                                                          In JavaScript, it’s possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at eliminating variables that have multiple declarations in the same scope.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-redeclare: "error"*/

                                                          var a = 3;
                                                          var a = 10;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-redeclare: "error"*/

                                                          var a = 3;
                                                          // ...
                                                          a = 10;
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. +If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number

                                                          + +

                                                          builtinGlobals

                                                          + +

                                                          Examples of incorrect code for the { "builtinGlobals": true } option:

                                                          + +
                                                          /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/

                                                          var Object = 0;
                                                          +
                                                          + +

                                                          Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

                                                          + +
                                                          /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
                                                          /*eslint-env browser*/

                                                          var top = 0;
                                                          +
                                                          + +

                                                          The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-regex-spaces.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-regex-spaces.html new file mode 100644 index 0000000..f0e6be4 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-regex-spaces.html @@ -0,0 +1,69 @@ + + + +

                                                          disallow multiple spaces in regular expression literals (no-regex-spaces)

                                                          + +

                                                          Regular expressions can be very complex and difficult to understand, which is why it’s important to keep them as simple as possible in order to avoid mistakes. One of the more error-prone things you can do with a regular expression is to use more than one space, such as:

                                                          + +
                                                          var re = /foo   bar/;
                                                          +
                                                          + +

                                                          In this regular expression, it’s very hard to tell how many spaces are intended to be matched. It’s better to use only one space and then specify how many spaces are expected, such as:

                                                          + +
                                                          var re = /foo {3}bar/;
                                                          +
                                                          + +

                                                          Now it is very clear that three spaces are expected to be matched.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows multiple spaces in regular expression literals.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-regex-spaces: "error"*/

                                                          var re = /foo bar/;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-regex-spaces: "error"*/

                                                          var re = /foo {3}bar/;
                                                          +
                                                          + +

                                                          Known Limitations

                                                          + +

                                                          This rule does not report multiple spaces in the string argument of calls to the RegExp constructor.

                                                          + +

                                                          Example of a false negative when this rule reports correct code:

                                                          + +
                                                          /*eslint no-regex-spaces: "error"*/

                                                          var re = new RegExp("foo bar");
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to allow multiple spaces in a regular expression, then you can safely turn this rule off.

                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-restricted-globals.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-restricted-globals.html new file mode 100644 index 0000000..c54368d --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-restricted-globals.html @@ -0,0 +1,45 @@ + + + +

                                                          Disallow specific global variables (no-restricted-globals)

                                                          + +

                                                          Disallowing usage of specific global variables can be useful if you want to allow a set of global +variables by enabling an environment, but still want to disallow some of those.

                                                          + +

                                                          For instance, early Internet Explorer versions exposed the current DOM event as a global variable +event, but using this variable has been considered as a bad practice for a long time. Restricting +this will make sure this variable isn’t used in browser code.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule allows you to specify global variable names that you don’t want to use in your application.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule takes a list of strings which are the global variable names.

                                                          + +

                                                          Examples of incorrect code for sample "event", "fdescribe" global variable names:

                                                          + +
                                                          /*global event, fdescribe*/
                                                          /*eslint no-restricted-globals: ["error", "event", "fdescribe"]*/

                                                          function onClick() {
                                                          console.log(event);
                                                          }

                                                          fdescribe("foo", function() {
                                                          });
                                                          +
                                                          + +

                                                          Examples of correct code for a sample "event" global variable name:

                                                          + +
                                                          /*global event*/
                                                          /*eslint no-restricted-globals: ["error", "event"]*/

                                                          import event from "event-module";
                                                          +
                                                          + +
                                                          /*global event*/
                                                          /*eslint no-restricted-globals: ["error", "event"]*/

                                                          var event = 1;
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.3.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-restricted-imports.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-restricted-imports.html new file mode 100644 index 0000000..0218ef3 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-restricted-imports.html @@ -0,0 +1,63 @@ + + + +

                                                          Disallow specific imports (no-restricted-imports)

                                                          + +

                                                          Imports are an ES6/ES2015 standard for making the functionality of other modules available in your current module. In CommonJS this is implemented through the require() call which makes this ESLint rule roughly equivalent to its CommonJS counterpart no-restricted-modules.

                                                          + +

                                                          Why would you want to restrict imports?

                                                          + +
                                                            +
                                                          • +

                                                            Some imports might not make sense in a particular environment. For example, Node.js’ fs module would not make sense in an environment that didn’t have a file system.

                                                            +
                                                          • +
                                                          • +

                                                            Some modules provide similar or identical functionality, think lodash and underscore. Your project may have standardized on a module. You want to make sure that the other alternatives are not being used as this would unnecessarily bloat the project and provide a higher maintenance cost of two dependencies when one would suffice.

                                                            +
                                                          • +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule allows you to specify imports that you don’t want to use in your application.

                                                          + +

                                                          Options

                                                          + +

                                                          The syntax to specify restricted modules looks like this:

                                                          + +
                                                          "no-restricted-imports": ["error", "import1", "import2"]
                                                          +
                                                          + +

                                                          To restrict the use of all Node.js core imports (via https://github.com/nodejs/node/tree/master/lib):

                                                          + +
                                                              "no-restricted-imports": ["error",
                                                          "assert","buffer","child_process","cluster","crypto","dgram","dns","domain","events","freelist","fs","http","https","module","net","os","path","punycode","querystring","readline","repl","smalloc","stream","string_decoder","sys","timers","tls","tracing","tty","url","util","vm","zlib"
                                                          ],
                                                          +
                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-restricted-imports: ["error", "fs"]*/

                                                          import fs from 'fs';
                                                          +
                                                          + +
                                                          /*eslint no-restricted-imports: ["error", "cluster"]*/

                                                          import cluster from ' cluster ';
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-restricted-imports: ["error", "fs"]*/

                                                          import crypto from 'crypto';
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          Don’t use this rule or don’t include a module in the list for this rule if you want to be able to import a module in your project without an ESLint error or warning.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-alpha-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-restricted-modules.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-restricted-modules.html new file mode 100644 index 0000000..a86aec3 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-restricted-modules.html @@ -0,0 +1,46 @@ + + + +

                                                          Disallow Node.js modules (no-restricted-modules)

                                                          + +

                                                          Disallowing usage of specific Node.js modules can be useful if you want to control the available methods, a developer can +use, to implement a feature.

                                                          + +

                                                          This way you can block usage of the fs module if you want disallow file system access. +Blocking the os module can be useful if you don’t want to allow any operating system specific code.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule allows you to specify modules that you don’t want to use in your application.

                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes one or more strings as options: the names of restricted modules.

                                                          + +

                                                          For example, to restrict the use of all Node.js core modules (via https://github.com/nodejs/node/tree/master/lib):

                                                          + +
                                                          {
                                                          "no-restricted-modules": ["error",
                                                          "assert","buffer","child_process","cluster","crypto","dgram","dns","domain","events","freelist","fs","http","https","module","net","os","path","punycode","querystring","readline","repl","smalloc","stream","string_decoder","sys","timers","tls","tracing","tty","url","util","vm","zlib"
                                                          ]
                                                          }
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with sample "fs", "cluster" restricted modules:

                                                          + +
                                                          /*eslint no-restricted-modules: ["error", "fs", "cluster"]*/

                                                          var fs = require('fs');
                                                          var cluster = require(' cluster ');
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with sample "fs", "cluster" restricted modules:

                                                          + +
                                                          /*eslint no-restricted-modules: ["error", "fs", "cluster"]*/

                                                          var crypto = require('crypto');
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.6.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-restricted-syntax.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-restricted-syntax.html new file mode 100644 index 0000000..b2985be --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-restricted-syntax.html @@ -0,0 +1,54 @@ + + + +

                                                          Disallow certain syntax (no-restricted-syntax)

                                                          + +

                                                          JavaScript has a lot of language features, and not everyone likes every features. As a result, some projects choose to disallow the use of certain language features altogether. For instance, you might decide to disallow the use of try-catch or class.

                                                          + +

                                                          Rather than creating separate rules for every language feature you want to turn off, this rule allows you to configure the syntax elements you want to restrict use of. These elements are represented by their ESTree node types. For example, a function declaration is represented by FunctionDeclaration and the with statement is represented by WithStatement. You may find the full list of AST node names you can use on GitHub and use the online parser to see what type of nodes your code consists of.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at eliminating certain syntax from your JavaScript. As such, it warns whenever it sees a node type that is restricted by its options.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule takes a list of strings where strings denote the node types:

                                                          + +
                                                          {
                                                          "rules": {
                                                          "no-restricted-syntax": ["error", "FunctionExpression", "WithStatement"]
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /* eslint no-restricted-syntax: ["error", "FunctionExpression", "WithStatement"] */

                                                          with (me) {
                                                          dontMess();
                                                          }

                                                          var doSomething = function () {};
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /* eslint no-restricted-syntax: ["error", "FunctionExpression", "WithStatement"] */

                                                          me.dontMess();

                                                          function doSomething() {};
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to restrict your code from using any JavaScript features or syntax, you should not use this rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-return-assign.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-return-assign.html new file mode 100644 index 0000000..06e6e5a --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-return-assign.html @@ -0,0 +1,73 @@ + + + +

                                                          Disallow Assignment in return Statement (no-return-assign)

                                                          + +

                                                          One of the interesting, and sometimes confusing, aspects of JavaScript is that assignment can happen at almost any point. Because of this, an errant equals sign can end up causing assignment when the true intent was to do a comparison. This is especially true when using a return statement. For example:

                                                          + +
                                                          function doSomething() {
                                                          return foo = bar + 2;
                                                          }
                                                          +
                                                          + +

                                                          It is difficult to tell the intent of the return statement here. It’s possible that the function is meant to return the result of bar + 2, but then why is it assigning to foo? It’s also possible that the intent was to use a comparison operator such as == and that this code is an error.

                                                          + +

                                                          Because of this ambiguity, it’s considered a best practice to not use assignment in return statements.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to eliminate assignments from return statements. As such, it will warn whenever an assignment is found as part of return.

                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes one option, a string, which must contain one of the following values:

                                                          + +
                                                            +
                                                          • except-parens (default): Disallow assignments unless they are enclosed in parentheses.
                                                          • +
                                                          • always: Disallow all assignments.
                                                          • +
                                                          + +

                                                          except-parens

                                                          + +

                                                          This is the default option. +It disallows assignments unless they are enclosed in parentheses.

                                                          + +

                                                          Examples of incorrect code for the default "except-parens" option:

                                                          + +
                                                          /*eslint no-return-assign: "error"*/

                                                          function doSomething() {
                                                          return foo = bar + 2;
                                                          }

                                                          function doSomething() {
                                                          return foo += 2;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for the default "except-parens" option:

                                                          + +
                                                          /*eslint no-return-assign: "error"*/

                                                          function doSomething() {
                                                          return foo == bar + 2;
                                                          }

                                                          function doSomething() {
                                                          return foo === bar + 2;
                                                          }

                                                          function doSomething() {
                                                          return (foo = bar + 2);
                                                          }
                                                          +
                                                          + +

                                                          always

                                                          + +

                                                          This option disallows all assignments in return statements. +All assignments are treated as problems.

                                                          + +

                                                          Examples of incorrect code for the "always" option:

                                                          + +
                                                          /*eslint no-return-assign: ["error", "always"]*/

                                                          function doSomething() {
                                                          return foo = bar + 2;
                                                          }

                                                          function doSomething() {
                                                          return foo += 2;
                                                          }

                                                          function doSomething() {
                                                          return (foo = bar + 2);
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for the "always" option:

                                                          + +
                                                          /*eslint no-return-assign: ["error", "always"]*/

                                                          function doSomething() {
                                                          return foo == bar + 2;
                                                          }

                                                          function doSomething() {
                                                          return foo === bar + 2;
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to allow the use of assignment operators in a return statement, then you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-script-url.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-script-url.html new file mode 100644 index 0000000..d8cbd36 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-script-url.html @@ -0,0 +1,38 @@ + + + +

                                                          Disallow Script URLs (no-script-url)

                                                          + +

                                                          Using javascript: URLs is considered by some as a form of eval. Code passed in javascript: URLs has to be parsed and evaluated by the browser in the same way that eval is processed.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-script-url: "error"*/

                                                          location.href = "javascript:void(0)";
                                                          +
                                                          + +

                                                          Compatibility

                                                          + +
                                                            +
                                                          • JSHint: This rule corresponds to scripturl rule of JSHint.
                                                          • +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-self-assign.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-self-assign.html new file mode 100644 index 0000000..e049c60 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-self-assign.html @@ -0,0 +1,41 @@ + + + +

                                                          Disallow Self Assignment (no-self-assign)

                                                          + +

                                                          Self assignments have no effect, so probably those are an error due to incomplete refactoring. +Those indicate that what you should do is still remaining.

                                                          + +
                                                          foo = foo;
                                                          [bar, baz] = [bar, qiz];
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at eliminating self assignments.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-self-assign: "error"*/

                                                          foo = foo;

                                                          [a, b] = [a, b];

                                                          [a, ...b] = [x, ...b];

                                                          ({a, b} = {a, x});
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-self-assign: "error"*/

                                                          foo = bar;
                                                          [a, b] = [b, a];

                                                          // This pattern is warned by the `no-use-before-define` rule.
                                                          let foo = foo;

                                                          // The default values have an effect.
                                                          [foo = 1] = [foo];
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to notify about self assignments, then it’s safe to disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-rc.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-self-compare.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-self-compare.html new file mode 100644 index 0000000..c07fc97 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-self-compare.html @@ -0,0 +1,36 @@ + + + +

                                                          Disallow Self Compare (no-self-compare)

                                                          + +

                                                          Comparing a variable against itself is usually an error, either an typo or refactoring error. It is confusing to the reader and may potentially introduce a runtime error.

                                                          + +

                                                          The only time you would compare a variable against itself is when you are testing for NaN. However, it is far more appropriate to use typeof x === 'number' && isNaN(x) or the Number.isNaN ES2015 function for that use case rather than leaving the reader of the code to determine the intent of self comparison.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This error is raised to highlight a potentially confusing and potentially pointless piece of code. There are almost no situations in which you would need to compare something to itself.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-self-compare: "error"*/

                                                          var x = 10;
                                                          if (x === x) {
                                                          x = 20;
                                                          }
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-sequences.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-sequences.html new file mode 100644 index 0000000..50c581d --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-sequences.html @@ -0,0 +1,45 @@ + + + +

                                                          Disallow Use of the Comma Operator (no-sequences)

                                                          + +

                                                          The comma operator includes multiple expressions where only one is expected. It evaluates each operand from left to right and returns the value of the last operand. However, this frequently obscures side effects, and its use is often an accident. Here are some examples of sequences:

                                                          + +
                                                          var a = (3, 5); // a = 5

                                                          a = b += 5, a + b;

                                                          while (a = next(), a && a.length);

                                                          (0, eval)("doSomething();");
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule forbids the use of the comma operator, with the following exceptions:

                                                          + +
                                                            +
                                                          • In the initialization or update portions of a for statement.
                                                          • +
                                                          • If the expression sequence is explicitly wrapped in parentheses.
                                                          • +
                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-sequences: "error"*/

                                                          foo = doSomething(), val;

                                                          0, eval("doSomething();");

                                                          do {} while (doSomething(), !!test);

                                                          for (; doSomething(), !!test; );

                                                          if (doSomething(), !!test);

                                                          switch (val = foo(), val) {}

                                                          while (val = foo(), val < 42);

                                                          with (doSomething(), val) {}
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-sequences: "error"*/

                                                          foo = (doSomething(), val);

                                                          (0, eval)("doSomething();");

                                                          do {} while ((doSomething(), !!test));

                                                          for (i = 0, j = 10; i < j; i++, j--);

                                                          if ((doSomething(), !!test));

                                                          switch ((val = foo(), val)) {}

                                                          while ((val = foo(), val < 42));

                                                          // with ((doSomething(), val)) {}
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          Disable this rule if sequence expressions with the comma operator are acceptable.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.5.1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-shadow-restricted-names.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-shadow-restricted-names.html new file mode 100644 index 0000000..74df267 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-shadow-restricted-names.html @@ -0,0 +1,49 @@ + + + +

                                                          Disallow Shadowing of Restricted Names (no-shadow-restricted-names)

                                                          + +

                                                          ES5 §15.1.1 Value Properties of the Global Object (NaN, Infinity, undefined) as well as strict mode restricted identifiers eval and arguments are considered to be restricted names in JavaScript. Defining them to mean something else can have unintended consequences and confuse others reading the code. For example, there’s nothing prevent you from writing:

                                                          + +
                                                          var undefined = "foo";
                                                          +
                                                          + +

                                                          Then any code used within the same scope would not get the global undefined, but rather the local version with a very different meaning.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-shadow-restricted-names: "error"*/

                                                          function NaN(){}

                                                          !function(Infinity){};

                                                          var undefined;

                                                          try {} catch(eval){}
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-shadow-restricted-names: "error"*/

                                                          var Object;

                                                          function f(a, b){}
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.1.4.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-shadow.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-shadow.html new file mode 100644 index 0000000..d015af4 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-shadow.html @@ -0,0 +1,113 @@ + + + +

                                                          Disallow Shadowing (no-shadow)

                                                          + +

                                                          Shadowing is the process by which a local variable shares the same name as a variable in its containing scope. For example:

                                                          + +
                                                          var a = 3;
                                                          function b() {
                                                          var a = 10;
                                                          }
                                                          +
                                                          + +

                                                          In this case, the variable a inside of b() is shadowing the variable a in the global scope. This can cause confusion while reading the code and it’s impossible to access the global variable.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to eliminate shadowed variable declarations.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-shadow: "error"*/
                                                          /*eslint-env es6*/

                                                          var a = 3;
                                                          function b() {
                                                          var a = 10;
                                                          }

                                                          var b = function () {
                                                          var a = 10;
                                                          }

                                                          function b(a) {
                                                          a = 10;
                                                          }
                                                          b(a);

                                                          if (true) {
                                                          let a = 5;
                                                          }
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule takes one option, an object, with properties "builtinGlobals", "hoist" and "allow".

                                                          + +
                                                          {
                                                          "no-shadow": ["error", { "builtinGlobals": false, "hoist": "functions", "allow": [] }]
                                                          }
                                                          +
                                                          + +

                                                          builtinGlobals

                                                          + +

                                                          The builtinGlobals option is false by default. +If it is true, the rule prevents shadowing of built-in global variables: Object, Array, Number, and so on.

                                                          + +

                                                          Examples of incorrect code for the { "builtinGlobals": true } option:

                                                          + +
                                                          /*eslint no-shadow: ["error", { "builtinGlobals": true }]*/

                                                          function foo() {
                                                          var Object = 0;
                                                          }
                                                          +
                                                          + +

                                                          hoist

                                                          + +

                                                          The hoist option has three settings:

                                                          + +
                                                            +
                                                          • functions (by default) - reports shadowing before the outer functions are defined.
                                                          • +
                                                          • all - reports all shadowing before the outer variables/functions are defined.
                                                          • +
                                                          • never - never report shadowing before the outer variables/functions are defined.
                                                          • +
                                                          + +

                                                          hoist: functions

                                                          + +

                                                          Examples of incorrect code for the default { "hoist": "functions" } option:

                                                          + +
                                                          /*eslint no-shadow: ["error", { "hoist": "functions" }]*/
                                                          /*eslint-env es6*/

                                                          if (true) {
                                                          let b = 6;
                                                          }

                                                          function b() {}
                                                          +
                                                          + +

                                                          Although let b in the if statement is before the function declaration in the outer scope, it is incorrect.

                                                          + +

                                                          Examples of correct code for the default { "hoist": "functions" } option:

                                                          + +
                                                          /*eslint no-shadow: ["error", { "hoist": "functions" }]*/
                                                          /*eslint-env es6*/

                                                          if (true) {
                                                          let a = 3;
                                                          }

                                                          let a = 5;
                                                          +
                                                          + +

                                                          Because let a in the if statement is before the variable declaration in the outer scope, it is correct.

                                                          + +

                                                          hoist: all

                                                          + +

                                                          Examples of incorrect code for the { "hoist": "all" } option:

                                                          + +
                                                          /*eslint no-shadow: ["error", { "hoist": "all" }]*/
                                                          /*eslint-env es6*/

                                                          if (true) {
                                                          let a = 3;
                                                          let b = 6;
                                                          }

                                                          let a = 5;
                                                          function b() {}
                                                          +
                                                          + +

                                                          hoist: never

                                                          + +

                                                          Examples of correct code for the { "hoist": "never" } option:

                                                          + +
                                                          /*eslint no-shadow: ["error", { "hoist": "never" }]*/
                                                          /*eslint-env es6*/

                                                          if (true) {
                                                          let a = 3;
                                                          let b = 6;
                                                          }

                                                          let a = 5;
                                                          function b() {}
                                                          +
                                                          + +

                                                          Because let a and let b in the if statement are before the declarations in the outer scope, they are correct.

                                                          + +

                                                          allow

                                                          + +

                                                          The allow option is an array of identifier names for which shadowing is allowed. For example, "resolve", "reject", "done", "cb".

                                                          + +

                                                          Examples of correct code for the { "allow": ["done"] } option:

                                                          + +
                                                          /*eslint no-shadow: ["error", { "allow": ["done"] }]*/
                                                          /*eslint-env es6*/

                                                          import async from 'async';

                                                          function foo(done) {
                                                          async.map([1, 2], function (e, done) {
                                                          done(null, e * 2)
                                                          }, done);
                                                          }

                                                          foo(function (err, result) {
                                                          console.log({ err, result });
                                                          });
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-spaced-func.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-spaced-func.html new file mode 100644 index 0000000..703d7ff --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-spaced-func.html @@ -0,0 +1,38 @@ + + + +

                                                          Disallow Spaces in Function Calls (no-spaced-func)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          While it’s possible to have whitespace between the name of a function and the parentheses that execute it, such patterns tend to look more like errors.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule does not allow gaps between the function identifier and application.

                                                          + +
                                                          fn ()
                                                          +
                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-spaced-func: "error"*/

                                                          fn ()

                                                          fn
                                                          ()
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-spaced-func: "error"*/

                                                          fn()
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.1.2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-sparse-arrays.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-sparse-arrays.html new file mode 100644 index 0000000..12c9828 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-sparse-arrays.html @@ -0,0 +1,55 @@ + + + +

                                                          disallow sparse arrays (no-sparse-arrays)

                                                          + +

                                                          Sparse arrays contain empty slots, most frequently due to multiple commas being used in an array literal, such as:

                                                          + +
                                                          var items = [,,];
                                                          +
                                                          + +

                                                          While the items array in this example has a length of 2, there are actually no values in items[0] or items[1]. The fact that the array literal is valid with only commas inside, coupled with the length being set and actual item values not being set, make sparse arrays confusing for many developers. Consider the following:

                                                          + +
                                                          var colors = [ "red",, "blue" ];
                                                          +
                                                          + +

                                                          In this example, the colors array has a length of 3. But did the developer intend for there to be an empty spot in the middle of the array? Or is it a typo?

                                                          + +

                                                          The confusion around sparse arrays defined in this manner is enough that it’s recommended to avoid using them unless you are certain that they are useful in your code.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows sparse array literals which have “holes” where commas are not preceded by elements. It does not apply to a trailing comma following the last element.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-sparse-arrays: "error"*/

                                                          var items = [,];
                                                          var colors = [ "red",, "blue" ];
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-sparse-arrays: "error"*/

                                                          var items = [];
                                                          var items = new Array(23);

                                                          // trailing comma (after the last element) is not a problem
                                                          var colors = [ "red", "blue", ];
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to use sparse arrays, then it is safe to disable this rule.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-sync.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-sync.html new file mode 100644 index 0000000..dc8e365 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-sync.html @@ -0,0 +1,37 @@ + + + +

                                                          Disallow Synchronous Methods (no-sync)

                                                          + +

                                                          In Node.js, most I/O is done through asynchronous methods. However, there are often synchronous versions of the asynchronous methods. For example, fs.exists() and fs.existsSync(). In some contexts, using synchronous operations is okay (if, as with ESLint, you are writing a command line utility). However, in other contexts the use of synchronous operations is considered a bad practice that should be avoided. For example, if you are running a high-travel web server on Node.js, you should consider carefully if you want to allow any synchronous operations that could lock up the server.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at preventing synchronous methods from being called in Node.js. It looks specifically for the method suffix “Sync” (as is the convention with Node.js operations).

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-sync: "error"*/

                                                          fs.existsSync(somePath);

                                                          var contents = fs.readFileSync(somePath).toString();
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-sync: "error"*/

                                                          obj.sync();

                                                          async(function() {
                                                          // ...
                                                          });
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to allow synchronous operations in your script.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-ternary.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-ternary.html new file mode 100644 index 0000000..d60b55c --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-ternary.html @@ -0,0 +1,43 @@ + + + +

                                                          Disallow Ternary Operators (no-ternary)

                                                          + +

                                                          The ternary operator is used to conditionally assign a value to a variable. Some believe that the use of ternary operators leads to unclear code.

                                                          + +
                                                          var foo = isBar ? baz : qux;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          The no-ternary rule aims to disallow the use of ternary operators.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-ternary: "error"*/

                                                          var foo = isBar ? baz : qux;

                                                          foo ? bar() : baz();

                                                          function quux() {
                                                          return foo ? bar : baz;
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are considered okay and could be used alternatively:

                                                          + +
                                                          /*eslint no-ternary: "error"*/

                                                          var foo;

                                                          if (isBar) {
                                                          foo = baz;
                                                          } else {
                                                          foo = qux;
                                                          }

                                                          if (foo) {
                                                          bar();
                                                          } else {
                                                          baz();
                                                          }

                                                          function quux() {
                                                          if (foo) {
                                                          return bar;
                                                          } else {
                                                          return baz;
                                                          }
                                                          }
                                                          +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-this-before-super.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-this-before-super.html new file mode 100644 index 0000000..c27145c --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-this-before-super.html @@ -0,0 +1,39 @@ + + + +

                                                          Disallow use of this/super before calling super() in constructors. (no-this-before-super)

                                                          + +

                                                          In the constructor of derived classes, if this/super are used before super() calls, it raises a reference error.

                                                          + +

                                                          This rule checks this/super keywords in constructors, then reports those that are before super().

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed to flag this/super keywords before super() callings.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-this-before-super: "error"*/
                                                          /*eslint-env es6*/

                                                          class A extends B {
                                                          constructor() {
                                                          this.a = 0;
                                                          super();
                                                          }
                                                          }

                                                          class A extends B {
                                                          constructor() {
                                                          this.foo();
                                                          super();
                                                          }
                                                          }

                                                          class A extends B {
                                                          constructor() {
                                                          super.foo();
                                                          super();
                                                          }
                                                          }

                                                          class A extends B {
                                                          constructor() {
                                                          super(this.foo());
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-this-before-super: "error"*/
                                                          /*eslint-env es6*/

                                                          class A {
                                                          constructor() {
                                                          this.a = 0; // OK, this class doesn't have an `extends` clause.
                                                          }
                                                          }

                                                          class A extends B {
                                                          constructor() {
                                                          super();
                                                          this.a = 0; // OK, this is after `super()`.
                                                          }
                                                          }

                                                          class A extends B {
                                                          foo() {
                                                          this.a = 0; // OK. this is not in a constructor.
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about using this/super before super() in constructors, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.24.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-throw-literal.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-throw-literal.html new file mode 100644 index 0000000..fa32bb8 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-throw-literal.html @@ -0,0 +1,45 @@ + + + +

                                                          Restrict what can be thrown as an exception (no-throw-literal)

                                                          + +

                                                          It is considered good practice to only throw the Error object itself or an object using the Error object as base objects for user-defined exceptions. +The fundamental benefit of Error objects is that they automatically keep track of where they were built and originated.

                                                          + +

                                                          This rule restricts what can be thrown as an exception. When it was first created, it only prevented literals from being thrown (hence the name), but it has now been expanded to only allow expressions which have a possibility of being an Error object.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at maintaining consistency when throwing exception by disallowing to throw literals and other expressions which cannot possibly be an Error object.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-throw-literal: "error"*/
                                                          /*eslint-env es6*/

                                                          throw "error";

                                                          throw 0;

                                                          throw undefined;

                                                          throw null;

                                                          var err = new Error();
                                                          throw "an " + err;
                                                          // err is recast to a string literal

                                                          var err = new Error();
                                                          throw `${err}`

                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-throw-literal: "error"*/

                                                          throw new Error();

                                                          throw new Error("error");

                                                          var e = new Error("error");
                                                          throw e;

                                                          try {
                                                          throw new Error("error");
                                                          } catch (e) {
                                                          throw e;
                                                          }
                                                          +
                                                          + +

                                                          Known Limitations

                                                          + +

                                                          Due to the limits of static analysis, this rule cannot guarantee that you will only throw Error objects.

                                                          + +

                                                          Examples of correct code for this rule, but which do not throw an Error object:

                                                          + +
                                                          /*eslint no-throw-literal: "error"*/

                                                          var err = "error";
                                                          throw err;

                                                          function foo(bar) {
                                                          console.log(bar);
                                                          }
                                                          throw foo("error");

                                                          throw new String("error");

                                                          var foo = {
                                                          bar: "error"
                                                          };
                                                          throw foo.bar;
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.15.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-trailing-spaces.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-trailing-spaces.html new file mode 100644 index 0000000..7bda4af --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-trailing-spaces.html @@ -0,0 +1,47 @@ + + + +

                                                          Disallow trailing spaces at the end of lines (no-trailing-spaces)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Sometimes in the course of editing files, you can end up with extra whitespace at the end of lines. These whitespace differences can be picked up by source control systems and flagged as diffs, causing frustration for developers. While this extra whitespace causes no functional issues, many code conventions require that trailing spaces be removed before checkin.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-trailing-spaces: "error"*/

                                                          // spaces, tabs and unicode whitespaces
                                                          // are not allowed at the end of lines
                                                          var foo = 0;//•••••
                                                          var baz = 5;//••
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-trailing-spaces: "error"*/

                                                          var foo = 0;

                                                          var baz = 5;
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          There is one option for this rule, skipBlankLines. When set to true, the rule will not flag any lines that are made up purely of whitespace. In short, if a line is zero-length after being trimmed of whitespace, then the rule will not flag that line when skipBlankLines is enabled.

                                                          + +

                                                          You can enable this option in your config like this:

                                                          + +
                                                          {
                                                          "no-trailing-spaces": ["error", { "skipBlankLines": true }]
                                                          }
                                                          +
                                                          + +

                                                          With this option enabled, The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-trailing-spaces: ["error", { "skipBlankLines": true }]*/

                                                          var foo = 0;
                                                          //••••
                                                          var baz = 5;
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.7.1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-undef-init.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-undef-init.html new file mode 100644 index 0000000..7faea87 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-undef-init.html @@ -0,0 +1,83 @@ + + + +

                                                          Disallow Initializing to undefined (no-undef-init)

                                                          + +

                                                          In JavaScript, a variable that is declared and not initialized to any value automatically gets the value of undefined. For example:

                                                          + +
                                                          var foo;

                                                          console.log(foo === undefined); // true
                                                          +
                                                          + +

                                                          It’s therefore unnecessary to initialize a variable to undefined, such as:

                                                          + +
                                                          var foo = undefined;
                                                          +
                                                          + +

                                                          It’s considered a best practice to avoid initializing variables to undefined.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to eliminate variable declarations that initialize to undefined.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-undef-init: "error"*/
                                                          /*eslint-env es6*/

                                                          var foo = undefined;
                                                          let bar = undefined;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-undef-init: "error"*/
                                                          /*eslint-env es6*/

                                                          var foo;
                                                          let bar;
                                                          const baz = undefined;
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          There is one situation where initializing to undefined behaves differently than omitting the initialization, and that’s when a var declaration occurs inside of a loop. For example:

                                                          + +

                                                          Example of incorrect code for this rule:

                                                          + +
                                                          for (i = 0; i < 10; i++) {
                                                          var x = undefined;
                                                          console.log(x);
                                                          x = i;
                                                          }
                                                          +
                                                          + +

                                                          In this case, the var x is hoisted out of the loop, effectively creating:

                                                          + +
                                                          var x;

                                                          for (i = 0; i < 10; i++) {
                                                          x = undefined;
                                                          console.log(x);
                                                          x = i;
                                                          }
                                                          +
                                                          + +

                                                          If you were to remove the initialization, then the behavior of the loop changes:

                                                          + +
                                                          for (i = 0; i < 10; i++) {
                                                          var x;
                                                          console.log(x);
                                                          x = i;
                                                          }
                                                          +
                                                          + +

                                                          This code is equivalent to:

                                                          + +
                                                          var x;

                                                          for (i = 0; i < 10; i++) {
                                                          console.log(x);
                                                          x = i;
                                                          }
                                                          +
                                                          + +

                                                          This produces a different outcome than defining var x = undefined in the loop, as x is no longer reset to undefined each time through the loop.

                                                          + +

                                                          If you’re using such an initialization inside of a loop, then you should disable this rule.

                                                          + +

                                                          Example of correct code for this rule, because it is disabled on a specific line:

                                                          + +
                                                          /*eslint no-undef-init: "error"*/

                                                          for (i = 0; i < 10; i++) {
                                                          var x = undefined; // eslint-disable-line no-undef-init
                                                          console.log(x);
                                                          x = i;
                                                          }
                                                          +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.6.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-undef.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-undef.html new file mode 100644 index 0000000..eaf7787 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-undef.html @@ -0,0 +1,99 @@ + + + +

                                                          Disallow Undeclared Variables (no-undef)

                                                          + +

                                                          This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for example, from forgetting the var keyword in a for loop initializer).

                                                          + +

                                                          Rule Details

                                                          + +

                                                          Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/ comment.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-undef: "error"*/

                                                          var a = someFunction();
                                                          b = 10;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with global declaration:

                                                          + +
                                                          /*global someFunction b:true*/
                                                          /*eslint no-undef: "error"*/

                                                          var a = someFunction();
                                                          b = 10;
                                                          +
                                                          + +

                                                          The b:true syntax in /*global */ indicates that assignment to b is correct.

                                                          + +

                                                          Examples of incorrect code for this rule with global declaration:

                                                          + +
                                                          /*global b*/
                                                          /*eslint no-undef: "error"*/

                                                          b = 10;
                                                          +
                                                          + +

                                                          By default, variables declared in /*global */ are read-only, therefore assignment is incorrect.

                                                          + +

                                                          Options

                                                          + +
                                                            +
                                                          • typeof set to true will warn for variables used inside typeof check (Default false).
                                                          • +
                                                          + +

                                                          typeof

                                                          + +

                                                          Examples of correct code for the default { "typeof": false } option:

                                                          + +
                                                          /*eslint no-undef: "error"*/

                                                          if (typeof UndefinedIdentifier === "undefined") {
                                                          // do something ...
                                                          }
                                                          +
                                                          + +

                                                          You can use this option if you want to prevent typeof check on a variable which has not been declared.

                                                          + +

                                                          Examples of incorrect code for the { "typeof": true } option:

                                                          + +
                                                          /*eslint no-undef: ["error", { "typeof": true }] */

                                                          if(typeof a === "string"){}
                                                          +
                                                          + +

                                                          Examples of correct code for the { "typeof": true } option with global declaration:

                                                          + +
                                                          /*global a*/
                                                          /*eslint no-undef: ["error", { "typeof": true }] */

                                                          if(typeof a === "string"){}
                                                          +
                                                          + +

                                                          Environments

                                                          + +

                                                          For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments. This rule supports these environments, as listed in Specifying Environments. A few examples are given below.

                                                          + +

                                                          browser

                                                          + +

                                                          Examples of correct code for this rule with browser environment:

                                                          + +
                                                          /*eslint no-undef: "error"*/
                                                          /*eslint-env browser*/

                                                          setTimeout(function() {
                                                          alert("Hello");
                                                          });
                                                          +
                                                          + +

                                                          node

                                                          + +

                                                          Examples of correct code for this rule with node environment:

                                                          + +
                                                          /*eslint no-undef: "error"*/
                                                          /*eslint-env node*/

                                                          var fs = require("fs");
                                                          module.exports = function() {
                                                          console.log(fs);
                                                          };
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If explicit declaration of global variables is not to your taste.

                                                          + +

                                                          Compatibility

                                                          + +

                                                          This rule provides compatibility with treatment of global variables in JSHint and JSLint.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-undefined.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-undefined.html new file mode 100644 index 0000000..3458c28 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-undefined.html @@ -0,0 +1,90 @@ + + + +

                                                          Disallow Use of undefined Variable (no-undefined)

                                                          + +

                                                          The undefined variable is unique in JavaScript because it is actually a property of the global object. As such, in ECMAScript 3 it was possible to overwrite the value of undefined. While ECMAScript 5 disallows overwriting undefined, it’s still possible to shadow undefined, such as:

                                                          + +
                                                          function doSomething(data) {
                                                          var undefined = "hi";

                                                          // doesn't do what you think it does
                                                          if (data === undefined) {
                                                          // ...
                                                          }

                                                          }
                                                          +
                                                          + +

                                                          This represents a problem for undefined that doesn’t exist for null, which is a keyword and primitive value that can neither be overwritten nor shadowed.

                                                          + +

                                                          All uninitialized variables automatically get the value of undefined:

                                                          + +
                                                          var foo;

                                                          console.log(foo === undefined); // true (assuming no shadowing)
                                                          +
                                                          + +

                                                          For this reason, it’s not necessary to explicitly initialize a variable to undefined.

                                                          + +

                                                          Taking all of this into account, some style guides forbid the use of undefined, recommending instead:

                                                          + +
                                                            +
                                                          • Variables that should be undefined are simply left uninitialized.
                                                          • +
                                                          • Checking if a value is undefined should be done with typeof.
                                                          • +
                                                          • Using the void operator to generate the value of undefined if necessary.
                                                          • +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to eliminate the use of undefined, and as such, generates a warning whenever it is used.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-undefined: "error"*/

                                                          var foo = undefined;

                                                          var undefined = "foo";

                                                          if (foo === undefined) {
                                                          // ...
                                                          }

                                                          function foo(undefined) {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-undefined: "error"*/

                                                          var foo = void 0;

                                                          var Undefined = "foo";

                                                          if (typeof foo === "undefined") {
                                                          // ...
                                                          }

                                                          global.undefined = "foo";
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to allow the use of undefined in your code, then you can safely turn this rule off.

                                                          + +

                                                          Further Reading

                                                          + +
                                                            +
                                                          • + + + + + + + +
                                                            [undefined - JavaScriptMDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)
                                                            +
                                                          • +
                                                          • + + + + + + + +
                                                            [Understanding JavaScript’s ‘undefined’JavaScript, JavaScript…](http://javascriptweblog.wordpress.com/2010/08/16/understanding-undefined-and-preventing-referenceerrors/)
                                                            +
                                                          • +
                                                          • ECMA262 edition 5.1 §15.1.1.3: undefined
                                                          • +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.7.1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-underscore-dangle.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-underscore-dangle.html new file mode 100644 index 0000000..d522994 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-underscore-dangle.html @@ -0,0 +1,66 @@ + + + +

                                                          Disallow Dangling Underscores in Identifiers (no-underscore-dangle)

                                                          + +

                                                          As far as naming conventions for identifiers go, dangling underscores may be the most polarizing in JavaScript. Dangling underscores are underscores at either the beginning or end of an identifier, such as:

                                                          + +
                                                          var _foo;
                                                          +
                                                          + +

                                                          There is actually a long history of using dangling underscores to indicate “private” members of objects in JavaScript (though JavaScript doesn’t have truly private members, this convention served as a warning). This began with SpiderMonkey adding nonstandard methods such as __defineGetter__(). The intent with the underscores was to make it obvious that this method was special in some way. Since that time, using a single underscore prefix has become popular as a way to indicate “private” members of objects.

                                                          + +

                                                          Whether or not you choose to allow dangling underscores in identifiers is purely a convention and has no effect on performance, readability, or complexity. It’s purely a preference.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to eliminate the use of dangling underscores in identifiers.

                                                          + +

                                                          Options

                                                          + +

                                                          allow

                                                          + +
                                                          "no-underscore-dangle": ["error", { "allow": [] }]
                                                          +
                                                          + +

                                                          Array of variable names that are permitted to be used with underscore. If provided, it must be an Array.

                                                          + +

                                                          allowAfterThis

                                                          + +
                                                          "no-underscore-dangle": ["error", { "allowAfterThis": true }]
                                                          +
                                                          + +

                                                          This option allows usage of dangled variables as members of this.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-underscore-dangle: "error"*/

                                                          var foo_;
                                                          var __proto__ = {};
                                                          foo._bar();
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-underscore-dangle: "error"*/

                                                          var _ = require('underscore');
                                                          var obj = _.contains(items, item);
                                                          obj.__proto__ = {};
                                                          var file = __filename;
                                                          +
                                                          + +
                                                          /*eslint no-underscore-dangle: ["error", { "allow": ["foo_", "_bar"] }]*/

                                                          var foo_;
                                                          foo._bar();
                                                          +
                                                          + +
                                                          /*eslint no-underscore-dangle: ["error", { "allowAfterThis": true }]*/

                                                          var a = this.foo_;
                                                          this._bar();
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to allow dangling underscores in identifiers, then you can safely turn this rule off.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unexpected-multiline.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unexpected-multiline.html new file mode 100644 index 0000000..59e81ae --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unexpected-multiline.html @@ -0,0 +1,58 @@ + + + +

                                                          disallow confusing multiline expressions (no-unexpected-multiline)

                                                          + +

                                                          Semicolons are usually optional in JavaScript, because of automatic semicolon insertion (ASI). You can require or disallow semicolons with the semi rule.

                                                          + +

                                                          The rules for ASI are relatively straightforward: As once described by Isaac Schlueter, a newline character character always ends a statement, just like a semicolon, except where one of the following is true:

                                                          + +
                                                            +
                                                          • The statement has an unclosed paren, array literal, or object literal or ends in some other way that is not a valid way to end a statement. (For instance, ending with . or ,.)
                                                          • +
                                                          • The line is -- or ++ (in which case it will decrement/increment the next token.)
                                                          • +
                                                          • It is a for(), while(), do, if(), or else, and there is no {
                                                          • +
                                                          • The next line starts with [, (, +, *, /, -, ,, ., or some other binary operator that can only be found between two tokens in a single expression.
                                                          • +
                                                          + +

                                                          In the exceptions where a newline does not end a statement, a typing mistake to omit a semicolon causes two unrelated consecutive lines to be interpreted as one expression. Especially for a coding style without semicolons, readers might overlook the mistake. Although syntactically correct, the code might throw exceptions when it is executed.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows confusing multiline expressions where a newline looks like it is ending a statement, but is not.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-unexpected-multiline: "error"*/

                                                          var foo = bar
                                                          (1 || 2).baz();

                                                          var hello = 'world'
                                                          [1, 2, 3].forEach(addNumber);

                                                          let x = function() {}
                                                          `hello`

                                                          let x = function() {}
                                                          x
                                                          `hello`
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-unexpected-multiline: "error"*/

                                                          var foo = bar;
                                                          (1 || 2).baz();

                                                          var foo = bar
                                                          ;(1 || 2).baz()

                                                          var hello = 'world';
                                                          [1, 2, 3].forEach(addNumber);

                                                          var hello = 'world'
                                                          void [1, 2, 3].forEach(addNumber);

                                                          let x = function() {};
                                                          `hello`

                                                          let tag = function() {}
                                                          tag `hello`
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are confident that you will not accidentally introduce code like this.

                                                          + +

                                                          Note that the patterns considered problems are not flagged by the semi rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.24.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unmodified-loop-condition.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unmodified-loop-condition.html new file mode 100644 index 0000000..dd7dba9 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unmodified-loop-condition.html @@ -0,0 +1,50 @@ + + + +

                                                          Disallow unmodified conditions of loops (no-unmodified-loop-condition)

                                                          + +

                                                          Variables in a loop condition often are modified in the loop. +If not, it’s possibly a mistake.

                                                          + +
                                                          while (node) {
                                                          doSomething(node);
                                                          }
                                                          +
                                                          + +
                                                          while (node) {
                                                          doSomething(node);
                                                          node = node.parent;
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule finds references which are inside of loop conditions, then checks the +variables of those references are modified in the loop.

                                                          + +

                                                          If a reference is inside of a binary expression or a ternary expression, this rule checks the result of +the expression instead. +If a reference is inside of a dynamic expression (e.g. CallExpression, +YieldExpression, …), this rule ignores it.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          while (node) {
                                                          doSomething(node);
                                                          }
                                                          node = other;

                                                          for (var j = 0; j < items.length; ++i) {
                                                          doSomething(items[j]);
                                                          }

                                                          while (node !== root) {
                                                          doSomething(node);
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          while (node) {
                                                          doSomething(node);
                                                          node = node.parent;
                                                          }

                                                          for (var j = 0; j < items.length; ++j) {
                                                          doSomething(items[j]);
                                                          }

                                                          // OK, the result of this binary expression is changed in this loop.
                                                          while (node !== root) {
                                                          doSomething(node);
                                                          node = node.parent;
                                                          }

                                                          // OK, the result of this ternary expression is changed in this loop.
                                                          while (node ? A : B) {
                                                          doSomething(node);
                                                          node = node.parent;
                                                          }

                                                          // A property might be a getter which has side effect...
                                                          // Or "doSomething" can modify "obj.foo".
                                                          while (obj.foo) {
                                                          doSomething(obj);
                                                          }

                                                          // A function call can return various values.
                                                          while (check(obj)) {
                                                          doSomething(obj);
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to notified about references inside of loop conditions, then it’s safe to disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-alpha-2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unneeded-ternary.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unneeded-ternary.html new file mode 100644 index 0000000..0d50f2b --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unneeded-ternary.html @@ -0,0 +1,68 @@ + + + +

                                                          Disallow conditional expressions that can be expressed with simpler constructs (no-unneeded-ternary)

                                                          + +

                                                          It’s a common mistake in JavaScript to use a conditional expression to select between two Boolean values instead of using ! to convert the test to a Boolean. +Here are some examples:

                                                          + +
                                                          // Bad
                                                          var isYes = answer === 1 ? true : false;

                                                          // Good
                                                          var isYes = answer === 1;


                                                          // Bad
                                                          var isNo = answer === 1 ? false : true;

                                                          // Good
                                                          var isNo = answer !== 1;
                                                          +
                                                          + +

                                                          This rule disallows the use of ‘Boolean’ literals inside conditional expressions.

                                                          + +

                                                          Another common mistake is using a single variable as both the conditional test and the consequent. In such cases, the logical OR can be used to provide the same functionality. +Here is an example:

                                                          + +
                                                          // Bad
                                                          var foo = bar ? bar : 1;

                                                          // Good
                                                          var foo = bar || 1;
                                                          +
                                                          + +

                                                          This rule disallows the conditional expression as a default assignment pattern when the defaultAssignment option is set to false.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces a coding style where it disallows conditional expressions that can be implemented using simpler language constructs. Specifically, this rule disallows the use of Boolean literals inside conditional expressions, and conditional expressions where a single variable is used as both the test and consequent. This rule’s default options are {"defaultAssignment": true }.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-unneeded-ternary: "error"*/

                                                          var a = x === 2 ? true : false;

                                                          var a = x ? true : false;
                                                          +
                                                          + +

                                                          The following pattern is considered a warning when defaultAssignment is false:

                                                          + +
                                                          var a = x ? x : 1;
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-unneeded-ternary: "error"*/

                                                          var a = x === 2 ? "Yes" : "No";

                                                          var a = x !== false;

                                                          var a = x ? "Yes" : "No";

                                                          var a = x ? y : x;
                                                          +
                                                          + +

                                                          The following pattern is not considered a warning when defaultAssignment is true:

                                                          + +
                                                          var a = x ? x : 1;
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with unnecessary complexity in conditional expressions.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.21.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unreachable.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unreachable.html new file mode 100644 index 0000000..9112297 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unreachable.html @@ -0,0 +1,36 @@ + + + +

                                                          disallow unreachable code after return, throw, continue, and break statements (no-unreachable)

                                                          + +

                                                          Because the return, throw, break, and continue statements unconditionally exit a block of code, any statements after them cannot be executed. Unreachable statements are usually a mistake.

                                                          + +
                                                          function fn() {
                                                          x = 1;
                                                          return x;
                                                          x = 3; // this will never execute
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows unreachable code after return, throw, continue, and break statements.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-unreachable: "error"*/

                                                          function foo() {
                                                          return true;
                                                          console.log("done");
                                                          }

                                                          function bar() {
                                                          throw new Error("Oops!");
                                                          console.log("done");
                                                          }

                                                          while(value) {
                                                          break;
                                                          console.log("done");
                                                          }

                                                          throw new Error("Oops!");
                                                          console.log("done");

                                                          function baz() {
                                                          if (Math.random() < 0.5) {
                                                          return;
                                                          } else {
                                                          throw new Error();
                                                          }
                                                          console.log("done");
                                                          }

                                                          for (;;) {}
                                                          console.log("done");
                                                          +
                                                          + +

                                                          Examples of correct code for this rule, because of JavaScript function and variable hoisting:

                                                          + +
                                                          /*eslint no-unreachable: "error"*/

                                                          function foo() {
                                                          return bar();
                                                          function bar() {
                                                          return 1;
                                                          }
                                                          }

                                                          function bar() {
                                                          return x;
                                                          var x;
                                                          }

                                                          switch (foo) {
                                                          case 1:
                                                          break;
                                                          var x;
                                                          }
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.6.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unsafe-finally.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unsafe-finally.html new file mode 100644 index 0000000..2ec24bd --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unsafe-finally.html @@ -0,0 +1,58 @@ + + + +

                                                          disallow control flow statements in finally blocks (no-unsafe-finally)

                                                          + +

                                                          JavaScript suspends the control flow statements of try and catch blocks until the execution of finally block finishes. So, when return, throw, break, or continue is used in finally, control flow statements inside try and catch are overwritten, which is considered as unexpected behavior. Such as:

                                                          + +
                                                          // We expect this function to return 1;
                                                          (() => {
                                                          try {
                                                          return 1; // 1 is returned but suspended until finally block ends
                                                          } catch(err) {
                                                          return 2;
                                                          } finally {
                                                          return 3; // 3 is returned before 1, which we did not expect
                                                          }
                                                          })();

                                                          // > 3
                                                          +
                                                          + +
                                                          // We expect this function to throw an error, then return
                                                          (() => {
                                                          try {
                                                          throw new Error("Try"); // error is thrown but suspended until finally block ends
                                                          } finally {
                                                          return 3; // 3 is returned before the error is thrown, which we did not expect
                                                          }
                                                          })();

                                                          // > 3
                                                          +
                                                          + +
                                                          // We expect this function to throw Try(...) error from the catch block
                                                          (() => {
                                                          try {
                                                          throw new Error("Try")
                                                          } catch(err) {
                                                          throw err; // The error thrown from try block is catched and rethrown
                                                          } finally {
                                                          throw new Error("Finally"); // Finally(...) is thrown, which we did not expect
                                                          }
                                                          })();

                                                          // > Uncaught Error: Finally(...)
                                                          +
                                                          + +
                                                          // We expect this function to return 0 from try block.
                                                          (() => {
                                                          label: try {
                                                          return 0; // 1 is returned but suspended until finally block ends
                                                          } finally {
                                                          break label; // It breaks out the try-finally block, before 0 is returned.
                                                          }
                                                          return 1;
                                                          })();

                                                          // > 1
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows return, throw, break, and continue statements inside finally blocks. It allows indirect usages, such as in function or class definitions.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-unsafe-finally: "error"*/
                                                          let foo = function() {
                                                          try {
                                                          return 1;
                                                          } catch(err) {
                                                          return 2;
                                                          } finally {
                                                          return 3;
                                                          }
                                                          };
                                                          +
                                                          + +
                                                          /*eslint no-unsafe-finally: "error"*/
                                                          let foo = function() {
                                                          try {
                                                          return 1;
                                                          } catch(err) {
                                                          return 2;
                                                          } finally {
                                                          throw new Error;
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-unsafe-finally: "error"*/
                                                          let foo = function() {
                                                          try {
                                                          return 1;
                                                          } catch(err) {
                                                          return 2;
                                                          } finally {
                                                          console.log("hola!");
                                                          }
                                                          };
                                                          +
                                                          + +
                                                          /*eslint no-unsafe-finally: "error"*/
                                                          let foo = function() {
                                                          try {
                                                          return 1;
                                                          } catch(err) {
                                                          return 2;
                                                          } finally {
                                                          let a = function() {
                                                          return "hola!";
                                                          }
                                                          }
                                                          };
                                                          +
                                                          + +
                                                          /*eslint no-unsafe-finally: "error"*/
                                                          let foo = function(a) {
                                                          try {
                                                          return 1;
                                                          } catch(err) {
                                                          return 2;
                                                          } finally {
                                                          switch(a) {
                                                          case 1: {
                                                          console.log("hola!")
                                                          break;
                                                          }
                                                          }
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you want to allow control flow operations in finally blocks, you can turn this rule off.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.9.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unused-expressions.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unused-expressions.html new file mode 100644 index 0000000..9a71ee0 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unused-expressions.html @@ -0,0 +1,91 @@ + + + +

                                                          Disallow Unused Expressions (no-unused-expressions)

                                                          + +

                                                          An unused expression which has no effect on the state of the program indicates a logic error.

                                                          + +

                                                          For example, n + 1; is not a syntax error, but it might be a typing mistake where a programmer meant an assignment statement n += 1; instead.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to eliminate unused expressions which have no effect on the state of the program.

                                                          + +

                                                          This rule does not apply to function calls or constructor calls with the new operator, because they could have side effects on the state of the program.

                                                          + +
                                                          var i = 0;
                                                          function increment() { i += 1; }
                                                          increment(); // return value is unused, but i changed as a side effect

                                                          var nThings = 0;
                                                          function Thing() { nThings += 1; }
                                                          new Thing(); // constructed object is unused, but nThings changed as a side effect
                                                          +
                                                          + +

                                                          This rule does not apply to directives (which are in the form of literal string expressions such as "use strict"; at the beginning of a script, module, or function).

                                                          + +

                                                          Sequence expressions (those using a comma, such as a = 1, b = 2) are always considered unused unless their return value is assigned or used in a condition evaluation, or a function call is made with the sequence expression value.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

                                                          + +
                                                            +
                                                          • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
                                                          • +
                                                          • allowTernary set to true will enable you use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
                                                          • +
                                                          + +

                                                          These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

                                                          + +

                                                          Examples of incorrect code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                                                          + +
                                                          /*eslint no-unused-expressions: "error"*/

                                                          0

                                                          if(0) 0

                                                          {0}

                                                          f(0), {}

                                                          a && b()

                                                          a, b()

                                                          c = a, b;

                                                          a() && function namedFunctionInExpressionContext () {f();}

                                                          (function anIncompleteIIFE () {});

                                                          +
                                                          + +

                                                          Note that one or more string expression statements (with or without semi-colons) will only be considered as unused if they are not in the beginning of a script, module, or function (alone and uninterrupted by other statements). Otherwise, they will be treated as part of a “directive prologue”, a section potentially usable by JavaScript engines. This includes “strict mode” directives.

                                                          + +
                                                          "use strict";
                                                          "use asm"
                                                          "use stricter";
                                                          "use babel"
                                                          "any other strings like this in the prologue";
                                                          +
                                                          + +

                                                          Examples of correct code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                                                          + +
                                                          /*eslint no-unused-expressions: "error"*/

                                                          {} // In this context, this is a block statement, not an object literal

                                                          {myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal

                                                          function namedFunctionDeclaration () {}

                                                          (function aGenuineIIFE () {}());

                                                          f()

                                                          a = 0

                                                          new C

                                                          delete a.b

                                                          void a
                                                          +
                                                          + +

                                                          allowShortCircuit

                                                          + +

                                                          Examples of incorrect code for the { "allowShortCircuit": true } option:

                                                          + +
                                                          /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/

                                                          a || b
                                                          +
                                                          + +

                                                          Examples of correct code for the { "allowShortCircuit": true } option:

                                                          + +
                                                          /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/

                                                          a && b()
                                                          a() || (b = c)
                                                          +
                                                          + +

                                                          allowTernary

                                                          + +

                                                          Examples of incorrect code for the { "allowTernary": true } option:

                                                          + +
                                                          /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/

                                                          a ? b : 0
                                                          a ? b : c()
                                                          +
                                                          + +

                                                          Examples of correct code for the { "allowTernary": true } option:

                                                          + +
                                                          /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/

                                                          a ? b() : c()
                                                          a ? (b = c) : d()
                                                          +
                                                          + +

                                                          allowShortCircuit and allowTernary

                                                          + +

                                                          Examples of correct code for the { "allowShortCircuit": true, "allowTernary": true } options:

                                                          + +
                                                          /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/

                                                          a ? b() || (c = d) : e()
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.1.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unused-labels.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unused-labels.html new file mode 100644 index 0000000..c5c0ca6 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unused-labels.html @@ -0,0 +1,51 @@ + + + +

                                                          Disallow Unused Labels (no-unused-labels)

                                                          + +

                                                          Labels that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring.

                                                          + +
                                                          OUTER_LOOP:
                                                          for (const student of students) {
                                                          if (checkScores(student.scores)) {
                                                          continue;
                                                          }
                                                          doSomething(student);
                                                          }
                                                          +
                                                          + +

                                                          In this case, probably removing OUTER_LOOP: had been forgotten. +Such labels take up space in the code and can lead to confusion by readers.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at eliminating unused labels.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-unused-labels: "error"*/

                                                          A: var foo = 0;

                                                          B: {
                                                          foo();
                                                          }

                                                          C:
                                                          for (let i = 0; i < 10; ++i) {
                                                          foo();
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-unused-labels: "error"*/

                                                          A: {
                                                          if (foo()) {
                                                          break A;
                                                          }
                                                          bar();
                                                          }

                                                          B:
                                                          for (let i = 0; i < 10; ++i) {
                                                          if (foo()) {
                                                          break B;
                                                          }
                                                          bar();
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about unused labels, then it’s safe to disable this rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-rc.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unused-vars.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unused-vars.html new file mode 100644 index 0000000..19375ec --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-unused-vars.html @@ -0,0 +1,174 @@ + + + +

                                                          Disallow Unused Variables (no-unused-vars)

                                                          + +

                                                          Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at eliminating unused variables, functions, and parameters of functions.

                                                          + +

                                                          A variable is considered to be used if any of the following are true:

                                                          + +
                                                            +
                                                          • It represents a function that is called (doSomething())
                                                          • +
                                                          • It is read (var y = x)
                                                          • +
                                                          • It is passed into a function as an argument (doSomething(x))
                                                          • +
                                                          + +

                                                          A variable is not considered to be used if it is only ever assigned to (var x = 5) or declared.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-unused-vars: "error"*/
                                                          /*global some_unused_var*/

                                                          //It checks variables you have defined as global
                                                          some_unused_var = 42;

                                                          var x;

                                                          var y = 10;
                                                          y = 5;

                                                          // By default, unused arguments cause warnings.
                                                          (function(foo) {
                                                          return 5;
                                                          })();

                                                          // Unused recursive functions also cause warnings.
                                                          function fact(n) {
                                                          if (n < 2) return 1;
                                                          return n * fact(n - 1);
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-unused-vars: "error"*/

                                                          var x = 10;
                                                          alert(x);

                                                          // foo is considered used here
                                                          myFunc(function foo() {
                                                          // ...
                                                          }.bind(this));

                                                          (function(foo) {
                                                          return foo;
                                                          })();
                                                          +
                                                          + +

                                                          exported

                                                          + +

                                                          In environments outside of CommonJS or ECMAScript modules, you may use var to create a global variable that may be used by other scripts. You can use the /* exported variableName */ comment block to indicate that this variable is being exported and therefore should not be considered unused.

                                                          + +

                                                          Note that /* exported */ has no effect for any of the following:

                                                          + +
                                                            +
                                                          • when the environment is node or commonjs
                                                          • +
                                                          • when parserOptions.sourceType is module
                                                          • +
                                                          • when ecmaFeatures.globalReturn is true
                                                          • +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule takes one argument which can be a string or an object. The string settings are the same as those of the vars property (explained below).

                                                          + +

                                                          By default this rule is enabled with all option for variables and after-used for arguments.

                                                          + +
                                                          {
                                                          "rules": {
                                                          "no-unused-vars": ["error", { "vars": "all", "args": "after-used" }]
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          vars

                                                          + +

                                                          The vars option has two settings:

                                                          + +
                                                            +
                                                          • all checks all variables for usage, including those in the global scope. This is the default setting.
                                                          • +
                                                          • local checks only that locally-declared variables are used but will allow global variables to be unused.
                                                          • +
                                                          + +

                                                          vars: local

                                                          + +

                                                          Examples of correct code for the { "vars": "local" } option:

                                                          + +
                                                          /*eslint no-unused-vars: ["error", { "vars": "local" }]*/
                                                          /*global some_unused_var */

                                                          some_unused_var = 42;
                                                          +
                                                          + +

                                                          varsIgnorePattern

                                                          + +

                                                          The varsIgnorePattern option specifies exceptions not to check for usage: variables whose names match a regexp pattern. For example, variables whose names contain ignored or Ignored.

                                                          + +

                                                          Examples of correct code for the { "varsIgnorePattern": "[iI]gnored" } option:

                                                          + +
                                                          /*eslint no-unused-vars: ["error", { "varsIgnorePattern": "[iI]gnored" }]*/

                                                          var firstVarIgnored = 1;
                                                          var secondVar = 2;
                                                          console.log(secondVar);
                                                          +
                                                          + +

                                                          args

                                                          + +

                                                          The args option has three settings:

                                                          + +
                                                            +
                                                          • after-used - only the last argument must be used. This allows you, for instance, to have two named parameters to a function and as long as you use the second argument, ESLint will not warn you about the first. This is the default setting.
                                                          • +
                                                          • all - all named arguments must be used.
                                                          • +
                                                          • none - do not check arguments.
                                                          • +
                                                          + +

                                                          args: after-used

                                                          + +

                                                          Examples of incorrect code for the default { "args": "after-used" } option:

                                                          + +
                                                          /*eslint no-unused-vars: ["error", { "args": "after-used" }]*/

                                                          // 1 error
                                                          // "baz" is defined but never used
                                                          (function(foo, bar, baz) {
                                                          return bar;
                                                          })();
                                                          +
                                                          + +

                                                          Examples of correct code for the default { "args": "after-used" } option:

                                                          + +
                                                          /*eslint no-unused-vars: ["error", {"args": "after-used"}]*/

                                                          (function(foo, bar, baz) {
                                                          return baz;
                                                          })();
                                                          +
                                                          + +

                                                          args: all

                                                          + +

                                                          Examples of incorrect code for the { "args": "all" } option:

                                                          + +
                                                          /*eslint no-unused-vars: ["error", { "args": "all" }]*/

                                                          // 2 errors
                                                          // "foo" is defined but never used
                                                          // "baz" is defined but never used
                                                          (function(foo, bar, baz) {
                                                          return bar;
                                                          })();
                                                          +
                                                          + +

                                                          args: none

                                                          + +

                                                          Examples of correct code for the { "args": "none" } option:

                                                          + +
                                                          /*eslint no-unused-vars: ["error", { "args": "none" }]*/

                                                          (function(foo, bar, baz) {
                                                          return bar;
                                                          })();
                                                          +
                                                          + +

                                                          argsIgnorePattern

                                                          + +

                                                          The argsIgnorePattern option specifies exceptions not to check for usage: arguments whose names match a regexp pattern. For example, variables whose names begin with an underscore.

                                                          + +

                                                          Examples of correct code for the { "argsIgnorePattern": "^_" } option:

                                                          + +
                                                          /*eslint no-unused-vars: ["error", { "argsIgnorePattern": "^_" }]*/

                                                          function foo(x, _y) {
                                                          return x + 1;
                                                          }
                                                          foo();
                                                          +
                                                          + +

                                                          caughtErrors

                                                          + +

                                                          The caughtErrors option is used for catch block arguments validation.

                                                          + +

                                                          It has two settings:

                                                          + +
                                                            +
                                                          • none - do not check error objects. This is the default setting.
                                                          • +
                                                          • all - all named arguments must be used.
                                                          • +
                                                          + +

                                                          caughtErrors: none

                                                          + +

                                                          Not specifying this rule is equivalent of assigning it to none.

                                                          + +

                                                          Examples of correct code for the { "caughtErrors": "none" } option:

                                                          + +
                                                          /*eslint no-unused-vars: ["error", { "caughtErrors": "none" }]*/

                                                          try {
                                                          //...
                                                          } catch (err) {
                                                          console.error("errors");
                                                          }
                                                          +
                                                          + +

                                                          caughtErrors: all

                                                          + +

                                                          Examples of incorrect code for the { "caughtErrors": "all" } option:

                                                          + +
                                                          /*eslint no-unused-vars: ["error", { "caughtErrors": "all" }]*/

                                                          // 1 error
                                                          // "err" is defined but never used
                                                          try {
                                                          //...
                                                          } catch (err) {
                                                          console.error("errors");
                                                          }
                                                          +
                                                          + +

                                                          caughtErrorsIgnorePattern

                                                          + +

                                                          The caughtErrorsIgnorePattern option specifies exceptions not to check for usage: catch arguments whose names match a regexp pattern. For example, variables whose names begin with a string ‘ignore’.

                                                          + +

                                                          Examples of correct code for the { "caughtErrorsIgnorePattern": "^ignore" } option:

                                                          + +
                                                          /*eslint no-unused-vars: ["error", { "caughtErrorsIgnorePattern": "^ignore" }]*/

                                                          try {
                                                          //...
                                                          } catch (ignoreErr) {
                                                          console.error("errors");
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about unused variables or function arguments, you can safely turn this rule off.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-use-before-define.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-use-before-define.html new file mode 100644 index 0000000..3d34d53 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-use-before-define.html @@ -0,0 +1,77 @@ + + + +

                                                          Disallow Early Use (no-use-before-define)

                                                          + +

                                                          In JavaScript, prior to ES6, variable and function declarations are hoisted to the top of a scope, so it’s possible to use identifiers before their formal declarations in code. This can be confusing and some believe it is best to always declare variables and functions before using them.

                                                          + +

                                                          In ES6, block-level bindings (let and const) introduce a “temporal dead zone” where a ReferenceError will be thrown with any attempt to access the variable before its declaration.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule will warn when it encounters a reference to an identifier that has not yet been declared.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-use-before-define: "error"*/
                                                          /*eslint-env es6*/

                                                          alert(a);
                                                          var a = 10;

                                                          f();
                                                          function f() {}

                                                          function g() {
                                                          return b;
                                                          }
                                                          var b = 1;

                                                          // With blockBindings: true
                                                          {
                                                          alert(c);
                                                          let c = 1;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-use-before-define: "error"*/
                                                          /*eslint-env es6*/

                                                          var a;
                                                          a = 10;
                                                          alert(a);

                                                          function f() {}
                                                          f(1);

                                                          var b = 1;
                                                          function g() {
                                                          return b;
                                                          }

                                                          // With blockBindings: true
                                                          {
                                                          let C;
                                                          c++;
                                                          }
                                                          +
                                                          + +

                                                          Options

                                                          + +
                                                          {
                                                          "no-use-before-define": ["error", { "functions": true, "classes": true }]
                                                          }
                                                          +
                                                          + +
                                                            +
                                                          • functions (boolean) - +The flag which shows whether or not this rule checks function declarations. +If this is true, this rule warns every reference to a function before the function declaration. +Otherwise, ignores those references. +Function declarations are hoisted, so it’s safe. +Default is true.
                                                          • +
                                                          • classes (boolean) - +The flag which shows whether or not this rule checks class declarations of upper scopes. +If this is true, this rule warns every reference to a class before the class declaration. +Otherwise, ignores those references if the declaration is in upper function scopes. +Class declarations are not hoisted, so it might be danger. +Default is true.
                                                          • +
                                                          + +

                                                          This rule accepts "nofunc" string as a option. +"nofunc" is the same as { "functions": false, "classes": true }.

                                                          + +

                                                          functions

                                                          + +

                                                          Examples of correct code for the { "functions": false } option:

                                                          + +
                                                          /*eslint no-use-before-define: ["error", { "functions": false }]*/

                                                          f();
                                                          function f() {}
                                                          +
                                                          + +

                                                          classes

                                                          + +

                                                          Examples of incorrect code for the { "classes": false } option:

                                                          + +
                                                          /*eslint no-use-before-define: ["error", { "classes": false }]*/
                                                          /*eslint-env es6*/

                                                          new A();
                                                          class A {
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for the { "classes": false } option:

                                                          + +
                                                          /*eslint no-use-before-define: ["error", { "classes": false }]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          return new A();
                                                          }

                                                          class A {
                                                          }
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-call.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-call.html new file mode 100644 index 0000000..ee3e536 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-call.html @@ -0,0 +1,53 @@ + + + +

                                                          Disallow unnecessary .call() and .apply(). (no-useless-call)

                                                          + +

                                                          The function invocation can be written by Function.prototype.call() and Function.prototype.apply(). +But Function.prototype.call() and Function.prototype.apply() are slower than the normal function invocation.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed to flag usage of Function.prototype.call() and Function.prototype.apply() that can be replaced with the normal function invocation.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-useless-call: "error"*/

                                                          // These are same as `foo(1, 2, 3);`
                                                          foo.call(undefined, 1, 2, 3);
                                                          foo.apply(undefined, [1, 2, 3]);
                                                          foo.call(null, 1, 2, 3);
                                                          foo.apply(null, [1, 2, 3]);

                                                          // These are same as `obj.foo(1, 2, 3);`
                                                          obj.foo.call(obj, 1, 2, 3);
                                                          obj.foo.apply(obj, [1, 2, 3]);
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-useless-call: "error"*/

                                                          // The `this` binding is different.
                                                          foo.call(obj, 1, 2, 3);
                                                          foo.apply(obj, [1, 2, 3]);
                                                          obj.foo.call(null, 1, 2, 3);
                                                          obj.foo.apply(null, [1, 2, 3]);
                                                          obj.foo.call(otherObj, 1, 2, 3);
                                                          obj.foo.apply(otherObj, [1, 2, 3]);

                                                          // The argument list is variadic.
                                                          foo.apply(undefined, args);
                                                          foo.apply(null, args);
                                                          obj.foo.apply(obj, args);
                                                          +
                                                          + +

                                                          Known Limitations

                                                          + +

                                                          This rule compares code statically to check whether or not thisArg is changed. +So if the code about thisArg is a dynamic expression, this rule cannot judge correctly.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-useless-call: "error"*/

                                                          a[i++].foo.call(a[i++], 1, 2, 3);
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-useless-call: "error"*/

                                                          a[++i].foo.call(a[i], 1, 2, 3);
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about unnecessary .call() and .apply(), you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0-rc-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-computed-key.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-computed-key.html new file mode 100644 index 0000000..57a92cb --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-computed-key.html @@ -0,0 +1,45 @@ + + + +

                                                          Disallow unnecessary computed property keys on objects (no-useless-computed-key)

                                                          + +

                                                          It’s unnecessary to use computed properties with literals such as:

                                                          + +
                                                          var foo = {["a"]: "b"};
                                                          +
                                                          + +

                                                          The code can be rewritten as:

                                                          + +
                                                          var foo = {"a": "b"};
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows unnecessary usage of computed property keys.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-useless-computed-key: "error"*/
                                                          /*eslint-env es6*/

                                                          var a = { ['0']: 0 };
                                                          var a = { ['0+1,234']: 0 };
                                                          var a = { [0]: 0 };
                                                          var a = { ['x']: 0 };
                                                          var a = { ['x']() {} };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-useless-computed-key: "error"*/

                                                          var c = { 'a': 0 };
                                                          var c = { 0: 0 };
                                                          var a = { x() {} };
                                                          var c = { a: 0 };
                                                          var c = { '0+1,234': 0 };
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about unnecessary computed property keys, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.9.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-concat.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-concat.html new file mode 100644 index 0000000..b8ee6c4 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-concat.html @@ -0,0 +1,45 @@ + + + +

                                                          Disallow unnecessary concatenation of strings (no-useless-concat)

                                                          + +

                                                          It’s unnecessary to concatenate two strings together, such as:

                                                          + +
                                                          var foo = "a" + "b";
                                                          +
                                                          + +

                                                          This code is likely the result of refactoring where a variable was removed from the concatenation (such as "a" + b + "b"). In such a case, the concatenation isn’t important and the code can be rewritten as:

                                                          + +
                                                          var foo = "ab";
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to flag the concatenation of 2 literals when they could be combined into a single literal. Literals can be strings or template literals.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-useless-concat: "error"*/
                                                          /*eslint-env es6*/

                                                          // these are the same as "10"
                                                          var a = `some` + `string`;
                                                          var a = '1' + '0';
                                                          var a = '1' + `0`;
                                                          var a = `1` + '0';
                                                          var a = `1` + `0`;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-useless-concat: "error"*/

                                                          // when a non string is included
                                                          var c = a + b;
                                                          var c = '1' + a;
                                                          var a = 1 + '1';
                                                          var c = 1 - 2;
                                                          // when the string concatenation is multiline
                                                          var c = "foo" +
                                                          "bar";
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about unnecessary string concatenation, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.3.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-constructor.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-constructor.html new file mode 100644 index 0000000..7eecf56 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-constructor.html @@ -0,0 +1,40 @@ + + + +

                                                          Disallow unnecessary constructor (no-useless-constructor)

                                                          + +

                                                          ES2015 provides a default class constructor if one is not specified. As such, it is unnecessary to provide an empty constructor or one that simply delegates into its parent class, as in the following examples:

                                                          + +
                                                          class A {
                                                          constructor () {
                                                          }
                                                          }

                                                          class A extends B {
                                                          constructor (value) {
                                                          super(value);
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule flags class constructors that can be safely removed without changing how the class works.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-useless-constructor: "error"*/
                                                          /*eslint-env es6*/

                                                          class A {
                                                          constructor () {
                                                          }
                                                          }

                                                          class A extends B {
                                                          constructor (...args) {
                                                          super(...args);
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-useless-constructor: "error"*/

                                                          class A { }

                                                          class A {
                                                          constructor () {
                                                          doSomething();
                                                          }
                                                          }

                                                          class A extends B {
                                                          constructor() {
                                                          super('foo');
                                                          }
                                                          }

                                                          class A extends B {
                                                          constructor() {
                                                          super();
                                                          doSomething();
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about unnecessary constructors, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-beta.1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-escape.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-escape.html new file mode 100644 index 0000000..a19b618 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-useless-escape.html @@ -0,0 +1,40 @@ + + + +

                                                          Disallow unnecessary escape usage (no-useless-escape)

                                                          + +

                                                          Escaping non-special characters in strings and regular expressions doesn’t have any effects on results, as in the following example:

                                                          + +
                                                          let foo = "hol\a"; // > foo = "hola"
                                                          let bar = /\:/ // same functionality with /:/
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule flags escapes that can be safely removed without changing behavior.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-useless-escape: "error"*/

                                                          "\'";
                                                          '\"';
                                                          "\#";
                                                          "\e";
                                                          /\!/;
                                                          /\@/;

                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-useless-escape: "error"*/

                                                          "\"";
                                                          '\'';
                                                          "\x12";
                                                          "\u00a9";
                                                          "\371";
                                                          "xs\u2111";
                                                          /\\/g;
                                                          /\t/g;
                                                          /\\w\\$\\*\\^\\./;

                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about unnecessary escapes, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.5.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-var.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-var.html new file mode 100644 index 0000000..7b69b64 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-var.html @@ -0,0 +1,43 @@ + + + +

                                                          require let or const instead of var (no-var)

                                                          + +

                                                          ECMAScript 6 allows programmers to create variables with block scope instead of function scope using the let +and const keywords. Block scope is common in many other programming languages and helps programmers avoid mistakes +such as:

                                                          + +
                                                          var count = people.length;
                                                          var enoughFood = count > sandwiches.length;

                                                          if (enoughFood) {
                                                          var count = sandwiches.length; // accidently overriding the count variable
                                                          console.log("We have " + count + " sandwiches for everyone. Plenty for all!");
                                                          }

                                                          // our count variable is no longer accurate
                                                          console.log("We have " + count + " people and " + sandwiches.length + " sandwiches!");
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at discouraging the use of var and encouraging the use of const or let instead.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint no-var: "error"*/

                                                          var x = "y";
                                                          var CONFIG = {};
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-var: "error"*/
                                                          /*eslint-env es6*/

                                                          let x = "y";
                                                          const CONFIG = {};
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          In addition to non-ES6 environments, existing JavaScript projects that are beginning to introduce ES6 into their +codebase may not want to apply this rule if the cost of migrating from var to let is too costly.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.12.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-void.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-void.html new file mode 100644 index 0000000..33373d5 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-void.html @@ -0,0 +1,66 @@ + + + +

                                                          Disallow use of the void operator. (no-void)

                                                          + +

                                                          The void operator takes an operand and returns undefined: void expression will evaluate expression and return undefined. It can be used to ignore any side effects expression may produce:

                                                          + +

                                                          The common case of using void operator is to get a “pure” undefined value as prior to ES5 the undefined variable was mutable:

                                                          + +
                                                          // will always return undefined
                                                          (function(){
                                                          return void 0;
                                                          })();

                                                          // will return 1 in ES3 and undefined in ES5+
                                                          (function(){
                                                          undefined = 1;
                                                          return undefined;
                                                          })();

                                                          // will throw TypeError is ES5+
                                                          (function(){
                                                          'use strict';
                                                          undefined = 1;
                                                          })();
                                                          +
                                                          + +

                                                          Another common case is to minify code as void 0 is shorter than undefined:

                                                          + +
                                                          foo = void 0;
                                                          foo = undefined;
                                                          +
                                                          + +

                                                          When used with IIFE (immediately-invoked function expression) void can be used to force the function keyword to be treated as an expression instead of a declaration:

                                                          + +
                                                          var foo = 1;
                                                          void function(){ foo = 1; }() // will assign foo a value of 1
                                                          +function(){ foo = 1; }() // same as above
                                                          +
                                                          + +
                                                          function(){ foo = 1; }() // will throw SyntaxError
                                                          +
                                                          + +

                                                          Some code styles prohibit void operator marking it as non-obvious and hard to read.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to eliminate use of void operator.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-void: "error"*/

                                                          void foo

                                                          var foo = void bar();
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you intentionally use the void operator then you can disable this rule.

                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.8.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-warning-comments.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-warning-comments.html new file mode 100644 index 0000000..f05961f --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-warning-comments.html @@ -0,0 +1,64 @@ + + + +

                                                          Disallow Warning Comments (no-warning-comments)

                                                          + +

                                                          Developers often add comments to code which is not complete or needs review. Most likely you want to fix or review the code, and then remove the comment, before you consider the code to be production ready.

                                                          + +
                                                          // TODO: do something
                                                          // FIXME: this is not a good idea
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule reports comments that include any of the predefined terms specified in its configuration.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an options object literal:

                                                          + +
                                                            +
                                                          • "terms": optional array of terms to match. Defaults to ["todo", "fixme", "xxx"]. Terms are matched case-insensitive and as whole words: fix would match FIX but not fixing. Terms can consist of multiple words: really bad idea.
                                                          • +
                                                          • "location": optional string that configures where in your comments to check for matches. Defaults to "start". The other value is match anywhere in comments.
                                                          • +
                                                          + +

                                                          Example of incorrect code for the default { "terms": ["todo", "fixme", "xxx"], "location": "start" } options:

                                                          + +
                                                          /*eslint no-warning-comments: "error"*/

                                                          function callback(err, results) {
                                                          if (err) {
                                                          console.error(err);
                                                          return;
                                                          }
                                                          // TODO
                                                          }
                                                          +
                                                          + +

                                                          Example of correct code for the default { "terms": ["todo", "fixme", "xxx"], "location": "start" } options:

                                                          + +
                                                          /*eslint no-warning-comments: "error"*/

                                                          function callback(err, results) {
                                                          if (err) {
                                                          console.error(err);
                                                          return;
                                                          }
                                                          // NOT READY FOR PRIME TIME
                                                          // but too bad, it is not a predefined warning term
                                                          }
                                                          +
                                                          + +

                                                          terms and location

                                                          + +

                                                          Examples of incorrect code for the { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" } options:

                                                          + +
                                                          /*eslint no-warning-comments: ["error", { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" }]*/

                                                          // TODO: this
                                                          // todo: this too
                                                          // Even this: TODO
                                                          /* /*
                                                          * The same goes for this TODO comment
                                                          * Or a fixme
                                                          * as well as any other term
                                                          */

                                                          +
                                                          + +

                                                          Examples of correct code for the { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" } options:

                                                          + +
                                                          /*eslint no-warning-comments: ["error", { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" }]*/

                                                          // This is to do
                                                          // even not any other term
                                                          // any other terminal
                                                          /*
                                                          * The same goes for block comments
                                                          * with any other interesting term
                                                          * or fix me this
                                                          */

                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +
                                                            +
                                                          • If you have a large code base that was not developed with a policy to not use such warning terms, you might get hundreds of warnings / errors which might be contra-productive if you can’t fix all of them (e.g. if you don’t get the time to do it) as you might overlook other warnings / errors or get used to many of them and don’t pay attention on it anymore.
                                                          • +
                                                          • Same reason as the point above: You shouldn’t configure terms that are used very often (e.g. central parts of the native language used in your comments).
                                                          • +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.4.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-whitespace-before-property.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-whitespace-before-property.html new file mode 100644 index 0000000..2db9db7 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-whitespace-before-property.html @@ -0,0 +1,45 @@ + + + +

                                                          Disallow whitespace before properties (no-whitespace-before-property)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          JavaScript allows whitespace between objects and their properties. However, inconsistent spacing can make code harder to read and can lead to errors.

                                                          + +
                                                          foo. bar .baz . quz
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule alerts for whitespace around the dot or before the opening bracket before properties of objects if they are on the same line. It does not alert for whitespace when the object and property are on separate lines, as it is common to add newlines to longer chains of properties:

                                                          + +
                                                          foo
                                                          .bar()
                                                          .baz()
                                                          .qux()
                                                          +
                                                          + +

                                                          The following patterns are considered problems when this rule is turned on:

                                                          + +
                                                          /*eslint no-whitespace-before-property: "error"*/

                                                          foo [bar]

                                                          foo. bar

                                                          foo .bar

                                                          foo. bar. baz

                                                          foo. bar()
                                                          .baz()

                                                          foo
                                                          .bar(). baz()
                                                          +
                                                          + +

                                                          And the following patterns are not considered problems:

                                                          + +
                                                          /*eslint no-whitespace-before-property: "error"*/

                                                          foo.bar

                                                          foo[bar]

                                                          foo[ bar ]

                                                          foo.bar.baz

                                                          foo
                                                          .bar().baz()

                                                          foo
                                                          .bar()
                                                          .baz()

                                                          foo.
                                                          bar().
                                                          baz()
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          Turn this rule off if you do not care about allowing whitespace around the dot or before the opening bracket before properties of objects if they are on the same line.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-beta.1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/no-with.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-with.html new file mode 100644 index 0000000..bcf3d72 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/no-with.html @@ -0,0 +1,45 @@ + + + +

                                                          disallow with statements (no-with)

                                                          + +

                                                          The with statement is potentially problematic because it adds members of an object to the current scope, making it impossible to tell what a variable inside the block actually refers to.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows with statements.

                                                          + +

                                                          If ESLint parses code in strict mode, the parser (instead of this rule) reports the error.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint no-with: "error"*/

                                                          with (point) {
                                                          r = Math.sqrt(x * x + y * y); // is r a member of point?
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint no-with: "error"*/
                                                          /*eslint-env es6*/

                                                          const r = ({x, y}) => Math.sqrt(x * x + y * y);
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you intentionally use with statements then you can disable this rule.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/object-curly-spacing.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/object-curly-spacing.html new file mode 100644 index 0000000..78fec97 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/object-curly-spacing.html @@ -0,0 +1,130 @@ + + + +

                                                          Disallow or enforce spaces inside of curly braces in objects. (object-curly-spacing)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          While formatting preferences are very personal, a number of style guides require +or disallow spaces between curly braces in the following situations:

                                                          + +
                                                          // simple object literals
                                                          var obj = { foo: "bar" };

                                                          // nested object literals
                                                          var obj = { foo: { zoo: "bar" } };

                                                          // destructuring assignment (EcmaScript 6)
                                                          var { x, y } = y;

                                                          // import/export declarations (EcmaScript 6)
                                                          import { foo } from "bar";
                                                          export { foo };
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to maintain consistency around the spacing inside of object literals. It also +applies to EcmaScript 6 destructured assignment and import/export specifiers.

                                                          + +

                                                          It either requires or disallows spaces between those braces and the values inside of them. +Braces that are separated from the adjacent value by a new line are exempt from this rule.

                                                          + +

                                                          Options

                                                          + +

                                                          There are two main options for the rule:

                                                          + +
                                                            +
                                                          • "always" enforces a space inside of curly braces
                                                          • +
                                                          • "never" disallows spaces inside of curly braces (default)
                                                          • +
                                                          + +

                                                          Depending on your coding conventions, you can choose either option by specifying it in your configuration:

                                                          + +
                                                          "object-curly-spacing": ["error", "always"]
                                                          +
                                                          + +

                                                          “never”

                                                          + +

                                                          When "never" is set, the following patterns are considered problems:

                                                          + +
                                                          /*eslint object-curly-spacing: ["error", "never"]*/

                                                          var obj = { 'foo': 'bar' };
                                                          var obj = {'foo': 'bar' };
                                                          var obj = { baz: {'foo': 'qux'}, bar};
                                                          var obj = {baz: { 'foo': 'qux'}, bar};
                                                          var {x } = y;
                                                          import { foo } from 'bar';
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint object-curly-spacing: ["error", "never"]*/

                                                          var obj = {'foo': 'bar'};
                                                          var obj = {'foo': {'bar': 'baz'}, 'qux': 'quxx'};
                                                          var obj = {
                                                          'foo': 'bar'
                                                          };
                                                          var obj = {'foo': 'bar'
                                                          };
                                                          var obj = {
                                                          'foo':'bar'};
                                                          var obj = {};
                                                          var {x} = y;
                                                          import {foo} from 'bar';
                                                          +
                                                          + +

                                                          “always”

                                                          + +

                                                          When "always" is used, the following patterns are considered problems:

                                                          + +
                                                          /*eslint object-curly-spacing: ["error", "always"]*/

                                                          var obj = {'foo': 'bar'};
                                                          var obj = {'foo': 'bar' };
                                                          var obj = { baz: {'foo': 'qux'}, bar};
                                                          var obj = {baz: { 'foo': 'qux' }, bar};
                                                          var obj = {'foo': 'bar'
                                                          };
                                                          var obj = {
                                                          'foo':'bar'};
                                                          var {x} = y;
                                                          import {foo } from 'bar';
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint object-curly-spacing: ["error", "always"]*/

                                                          var obj = {};
                                                          var obj = { 'foo': 'bar' };
                                                          var obj = { 'foo': { 'bar': 'baz' }, 'qux': 'quxx' };
                                                          var obj = {
                                                          'foo': 'bar'
                                                          };
                                                          var { x } = y;
                                                          import { foo } from 'bar';
                                                          +
                                                          + +

                                                          Note that {} is always exempt from spacing requirements with this rule.

                                                          + +

                                                          Exceptions

                                                          + +

                                                          There are two exceptions you can apply to this rule: objectsInObjects and +arraysInObjects. Their values can be set to either true or false as part +of an object literal set as the 3rd argument for the rule.

                                                          + +

                                                          These exceptions work in the context of the first option. +That is, if "always" is set to enforce spacing and an exception is set to false, +it will disallow spacing for cases matching the exception. Likewise, +if "never" is set to disallow spacing and an exception is set to true, +it will enforce spacing for cases matching the exception.

                                                          + +

                                                          You can add exceptions like so:

                                                          + +
                                                          "object-curly-spacing": ["error", "always", {
                                                          "objectsInObjects": false,
                                                          "arraysInObjects": false
                                                          }]
                                                          +
                                                          + +

                                                          objectsInObjects

                                                          + +

                                                          In the case of the "always" option, set objectsInObjects exception to false to +enforce the following syntax (notice the }} at the end):

                                                          + +
                                                          var obj = { "foo": { "baz": 1, "bar": 2 }};
                                                          +
                                                          + +

                                                          In the case of the "never" option, set objectsInObjects exception to true to enforce +the following style (with a space between the } at the end:

                                                          + +
                                                          var obj = {"foo": {"baz": 1, "bar": 2} };
                                                          +
                                                          + +

                                                          arraysInObjects

                                                          + +

                                                          In the case of the "always" option, set arraysInObjects exception to false to +enforce the following syntax (notice the ]} at the end):

                                                          + +
                                                          var obj = { "foo": [ 1, 2 ]};
                                                          var obj = { "foo": [ "baz", "bar" ]};
                                                          +
                                                          + +

                                                          In the case of the "never" option, set arraysInObjects exception to true to enforce +the following style (with a space between the ] and } at the end:

                                                          + +
                                                          var obj = {"foo": [ 1, 2 ] };
                                                          var obj = {"foo": [ "baz", "bar" ] };
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with the consistency of spacing between curly braces.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.22.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/object-property-newline.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/object-property-newline.html new file mode 100644 index 0000000..aaf5dab --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/object-property-newline.html @@ -0,0 +1,75 @@ + + + +

                                                          enforce placing object properties on separate lines (object-property-newline)

                                                          + +

                                                          While formatting preferences are very personal, a number of style guides require that object properties be placed on separate lines for better readability.

                                                          + +

                                                          Another argument in favor of this style is that it improves the readability of diffs when a property is changed:

                                                          + +
                                                          // More readable
                                                          var obj = {
                                                          foo: "foo",
                                                          - bar: "bar",
                                                          + bar: "bazz",
                                                          baz: "baz"
                                                          };
                                                          +
                                                          + +
                                                          // Less readable
                                                          -var obj = { foo: "foo", bar: "bar", baz: "baz" };
                                                          +var obj = { foo: "foo", bar: "bazz", baz: "baz" };
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to maintain consistency of newlines between object properties.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint object-property-newline: "error"*/

                                                          var obj = { foo: "foo", bar: "bar", baz: "baz" };

                                                          var obj2 = {
                                                          foo: "foo", bar: "bar", baz: "baz"
                                                          };

                                                          var obj3 = {
                                                          foo: "foo", bar: "bar",
                                                          baz: "baz"
                                                          };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint object-property-newline: "error"*/

                                                          var obj = {
                                                          foo: "foo",
                                                          bar: "bar",
                                                          baz: "baz"
                                                          };
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has an object option:

                                                          + +
                                                            +
                                                          • "allowMultiplePropertiesPerLine": true allows all keys and values to be on the same line
                                                          • +
                                                          + +

                                                          allowMultiplePropertiesPerLine

                                                          + +

                                                          Examples of additional correct code for this rule with the { "allowMultiplePropertiesPerLine": true } option:

                                                          + +
                                                          /*eslint object-property-newline: ["error", { "allowMultiplePropertiesPerLine": true }]*/

                                                          var obj = { foo: "foo", bar: "bar", baz: "baz" };

                                                          var obj2 = {
                                                          foo: "foo", bar: "bar", baz: "baz"
                                                          };
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with the consistency of newlines between object properties.

                                                          + +

                                                          Compatibility

                                                          + +
                                                            +
                                                          • JSCS: requireObjectKeysOnNewLine
                                                          • +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.10.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/object-shorthand.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/object-shorthand.html new file mode 100644 index 0000000..ea7743a --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/object-shorthand.html @@ -0,0 +1,103 @@ + + + +

                                                          Require Object Literal Shorthand Syntax (object-shorthand)

                                                          + +

                                                          EcmaScript 6 provides a concise form for defining object literal methods and properties. This +syntax can make defining complex object literals much cleaner.

                                                          + +

                                                          Here are a few common examples using the ES5 syntax:

                                                          + +
                                                          // properties
                                                          var foo = {
                                                          x: x,
                                                          y: y,
                                                          z: z,
                                                          };

                                                          // methods
                                                          var foo = {
                                                          a: function() {},
                                                          b: function() {}
                                                          };
                                                          +
                                                          + +

                                                          Now here are ES6 equivalents:

                                                          + +
                                                          /*eslint-env es6*/

                                                          // properties
                                                          var foo = {x, y, z};

                                                          // methods
                                                          var foo = {
                                                          a() {},
                                                          b() {}
                                                          };
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces the use of the shorthand syntax. This applies +to all methods (including generators) defined in object literals and any +properties defined where the key name matches name of the assigned variable.

                                                          + +

                                                          Each of the following properties would warn:

                                                          + +
                                                          /*eslint object-shorthand: "error"*/
                                                          /*eslint-env es6*/

                                                          var foo = {
                                                          w: function() {},
                                                          x: function *() {},
                                                          [y]: function() {},
                                                          z: z
                                                          };
                                                          +
                                                          + +

                                                          In that case the expected syntax would have been:

                                                          + +
                                                          /*eslint object-shorthand: "error"*/
                                                          /*eslint-env es6*/

                                                          var foo = {
                                                          w() {},
                                                          *x() {},
                                                          [y]() {},
                                                          z
                                                          };
                                                          +
                                                          + +

                                                          This rule does not flag arrow functions inside of object literals. +The following will not warn:

                                                          + +
                                                          /*eslint object-shorthand: "error"*/
                                                          /*eslint-env es6*/

                                                          var foo = {
                                                          x: (y) => y
                                                          };
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes an option which specifies when it should be applied. It can be set to +“always”, “properties”, “methods”, or “never”. The default is “always”.

                                                          + +
                                                            +
                                                          • "always" expects that the shorthand will be used whenever possible.
                                                          • +
                                                          • "methods" ensures the method shorthand is used (also applies to generators).
                                                          • +
                                                          • "properties ensures the property shorthand is used (where the key and variable name match).
                                                          • +
                                                          • "never" ensures that no property or method shorthand is used in any object literal.
                                                          • +
                                                          + +

                                                          You can set the option in configuration like this:

                                                          + +
                                                          {
                                                          "object-shorthand": ["error", "always"]
                                                          }
                                                          +
                                                          + +

                                                          While set to "always", "methods", or "properties", shorthand syntax using string literal keys can be ignored using the optional parameter "avoidQuotes". This will make it so longform syntax is preferred whenever the object key is a string literal. Note: The first parameter must be specified when using this optional parameter.

                                                          + +
                                                          {
                                                          "object-shorthand": ["error", "always", { "avoidQuotes": true }]
                                                          }
                                                          +
                                                          + +

                                                          Examples of incorrect code for this rule with the "avoidQuotes" option:

                                                          + +
                                                          /*eslint object-shorthand: ["error", "always", { "avoidQuotes": true }]*/
                                                          /*eslint-env es6*/

                                                          var foo = {
                                                          "bar-baz"() {}
                                                          };
                                                          +
                                                          + +

                                                          Examples of correct code for this rule with the "avoidQuotes" option:

                                                          + +
                                                          /*eslint object-shorthand: ["error", "always", { "avoidQuotes": true }]*/
                                                          /*eslint-env es6*/

                                                          var foo = {
                                                          "bar-baz": function() {},
                                                          "qux": qux
                                                          };
                                                          +
                                                          + +

                                                          While set to "always" or "methods", constructor functions can be ignored with the optional parameter "ignoreConstructors" enabled. Note: The first parameter must be specified when using this optional parameter.

                                                          + +
                                                          {
                                                          "object-shorthand": ["error", "always", { "ignoreConstructors": true }]
                                                          }
                                                          +
                                                          + +

                                                          The following will not warn when "ignoreConstructors" is enabled:

                                                          + +
                                                          /*eslint object-shorthand: ["error", "always", { "ignoreConstructors": true }]*/
                                                          /*eslint-env es6*/

                                                          var foo = {
                                                          ConstructorFunction: function() {}
                                                          };
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          Anyone not yet in an ES6 environment would not want to apply this rule. Others may find the terseness of the shorthand +syntax harder to read and may not want to encourage it with this rule.

                                                          + +

                                                          Further Reading

                                                          + +

                                                          Object initializer - MDN

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.20.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/one-var-declaration-per-line.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/one-var-declaration-per-line.html new file mode 100644 index 0000000..bb7787b --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/one-var-declaration-per-line.html @@ -0,0 +1,68 @@ + + + +

                                                          Require or disallow an newline around variable declarations (one-var-declaration-per-line)

                                                          + +

                                                          Some developers declare multiple var statements on the same line:

                                                          + +
                                                          var foo, bar, baz;
                                                          +
                                                          + +

                                                          Others prefer to declare one var per line.

                                                          + +
                                                          var foo,
                                                          bar,
                                                          baz;
                                                          +
                                                          + +

                                                          This rule enforces a consistent style across the entire project.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces a consistent coding style where newlines are required or disallowed after each var declaration or just when there is a variable initialization. It ignores var declarations inside for loop conditionals.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule takes one option, a string, which can be:

                                                          + +
                                                            +
                                                          • "always" enforces a newline around each variable declaration
                                                          • +
                                                          • "initializations" enforces a newline around each variable initialization (default)
                                                          • +
                                                          + +

                                                          The following patterns are considered problems when set to "always":

                                                          + +
                                                          /*eslint one-var-declaration-per-line: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          var a, b;

                                                          let a, b = 0;

                                                          const a = 0, b = 0;
                                                          +
                                                          + +

                                                          The following patterns are not considered problems when set to "always":

                                                          + +
                                                          /*eslint one-var-declaration-per-line: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          var a,
                                                          b;

                                                          let a,
                                                          b = 0;
                                                          +
                                                          + +

                                                          The following patterns are considered problems when set to "initializations":

                                                          + +
                                                          /*eslint one-var-declaration-per-line: ["error", "initializations"]*/
                                                          /*eslint-env es6*/

                                                          var a, b, c = 0;

                                                          let a,
                                                          b = 0, c;
                                                          +
                                                          + +

                                                          The following patterns are not considered problems when set to "initializations":

                                                          + +
                                                          /*eslint one-var-declaration-per-line: ["error", "initializations"]*/
                                                          /*eslint-env es6*/

                                                          var a, b;

                                                          let a,
                                                          b;

                                                          let a,
                                                          b = 0;
                                                          +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-beta.3.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/one-var.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/one-var.html new file mode 100644 index 0000000..e0caac7 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/one-var.html @@ -0,0 +1,128 @@ + + + +

                                                          Require or Disallow One Variable Declaration per Scope (one-var)

                                                          + +

                                                          Variables can be declared at any point in JavaScript code using var, let, or const. There are many styles and preferences related to the declaration of variables, and one of those is deciding on how many variable declarations should be allowed in a single function.

                                                          + +

                                                          There are two schools of thought in this regard:

                                                          + +
                                                            +
                                                          1. There should be just one variable declaration for all variables in the function. That declaration typically appears at the top of the function.
                                                          2. +
                                                          3. You should use one variable declaration for each variable you want to define.
                                                          4. +
                                                          + +

                                                          For instance:

                                                          + +
                                                          // one variable declaration per function
                                                          function foo() {
                                                          var bar, baz;
                                                          }

                                                          // multiple variable declarations per function
                                                          function foo() {
                                                          var bar;
                                                          var baz;
                                                          }
                                                          +
                                                          + +

                                                          The single-declaration school of thought is based in pre-ECMAScript 6 behaviors, where there was no such thing as block scope, only function scope. Since all var statements are hoisted to the top of the function anyway, some believe that declaring all variables in a single declaration at the top of the function removes confusion around scoping rules.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at enforcing the use of either one variable declaration or multiple declarations per function (for var) or block (for let and const) scope. As such, it will warn when it encounters an unexpected number of variable declarations.

                                                          + +

                                                          Options

                                                          + +

                                                          There are two ways to configure this rule. The first is by using one string specified as "always" (the default) to enforce one variable declaration per scope or "never" to enforce multiple variable declarations per scope. If you declare variables in your code with let and const, then "always" and "never" will apply to the block scope for those declarations, not the function scope.

                                                          + +

                                                          The second way to configure this rule is with an object. The keys are any of:

                                                          + +
                                                            +
                                                          • var
                                                          • +
                                                          • let
                                                          • +
                                                          • const
                                                          • +
                                                          + +

                                                          or:

                                                          + +
                                                            +
                                                          • uninitialized
                                                          • +
                                                          • initialized
                                                          • +
                                                          + +

                                                          and the values are either "always" or "never". This allows you to set behavior differently for each type of declaration, or whether variables are initialized during declaration.

                                                          + +

                                                          You can configure the rule as follows:

                                                          + +

                                                          (default) Exactly one variable declaration per type per function (var) or block (let or const)

                                                          + +
                                                          "one-var": [2, "always"]
                                                          +
                                                          + +

                                                          Exactly one declarator per declaration per function (var) or block (let or const)

                                                          + +
                                                          "one-var": ["error", "never"]
                                                          +
                                                          + +

                                                          Configure each declaration type individually. Defaults to "always" if key not present.

                                                          + +
                                                          "one-var": ["error", {
                                                          "var": "always", // Exactly one var declaration per function
                                                          "let": "always", // Exactly one let declaration per block
                                                          "const": "never" // Exactly one declarator per const declaration per block
                                                          }]
                                                          +
                                                          + +

                                                          Configure uninitialized and initialized seperately. Defaults to "always" if key not present.

                                                          + +
                                                          "one-var": [2, {
                                                          "uninitialized": "always", // Exactly one declaration for uninitialized variables per function (var) or block (let or const)
                                                          "initialized": "never" // Exactly one declarator per initialized variable declaration per function (var) or block (let or const)
                                                          }]
                                                          +
                                                          + +

                                                          When configured with "always" as the first option (the default), the following patterns are considered problems:

                                                          + +
                                                          /*eslint one-var: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          var bar;
                                                          var baz;
                                                          let qux;
                                                          let norf;
                                                          }

                                                          function foo(){
                                                          const bar = false;
                                                          const baz = true;
                                                          let qux;
                                                          let norf;
                                                          }

                                                          function foo() {
                                                          var bar;

                                                          if (baz) {
                                                          var qux = true;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint one-var: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          var bar,
                                                          baz;
                                                          let qux,
                                                          norf;
                                                          }

                                                          function foo(){
                                                          const bar = true,
                                                          baz = false;
                                                          let qux,
                                                          norf;
                                                          }

                                                          function foo() {
                                                          var bar,
                                                          qux;

                                                          if (baz) {
                                                          qux = true;
                                                          }
                                                          }

                                                          function foo(){
                                                          let bar;

                                                          if (baz) {
                                                          let qux;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          When configured with "never" as the first option, the following patterns are considered problems:

                                                          + +
                                                          /*eslint one-var: ["error", "never"]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          var bar,
                                                          baz;
                                                          const bar = true,
                                                          baz = false;
                                                          }

                                                          function foo() {
                                                          var bar,
                                                          qux;

                                                          if (baz) {
                                                          qux = true;
                                                          }
                                                          }

                                                          function foo(){
                                                          let bar = true,
                                                          baz = false;
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint one-var: ["error", "never"]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          var bar;
                                                          var baz;
                                                          }

                                                          function foo() {
                                                          var bar;

                                                          if (baz) {
                                                          var qux = true;
                                                          }
                                                          }

                                                          function foo() {
                                                          let bar;

                                                          if (baz) {
                                                          let qux = true;
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          When configured with an object as the first option, you can individually control how var, let, and const are handled, or alternatively how uninitialized and initialized variables are handled (which if used will override var, let, and const).

                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint one-var: ["error", { var: "always", let: "never", const: "never" }]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          var bar,
                                                          baz;
                                                          let qux;
                                                          let norf;
                                                          }

                                                          function foo() {
                                                          const bar = 1;
                                                          const baz = 2;
                                                          let qux;
                                                          let norf;
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint one-var: ["error", { uninitialized: "always", initialized: "never" }]*/

                                                          function foo() {
                                                          var a, b, c;
                                                          var foo = true;
                                                          var bar = false;
                                                          }
                                                          +
                                                          + +

                                                          If you are configuring the rule with an object, by default, if you didn’t specify declaration type it will not be checked. So the following pattern is not considered a warning when options are set to: { var: "always", let: "always" }

                                                          + +
                                                          /*eslint one-var: ["error", { var: "always", let: "always" }]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          var a, b;
                                                          const foo = true;
                                                          const bar = true;
                                                          let c, d;
                                                          }
                                                          +
                                                          + +

                                                          Compatibility

                                                          + +
                                                            +
                                                          • JSHint - This rule maps to the onevar JSHint rule, but allows let and const to be configured separately.
                                                          • +
                                                          • JSCS - This rule roughly maps to "disallowMultipleVarDecl"
                                                          • +
                                                          + +

                                                          Further Reading

                                                          + +

                                                          JSLint Errors - Combine this with the previous ‘var’ statement

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/operator-assignment.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/operator-assignment.html new file mode 100644 index 0000000..d153757 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/operator-assignment.html @@ -0,0 +1,66 @@ + + + +

                                                          Operator Assignment Shorthand (operator-assignment)

                                                          + +

                                                          JavaScript provides shorthand operators that combine variable assignment and some simple mathematical operations. For example, x = x + 4 can be shortened to x += 4. The supported shorthand forms are as follows:

                                                          + +
                                                           Shorthand | Separate
                                                          -----------|------------
                                                          x += y | x = x + y
                                                          x -= y | x = x - y
                                                          x *= y | x = x * y
                                                          x /= y | x = x / y
                                                          x %= y | x = x % y
                                                          x <<= y | x = x << y
                                                          x >>= y | x = x >> y
                                                          x >>>= y | x = x >>> y
                                                          x &= y | x = x & y
                                                          x ^= y | x = x ^ y
                                                          x |= y | x = x | y
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces use of the shorthand assignment operators by requiring them where possible or prohibiting them entirely.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule has two options: always and never. The default is always.

                                                          + +

                                                          “always”

                                                          + +

                                                          "operator-assignment": ["error", "always"]

                                                          + +

                                                          This mode enforces use of operator assignment shorthand where possible.

                                                          + +

                                                          The following are examples of valid patterns:

                                                          + +
                                                          /*eslint operator-assignment: ["error", "always"]*/

                                                          x = y;
                                                          x += y;
                                                          x = y * z;
                                                          x = (x * y) * z;
                                                          x[0] /= y;
                                                          x[foo()] = x[foo()] % 2;
                                                          x = y + x; // `+` is not always commutative (e.g. x = "abc")
                                                          +
                                                          + +

                                                          The following patterns are considered problems and should be replaced by their shorthand equivalents:

                                                          + +
                                                          /*eslint operator-assignment: ["error", "always"]*/

                                                          x = x + y;
                                                          x = y * x;
                                                          x[0] = x[0] / y;
                                                          x.y = x.y << z;
                                                          +
                                                          + +

                                                          “never”

                                                          + +

                                                          "operator-assignment": ["error", "never"]

                                                          + +

                                                          This mode warns on any use of operator assignment shorthand.

                                                          + +

                                                          The following are examples of valid patterns:

                                                          + +
                                                          /*eslint operator-assignment: ["error", "never"]*/

                                                          x = x + y;
                                                          x.y = x.y / a.b;
                                                          +
                                                          + +

                                                          The following patterns are considered problems and should be written out fully without the shorthand assignments:

                                                          + +
                                                          /*eslint operator-assignment: ["error", "never"]*/

                                                          x *= y;
                                                          x ^= (y + z) / foo();
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          Use of operator assignment shorthand is a stylistic choice. Leaving this rule turned off would allow developers to choose which style is more readable on a case-by-case basis.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.10.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/operator-linebreak.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/operator-linebreak.html new file mode 100644 index 0000000..6d77f03 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/operator-linebreak.html @@ -0,0 +1,112 @@ + + + +

                                                          Operator Linebreak (operator-linebreak)

                                                          + +

                                                          When a statement is too long to fit on a single line, line breaks are generally inserted next to the operators separating expressions. The first style coming to mind would be to place the operator at the end of the line, following the english punctuation rules.

                                                          + +
                                                          var fullHeight = borderTop +
                                                          innerHeight +
                                                          borderBottom;
                                                          +
                                                          + +

                                                          Some developers find that placing operators at the beginning of the line makes the code more readable.

                                                          + +
                                                          var fullHeight = borderTop
                                                          + innerHeight
                                                          + borderBottom;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          The operator-linebreak rule is aimed at enforcing a particular operator line break style. As such, it warns whenever it sees a binary operator or assignment that does not adhere to a particular style: either placing linebreaks after or before the operators.

                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes two options, a string, which can be "after", "before" or "none" where the default is "after" and an object for more fine-grained configuration.

                                                          + +

                                                          You can set the style in configuration like this:

                                                          + +
                                                          "operator-linebreak": ["error", "before", { "overrides": { "?": "after" } }]
                                                          +
                                                          + +

                                                          The default configuration is to enforce line breaks after the operator except for the ternary operator ? and : following that.

                                                          + +

                                                          “after”

                                                          + +

                                                          This is the default setting for this rule. This option requires the line break to be placed after the operator.

                                                          + +

                                                          While using this setting, the following patterns are considered problems:

                                                          + +
                                                          /*eslint operator-linebreak: ["error", "after"]*/

                                                          foo = 1
                                                          +
                                                          2;

                                                          foo = 1
                                                          + 2;

                                                          foo
                                                          = 5;

                                                          if (someCondition
                                                          || otherCondition) {
                                                          }

                                                          answer = everything
                                                          ? 42
                                                          : foo;
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint operator-linebreak: ["error", "after"]*/

                                                          foo = 1 + 2;

                                                          foo = 1 +
                                                          2;

                                                          foo =
                                                          5;

                                                          if (someCondition ||
                                                          otherCondition) {
                                                          }

                                                          answer = everything ?
                                                          42 :
                                                          foo;
                                                          +
                                                          + +

                                                          “before”

                                                          + +

                                                          This option requires the line break to be placed before the operator.

                                                          + +

                                                          While using this setting, the following patterns are considered problems:

                                                          + +
                                                          /*eslint operator-linebreak: ["error", "before"]*/

                                                          foo = 1 +
                                                          2;

                                                          foo =
                                                          5;

                                                          if (someCondition ||
                                                          otherCondition) {
                                                          }

                                                          answer = everything ?
                                                          42 :
                                                          foo;
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint operator-linebreak: ["error", "before"]*/

                                                          foo = 1 + 2;

                                                          foo = 1
                                                          + 2;

                                                          foo
                                                          = 5;

                                                          if (someCondition
                                                          || otherCondition) {
                                                          }

                                                          answer = everything
                                                          ? 42
                                                          : foo;
                                                          +
                                                          + +

                                                          “none”

                                                          + +

                                                          This option disallows line breaks on either side of the operator.

                                                          + +

                                                          While using this setting, the following patterns are considered problems:

                                                          + +
                                                          /*eslint operator-linebreak: ["error", "none"]*/

                                                          foo = 1 +
                                                          2;

                                                          foo = 1
                                                          + 2;

                                                          if (someCondition ||
                                                          otherCondition) {
                                                          }

                                                          if (someCondition
                                                          || otherCondition) {
                                                          }

                                                          answer = everything
                                                          ? 42
                                                          : foo;

                                                          answer = everything ?
                                                          42 :
                                                          foo;
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint operator-linebreak: ["error", "none"]*/

                                                          foo = 1 + 2;

                                                          foo = 5;

                                                          if (someCondition || otherCondition) {
                                                          }

                                                          answer = everything ? 42 : foo;
                                                          +
                                                          + +

                                                          Fine-grained control

                                                          + +

                                                          The rule allows you to have even finer-grained control over individual operators by specifying an overrides dictionary:

                                                          + +
                                                          "operator-linebreak": ["error", "before", { "overrides": { "?": "after", "+=": "none" } }]
                                                          +
                                                          + +

                                                          This would override the global setting for that specific operator.

                                                          + +

                                                          “ignore” override

                                                          + +

                                                          This option is only supported using overrides and ignores line breaks on either side of the operator.

                                                          + +

                                                          While using this setting, the following patterns are not considered problems:

                                                          + +
                                                          /*eslint operator-linebreak: ["error", "after", { "overrides": { "?": "ignore", ":": "ignore"} }]*/

                                                          answer = everything ?
                                                          42
                                                          : foo;

                                                          answer = everything
                                                          ?
                                                          42
                                                          :
                                                          foo;
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If your project will not be using a common operator line break style, turn this rule off.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.19.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/padded-blocks.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/padded-blocks.html new file mode 100644 index 0000000..3a79a96 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/padded-blocks.html @@ -0,0 +1,98 @@ + + + +

                                                          Enforce padding within blocks (padded-blocks)

                                                          + +

                                                          Some style guides require block statements to start and end with blank lines. The goal is +to improve readability by visually separating the block content and the surrounding code.

                                                          + +
                                                          if (a) {

                                                          b();

                                                          }
                                                          +
                                                          + +

                                                          Since it’s good to have a consistent code style, you should either always write +padded blocks or never do it.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces consistent padding within blocks.

                                                          + +

                                                          This rule takes one argument, which can be an string or an object. If it is "always" (the default) then block statements must start and end with a blank line. If "never", then block statements should neither start nor end with a blank line. By default, this rule ignores padding in switch statements and classes.

                                                          + +

                                                          If you want to enforce padding within switches and classes, a configuration object can be passed as the rule argument to configure the cases separately ( e.g. { "blocks": "always", "switches": "always", "classes": "always" } ).

                                                          + +

                                                          The following patterns are considered problems when set to "always":

                                                          + +
                                                          /*eslint padded-blocks: ["error", "always"]*/

                                                          if (a) {
                                                          b();
                                                          }

                                                          if (a) { b(); }

                                                          if (a)
                                                          {
                                                          b();
                                                          }

                                                          if (a) {

                                                          b();
                                                          }

                                                          if (a) {
                                                          b();

                                                          }

                                                          if (a) {
                                                          // comment
                                                          b();

                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems when set to "always":

                                                          + +
                                                          /*eslint padded-blocks: ["error", "always"]*/

                                                          if (a) {

                                                          b();

                                                          }

                                                          if (a)
                                                          {

                                                          b();

                                                          }

                                                          if (a) {

                                                          // comment
                                                          b();

                                                          }
                                                          +
                                                          + +

                                                          The following patterns are considered problems when set to "never":

                                                          + +
                                                          /*eslint padded-blocks: ["error", "never"]*/

                                                          if (a) {

                                                          b();

                                                          }

                                                          if (a)
                                                          {

                                                          b();

                                                          }

                                                          if (a) {

                                                          b();
                                                          }

                                                          if (a) {
                                                          b();

                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems when set to "never":

                                                          + +
                                                          /*eslint padded-blocks: ["error", "never"]*/

                                                          if (a) {
                                                          b();
                                                          }

                                                          if (a)
                                                          {
                                                          b();
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are considered problems when configured { "switches": "always" }:

                                                          + +
                                                          /*eslint padded-blocks: ["error", { "switches": "always" }]*/

                                                          switch (a) {
                                                          case 0: foo();
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems when configured { "switches": "always" }:

                                                          + +
                                                          /*eslint padded-blocks: ["error", { "switches": "always" }]*/

                                                          switch (a) {

                                                          case 0: foo();

                                                          }

                                                          if (a) {
                                                          b();
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are considered problems when configured { "switches": "never" }:

                                                          + +
                                                          /*eslint padded-blocks: ["error", { "switches": "never" }]*/

                                                          switch (a) {

                                                          case 0: foo();

                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems when configured { "switches": "never" }:

                                                          + +
                                                          /*eslint padded-blocks: ["error", { "switches": "never" }]*/

                                                          switch (a) {
                                                          case 0: foo();
                                                          }

                                                          if (a) {

                                                          b();

                                                          }
                                                          +
                                                          + +

                                                          The following patterns are considered problems when configured { "classes": "always" }:

                                                          + +
                                                          /*eslint padded-blocks: ["error", { "classes": "always" }]*/

                                                          class A {
                                                          constructor(){
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems when configured { "classes": "always" }:

                                                          + +
                                                          /*eslint padded-blocks: ["error", { "classes": "always" }]*/

                                                          class A {

                                                          constructor(){
                                                          }

                                                          }
                                                          +
                                                          + +

                                                          The following patterns are considered problems when configured { "classes": "never" }:

                                                          + +
                                                          /*eslint padded-blocks: ["error", { "classes": "never" }]*/

                                                          class A {

                                                          constructor(){
                                                          }

                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems when configured { "classes": "never" }:

                                                          + +
                                                          /*eslint padded-blocks: ["error", { "classes": "never" }]*/

                                                          class A {
                                                          constructor(){
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with the consistency of padding within blocks.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.9.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-arrow-callback.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-arrow-callback.html new file mode 100644 index 0000000..433eaf9 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-arrow-callback.html @@ -0,0 +1,66 @@ + + + +

                                                          Suggest using arrow functions as callbacks. (prefer-arrow-callback)

                                                          + +

                                                          Arrow functions are suited to callbacks, because:

                                                          + +
                                                            +
                                                          • this keywords in arrow functions bind to the upper scope’s.
                                                          • +
                                                          • The notation of the arrow function is shorter than function expression’s.
                                                          • +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed to flag usage of function expressions in an argument list.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint prefer-arrow-callback: "error"*/

                                                          foo(function(a) { return a; });
                                                          foo(function() { return this.a; }.bind(this));
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint prefer-arrow-callback: "error"*/
                                                          /*eslint-env es6*/

                                                          foo(a => a);
                                                          foo(function*() { yield; });

                                                          // this is not a callback.
                                                          var foo = function foo(a) { return a; };

                                                          // using `this` without `.bind(this)`.
                                                          foo(function() { return this.a; });

                                                          // recursively.
                                                          foo(function bar(n) { return n && n + bar(n - 1); });
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule takes one optional argument, an object which is an options object.

                                                          + +

                                                          allowNamedFunctions

                                                          + +

                                                          This is a boolean option and it is false by default. When set to true, the rule doesn’t warn on named functions used as callbacks.

                                                          + +

                                                          Examples of correct code for the { "allowNamedFunctions": true } option:

                                                          + +
                                                          /*eslint prefer-arrow-callback: ["error", { "allowNamedFunctions": true }]*/

                                                          foo(function bar() {});
                                                          +
                                                          + +

                                                          allowUnboundThis

                                                          + +

                                                          This is a boolean option and it is true by default. When set to false, this option allows the use of this without restriction and checks for dynamically assigned this values such as when using Array.prototype.map with a context argument. Normally, the rule will flag the use of this whenever a function does not use bind() to specify the value of this constantly.

                                                          + +

                                                          Examples of incorrect code for the { "allowUnboundThis": false } option:

                                                          + +
                                                          /*eslint prefer-arrow-callback: ["error", { "allowUnboundThis": false }]*/
                                                          /*eslint-env es6*/

                                                          foo(function() { this.a; });

                                                          foo(function() { (() => this); });

                                                          someArray.map(function (itm) { return this.doSomething(itm); }, someObject);
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          This rule should not be used in ES3/5 environments.

                                                          + +

                                                          In ES2015 (ES6) or later, if you don’t want to be notified about function expressions in an argument list, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.2.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-const.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-const.html new file mode 100644 index 0000000..52878eb --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-const.html @@ -0,0 +1,97 @@ + + + +

                                                          Suggest using const (prefer-const)

                                                          + +

                                                          If a variable is never reassigned, using the const declaration is better.

                                                          + +

                                                          const declaration tells readers, “this variable is never reassigned,” reducing cognitive load and improving maintainability.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at flagging variables that are declared using let keyword, but never reassigned after the initial assignment.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint prefer-const: "error"*/
                                                          /*eslint-env es6*/

                                                          // it's initialized and never reassigned.
                                                          let a = 3;
                                                          console.log(a);

                                                          let a;
                                                          a = 0;
                                                          console.log(a);

                                                          // `i` is redefined (not reassigned) on each loop step.
                                                          for (let i in [1, 2, 3]) {
                                                          console.log(i);
                                                          }

                                                          // `a` is redefined (not reassigned) on each loop step.
                                                          for (let a of [1, 2, 3]) {
                                                          console.log(a);
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint prefer-const: "error"*/
                                                          /*eslint-env es6*/

                                                          // using const.
                                                          const a = 0;

                                                          // it's never initialized.
                                                          let a;
                                                          console.log(a);

                                                          // it's reassigned after initialized.
                                                          let a;
                                                          a = 0;
                                                          a = 1;
                                                          console.log(a);

                                                          // it's initialized in a different block from the declaration.
                                                          let a;
                                                          if (true) {
                                                          a = 0;
                                                          }
                                                          console.log(a);

                                                          // it's initialized at a place that we cannot write a variable declaration.
                                                          let a;
                                                          if (true) a = 0;
                                                          console.log(a);

                                                          // `i` gets a new binding each iteration
                                                          for (const i in [1, 2, 3]) {
                                                          console.log(i);
                                                          }

                                                          // `a` gets a new binding each iteration
                                                          for (const a of [1, 2, 3]) {
                                                          console.log(a);
                                                          }

                                                          // `end` is never reassigned, but we cannot separate the declarations without modifying the scope.
                                                          for (let i = 0, end = 10; i < end; ++i) {
                                                          console.log(a);
                                                          }

                                                          // suggest to use `no-var` rule.
                                                          var b = 3;
                                                          console.log(b);
                                                          +
                                                          + +

                                                          Options

                                                          + +
                                                          {
                                                          "prefer-const": ["error", {
                                                          "destructuring": "any",
                                                          "ignoreReadBeforeAssign": false
                                                          }]
                                                          }
                                                          +
                                                          + +

                                                          destructuring

                                                          + +

                                                          The kind of the way to address variables in destructuring. +There are 2 values:

                                                          + +
                                                            +
                                                          • "any" (default) - If any variables in destructuring should be const, this rule warns for those variables.
                                                          • +
                                                          • "all" - If all variables in destructuring should be const, this rule warns the variables. Otherwise, ignores them.
                                                          • +
                                                          + +

                                                          Examples of incorrect code for the default {"destructuring": "any"} option:

                                                          + +
                                                          /*eslint prefer-const: "error"*/
                                                          /*eslint-env es6*/

                                                          let {a, b} = obj; /*error 'b' is never reassigned, use 'const' instead.*/
                                                          a = a + 1;
                                                          +
                                                          + +

                                                          Examples of correct code for the default {"destructuring": "any"} option:

                                                          + +
                                                          /*eslint prefer-const: "error"*/
                                                          /*eslint-env es6*/

                                                          // using const.
                                                          const {a: a0, b} = obj;
                                                          const a = a0 + 1;

                                                          // all variables are reassigned.
                                                          let {a, b} = obj;
                                                          a = a + 1;
                                                          b = b + 1;
                                                          +
                                                          + +

                                                          Examples of incorrect code for the {"destructuring": "all"} option:

                                                          + +
                                                          /*eslint prefer-const: ["error", {"destructuring": "all"}]*/
                                                          /*eslint-env es6*/

                                                          // all of `a` and `b` should be const, so those are warned.
                                                          let {a, b} = obj; /*error 'a' is never reassigned, use 'const' instead.
                                                          'b' is never reassigned, use 'const' instead.*/

                                                          +
                                                          + +

                                                          Examples of correct code for the {"destructuring": "all"} option:

                                                          + +
                                                          /*eslint prefer-const: ["error", {"destructuring": "all"}]*/
                                                          /*eslint-env es6*/

                                                          // 'b' is never reassigned, but all of `a` and `b` should not be const, so those are ignored.
                                                          let {a, b} = obj;
                                                          a = a + 1;
                                                          +
                                                          + +

                                                          ignoreReadBeforeAssign

                                                          + +

                                                          This is an option to avoid conflicting with no-use-before-define rule (without "nofunc" option). +If true is specified, this rule will ignore variables that are read between the declaration and the first assignment. +Default is false.

                                                          + +

                                                          Examples of correct code for the {"ignoreReadBeforeAssign": true} option:

                                                          + +
                                                          /*eslint prefer-const: ["error", {"ignoreReadBeforeAssign": true}]*/
                                                          /*eslint-env es6*/

                                                          let timer;
                                                          function initialize() {
                                                          if (foo()) {
                                                          clearInterval(timer);
                                                          }
                                                          }
                                                          timer = setInterval(initialize, 100);
                                                          +
                                                          + +

                                                          Examples of correct code for the defaut {"ignoreReadBeforeAssign": false} option:

                                                          + +
                                                          /*eslint prefer-const: ["error", {"ignoreReadBeforeAssign": false}]*/
                                                          /*eslint-env es6*/

                                                          const timer = setInterval(initialize, 100);
                                                          function initialize() {
                                                          if (foo()) {
                                                          clearInterval(timer);
                                                          }
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about variables that are never reassigned after initial assignment, you can safely disable this rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.23.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-reflect.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-reflect.html new file mode 100644 index 0000000..4a4c99e --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-reflect.html @@ -0,0 +1,205 @@ + + + +

                                                          Suggest using Reflect methods where applicable (prefer-reflect)

                                                          + +

                                                          The ES6 Reflect API comes with a handful of methods which somewhat deprecate methods on old constructors:

                                                          + + + +

                                                          The prefer-reflect rule will flag usage of any older method, suggesting to instead use the newer Reflect version.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          Options

                                                          + +

                                                          Exceptions

                                                          + +
                                                          "prefer-reflect": [<enabled>, { exceptions: [<...exceptions>] }]
                                                          +
                                                          + +

                                                          The exceptions option allows you to pass an array of methods names you’d like to continue to use in the old style.

                                                          + +

                                                          For example if you wish to use all Reflect methods, except for Function.prototype.apply then your config would look like prefer-reflect: [2, { exceptions: ["apply"] }].

                                                          + +

                                                          If you want to use Reflect methods, but keep using the delete keyword, then your config would look like prefer-reflect: [2, { exceptions: ["delete"] }].

                                                          + +

                                                          These can be combined as much as you like. To make all methods exceptions (thereby rendering this rule useless), use prefer-reflect: [2, { exceptions: ["apply", "call", "defineProperty", "getOwnPropertyDescriptor", "getPrototypeOf", "setPrototypeOf", "isExtensible", "getOwnPropertyNames", "preventExtensions", "delete"] }]

                                                          + +

                                                          Reflect.apply (Function.prototype.apply/Function.prototype.call)

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          foo.apply(undefined, args);
                                                          foo.apply(null, args);
                                                          obj.foo.apply(obj, args);
                                                          obj.foo.apply(other, args);

                                                          foo.call(undefined, arg);
                                                          foo.call(null, arg);
                                                          obj.foo.call(obj, arg);
                                                          obj.foo.call(other, arg);
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Reflect.apply(undefined, args);
                                                          Reflect.apply(null, args);
                                                          Reflect.apply(obj.foo, obj, args);
                                                          Reflect.apply(obj.foo, other, args);
                                                          Reflect.apply(undefined, [arg]);
                                                          Reflect.apply(null, [arg]);
                                                          Reflect.apply(obj.foo, obj, [arg]);
                                                          Reflect.apply(obj.foo, other, [arg]);
                                                          +
                                                          + +
                                                          /*eslint prefer-reflect: ["error", { exceptions: ["apply"] }]*/

                                                          foo.apply(undefined, args);
                                                          foo.apply(null, args);
                                                          obj.foo.apply(obj, args);
                                                          obj.foo.apply(other, args);
                                                          Reflect.apply(undefined, args);
                                                          Reflect.apply(null, args);
                                                          Reflect.apply(obj.foo, obj, args);
                                                          Reflect.apply(obj.foo, other, args);
                                                          +
                                                          + +
                                                          /*eslint prefer-reflect: ["error", { exceptions: ["call"] }]*/

                                                          foo.call(undefined, arg);
                                                          foo.call(null, arg);
                                                          obj.foo.call(obj, arg);
                                                          obj.foo.call(other, arg);
                                                          Reflect.apply(undefined, [arg]);
                                                          Reflect.apply(null, [arg]);
                                                          Reflect.apply(obj.foo, obj, [arg]);
                                                          Reflect.apply(obj.foo, other, [arg]);
                                                          +
                                                          + +

                                                          Reflect.defineProperty (Object.defineProperty)

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Object.defineProperty({}, 'foo', {value: 1})
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Reflect.defineProperty({}, 'foo', {value: 1})
                                                          +
                                                          + +
                                                          /*eslint prefer-reflect: ["error", { exceptions: ["defineProperty"] }]*/

                                                          Object.defineProperty({}, 'foo', {value: 1})
                                                          Reflect.defineProperty({}, 'foo', {value: 1})
                                                          +
                                                          + +

                                                          Reflect.getOwnPropertyDescriptor (Object.getOwnPropertyDescriptor)

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Object.getOwnPropertyDescriptor({}, 'foo')
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Reflect.getOwnPropertyDescriptor({}, 'foo')
                                                          +
                                                          + +

                                                          config: prefer-reflect: ["error", { exceptions: ["getOwnPropertyDescriptor"] }]

                                                          + +
                                                          /*eslint prefer-reflect: ["error", { exceptions: ["getOwnPropertyDescriptor"] }]*/

                                                          Object.getOwnPropertyDescriptor({}, 'foo')
                                                          Reflect.getOwnPropertyDescriptor({}, 'foo')
                                                          +
                                                          + +

                                                          Reflect.getPrototypeOf (Object.getPrototypeOf)

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Object.getPrototypeOf({}, 'foo')
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Reflect.getPrototypeOf({}, 'foo')
                                                          +
                                                          + +
                                                          /*eslint prefer-reflect: ["error", { exceptions: ["getPrototypeOf"] }]*/

                                                          Object.getPrototypeOf({}, 'foo')
                                                          Reflect.getPrototypeOf({}, 'foo')
                                                          +
                                                          + +

                                                          Reflect.setPrototypeOf (Object.setPrototypeOf)

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Object.setPrototypeOf({}, Object.prototype)
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Reflect.setPrototypeOf({}, Object.prototype)
                                                          +
                                                          + +

                                                          config: prefer-reflect: ["error", { exceptions: ["setPrototypeOf"] }]

                                                          + +
                                                          /*eslint prefer-reflect: ["error", { exceptions: ["setPrototypeOf"] }]*/

                                                          Object.setPrototypeOf({}, Object.prototype)
                                                          Reflect.setPrototypeOf({}, Object.prototype)
                                                          +
                                                          + +

                                                          Reflect.isExtensible (Object.isExtensible)

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Object.isExtensible({})
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Reflect.isExtensible({})
                                                          +
                                                          + +
                                                          /*eslint prefer-reflect: ["error", { exceptions: ["isExtensible"] }]*/

                                                          Object.isExtensible({})
                                                          Reflect.isExtensible({})
                                                          +
                                                          + +

                                                          Reflect.getOwnPropertyNames (Object.getOwnPropertyNames)

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Object.getOwnPropertyNames({})
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Reflect.getOwnPropertyNames({})
                                                          +
                                                          + +
                                                          /*eslint prefer-reflect: ["error", { exceptions: ["getOwnPropertyNames"] }]*/

                                                          Object.getOwnPropertyNames({})
                                                          Reflect.getOwnPropertyNames({})
                                                          +
                                                          + +

                                                          Reflect.preventExtensions (Object.preventExtensions)

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Object.preventExtensions({})
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          Reflect.preventExtensions({})
                                                          +
                                                          + +
                                                          /*eslint prefer-reflect: ["error", { exceptions: ["preventExtensions"] }]*/

                                                          Object.preventExtensions({})
                                                          Reflect.preventExtensions({})
                                                          +
                                                          + +

                                                          Reflect.deleteProperty (The delete keyword)

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          delete foo.bar;
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint prefer-reflect: "error"*/

                                                          delete bar; // Does not reference an object, just a var
                                                          Reflect.deleteProperty(foo, 'bar');
                                                          +
                                                          + +

                                                          (Note: For a rule preventing deletion of variables, see no-delete-var instead)

                                                          + +
                                                          /*eslint prefer-reflect: ["error", { exceptions: ["delete"] }]*/

                                                          delete bar
                                                          delete foo.bar
                                                          Reflect.deleteProperty(foo, 'bar');
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          This rule should not be used in ES3/5 environments.

                                                          + +

                                                          In ES2015 (ES6) or later, if you don’t want to be notified about places where Reflect could be used, you can safely disable this rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0-rc-2.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-rest-params.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-rest-params.html new file mode 100644 index 0000000..fcc35ae --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-rest-params.html @@ -0,0 +1,48 @@ + + + +

                                                          Suggest using the rest parameters instead of arguments (prefer-rest-params)

                                                          + +

                                                          There are rest parameters in ES2015. +We can use that feature for variadic functions instead of the arguments variable.

                                                          + +

                                                          arguments does not have methods of Array.prototype, so it’s a bit of an inconvenience.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed to flag usage of arguments variables.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          function foo() {
                                                          console.log(arguments);
                                                          }

                                                          function foo(action) {
                                                          var args = [].slice.call(arguments, 1);
                                                          action.apply(null, args);
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          function foo(...args) {
                                                          console.log(args);
                                                          }

                                                          function foo(action, ...args) {
                                                          action.apply(null, args); // or `action(...args)`, related to the `prefer-spread` rule.
                                                          }

                                                          // Note: the implicit arguments can be overwritten.
                                                          function foo(arguments) {
                                                          console.log(arguments); // This is the first argument.
                                                          }
                                                          function foo() {
                                                          var arguments = 0;
                                                          console.log(arguments); // This is a local variable.
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          This rule should not be used in ES3/5 environments.

                                                          + +

                                                          In ES2015 (ES6) or later, if you don’t want to be notified about arguments variables, then it’s safe to disable this rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-alpha-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-spread.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-spread.html new file mode 100644 index 0000000..f02a150 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-spread.html @@ -0,0 +1,61 @@ + + + +

                                                          Suggest using the spread operator instead of .apply(). (prefer-spread)

                                                          + +

                                                          Before ES2015, one must use Function.prototype.apply() to call variadic functions.

                                                          + +
                                                          var args = [1, 2, 3, 4];
                                                          Math.max.apply(Math, args);
                                                          +
                                                          + +

                                                          In ES2015, one can use the spread operator to call variadic functions.

                                                          + +
                                                          /*eslint-env es6*/

                                                          var args = [1, 2, 3, 4];
                                                          Math.max(...args);
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed to flag usage of Function.prototype.apply() that can be replaced with the spread operator.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint prefer-spread: "error"*/

                                                          foo.apply(undefined, args);

                                                          foo.apply(null, args);

                                                          obj.foo.apply(obj, args);
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint prefer-spread: "error"*/

                                                          // The `this` binding is different.
                                                          foo.apply(obj, args);
                                                          obj.foo.apply(null, args);
                                                          obj.foo.apply(otherObj, args);

                                                          // The argument list is not variadic.
                                                          // Those are warned by the `no-useless-call` rule.
                                                          foo.apply(undefined, [1, 2, 3]);
                                                          foo.apply(null, [1, 2, 3]);
                                                          obj.foo.apply(obj, [1, 2, 3]);
                                                          +
                                                          + +

                                                          Known limitations:

                                                          + +

                                                          This rule analyzes code statically to check whether or not the this argument is changed. +So if the this argument is computed in a dynamic expression, this rule cannot detect a violation.

                                                          + +
                                                          /*eslint prefer-spread: "error"*/

                                                          // This warns.
                                                          a[i++].foo.apply(a[i++], args);

                                                          // This does not warn.
                                                          a[++i].foo.apply(a[i], args);
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          This rule should not be used in ES3/5 environments.

                                                          + +

                                                          In ES2015 (ES6) or later, if you don’t want to be notified about Function.prototype.apply() callings, you can safely disable this rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0-rc-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-template.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-template.html new file mode 100644 index 0000000..47c0700 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/prefer-template.html @@ -0,0 +1,51 @@ + + + +

                                                          Suggest using template literals instead of string concatenation. (prefer-template)

                                                          + +

                                                          In ES2015 (ES6), we can use template literals instead of string concatenation.

                                                          + +
                                                          var str = "Hello, " + name + "!";
                                                          +
                                                          + +
                                                          /*eslint-env es6*/

                                                          var str = `Hello, ${name}!`;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed to flag usage of + operators with strings.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint prefer-template: "error"*/

                                                          var str = "Hello, " + name + "!";
                                                          var str = "Time: " + (12 * 60 * 60 * 1000);
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint prefer-template: "error"*/
                                                          /*eslint-env es6*/

                                                          var str = "Hello World!";
                                                          var str = `Hello, ${name}!`;
                                                          var str = `Time: ${12 * 60 * 60 * 1000}`;

                                                          // This is reported by `no-useless-concat`.
                                                          var str = "Hello, " + "World!";
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          This rule should not be used in ES3/5 environments.

                                                          + +

                                                          In ES2015 (ES6) or later, if you don’t want to be notified about string concatenation, you can safely disable this rule.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.2.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/quote-props.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/quote-props.html new file mode 100644 index 0000000..132d1ed --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/quote-props.html @@ -0,0 +1,168 @@ + + + +

                                                          Quoting Style for Property Names (quote-props)

                                                          + +

                                                          Object literal property names can be defined in two ways: using literals or using strings. For example, these two objects are equivalent:

                                                          + +
                                                          var object1 = {
                                                          property: true
                                                          };

                                                          var object2 = {
                                                          "property": true
                                                          };
                                                          +
                                                          + +

                                                          In many cases, it doesn’t matter if you choose to use an identifier instead of a string or vice-versa. Even so, you might decide to enforce a consistent style in your code.

                                                          + +

                                                          There are, however, some occasions when you must use quotes:

                                                          + +
                                                            +
                                                          1. If you are using an ECMAScript 3 JavaScript engine (such as IE8) and you want to use a keyword (such as if) as a property name. This restriction was removed in ECMAScript 5.
                                                          2. +
                                                          3. You want to use a non-identifier character in your property name, such as having a property with a space like "one two".
                                                          4. +
                                                          + +

                                                          Another example where quotes do matter is when using numeric literals as property keys:

                                                          + +
                                                          var object = {
                                                          1e2: 1,
                                                          100: 2
                                                          };
                                                          +
                                                          + +

                                                          This may look alright at first sight, but this code in fact throws a syntax error in ECMAScript 5 strict mode. This happens because 1e2 and 100 are coerced into strings before getting used as the property name. Both String(1e2) and String(100) happen to be equal to "100", which causes the “Duplicate data property in object literal not allowed in strict mode” error. Issues like that can be tricky to debug, so some prefer to require quotes around all property names.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to enforce use of quotes in property names and as such will flag any properties that don’t use quotes (default behavior).

                                                          + +

                                                          Options

                                                          + +

                                                          There are four behaviors for this rule: "always" (default), "as-needed", "consistent" and "consistent-as-needed". You can define these options in your configuration as:

                                                          + +
                                                          {
                                                          "quote-props": ["error", "as-needed"]
                                                          }
                                                          +
                                                          + +

                                                          “always”

                                                          + +

                                                          When configured with "always" as the first option (the default), quoting for all properties will be enforced. Some believe that ensuring property names in object literals are always wrapped in quotes is generally a good idea, since depending on the property name you may need to quote them anyway. Consider this example:

                                                          + +
                                                          var object = {
                                                          foo: "bar",
                                                          baz: 42,
                                                          "qux-lorem": true
                                                          };
                                                          +
                                                          + +

                                                          Here, the properties foo and baz are not wrapped in quotes, but qux-lorem is, because it doesn’t work without the quotes. This is rather inconsistent. Instead, you may prefer to quote names of all properties:

                                                          + +
                                                          var object = {
                                                          "foo": "bar",
                                                          "baz": 42,
                                                          "qux-lorem": true
                                                          };
                                                          +
                                                          + +

                                                          or, if you prefer single quotes:

                                                          + +
                                                          var object = {
                                                          'foo': 'bar',
                                                          'baz': 42,
                                                          'qux-lorem': true
                                                          };
                                                          +
                                                          + +

                                                          When configured with "always" as the first option (the default), quoting for all properties will be enforced. The following patterns are considered problems:

                                                          + +
                                                          /*eslint quote-props: ["error", "always"]*/

                                                          var object = {
                                                          foo: "bar",
                                                          baz: 42,
                                                          "qux-lorem": true
                                                          };
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint quote-props: ["error", "always"]*/
                                                          /*eslint-env es6*/

                                                          var object1 = {
                                                          "foo": "bar",
                                                          "baz": 42,
                                                          "qux-lorem": true
                                                          };

                                                          var object2 = {
                                                          'foo': 'bar',
                                                          'baz': 42,
                                                          'qux-lorem': true
                                                          };

                                                          var object3 = {
                                                          foo() {
                                                          return;
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          “as-needed”

                                                          + +

                                                          When configured with "as-needed" as the first option, quotes will be enforced when they are strictly required, and unnecessary quotes will cause warnings. The following patterns are considered problems:

                                                          + +
                                                          /*eslint quote-props: ["error", "as-needed"]*/

                                                          var object = {
                                                          "a": 0,
                                                          "0": 0,
                                                          "true": 0,
                                                          "null": 0
                                                          };
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint quote-props: ["error", "as-needed"]*/
                                                          /*eslint-env es6*/

                                                          var object1 = {
                                                          "a-b": 0,
                                                          "0x0": 0,
                                                          "1e2": 0
                                                          };

                                                          var object2 = {
                                                          foo: 'bar',
                                                          baz: 42,
                                                          true: 0,
                                                          0: 0,
                                                          'qux-lorem': true
                                                          };

                                                          var object3 = {
                                                          foo() {
                                                          return;
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          When the "as-needed" mode is selected, an additional keywords option can be provided. This flag indicates whether language keywords should be quoted as properties. By default it is set to false.

                                                          + +
                                                          {
                                                          "quote-props": ["error", "as-needed", { "keywords": true }]
                                                          }
                                                          +
                                                          + +

                                                          When keywords is set to true, the following patterns become problems:

                                                          + +
                                                          /*eslint quote-props: ["error", "as-needed", { "keywords": true }]*/

                                                          var x = {
                                                          while: 1,
                                                          volatile: "foo"
                                                          };
                                                          +
                                                          + +

                                                          Another modifier for this rule is the unnecessary option which defaults to true. Setting this to false will prevent the rule from complaining about unnecessarily quoted properties. This comes in handy when you only care about quoting keywords.

                                                          + +
                                                          {
                                                          "quote-props": ["error", "as-needed", { "keywords": true, "unnecessary": false }]
                                                          }
                                                          +
                                                          + +

                                                          When unnecessary is set to false, the following patterns stop being problems:

                                                          + +
                                                          /*eslint quote-props: ["error", "as-needed", { "keywords": true, "unnecessary": false }]*/

                                                          var x = {
                                                          "while": 1,
                                                          "foo": "bar" // Would normally have caused a warning
                                                          };
                                                          +
                                                          + +

                                                          A numbers flag, with default value false, can also be used as a modifier for the "as-needed" mode. When it is set to true, numeric literals should always be quoted.

                                                          + +
                                                          {
                                                          "quote-props": ["error", "as-needed", {"numbers": true}]
                                                          }
                                                          +
                                                          + +

                                                          When numbers is set to true, the following patterns become problems:

                                                          + +
                                                          /*eslint quote-props: ["error", "as-needed", { "numbers": true }]*/

                                                          var x = {
                                                          100: 1
                                                          }
                                                          +
                                                          + +

                                                          and the following patterns stop being problems:

                                                          + +
                                                          var x = {
                                                          "100": 1
                                                          }
                                                          +
                                                          + +

                                                          “consistent”

                                                          + +

                                                          When configured with "consistent", the patterns below are considered problems. Basically "consistent" means all or no properties are expected to be quoted, in other words quoting style can’t be mixed within an object. Please note the latter situation (no quotation at all) isn’t always possible as some property names require quoting.

                                                          + +
                                                          /*eslint quote-props: ["error", "consistent"]*/

                                                          var object1 = {
                                                          foo: "bar",
                                                          "baz": 42,
                                                          "qux-lorem": true
                                                          };

                                                          var object2 = {
                                                          'foo': 'bar',
                                                          baz: 42
                                                          };
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint quote-props: ["error", "consistent"]*/

                                                          var object1 = {
                                                          "foo": "bar",
                                                          "baz": 42,
                                                          "qux-lorem": true
                                                          };

                                                          var object2 = {
                                                          'foo': 'bar',
                                                          'baz': 42
                                                          };

                                                          var object3 = {
                                                          foo: 'bar',
                                                          baz: 42
                                                          };
                                                          +
                                                          + +

                                                          “consistent-as-needed”

                                                          + +

                                                          When configured with "consistent-as-needed", the behavior is similar to "consistent" with one difference. Namely, properties’ quoting should be consistent (as in "consistent") but whenever all quotes are redundant a warning is raised. In other words if at least one property name has to be quoted (like qux-lorem) then all property names must be quoted, otherwise no properties can be quoted. The following patterns are considered problems:

                                                          + +
                                                          /*eslint quote-props: ["error", "consistent-as-needed"]*/

                                                          var object1 = {
                                                          foo: "bar",
                                                          "baz": 42,
                                                          "qux-lorem": true
                                                          };

                                                          var object2 = {
                                                          'foo': 'bar',
                                                          'baz': 42
                                                          };
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint quote-props: ["error", "consistent-as-needed"]*/

                                                          var object1 = {
                                                          "foo": "bar",
                                                          "baz": 42,
                                                          "qux-lorem": true
                                                          };

                                                          var object2 = {
                                                          foo: 'bar',
                                                          baz: 42
                                                          };
                                                          +
                                                          + +

                                                          When the "consistent-as-needed" mode is selected, an additional keywords option can be provided. This flag indicates whether language keywords can be used unquoted as properties. By default it is set to false.

                                                          + +
                                                          {
                                                          "quote-props": ["error", "consistent-as-needed", { "keywords": true }]
                                                          }
                                                          +
                                                          + +

                                                          When keywords is set to true, the following patterns are considered problems:

                                                          + +
                                                          /*eslint quote-props: ["error", "consistent-as-needed", { "keywords": true }]*/

                                                          var x = {
                                                          while: 1,
                                                          volatile: "foo"
                                                          };
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t care if property names are consistently wrapped in quotes or not, and you don’t target legacy ES3 environments, turn this rule off.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.6.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/quotes.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/quotes.html new file mode 100644 index 0000000..59f5060 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/quotes.html @@ -0,0 +1,103 @@ + + + +

                                                          Enforce Quote Style (quotes)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          JavaScript allows you to define strings in one of three ways: double quotes, single quotes, and backticks (as of ECMAScript 6). For example:

                                                          + +
                                                          /*eslint-env es6*/

                                                          var double = "double";
                                                          var single = 'single';
                                                          var backtick = `backtick`; // ES6 only
                                                          +
                                                          + +

                                                          Each of these lines creates a string and, in some cases, can be used interchangeably. The choice of how to define strings in a codebase is a stylistic one outside of template literals (which allow embedded of expressions to be interpreted).

                                                          + +

                                                          Many codebases require strings to be defined in a consistent manner.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at ensuring consistency of string quotes and as such will report a problem when an inconsistent style is found.

                                                          + +

                                                          The rule configuration takes up to two options:

                                                          + +
                                                            +
                                                          1. The first option is "double", "single" or "backtick" for double-quotes, single-quotes or backticks respectively. The default is "double".
                                                          2. +
                                                          3. The second option takes two options: +
                                                              +
                                                            1. "avoidEscape": When using "avoidEscape", this rule will not report a problem when a string is using single-quotes or double-quotes so long as the string contains a quote that would have to be escaped otherwise. For example, if you specify "double" and "avoidEscape", the string 'He said, "hi!"' is not considered a problem because using double quotes for that string would require escaping the double quotes inside of the string. This option is off by default.
                                                            2. +
                                                            3. "allowTemplateLiterals": when using "allowTemplateLiterals", this rule will not report a problem when a string is using backticks and option one is either "double" or "single".
                                                            4. +
                                                            +
                                                          4. +
                                                          + +

                                                          When using "single" or "double", template literals that don’t contain a substitution, don’t contain a line break and aren’t tagged templates, are flagged as problems, even with the "avoidEscape" option. However they are not problems when "allowTemplateLiterals" is used.

                                                          + +

                                                          Configuration looks like this:

                                                          + +
                                                          [2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}]
                                                          +
                                                          + +

                                                          Deprecation notice: The avoid-escape option is a deprecated syntax and you should use the object form instead.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint quotes: ["error", "double"]*/

                                                          var single = 'single';
                                                          var unescaped = 'a string containing "double" quotes';
                                                          +
                                                          + +
                                                          /*eslint quotes: ["error", "single"]*/

                                                          var double = "double";
                                                          var unescaped = "a string containing 'single' quotes";
                                                          +
                                                          + +
                                                          /*eslint quotes: ["error", "double", {"avoidEscape": true}]*/

                                                          var single = 'single';
                                                          var single = `single`;
                                                          +
                                                          + +
                                                          /*eslint quotes: ["error", "single", {"avoidEscape": true}]*/

                                                          var double = "double";
                                                          var double = `double`;
                                                          +
                                                          + +
                                                          /*eslint quotes: ["error", "backtick"]*/

                                                          var single = 'single';
                                                          var double = "double";
                                                          var unescaped = 'a string containing `backticks`';
                                                          +
                                                          + +
                                                          /*eslint quotes: ["error", "backtick", {"avoidEscape": true}]*/

                                                          var single = 'single';
                                                          var double = "double";
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint quotes: ["error", "double"]*/
                                                          /*eslint-env es6*/

                                                          var double = "double";
                                                          var backtick = `back\ntick`; // backticks are allowed due to newline
                                                          var backtick = tag`backtick`; // backticks are allowed due to tag
                                                          +
                                                          + +
                                                          /*eslint quotes: ["error", "single"]*/
                                                          /*eslint-env es6*/

                                                          var single = 'single';
                                                          var backtick = `back${x}tick`; // backticks are allowed due to substitution
                                                          +
                                                          + +
                                                          /*eslint quotes: ["error", "double", {"avoidEscape": true}]*/

                                                          var single = 'a string containing "double" quotes';
                                                          +
                                                          + +
                                                          /*eslint quotes: ["error", "single", {"avoidEscape": true}]*/

                                                          var double = "a string containing 'single' quotes";
                                                          +
                                                          + +
                                                          /*eslint quotes: ["error", "double", {"allowTemplateLiterals": true}]*/

                                                          var single = 'single';
                                                          var single = `single`;
                                                          +
                                                          + +
                                                          /*eslint quotes: ["error", "single", {"allowTemplateLiterals": true}]*/

                                                          var double = "double";
                                                          var double = `double`;
                                                          +
                                                          + +
                                                          /*eslint quotes: ["error", "backtick"]*/
                                                          /*eslint-env es6*/

                                                          var backtick = `backtick`;
                                                          +
                                                          + +
                                                          /*eslint quotes: ["error", "backtick", {"avoidEscape": true}]*/

                                                          var double = "a string containing `backtick` quotes"
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you do not need consistency in your string styles, you can safely disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.7.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/radix.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/radix.html new file mode 100644 index 0000000..7270b3e --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/radix.html @@ -0,0 +1,81 @@ + + + +

                                                          Require Radix Parameter (radix)

                                                          + +

                                                          When using the parseInt() function it is common to omit the second argument, the radix, and let the function try to determine from the first argument what type of number it is. By default, parseInt() will autodetect decimal and hexadecimal (via 0x prefix). Prior to ECMAScript 5, parseInt() also autodetected octal literals, which caused problems because many developers assumed a leading 0 would be ignored.

                                                          + +

                                                          This confusion led to the suggestion that you always use the radix parameter to parseInt() to eliminate unintended consequences. So instead of doing this:

                                                          + +
                                                          var num = parseInt("071");      // 57
                                                          +
                                                          + +

                                                          Do this:

                                                          + +
                                                          var num = parseInt("071", 10);  // 71
                                                          +
                                                          + +

                                                          ECMAScript 5 changed the behavior of parseInt() so that it no longer autodetects octal literals and instead treats them as decimal literals. However, the differences between hexadecimal and decimal interpretation of the first parameter causes many developers to continue using the radix parameter to ensure the string is interpreted in the intended way.

                                                          + +

                                                          On the other hand, if the code is targeting only ES5-compliant environments passing the radix 10 may be redundant. In such a case you might want to disallow using such a radix.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at preventing the unintended conversion of a string to a number of a different base than intended or at preventing the redundant 10 radix if targeting modern environments only.

                                                          + +

                                                          Options

                                                          + +

                                                          There are two options for this rule:

                                                          + +
                                                            +
                                                          • "always" enforces providing a radix (default)
                                                          • +
                                                          • "as-needed" disallows providing the 10 radix
                                                          • +
                                                          + +

                                                          always

                                                          + +

                                                          Examples of incorrect code for the default "always" option:

                                                          + +
                                                          /*eslint radix: "error"*/

                                                          var num = parseInt("071");

                                                          var num = parseInt(someValue);

                                                          var num = parseInt("071", "abc");

                                                          var num = parseInt();
                                                          +
                                                          + +

                                                          Examples of correct code for the default "always" option:

                                                          + +
                                                          /*eslint radix: "error"*/

                                                          var num = parseInt("071", 10);

                                                          var num = parseInt("071", 8);

                                                          var num = parseFloat(someValue);
                                                          +
                                                          + +

                                                          as-needed

                                                          + +

                                                          Examples of incorrect code for the "as-needed" option:

                                                          + +
                                                          /*eslint radix: ["error", "as-needed"]*/

                                                          var num = parseInt("071", 10);

                                                          var num = parseInt("071", "abc");

                                                          var num = parseInt();
                                                          +
                                                          + +

                                                          Examples of correct code for the "as-needed" option:

                                                          + +
                                                          /*eslint radix: ["error", "as-needed"]*/

                                                          var num = parseInt("071");

                                                          var num = parseInt("071", 8);

                                                          var num = parseFloat(someValue);
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to enforce either presence or omission of the 10 radix value you can turn this rule off.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.7.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/require-jsdoc.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/require-jsdoc.html new file mode 100644 index 0000000..2b34e03 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/require-jsdoc.html @@ -0,0 +1,69 @@ + + + +

                                                          Require JSDoc comment (require-jsdoc)

                                                          + +

                                                          JSDoc is a JavaScript API documentation generator. It uses specially-formatted comments inside of code to generate API documentation automatically. For example, this is what a JSDoc comment looks like for a function:

                                                          + +
                                                          /**
                                                          * Adds two numbers together.
                                                          * @param {int} num1 The first number.
                                                          * @param {int} num2 The second number.
                                                          * @returns {int} The sum of the two numbers.
                                                          */

                                                          function sum(num1, num2) {
                                                          return num1 + num2;
                                                          }
                                                          +
                                                          + +

                                                          Some style guides require JSDoc comments for all functions as a way of explaining function behavior.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule generates warnings for nodes that do not have JSDoc comments when they should. Supported nodes:

                                                          + +
                                                            +
                                                          • FunctionDeclaration
                                                          • +
                                                          • ClassDeclaration
                                                          • +
                                                          • MethodDefinition
                                                          • +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule accepts a require object with its properties as

                                                          + +
                                                            +
                                                          • FunctionDeclaration (default: true)
                                                          • +
                                                          • ClassDeclaration (default: false)
                                                          • +
                                                          • MethodDefinition (default: false)
                                                          • +
                                                          + +

                                                          Default option settings are

                                                          + +
                                                          {
                                                          "require-jsdoc": ["error", {
                                                          "require": {
                                                          "FunctionDeclaration": true,
                                                          "MethodDefinition": false,
                                                          "ClassDeclaration": false
                                                          }
                                                          }]
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint "require-jsdoc": ["error", {
                                                          "require": {
                                                          "FunctionDeclaration": true,
                                                          "MethodDefinition": true,
                                                          "ClassDeclaration": true
                                                          }
                                                          }]*/


                                                          function foo() {
                                                          return 10;
                                                          }

                                                          class Test{
                                                          getDate(){}
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint "require-jsdoc": ["error", {
                                                          "require": {
                                                          "FunctionDeclaration": true,
                                                          "MethodDefinition": true,
                                                          "ClassDeclaration": true
                                                          }
                                                          }]*/


                                                          /**
                                                          * It returns 10
                                                          */

                                                          function foo() {
                                                          return 10;
                                                          }

                                                          /**
                                                          * It returns 10
                                                          */

                                                          var foo = function() {
                                                          return 10;
                                                          }

                                                          var array = [1,2,3];
                                                          array.filter(function(item) {
                                                          return item > 2;
                                                          });

                                                          /**
                                                          * It returns 10
                                                          */

                                                          class Test{
                                                          /**
                                                          * returns the date
                                                          */

                                                          getDate(){}
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you do not require JSDoc for your functions, then you can leave this rule off.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/require-yield.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/require-yield.html new file mode 100644 index 0000000..e70cc6c --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/require-yield.html @@ -0,0 +1,31 @@ + + + +

                                                          Disallow generator functions that do not have yield (require-yield)

                                                          + +

                                                          This rule generates warnings for generator functions that do not have the yield keyword.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint require-yield: "error"*/
                                                          /*eslint-env es6*/

                                                          function* foo() {
                                                          return 10;
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint require-yield: "error"*/
                                                          /*eslint-env es6*/

                                                          function* foo() {
                                                          yield 5;
                                                          return 10;
                                                          }

                                                          function foo() {
                                                          return 10;
                                                          }

                                                          // This rule does not warn on empty generator functions.
                                                          function* foo() { }
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 1.0.0-rc-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/semi-spacing.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/semi-spacing.html new file mode 100644 index 0000000..e1829c6 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/semi-spacing.html @@ -0,0 +1,98 @@ + + + +

                                                          Enforce spacing before and after semicolons (semi-spacing)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          JavaScript allows you to place unnecessary spaces before or after a semicolon.

                                                          + +

                                                          Disallowing or enforcing space around a semicolon can improve the readability of your program.

                                                          + +
                                                          var a = "b" ;

                                                          var c = "d";var e = "f";
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to enforce spacing around a semicolon. This rule prevents the use of spaces before a semicolon in expressions.

                                                          + +

                                                          This rule doesn’t check spacing in the following cases:

                                                          + +
                                                            +
                                                          • +

                                                            The spacing after the semicolon if it is the first token in the line.

                                                            +
                                                          • +
                                                          • +

                                                            The spacing before the semicolon if it is after an opening parenthesis (( or {), or the spacing after the semicolon if it is before a closing parenthesis () or }). That spacing is checked by space-in-parens or block-spacing.

                                                            +
                                                          • +
                                                          • +

                                                            The spacing around the semicolon in a for loop with an empty condition (for(;;)).

                                                            +
                                                          • +
                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes one option, an object, which has two keys before and after having boolean values true or false. +If before is true, space is enforced before semicolons and if it’s false, space is disallowed before semicolons. +If after is true, space is enforced after semicolons and if it’s false, space is disallowed after semicolons. +The after option will be only applied if a semicolon is not at the end of line.

                                                          + +

                                                          The default is {"before": false, "after": true}.

                                                          + +
                                                              "semi-spacing": ["error", {"before": false, "after": true}]
                                                          +
                                                          + +

                                                          {"before": false, "after": true}

                                                          + +

                                                          This is the default option. It enforces spacing after semicolons and disallows spacing before semicolons.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint semi-spacing: "error"*/

                                                          var foo ;
                                                          var foo;var bar;
                                                          throw new Error("error") ;
                                                          while (a) { break ; }
                                                          for (i = 0 ; i < 10 ; i++) {}
                                                          for (i = 0;i < 10;i++) {}
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint semi-spacing: "error"*/

                                                          var foo;
                                                          var foo; var bar;
                                                          throw new Error("error");
                                                          while (a) { break; }
                                                          for (i = 0; i < 10; i++) {}
                                                          for (;;) {}
                                                          if (true) {;}
                                                          ;foo();
                                                          +
                                                          + +

                                                          {"before": true, "after": false}

                                                          + +

                                                          This option enforces spacing before semicolons and disallows spacing after semicolons.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint semi-spacing: ["error", { "before": true, "after": false }]*/

                                                          var foo;
                                                          var foo ; var bar;
                                                          throw new Error("error");
                                                          while (a) { break; }
                                                          for (i = 0;i < 10;i++) {}
                                                          for (i = 0; i < 10; i++) {}
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint semi-spacing: ["error", { "before": true, "after": false }]*/

                                                          var foo ;
                                                          var foo ;var bar ;
                                                          throw new Error("error") ;
                                                          while (a) {break ;}
                                                          for (i = 0 ;i < 10 ;i++) {}
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with the consistency of spacing before or after semicolons.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.16.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/semi.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/semi.html new file mode 100644 index 0000000..3f8bb6f --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/semi.html @@ -0,0 +1,142 @@ + + + +

                                                          Enforce or Disallow Semicolons (semi)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          JavaScript is unique amongst the C-like languages in that it doesn’t require semicolons at the end of each statement. In many cases, the JavaScript engine can determine that a semicolon should be in a certain spot and will automatically add it. This feature is known as automatic semicolon insertion (ASI) and is considered one of the more controversial features of JavaScript. For example, the following lines are both valid:

                                                          + +
                                                          var name = "ESLint"
                                                          var website = "eslint.org";
                                                          +
                                                          + +

                                                          On the first line, the JavaScript engine will automatically insert a semicolon, so this is not considered a syntax error. The JavaScript engine still knows how to interpret the line and knows that the line end indicates the end of the statement.

                                                          + +

                                                          In the debate over ASI, there are generally two schools of thought. The first is that we should treat ASI as if it didn’t exist and always include semicolons manually. The rationale is that it’s easier to always include semicolons than to try to remember when they are or are not required, and thus decreases the possibility of introducing an error.

                                                          + +

                                                          However, the ASI mechanism can sometimes be tricky to people who are using semicolons. For example, consider this code:

                                                          + +
                                                          return
                                                          {
                                                          name: "ESLint"
                                                          };
                                                          +
                                                          + +

                                                          This may look like a return statement that returns an object literal, however, the JavaScript engine will interpret this code as:

                                                          + +
                                                          return;
                                                          {
                                                          name: "ESLint";
                                                          }
                                                          +
                                                          + +

                                                          Effectively, a semicolon is inserted after the return statement, causing the code below it (a labeled literal inside a block) to be unreachable. This rule and the no-unreachable rule will protect your code from such cases.

                                                          + +

                                                          On the other side of the argument are those who says that since semicolons are inserted automatically, they are optional and do not need to be inserted manually. However, the ASI mechanism can also be tricky to people who don’t use semicolons. For example, consider this code:

                                                          + +
                                                          var globalCounter = { }

                                                          (function () {
                                                          var n = 0
                                                          globalCounter.increment = function () {
                                                          return ++n
                                                          }
                                                          })()
                                                          +
                                                          + +

                                                          In this example, a semicolon will not be inserted after the first line, causing a run-time error (because an empty object is called as if it’s a function). The no-unexpected-multiline rule can protect your code from such cases.

                                                          + +

                                                          Although ASI allows for more freedom over your coding style, it can also make your code behave in an unexpected way, whether you use semicolons or not. Therefore, it is best to know when ASI takes place and when it does not, and have ESLint protect your code from these potentially unexpected cases. In short, as once described by Isaac Schlueter, a \n character always ends a statement (just like a semicolon) unless one of the following is true:

                                                          + +
                                                            +
                                                          1. The statement has an unclosed paren, array literal, or object literal or ends in some other way that is not a valid way to end a statement. (For instance, ending with . or ,.)
                                                          2. +
                                                          3. The line is -- or ++ (in which case it will decrement/increment the next token.)
                                                          4. +
                                                          5. It is a for(), while(), do, if(), or else, and there is no {
                                                          6. +
                                                          7. The next line starts with [, (, +, *, /, -, ,, ., or some other binary operator that can only be found between two tokens in a single expression.
                                                          8. +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at ensuring consistent use of semicolons. You can decide whether or not to require semicolons at the end of statements.

                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes one or two options. The first one is a string, which could be "always" or "never". The default is "always". The second one is an object for more fine-grained configuration when the first option is "always".

                                                          + +

                                                          You can set the option in configuration like this:

                                                          + +

                                                          “always”

                                                          + +

                                                          By using the default option, semicolons must be used any place where they are valid.

                                                          + +
                                                          semi: ["error", "always"]
                                                          +
                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint semi: "error"*/

                                                          var name = "ESLint"

                                                          object.method = function() {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint semi: "error"*/

                                                          var name = "ESLint";

                                                          object.method = function() {
                                                          // ...
                                                          };
                                                          +
                                                          + +

                                                          Fine-grained control

                                                          + +

                                                          When setting the first option as “always”, an additional option can be added to omit the last semicolon in a one-line block, that is, a block in which its braces (and therefore the content of the block) are in the same line:

                                                          + +
                                                          semi: ["error", "always", { "omitLastInOneLineBlock": true}]
                                                          +
                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint semi: ["error", "always", { "omitLastInOneLineBlock": true}] */

                                                          if (foo) {
                                                          bar()
                                                          }

                                                          if (foo) { bar(); }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint semi: ["error", "always", { "omitLastInOneLineBlock": true}] */

                                                          if (foo) { bar() }

                                                          if (foo) { bar(); baz() }
                                                          +
                                                          + +

                                                          “never”

                                                          + +

                                                          If you want to enforce that semicolons are never used, switch the configuration to:

                                                          + +
                                                          semi: [2, "never"]
                                                          +
                                                          + +

                                                          Then, the following patterns are considered problems:

                                                          + +
                                                          /*eslint semi: ["error", "never"]*/

                                                          var name = "ESLint";

                                                          object.method = function() {
                                                          // ...
                                                          };
                                                          +
                                                          + +

                                                          And the following patterns are not considered problems:

                                                          + +
                                                          /*eslint semi: ["error", "never"]*/

                                                          var name = "ESLint"

                                                          object.method = function() {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Even in "never" mode, semicolons are still allowed to disambiguate statements beginning with [, (, /, +, or -:

                                                          + +
                                                          /*eslint semi: ["error", "never"]*/

                                                          var name = "ESLint"

                                                          ;(function() {
                                                          // ...
                                                          })()
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you do not want to enforce semicolon usage (or omission) in any particular way, then you can turn this rule off.

                                                          + +

                                                          Further Reading

                                                          + + + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.6.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/sort-imports.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/sort-imports.html new file mode 100644 index 0000000..246ffbb --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/sort-imports.html @@ -0,0 +1,134 @@ + + + +

                                                          Import Sorting (sort-imports)

                                                          + +

                                                          The import statement is used to import members (functions, objects or primitives) that have been exported from an external module. Using a specific member syntax:

                                                          + +
                                                          // single - Import single member.
                                                          import myMember from "my-module.js";

                                                          // multiple - Import multiple members.
                                                          import {foo, bar} from "my-module.js";

                                                          // all - Import all members, where myModule contains all the exported bindings.
                                                          import * as myModule from "my-module.js";
                                                          +
                                                          + +

                                                          The import statement can also import a module without exported bindings. Used when the module does not export anything, but runs it own code or changes the global context object.

                                                          + +
                                                          // none - Import module without exported bindings.
                                                          import "my-module.js"
                                                          +
                                                          + +

                                                          When declaring multiple imports, a sorted list of import declarations make it easier for developers to read the code and find necessary imports later. This rule is purely a matter of style.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule checks all import declarations and verifies that all imports are first sorted by the used member syntax and then alphabetically by the first member or alias name.

                                                          + +

                                                          The sort order of import declarations based on the member syntax can be configured via the memberSyntaxSortOrder option. +The default member syntax sort order is:

                                                          + +
                                                            +
                                                          • none - import module without exported bindings.
                                                          • +
                                                          • all - import all members provided by exported bindings.
                                                          • +
                                                          • multiple - import multiple members.
                                                          • +
                                                          • single - import single member.
                                                          • +
                                                          + +

                                                          The following example shows correct sorted import declarations:

                                                          + +
                                                          /*eslint sort-imports: "error"*/
                                                          import 'module-without-export.js';
                                                          import * as foo from 'foo.js';
                                                          import * as bar from 'bar.js';
                                                          import {alpha, beta} from 'alpha.js';
                                                          import {delta, gamma} from 'delta.js';
                                                          import a from 'baz.js';
                                                          import b from 'qux.js';
                                                          +
                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint sort-imports: "error"*/
                                                          import b from 'foo.js';
                                                          import a from 'bar.js';

                                                          /*eslint sort-imports: "error"*/
                                                          import a from 'foo.js';
                                                          import A from 'bar.js';

                                                          /*eslint sort-imports: "error"*/
                                                          import {b, c} from 'foo.js';
                                                          import {a, b} from 'bar.js';

                                                          /*eslint sort-imports: "error"*/
                                                          import a from 'foo.js';
                                                          import {b, c} from 'bar.js';

                                                          /*eslint sort-imports: "error"*/
                                                          import a from 'foo.js';
                                                          import * as b from 'bar.js';

                                                          /*eslint sort-imports: "error"*/
                                                          import {b, a, c} from 'foo.js'
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint sort-imports: "error"*/
                                                          import a from 'foo.js';
                                                          import b from 'bar.js';
                                                          import c from 'baz.js';

                                                          /*eslint sort-imports: "error"*/
                                                          import 'foo.js'
                                                          import * from 'bar.js';
                                                          import {a, b} from 'baz.js';
                                                          import c from 'qux.js';

                                                          /*eslint sort-imports: "error"*/
                                                          import {a, b, c} from 'foo.js'
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule accepts an object with its properties as

                                                          + +
                                                            +
                                                          • ignoreCase (default: false)
                                                          • +
                                                          • ignoreMemberSort (default: false)
                                                          • +
                                                          • memberSyntaxSortOrder (default: ["none", "all", "multiple", "single"])
                                                          • +
                                                          + +

                                                          Default option settings are

                                                          + +
                                                          {
                                                          "sort-imports": ["error", {
                                                          "ignoreCase": false,
                                                          "ignoreMemberSort": false,
                                                          "memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
                                                          }]
                                                          }
                                                          +
                                                          + +

                                                          ignoreCase

                                                          + +

                                                          When true the rule ignores the case-sensitivity of the imports local name.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint sort-imports: ["error", { "ignoreCase": true }]*/

                                                          import B from 'foo.js';
                                                          import a from 'bar.js';
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint sort-imports: ["error", { "ignoreCase": true }]*/

                                                          import a from 'foo.js';
                                                          import B from 'bar.js';
                                                          import c from 'baz.js';
                                                          +
                                                          + +

                                                          Default is false.

                                                          + +

                                                          ignoreMemberSort

                                                          + +

                                                          Ignores the member sorting within a multiple member import declaration.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint sort-imports: "error"*/
                                                          import {b, a, c} from 'foo.js'
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint sort-imports: ["error", { "ignoreMemberSort": true }]*/
                                                          import {b, a, c} from 'foo.js'
                                                          +
                                                          + +

                                                          Default is false.

                                                          + +

                                                          memberSyntaxSortOrder

                                                          + +

                                                          The member syntax sort order can be configured with this option. There are four different styles and the default member syntax sort order is:

                                                          + +
                                                            +
                                                          • none - import module without exported bindings.
                                                          • +
                                                          • all - import all members provided by exported bindings.
                                                          • +
                                                          • multiple - import multiple members.
                                                          • +
                                                          • single - import single member.
                                                          • +
                                                          + +

                                                          Use this option if you want a different sort order. Every style must be defined in the sort order (There shall be four items in the array).

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint sort-imports: "error"*/
                                                          import a from 'foo.js';
                                                          import * as b from 'bar.js';
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint sort-imports: ["error", { "memberSyntaxSortOrder": ['single', 'all', 'multiple', 'none'] }]*/

                                                          import a from 'foo.js';
                                                          import * as b from 'bar.js';

                                                          /*eslint sort-imports: ["error", { "memberSyntaxSortOrder": ['all', 'single', 'multiple', 'none'] }]*/

                                                          import * as foo from 'foo.js';
                                                          import z from 'zoo.js';
                                                          import {a, b} from 'foo.js';

                                                          +
                                                          + +

                                                          Default is ["none", "all", "multiple", "single"].

                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          This rule is a formatting preference and not following it won’t negatively affect the quality of your code. If alphabetizing imports isn’t a part of your coding standards, then you can leave this rule disabled.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-beta.1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/sort-vars.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/sort-vars.html new file mode 100644 index 0000000..b88666b --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/sort-vars.html @@ -0,0 +1,62 @@ + + + +

                                                          Variable Sorting (sort-vars)

                                                          + +

                                                          When declaring multiple variables within the same block, some developers prefer to sort variable names alphabetically to be able to find necessary variable easier at the later time. Others feel that it adds complexity and becomes burden to maintain.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule checks all variable declaration blocks and verifies that all variables are sorted alphabetically. +The default configuration of the rule is case-sensitive.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint sort-vars: "error"*/

                                                          var b, a;

                                                          var a, B, c;

                                                          var a, A;
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint sort-vars: "error"*/

                                                          var a, b, c, d;

                                                          var _a = 10;
                                                          var _b = 20;

                                                          var A, a;

                                                          var B, a, c;
                                                          +
                                                          + +

                                                          Alphabetical list is maintained starting from the first variable and excluding any that are considered problems. So the following code will produce two problems:

                                                          + +
                                                          /*eslint sort-vars: "error"*/

                                                          var c, d, a, b;
                                                          +
                                                          + +

                                                          But this one, will only produce one:

                                                          + +
                                                          /*eslint sort-vars: "error"*/

                                                          var c, d, a, e;
                                                          +
                                                          + +

                                                          Options

                                                          + +
                                                          "sort-vars": [<enabled>, { "ignoreCase": <boolean> }]
                                                          +
                                                          + +

                                                          ignoreCase

                                                          + +

                                                          When true the rule ignores the case-sensitivity of the variables order.

                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint sort-vars: ["error", { "ignoreCase": true }]*/

                                                          var a, A;

                                                          var a, B, c;
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          This rule is a formatting preference and not following it won’t negatively affect the quality of your code. If you alphabetizing variables isn’t a part of your coding standards, then you can leave this rule off.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.2.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/space-before-blocks.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/space-before-blocks.html new file mode 100644 index 0000000..b603883 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/space-before-blocks.html @@ -0,0 +1,110 @@ + + + +

                                                          Require Or Disallow Space Before Blocks (space-before-blocks)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Consistency is an important part of any style guide. +While it is a personal preference where to put the opening brace of blocks, +it should be consistent across a whole project. +Having an inconsistent style distracts the reader from seeing the important parts of the code.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule will enforce consistency of spacing before blocks. It is only applied on blocks that don’t begin on a new line.

                                                          + +
                                                            +
                                                          • This rule ignores spacing which is between => and a block. The spacing is handled by the arrow-spacing rule.
                                                          • +
                                                          • This rule ignores spacing which is between a keyword and a block. The spacing is handled by the keyword-spacing rule.
                                                          • +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule takes one argument. If it is "always" then blocks must always have at least one preceding space. If "never" +then all blocks should never have any preceding space. If different spacing is desired for function +blocks, keyword blocks and classes, an optional configuration object can be passed as the rule argument to +configure the cases separately.

                                                          + +

                                                          ( e.g. { "functions": "never", "keywords": "always", classes: "always" } )

                                                          + +

                                                          The default is "always".

                                                          + +

                                                          “always”

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint space-before-blocks: "error"*/

                                                          if (a){
                                                          b();
                                                          }

                                                          function a(){}

                                                          for (;;){
                                                          b();
                                                          }

                                                          try {} catch(a){}

                                                          class Foo{
                                                          constructor(){}
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-before-blocks: "error"*/

                                                          if (a) {
                                                          b();
                                                          }

                                                          if (a) {
                                                          b();
                                                          } else{ /*no error. this is checked by `keyword-spacing` rule.*/
                                                          c();
                                                          }


                                                          function a() {}

                                                          for (;;) {
                                                          b();
                                                          }

                                                          try {} catch(a) {}
                                                          +
                                                          + +

                                                          “never”

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint space-before-blocks: ["error", "never"]*/

                                                          if (a) {
                                                          b();
                                                          }

                                                          function a() {}

                                                          for (;;) {
                                                          b();
                                                          }

                                                          try {} catch(a) {}
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-before-blocks: ["error", "never"]*/

                                                          if (a){
                                                          b();
                                                          }

                                                          function a(){}

                                                          for (;;){
                                                          b();
                                                          }

                                                          try{} catch(a){}

                                                          class Foo{
                                                          constructor(){}
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are considered problems when configured { "functions": "never", "keywords": "always", classes: "never" }:

                                                          + +
                                                          /*eslint space-before-blocks: ["error", { "functions": "never", "keywords": "always", classes: "never" }]*/
                                                          /*eslint-env es6*/

                                                          function a() {}

                                                          try {} catch(a){}

                                                          class Foo{
                                                          constructor() {}
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems when configured { "functions": "never", "keywords": "always", classes: "never" }:

                                                          + +
                                                          /*eslint space-before-blocks: ["error", { "functions": "never", "keywords": "always", classes: "never" }]*/
                                                          /*eslint-env es6*/

                                                          for (;;) {
                                                          // ...
                                                          }

                                                          describe(function(){
                                                          // ...
                                                          });

                                                          class Foo {
                                                          constructor(){}
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are considered problems when configured { "functions": "always", "keywords": "never", classes: "never" }:

                                                          + +
                                                          /*eslint space-before-blocks: ["error", { "functions": "always", "keywords": "never", classes: "never" }]*/
                                                          /*eslint-env es6*/

                                                          function a(){}

                                                          try {} catch(a) {}

                                                          class Foo {
                                                          constructor(){}
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems when configured { "functions": "always", "keywords": "never", classes: "never" }:

                                                          + +
                                                          /*eslint space-before-blocks: ["error", { "functions": "always", "keywords": "never", classes: "never" }]*/
                                                          /*eslint-env es6*/

                                                          if (a){
                                                          b();
                                                          }

                                                          var a = function() {}

                                                          class Foo{
                                                          constructor() {}
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are considered problems when configured { "functions": "never", "keywords": "never", classes: "always" }:

                                                          + +
                                                          /*eslint space-before-blocks: ["error", { "functions": "never", "keywords": "never", classes: "always" }]*/
                                                          /*eslint-env es6*/

                                                          class Foo{
                                                          constructor(){}
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems when configured { "functions": "never", "keywords": "never", classes: "always" }:

                                                          + +
                                                          /*eslint space-before-blocks: ["error", { "functions": "never", "keywords": "never", classes: "always" }]*/
                                                          /*eslint-env es6*/

                                                          class Foo {
                                                          constructor(){}
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with the consistency of spacing before blocks or if you are using the space-after-keywords rule set to "never".

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.9.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/space-before-function-paren.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/space-before-function-paren.html new file mode 100644 index 0000000..88b217f --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/space-before-function-paren.html @@ -0,0 +1,107 @@ + + + +

                                                          Require or disallow a space before function parenthesis (space-before-function-paren)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          When formatting a function, whitespace is allowed between the function name or function keyword and the opening paren. Named functions also require a space between the function keyword and the function name, but anonymous functions require no whitespace. For example:

                                                          + +
                                                          function withoutSpace(x) {
                                                          // ...
                                                          }

                                                          function withSpace (x) {
                                                          // ...
                                                          }

                                                          var anonymousWithoutSpace = function() {};

                                                          var anonymousWithSpace = function () {};
                                                          +
                                                          + +

                                                          Style guides may require a space after the function keyword for anonymous functions, while others specify no whitespace. Similarly, the space after a function name may or may not be required.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to enforce consistent spacing before function parentheses and as such, will warn whenever whitespace doesn’t match the preferences specified.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule takes one argument. If it is "always" then all named functions and anonymous functions must have space before function parentheses. If "never" then all named functions and anonymous functions must not have space before function parentheses. If you want different spacing for named and anonymous functions you can pass a configuration object as the rule argument to configure those separately (e. g. {"anonymous": "always", "named": "never"}). In this case, you can use “ignore” to only apply the rule to one type of function (e. g. {"anonymous": "ignore", "named": "never"} will warn on spaces for named functions, but will not warn on anonymous functions one way or the other).

                                                          + +

                                                          The default configuration is "always".

                                                          + +

                                                          “always”

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint space-before-function-paren: "error"*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          // ...
                                                          }

                                                          var bar = function() {
                                                          // ...
                                                          };

                                                          var bar = function foo() {
                                                          // ...
                                                          };

                                                          class Foo {
                                                          constructor() {
                                                          // ...
                                                          }
                                                          }

                                                          var foo = {
                                                          bar() {
                                                          // ...
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-before-function-paren: "error"*/
                                                          /*eslint-env es6*/

                                                          function foo () {
                                                          // ...
                                                          }

                                                          var bar = function () {
                                                          // ...
                                                          };

                                                          var bar = function foo () {
                                                          // ...
                                                          };

                                                          class Foo {
                                                          constructor () {
                                                          // ...
                                                          }
                                                          }

                                                          var foo = {
                                                          bar () {
                                                          // ...
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          “never”

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint space-before-function-paren: ["error", "never"]*/
                                                          /*eslint-env es6*/

                                                          function foo () {
                                                          // ...
                                                          }

                                                          var bar = function () {
                                                          // ...
                                                          };

                                                          var bar = function foo () {
                                                          // ...
                                                          };

                                                          class Foo {
                                                          constructor () {
                                                          // ...
                                                          }
                                                          }

                                                          var foo = {
                                                          bar () {
                                                          // ...
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-before-function-paren: ["error", "never"]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          // ...
                                                          }

                                                          var bar = function() {
                                                          // ...
                                                          };

                                                          var bar = function foo() {
                                                          // ...
                                                          };

                                                          class Foo {
                                                          constructor() {
                                                          // ...
                                                          }
                                                          }

                                                          var foo = {
                                                          bar() {
                                                          // ...
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          {"anonymous": "always", "named": "never"}

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint space-before-function-paren: ["error", { "anonymous": "always", "named": "never" }]*/
                                                          /*eslint-env es6*/

                                                          function foo () {
                                                          // ...
                                                          }

                                                          var bar = function() {
                                                          // ...
                                                          };

                                                          class Foo {
                                                          constructor () {
                                                          // ...
                                                          }
                                                          }

                                                          var foo = {
                                                          bar () {
                                                          // ...
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-before-function-paren: ["error", { "anonymous": "always", "named": "never" }]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          // ...
                                                          }

                                                          var bar = function () {
                                                          // ...
                                                          };

                                                          class Foo {
                                                          constructor() {
                                                          // ...
                                                          }
                                                          }

                                                          var foo = {
                                                          bar() {
                                                          // ...
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          {"anonymous": "never", "named": "always"}

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint space-before-function-paren: ["error", { "anonymous": "never", "named": "always" }]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          // ...
                                                          }

                                                          var bar = function () {
                                                          // ...
                                                          };

                                                          class Foo {
                                                          constructor() {
                                                          // ...
                                                          }
                                                          }

                                                          var foo = {
                                                          bar() {
                                                          // ...
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-before-function-paren: ["error", { "anonymous": "never", "named": "always" }]*/
                                                          /*eslint-env es6*/

                                                          function foo () {
                                                          // ...
                                                          }

                                                          var bar = function() {
                                                          // ...
                                                          };

                                                          class Foo {
                                                          constructor () {
                                                          // ...
                                                          }
                                                          }

                                                          var foo = {
                                                          bar () {
                                                          // ...
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          {"anonymous": "ignore", "named": "always"}

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint space-before-function-paren: ["error", { "anonymous": "ignore", "named": "always" }]*/
                                                          /*eslint-env es6*/

                                                          function foo() {
                                                          // ...
                                                          }

                                                          class Foo {
                                                          constructor() {
                                                          // ...
                                                          }
                                                          }

                                                          var foo = {
                                                          bar() {
                                                          // ...
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-before-function-paren: ["error", { "anonymous": "ignore", "named": "always" }]*/
                                                          /*eslint-env es6*/

                                                          var bar = function() {
                                                          // ...
                                                          };

                                                          var bar = function () {
                                                          // ...
                                                          };

                                                          function foo () {
                                                          // ...
                                                          }

                                                          class Foo {
                                                          constructor () {
                                                          // ...
                                                          }
                                                          }

                                                          var foo = {
                                                          bar () {
                                                          // ...
                                                          }
                                                          };
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with the consistency of spacing before function parenthesis.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.18.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/space-in-parens.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/space-in-parens.html new file mode 100644 index 0000000..2c8ad20 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/space-in-parens.html @@ -0,0 +1,174 @@ + + + +

                                                          Disallow or enforce spaces inside of parentheses (space-in-parens)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Some style guides require or disallow spaces inside of parentheses:

                                                          + +
                                                          foo( 'bar' );
                                                          var x = ( 1 + 2 ) * 3;

                                                          foo('bar');
                                                          var x = (1 + 2) * 3;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule will enforce consistency of spacing directly inside of parentheses, by disallowing or requiring one or more spaces to the right of ( and to the left of ). In either case, () will still be allowed.

                                                          + +

                                                          Options

                                                          + +

                                                          There are two options for this rule:

                                                          + +
                                                            +
                                                          • "always" enforces a space inside of parentheses
                                                          • +
                                                          • "never" enforces zero spaces inside of parentheses (default)
                                                          • +
                                                          + +

                                                          Depending on your coding conventions, you can choose either option by specifying it in your configuration:

                                                          + +
                                                          "space-in-parens": ["error", "always"]
                                                          +
                                                          + +

                                                          “always”

                                                          + +

                                                          When "always" is set, the following patterns are considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "always"]*/

                                                          foo( 'bar');
                                                          foo('bar' );
                                                          foo('bar');

                                                          var foo = (1 + 2) * 3;
                                                          (function () { return 'bar'; }());
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "always"]*/

                                                          foo();

                                                          foo( 'bar' );

                                                          var foo = ( 1 + 2 ) * 3;
                                                          ( function () { return 'bar'; }() );
                                                          +
                                                          + +

                                                          “never”

                                                          + +

                                                          When "never" is used, the following patterns are considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "never"]*/

                                                          foo( 'bar');
                                                          foo('bar' );
                                                          foo( 'bar' );

                                                          var foo = ( 1 + 2 ) * 3;
                                                          ( function () { return 'bar'; }() );
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "never"]*/

                                                          foo();

                                                          foo('bar');

                                                          var foo = (1 + 2) * 3;
                                                          (function () { return 'bar'; }());
                                                          +
                                                          + +

                                                          Exceptions

                                                          + +

                                                          An object literal may be used as a third array item to specify exceptions, with the key "exceptions" and an array as the value. These exceptions work in the context of the first option. That is, if "always" is set to enforce spacing, then any “exception” will disallow spacing. Conversely, if "never" is set to disallow spacing, then any “exception” will enforce spacing.

                                                          + +

                                                          The following exceptions are available: ["{}", "[]", "()", "empty"].

                                                          + +

                                                          For example, given "space-in-parens": ["error", "always", { "exceptions": ["{}"] }], the following patterns are considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "always", { "exceptions": ["{}"] }]*/

                                                          foo( {bar: 'baz'} );
                                                          foo( 1, {bar: 'baz'} );
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "always", { "exceptions": ["{}"] }]*/

                                                          foo({bar: 'baz'});
                                                          foo( 1, {bar: 'baz'});
                                                          +
                                                          + +

                                                          Or, given "space-in-parens": ["error", "never", { "exceptions": ["{}"] }], the following patterns are considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "never", { "exceptions": ["{}"] }]*/

                                                          foo({bar: 'baz'});
                                                          foo(1, {bar: 'baz'});
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "never", { "exceptions": ["{}"] }]*/

                                                          foo( {bar: 'baz'} );
                                                          foo(1, {bar: 'baz'} );
                                                          +
                                                          + +

                                                          Given "space-in-parens": ["error", "always", { "exceptions": ["[]"] }], the following patterns are considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "always", { "exceptions": ["[]"] }]*/

                                                          foo( [bar, baz] );
                                                          foo( [bar, baz], 1 );
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "always", { "exceptions": ["[]"] }]*/

                                                          foo([bar, baz]);
                                                          foo([bar, baz], 1 );
                                                          +
                                                          + +

                                                          Or, given "space-in-parens": ["error", "never", { "exceptions": ["[]"] }], the following patterns are considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "never", { "exceptions": ["[]"] }]*/

                                                          foo([bar, baz]);
                                                          foo([bar, baz], 1);
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "never", { "exceptions": ["[]"] }]*/

                                                          foo( [bar, baz] );
                                                          foo( [bar, baz], 1);
                                                          +
                                                          + +

                                                          Given "space-in-parens": ["error", "always", { "exceptions": ["()"] }], the following patterns are considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "always", { "exceptions": ["()"] }]*/

                                                          foo( ( 1 + 2 ) );
                                                          foo( ( 1 + 2 ), 1 );
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "always", { "exceptions": ["()"] }]*/

                                                          foo(( 1 + 2 ));
                                                          foo(( 1 + 2 ), 1 );
                                                          +
                                                          + +

                                                          Or, given "space-in-parens": ["error", "never", { "exceptions": ["()"] }], the following patterns are considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "never", { "exceptions": ["()"] }]*/

                                                          foo((1 + 2));
                                                          foo((1 + 2), 1);
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "never", { "exceptions": ["()"] }]*/

                                                          foo( (1 + 2) );
                                                          foo( (1 + 2), 1);
                                                          +
                                                          + +

                                                          The "empty" exception concerns empty parentheses, and works the same way as the other exceptions, inverting the first option.

                                                          + +

                                                          For example, given "space-in-parens": ["error", "always", { "exceptions": ["empty"] }], the following patterns are considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "always", { "exceptions": ["empty"] }]*/

                                                          foo( );
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "always", { "exceptions": ["empty"] }]*/

                                                          foo();
                                                          +
                                                          + +

                                                          Or, given "space-in-parens": ["error", "never", { "exceptions": ["empty"] }], the following patterns are considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "never", { "exceptions": ["empty"] }]*/

                                                          foo();
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "never", { "exceptions": ["empty"] }]*/

                                                          foo( );
                                                          +
                                                          + +

                                                          You can include multiple entries in the "exceptions" array. For example, given "space-in-parens": ["error", "always", { "exceptions": ["{}", "[]"] }], the following patterns are considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "always", { "exceptions": ["{}", "[]"] }]*/

                                                          bar( {bar:'baz'} );
                                                          baz( 1, [1,2] );
                                                          foo( {bar: 'baz'}, [1, 2] );
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-in-parens: ["error", "always", { "exceptions": ["{}", "[]"] }]*/

                                                          bar({bar:'baz'});
                                                          baz( 1, [1,2]);
                                                          foo({bar: 'baz'}, [1, 2]);
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You can turn this rule off if you are not concerned with the consistency of spacing between parentheses.

                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.8.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/space-infix-ops.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/space-infix-ops.html new file mode 100644 index 0000000..af4d56d --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/space-infix-ops.html @@ -0,0 +1,59 @@ + + + +

                                                          Require Spaces Around Infix Operators (space-infix-ops)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          While formatting preferences are very personal, a number of style guides require spaces around operators, such as:

                                                          + +
                                                          var sum = 1 + 2;
                                                          +
                                                          + +

                                                          The proponents of these extra spaces believe it make the code easier to read and can more easily highlight potential errors, such as:

                                                          + +
                                                          var sum = i+++2;
                                                          +
                                                          + +

                                                          While this is valid JavaScript syntax, it is hard to determine what the author intended.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at ensuring there are spaces around infix operators.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule accepts a single options argument with the following defaults:

                                                          + +
                                                          "space-infix-ops": ["error", {"int32Hint": false}]
                                                          +
                                                          + +

                                                          int32Hint

                                                          + +

                                                          Set the int32Hint option to true (default is false) to allow write a|0 without space.

                                                          + +
                                                          var foo = bar|0; // `foo` is forced to be signed 32 bit integer
                                                          +
                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint space-infix-ops: "error"*/
                                                          /*eslint-env es6*/

                                                          a+b

                                                          a+ b

                                                          a +b

                                                          a?b:c

                                                          const a={b:1};

                                                          var {a=0}=bar;

                                                          function foo(a=0) { }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-infix-ops: "error"*/
                                                          /*eslint-env es6*/

                                                          a + b

                                                          a + b

                                                          a ? b : c

                                                          const a = {b:1};

                                                          var {a = 0} = bar;

                                                          function foo(a = 0) { }
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.2.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/space-unary-ops.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/space-unary-ops.html new file mode 100644 index 0000000..2ffa6de --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/space-unary-ops.html @@ -0,0 +1,68 @@ + + + +

                                                          Require or disallow spaces before/after unary operators (space-unary-ops)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Some styleguides require or disallow spaces before or after unary operators. This is mainly a stylistic issue, however, some JavaScript expressions can be written without spacing which makes it harder to read and maintain.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces consistency regarding the spaces after words unary operators and after/before nonwords unary operators.

                                                          + +

                                                          Examples of unary words operators:

                                                          + +
                                                          // new
                                                          var joe = new Person();

                                                          // delete
                                                          var obj = {
                                                          foo: 'bar'
                                                          };
                                                          delete obj.foo;

                                                          // typeof
                                                          typeof {} // object

                                                          // void
                                                          void 0 // undefined
                                                          +
                                                          + +

                                                          Examples of unary nonwords operators:

                                                          + +
                                                          if ([1,2,3].indexOf(1) !== -1) {};
                                                          foo = --foo;
                                                          bar = bar++;
                                                          baz = !foo;
                                                          qux = !!baz;
                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          This rule has three options:

                                                          + +
                                                            +
                                                          • words - applies to unary word operators such as: new, delete, typeof, void, yield
                                                          • +
                                                          • nonwords - applies to unary operators such as: -, +, --, ++, !, !!
                                                          • +
                                                          • overrides - specifies overwriting usage of spacing for each +operator, word or non word. This is empty by default, but can be used +to enforce or disallow spacing around operators. For example:
                                                          • +
                                                          + +
                                                              "space-unary-ops": [
                                                          2, {
                                                          "words": true,
                                                          "nonwords": false,
                                                          "overrides": {
                                                          "new": false,
                                                          "++": true
                                                          }
                                                          }]
                                                          +
                                                          + +

                                                          In this case, spacing will be disallowed after a new operator and required before/after a ++ operator.

                                                          + +

                                                          Given the default values words: true, nonwords: false, the following patterns are considered problems:

                                                          + +
                                                          /*eslint space-unary-ops: "error"*/

                                                          typeof!foo;

                                                          void{foo:0};

                                                          new[foo][0];

                                                          delete(foo.bar);

                                                          ++ foo;

                                                          foo --;

                                                          - foo;

                                                          + "3";
                                                          +
                                                          + +
                                                          /*eslint space-unary-ops: "error"*/
                                                          /*eslint-env es6*/

                                                          function *foo() {
                                                          yield(0)
                                                          }
                                                          +
                                                          + +

                                                          Given the default values words: true, nonwords: false, the following patterns are not considered problems:

                                                          + +
                                                          /*eslint space-unary-ops: "error"*/

                                                          // Word unary operator "delete" is followed by a whitespace.
                                                          delete foo.bar;

                                                          // Word unary operator "new" is followed by a whitespace.
                                                          new Foo;

                                                          // Word unary operator "void" is followed by a whitespace.
                                                          void 0;

                                                          // Unary operator "++" is not followed by whitespace.
                                                          ++foo;

                                                          // Unary operator "--" is not preceded by whitespace.
                                                          foo--;

                                                          // Unary operator "-" is not followed by whitespace.
                                                          -foo;

                                                          // Unary operator "+" is not followed by whitespace.
                                                          +"3";
                                                          +
                                                          + +
                                                          /*eslint space-unary-ops: "error"*/
                                                          /*eslint-env es6*/

                                                          function *foo() {
                                                          yield (0)
                                                          }
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.10.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/spaced-comment.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/spaced-comment.html new file mode 100644 index 0000000..8d91681 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/spaced-comment.html @@ -0,0 +1,164 @@ + + + +

                                                          Requires or disallows a whitespace (space or tab) beginning a comment (spaced-comment)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Some style guides require or disallow a whitespace immediately after the initial // or /* of a comment. +Whitespace after the // or /* makes it easier to read text in comments. +On the other hand, commenting out code is easier without having to put a whitespace right after the // or /*.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule will enforce consistency of spacing after the start of a comment // or /*. It also provides several +exceptions for various documentation styles.

                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes two options.

                                                          + +
                                                            +
                                                          • +

                                                            The first is a string which be either "always" or "never". The default is "always".

                                                            + +
                                                              +
                                                            • +

                                                              If "always" then the // or /* must be followed by at least one whitespace.

                                                              +
                                                            • +
                                                            • +

                                                              If "never" then there should be no whitespace following.

                                                              +
                                                            • +
                                                            +
                                                          • +
                                                          • +

                                                            This rule can also take a 2nd option, an object with either of the following keys: "exceptions" and "markers".

                                                            + +
                                                              +
                                                            • The "exceptions" value is an array of string patterns which are considered exceptions to the rule. + Please note that exceptions are ignored if the first argument is "never".
                                                            • +
                                                            + +

                                                            json + "spaced-comment": ["error", "always", { "exceptions": ["-", "+"] }] +

                                                            + +
                                                              +
                                                            • The "markers" value is an array of string patterns which are considered markers for docblock-style comments, + such as an additional /, used to denote documentation read by doxygen, vsdoc, etc. which must have additional characters. + The "markers" array will apply regardless of the value of the first argument, e.g. "always" or "never".
                                                            • +
                                                            + +

                                                            json + "spaced-comment": ["error", "always", { "markers": ["/"] }] +

                                                            +
                                                          • +
                                                          + +

                                                          The difference between a marker and an exception is that a marker only appears at the beginning of the comment whereas +exceptions can occur anywhere in the comment string.

                                                          + +

                                                          You can also define separate exceptions and markers for block and line comments:

                                                          + +
                                                          "spaced-comment": ["error", "always", {
                                                          "line": {
                                                          "markers": ["/"],
                                                          "exceptions": ["-", "+"]
                                                          },
                                                          "block": {
                                                          "markers": ["!"],
                                                          "exceptions": ["*"]
                                                          }
                                                          }]
                                                          +
                                                          + +

                                                          always

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint spaced-comment: ["error", "always"]*/

                                                          //This is a comment with no whitespace at the beginning

                                                          /*This is a comment with no whitespace at the beginning */
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /* eslint spaced-comment: ["error", "always"] */

                                                          // This is a comment with a whitespace at the beginning

                                                          /* This is a comment with a whitespace at the beginning */

                                                          /*
                                                          * This is a comment with a whitespace at the beginning
                                                          */


                                                          /*
                                                          This comment has a newline
                                                          */

                                                          +
                                                          + +
                                                          /* eslint spaced-comment: ["error", "always"] */

                                                          /**
                                                          * I am jsdoc
                                                          */

                                                          +
                                                          + +

                                                          never

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint spaced-comment: ["error", "never"]*/

                                                          // This is a comment with a whitespace at the beginning

                                                          /* This is a comment with a whitespace at the beginning */

                                                          /* \nThis is a comment with a whitespace at the beginning */
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint spaced-comment: ["error", "never"]*/

                                                          /*This is a comment with no whitespace at the beginning */
                                                          +
                                                          + +
                                                          /*eslint spaced-comment: ["error", "never"]*/

                                                          /**
                                                          * I am jsdoc
                                                          */

                                                          +
                                                          + +

                                                          exceptions

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /* eslint spaced-comment: ["error", "always", { "block": { "exceptions": ["-"] } }] */

                                                          //--------------
                                                          // Comment block
                                                          //--------------
                                                          +
                                                          + +
                                                          /* eslint spaced-comment: ["error", "always", { "exceptions": ["-", "+"] }] */

                                                          //------++++++++
                                                          // Comment block
                                                          //------++++++++
                                                          +
                                                          + +
                                                          /* eslint spaced-comment: ["error", "always", { "exceptions": ["-", "+"] }] */

                                                          /*------++++++++*/
                                                          /* Comment block */
                                                          /*------++++++++*/
                                                          +
                                                          + +
                                                          /* eslint spaced-comment: ["error", "always", { "line": { "exceptions": ["-+"] } }] */

                                                          /*-+-+-+-+-+-+-+*/
                                                          // Comment block
                                                          /*-+-+-+-+-+-+-+*/
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /* eslint spaced-comment: ["error", "always", { "exceptions": ["-"] }] */

                                                          //--------------
                                                          // Comment block
                                                          //--------------
                                                          +
                                                          + +
                                                          /* eslint spaced-comment: ["error", "always", { "line": { "exceptions": ["-"] } }] */

                                                          //--------------
                                                          // Comment block
                                                          //--------------
                                                          +
                                                          + +
                                                          /* eslint spaced-comment: ["error", "always", { "exceptions": ["*"] }] */

                                                          /****************
                                                          * Comment block
                                                          ****************/

                                                          +
                                                          + +
                                                          /* eslint spaced-comment: ["error", "always", { "exceptions": ["-+"] }] */

                                                          //-+-+-+-+-+-+-+
                                                          // Comment block
                                                          //-+-+-+-+-+-+-+

                                                          /*-+-+-+-+-+-+-+*/
                                                          // Comment block
                                                          /*-+-+-+-+-+-+-+*/
                                                          +
                                                          + +
                                                          /* eslint spaced-comment: ["error", "always", { "block": { "exceptions": ["-+"] } }] */

                                                          /*-+-+-+-+-+-+-+*/
                                                          // Comment block
                                                          /*-+-+-+-+-+-+-+*/
                                                          +
                                                          + +

                                                          markers

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /* eslint spaced-comment: ["error", "always", { "markers": ["/"] }] */

                                                          ///This is a comment with a marker but without whitespace
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /* eslint spaced-comment: ["error", "always", { "markers": ["/"] }] */

                                                          /// This is a comment with a marker
                                                          +
                                                          + +
                                                          /*eslint spaced-comment: ["error", "never", { "markers": ["!<"] }]*/

                                                          //!<This is a line comment with a marker

                                                          /*!<this is a block comment with a marker
                                                          subsequent lines are ignored
                                                          */

                                                          +
                                                          + +
                                                          /* eslint spaced-comment: ["error", "always", { "markers": ["global"] }] */

                                                          /*global ABC*/
                                                          +
                                                          + + + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.23.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/strict.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/strict.html new file mode 100644 index 0000000..8049779 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/strict.html @@ -0,0 +1,120 @@ + + + +

                                                          Strict Mode Directives (strict)

                                                          + +

                                                          A strict mode directive at the beginning of a script or function body enables strict mode semantics.

                                                          + +

                                                          When used globally, the entire script, including all contained functions, are strict mode code:

                                                          + +
                                                          "use strict";
                                                          +
                                                          + +

                                                          It is also possible to specify function-level strict mode, such that strict mode applies only to the function in which the directive occurs:

                                                          + +
                                                          function foo() {
                                                          "use strict";
                                                          return;
                                                          }

                                                          var bar = function() {
                                                          "use strict";
                                                          return;
                                                          };
                                                          +
                                                          + +

                                                          Unlike scripts, ECMAScript modules are always in strict mode. Strict mode directives in ECMAScript modules have no effect.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule is aimed at using strict mode directives effectively, and as such, will flag any unexpected uses or omissions of strict mode directives.

                                                          + +

                                                          Options

                                                          + +

                                                          There are four options for this rule:

                                                          + +
                                                            +
                                                          • "safe" - require "use strict" globally when inside a module wrapper and in function scopes everywhere else. This is the default.
                                                          • +
                                                          • "never" - disallow "use strict".
                                                          • +
                                                          • "global" - require "use strict" in the global scope.
                                                          • +
                                                          • "function" - require "use strict" in function scopes only.
                                                          • +
                                                          + +

                                                          All strict mode directives are flagged as unnecessary if ECMAScript modules or implied strict mode are enabled (see Specifying Parser Options). This behaviour does not depend on the rule options, but can be silenced by disabling this rule.

                                                          + +

                                                          safe

                                                          + +

                                                          Node.js and the CommonJS module system wrap modules inside a hidden function wrapper that defines each module’s scope. The wrapper makes it safe to concatenate strict mode modules while maintaining their original strict mode directives. When the node or commonjs environments are enabled or globalReturn is enabled in ecmaFeatures, ESLint considers code to be inside the module wrapper, and "safe" mode corresponds to "global" mode and enforces global strict mode directives. Everywhere else, "safe" mode corresponds to "function" mode and enforces strict mode directives inside top-level functions.

                                                          + +

                                                          never

                                                          + +

                                                          This mode forbids any occurrence of a strict mode directive.

                                                          + +

                                                          Examples of incorrect code for the "never" option:

                                                          + +
                                                          /*eslint strict: ["error", "never"]*/

                                                          "use strict";

                                                          function foo() {
                                                          "use strict";
                                                          return;
                                                          }

                                                          var bar = function() {
                                                          "use strict";
                                                          return;
                                                          };

                                                          foo();
                                                          bar();
                                                          +
                                                          + +

                                                          Examples of correct code for the "never" option:

                                                          + +
                                                          /*eslint strict: ["error", "never"]*/

                                                          function foo() {
                                                          return;
                                                          }

                                                          var bar = function() {
                                                          return;
                                                          };

                                                          foo();
                                                          bar();
                                                          +
                                                          + +

                                                          global

                                                          + +

                                                          This mode ensures that all code is in strict mode and that there are no extraneous strict mode directives at the top level or in nested functions, which are themselves already strict by virtue of being contained in strict global code. It requires that global code contains exactly one strict mode directive. Strict mode directives inside functions are considered unnecessary. Multiple strict mode directives at any level also trigger warnings.

                                                          + +

                                                          Examples of incorrect code for the "global" option:

                                                          + +
                                                          /*eslint strict: ["error", "global"]*/

                                                          "use strict";
                                                          "use strict";

                                                          function foo() {
                                                          "use strict";

                                                          return function() {
                                                          "use strict";
                                                          "use strict";

                                                          return;
                                                          };
                                                          }

                                                          foo();
                                                          +
                                                          + +

                                                          Examples of correct code for the "global" option:

                                                          + +
                                                          /*eslint strict: ["error", "global"]*/

                                                          "use strict";

                                                          function foo() {
                                                          return function() {
                                                          return;
                                                          };
                                                          }

                                                          foo();
                                                          +
                                                          + +

                                                          function

                                                          + +

                                                          This mode ensures that all function bodies are strict mode code, while global code is not. Particularly if a build step concatenates multiple scripts, a strict mode directive in global code of one script could unintentionally enable strict mode in another script that was not intended to be strict code. It forbids any occurrence of a strict mode directive in global code. It requires exactly one strict mode directive in each function declaration or expression whose parent is global code. Strict mode directives inside nested functions are considered unnecessary. Multiple strict mode directives at any level also trigger warnings.

                                                          + +

                                                          Examples of incorrect code for the "function" option:

                                                          + +
                                                          /*eslint strict: ["error", "function"]*/

                                                          "use strict";

                                                          function foo() {
                                                          // Missing strict mode directive

                                                          return function() {
                                                          "use strict"; // Unnecessary; parent should contain a strict mode directive
                                                          "use strict";

                                                          return;
                                                          };
                                                          }

                                                          foo();
                                                          +
                                                          + +

                                                          Examples of correct code for the "function" option:

                                                          + +
                                                          /*eslint strict: ["error", "function"]*/

                                                          function foo() {
                                                          "use strict";

                                                          return function() {
                                                          return;
                                                          };
                                                          }

                                                          (function() {
                                                          "use strict";

                                                          return;
                                                          }());

                                                          foo();
                                                          +
                                                          + +

                                                          earlier default (removed)

                                                          + +

                                                          Replacement notice: This mode, previously enabled by turning on the rule without specifying a mode, has been removed in ESLint v1.0. "function" mode is most similar to the deprecated behavior.

                                                          + +

                                                          This mode ensures that all functions are executed in strict mode. A strict mode directive must be present in global code or in every top-level function declaration or expression. It does not concern itself with unnecessary strict mode directives in nested functions that are already strict, nor with multiple strict mode directives at the same level.

                                                          + +

                                                          Examples of incorrect code for an earlier default option which has been removed:

                                                          + +
                                                          // "strict": "error"

                                                          function foo() {
                                                          return true;
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for an earlier default option which has been removed:

                                                          + +
                                                          // "strict": "error"

                                                          "use strict";

                                                          function foo() {
                                                          return true;
                                                          }
                                                          +
                                                          + +
                                                          // "strict": "error"

                                                          function foo() {

                                                          "use strict";

                                                          return true;
                                                          }
                                                          +
                                                          + +
                                                          // "strict": "error"

                                                          (function() {
                                                          "use strict";

                                                          // other code
                                                          }());
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          In a codebase that has both strict and non-strict code, either turn this rule off, or selectively disable it where necessary. For example, functions referencing arguments.callee are invalid in strict mode. A full list of strict mode differences is available on MDN.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.1.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/template-curly-spacing.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/template-curly-spacing.html new file mode 100644 index 0000000..395da2d --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/template-curly-spacing.html @@ -0,0 +1,65 @@ + + + +

                                                          Enforce Usage of Spacing in Template Strings (template-curly-spacing)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          We can embed expressions in template strings with using a pair of ${ and }. +This rule can force usage of spacing inside of the curly brace pair according to style guides.

                                                          + +
                                                          let hello = `hello, ${people.name}!`;
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to maintain consistency around the spacing inside of template literals.

                                                          + +

                                                          Options

                                                          + +
                                                          {
                                                          "template-curly-spacing": ["error", "never"]
                                                          }
                                                          +
                                                          + +

                                                          This rule has one option which has either "never" or "always" as value.

                                                          + +
                                                            +
                                                          • "never" (by default) - Disallows spaces inside of the curly brace pair.
                                                          • +
                                                          • "always" - Requires one or more spaces inside of the curly brace pair.
                                                          • +
                                                          + +

                                                          The following patterns are considered problems when configured "never":

                                                          + +
                                                          /*eslint template-curly-spacing: "error"*/

                                                          `hello, ${ people.name}!`;
                                                          `hello, ${people.name }!`;

                                                          `hello, ${ people.name }!`;
                                                          +
                                                          + +

                                                          The following patterns are considered problems when configured "always":

                                                          + +
                                                          /*eslint template-curly-spacing: ["error", "always"]*/

                                                          `hello, ${ people.name}!`;
                                                          `hello, ${people.name }!`;

                                                          `hello, ${people.name}!`;
                                                          +
                                                          + +

                                                          The following patterns are not considered problems when configured "never":

                                                          + +
                                                          /*eslint template-curly-spacing: "error"*/

                                                          `hello, ${people.name}!`;

                                                          `hello, ${
                                                          people.name
                                                          }!`;
                                                          +
                                                          + +

                                                          The following patterns are not considered problems when configured "always":

                                                          + +
                                                          /*eslint template-curly-spacing: ["error", "always"]*/

                                                          `hello, ${ people.name }!`;

                                                          `hello, ${
                                                          people.name
                                                          }!`;
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you don’t want to be notified about usage of spacing inside of template strings, then it’s safe to disable this rule.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-rc.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/use-isnan.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/use-isnan.html new file mode 100644 index 0000000..1a3a8fa --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/use-isnan.html @@ -0,0 +1,48 @@ + + + +

                                                          require calls to isNaN() when checking for NaN (use-isnan)

                                                          + +

                                                          In JavaScript, NaN is a special value of the Number type. It’s used to represent any of the “not-a-number” values represented by the double-precision 64-bit format as specified by the IEEE Standard for Binary Floating-Point Arithmetic.

                                                          + +

                                                          Because NaN is unique in JavaScript by not being equal to anything, including itself, the results of comparisons to NaN are confusing:

                                                          + +
                                                            +
                                                          • NaN === NaN or NaN == NaN evaluate to false
                                                          • +
                                                          • NaN !== NaN or NaN != NaN evaluate to true
                                                          • +
                                                          + +

                                                          Therefore, use Number.isNaN() or global isNaN() functions to test whether a value is NaN.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule disallows comparisons to ‘NaN’.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint use-isnan: "error"*/

                                                          if (foo == NaN) {
                                                          // ...
                                                          }

                                                          if (foo != NaN) {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint use-isnan: "error"*/

                                                          if (isNaN(foo)) {
                                                          // ...
                                                          }

                                                          if (!isNaN(foo)) {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.6.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/valid-jsdoc.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/valid-jsdoc.html new file mode 100644 index 0000000..263f1e2 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/valid-jsdoc.html @@ -0,0 +1,121 @@ + + + +

                                                          Validates JSDoc comments are syntactically correct (valid-jsdoc)

                                                          + +

                                                          JSDoc is a JavaScript API documentation generator. It uses specially-formatted comments inside of code to generate API documentation automatically. For example, this is what a JSDoc comment looks like for a function:

                                                          + +
                                                          /**
                                                          * Adds two numbers together.
                                                          * @param {int} num1 The first number.
                                                          * @param {int} num2 The second number.
                                                          * @returns {int} The sum of the two numbers.
                                                          */

                                                          function sum(num1, num2) {
                                                          return num1 + num2;
                                                          }
                                                          +
                                                          + +

                                                          The JSDoc comments have a syntax all their own, and it is easy to mistakenly mistype a comment because comments aren’t often checked for correctness in editors. Further, it’s very easy for the function definition to get out of sync with the comments, making the comments a source of confusion and error.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to prevent invalid and incomplete JSDoc comments. It will warn when any of the following is true:

                                                          + +
                                                            +
                                                          • There is a JSDoc syntax error
                                                          • +
                                                          • A @param or @returns is used without a type specified
                                                          • +
                                                          • A @param or @returns is used without a description
                                                          • +
                                                          • A comment for a function is missing @returns
                                                          • +
                                                          • A parameter has no associated @param in the JSDoc comment
                                                          • +
                                                          • @params are out of order with named arguments
                                                          • +
                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint valid-jsdoc: "error"*/

                                                          // missing type for @param and missing @returns
                                                          /** // 2 errors
                                                          * A description
                                                          * @param num1 The first number.
                                                          */

                                                          function foo(num1) {
                                                          // ...
                                                          }

                                                          // missing description for @param
                                                          /** //error Missing JSDoc parameter description for 'num1'.
                                                          * A description
                                                          * @param {int} num1
                                                          * @returns {void}
                                                          */

                                                          function foo(num1) {
                                                          // ...
                                                          }

                                                          // no description for @returns
                                                          /** //error Missing JSDoc return description.
                                                          * A description
                                                          * @returns {int}
                                                          */

                                                          function foo() {
                                                          // ...
                                                          }

                                                          // no type for @returns
                                                          /** //error JSDoc syntax error.
                                                          * A description
                                                          * @returns Something awesome
                                                          */

                                                          function foo() {
                                                          // ...
                                                          }

                                                          // missing @param
                                                          /** //error Missing JSDoc for parameter 'a'.
                                                          * A description
                                                          * @returns {void}
                                                          */

                                                          function foo(a) {
                                                          // ...
                                                          }

                                                          // incorrect @param
                                                          /** //error Expected JSDoc for 'a' but found 'b'.
                                                          * A description
                                                          * @param {string} b Desc
                                                          * @returns {void}
                                                          */

                                                          function foo(a) {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint valid-jsdoc: "error"*/

                                                          /**
                                                          * Adds two numbers together.
                                                          * @param {int} num1 The first number.
                                                          * @param {int} num2 The second number.
                                                          * @returns {int} The sum of the two numbers.
                                                          */

                                                          function foo(num1, num2) {
                                                          return num1 + num2;
                                                          }

                                                          /**
                                                          * Represents a sum.
                                                          * @param {int} num1 The first number.
                                                          * @param {int} num2 The second number.
                                                          * @constructor
                                                          */

                                                          function foo(num1, num2) { }

                                                          // use of @override make @param and @returns optional
                                                          /**
                                                          * A description
                                                          * @override
                                                          */

                                                          function foo(a) {
                                                          return a;
                                                          }

                                                          // @returns is not required for a constructor
                                                          class Foo {
                                                          /**
                                                          *
                                                          * @param {int} num1 The first number.
                                                          */

                                                          constructor(num1) {
                                                          this.num1 = num1;
                                                          }
                                                          }

                                                          // @returns allowed without return if used with @abstract
                                                          class Foo {
                                                          /**
                                                          * @abstract
                                                          * @return {Number} num
                                                          */

                                                          abstractMethod () {
                                                          throw new Error('Not implemented');
                                                          }
                                                          }

                                                          +
                                                          + +

                                                          Options

                                                          + +

                                                          prefer

                                                          + +

                                                          JSDoc offers a lot of tags with overlapping meaning. For example, both @return and @returns are acceptable for specifying the return value of a function. However, you may want to enforce a certain tag be used instead of others. You can specify your preferences regarding tag substitution by providing a mapping called prefer in the rule configuration. For example, to specify that @returns should be used instead of @return, you can use the following configuration:

                                                          + +
                                                          "valid-jsdoc": ["error", {
                                                          "prefer": {
                                                          "return": "returns"
                                                          }
                                                          }]
                                                          +
                                                          + +

                                                          With this configuration, ESLint will warn when it finds @return and recommend to replace it with @returns.

                                                          + +

                                                          requireReturn

                                                          + +

                                                          By default ESLint requires you to document every function with a @return tag regardless of whether there is anything returned by the function. If instead you want to enforce that only functions with a return statement are documented with a @return tag, set the requireReturn option to false. When requireReturn is false, every function documented with a @return tag must have a return statement, and every function with a return statement must have a @return tag.

                                                          + +
                                                          "valid-jsdoc": ["error", {
                                                          "requireReturn": false
                                                          }]
                                                          +
                                                          + +

                                                          requireParamDescription

                                                          + +

                                                          By default ESLint requires you to specify a description for each @param. You can choose not to require descriptions for parameters by setting requireParamDescription to false.

                                                          + +
                                                          "valid-jsdoc": ["error", {
                                                          "requireParamDescription": false
                                                          }]
                                                          +
                                                          + +

                                                          requireReturnDescription

                                                          + +

                                                          By default ESLint requires you to specify a description for each @return. You can choose not to require descriptions for @return by setting requireReturnDescription to false.

                                                          + +
                                                          "valid-jsdoc": ["error", {
                                                          "requireReturnDescription": false
                                                          }]
                                                          +
                                                          + +

                                                          matchDescription

                                                          + +

                                                          Specify a regular expression to validate jsdoc comment block description against.

                                                          + +
                                                          "valid-jsdoc": ["error", {
                                                          "matchDescription": "^[A-Z][A-Za-z0-9\\s]*[.]$"
                                                          }]
                                                          +
                                                          + +

                                                          requireReturnType

                                                          + +

                                                          By default ESLint requires you to specify type for @return tag for every documented function.

                                                          + +
                                                          "valid-jsdoc": ["error", {
                                                          "requireReturnType": false
                                                          }]
                                                          +
                                                          + +

                                                          preferType

                                                          + +

                                                          It will validate all the types from jsdoc with the options setup by the user. Inside the options, key should be what the type you want to check and the value of it should be what the expected type should be. Note that we don’t check for spelling mistakes with this option. +In the example below, it will expect the “object” to start with an uppercase and all the “string” type to start with a lowercase.

                                                          + +
                                                          "valid-jsdoc": ["error", {
                                                          "preferType": {
                                                          "String": "string",
                                                          "object": "Object",
                                                          "test": "TesT"
                                                          }
                                                          }]
                                                          +
                                                          + +

                                                          Examples of incorrect code for a sample of "preferType" options:

                                                          + +
                                                          /*eslint valid-jsdoc: ["error", { "preferType": { "String": "string", "object": "Object", "test": "TesT" } }]*/

                                                          /**
                                                          * Adds two numbers together.
                                                          * @param {String} param1 The first parameter.
                                                          * @returns {object} The sum of the two numbers.
                                                          */

                                                          function foo(param1) {
                                                          return {a: param1};
                                                          }

                                                          /**
                                                          * Adds two numbers together.
                                                          * @param {Array<String>} param1 The first parameter.
                                                          * @param param2 The second parameter.
                                                          * @returns {object} The sum of the two numbers.
                                                          */

                                                          function foo(param1, param2) {
                                                          return {a: param1};
                                                          }

                                                          /**
                                                          * Adds two numbers together.
                                                          * @param {String|int} param1 The first parameter.
                                                          * @returns {object} The sum of the two numbers.
                                                          */

                                                          function foo(param1) {
                                                          return {a: param1};
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for a sample of "preferType" options:

                                                          + +
                                                          /*eslint valid-jsdoc: ["error", { "preferType": { "String": "string", "object": "Object", "test": "TesT" } }]*/

                                                          /**
                                                          * Adds two numbers together.
                                                          * @param {string} param1 The first parameter.
                                                          * @returns {Object} The sum of the two numbers.
                                                          */

                                                          function foo(param1) {
                                                          return {a: param1};
                                                          }

                                                          /**
                                                          * Adds two numbers together.
                                                          * @param {Array<string>} param1 The first parameter.
                                                          * @param param2 The second parameter.
                                                          * @returns {Object} The sum of the two numbers.
                                                          */

                                                          function foo(param1, param2) {
                                                          return {a: param1};
                                                          }

                                                          /**
                                                          * Adds two numbers together.
                                                          * @param {string|int} param1 The first parameter.
                                                          * @returns {Object} The sum of the two numbers.
                                                          */

                                                          function foo(param1) {
                                                          return {a: param1};
                                                          }
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If you aren’t using JSDoc, then you can safely turn this rule off.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.4.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/valid-typeof.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/valid-typeof.html new file mode 100644 index 0000000..f1c1643 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/valid-typeof.html @@ -0,0 +1,37 @@ + + + +

                                                          enforce comparing typeof expressions against valid strings (valid-typeof)

                                                          + +

                                                          For a vast majority of use cases, the result of the typeof operator is one of the following string literals: "undefined", "object", "boolean", "number", "string", "function" and "symbol". It is usually a typing mistake to compare the result of a typeof operator to other string literals.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces comparing typeof expressions to valid string literals.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint valid-typeof: "error"*/

                                                          typeof foo === "strnig"
                                                          typeof foo == "undefimed"
                                                          typeof bar != "nunber"
                                                          typeof bar !== "fucntion"
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint valid-typeof: "error"*/

                                                          typeof foo === "string"
                                                          typeof bar == "undefined"
                                                          typeof foo === baz
                                                          typeof bar === typeof qux
                                                          +
                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          You may want to turn this rule off if you will be using the typeof operator on host objects.

                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.5.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/vars-on-top.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/vars-on-top.html new file mode 100644 index 0000000..bfd932b --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/vars-on-top.html @@ -0,0 +1,54 @@ + + + +

                                                          Require Variable Declarations to be at the top of their scope (vars-on-top)

                                                          + +

                                                          The vars-on-top rule generates warnings when variable declarations are not used serially at the top of a function scope or the top of a program. +By default variable declarations are always moved (“hoisted”) invisibly to the top of their containing scope by the JavaScript interpreter. +This rule forces the programmer to represent that behaviour by manually moving the variable declaration to the top of its containing scope.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to keep all variable declarations in the leading series of statements. +Allowing multiple declarations helps promote maintainability and is thus allowed.

                                                          + +

                                                          Examples of incorrect code for this rule:

                                                          + +
                                                          /*eslint vars-on-top: "error"*/

                                                          // Variable declarations in a block:
                                                          function doSomething() {
                                                          var first;
                                                          if (true) {
                                                          first = true;
                                                          }
                                                          var second;
                                                          }

                                                          // Variable declaration in for initializer:
                                                          function doSomething() {
                                                          for (var i=0; i<10; i++) {}
                                                          }
                                                          +
                                                          + +
                                                          /*eslint vars-on-top: "error"*/

                                                          // Variables after other statements:
                                                          f();
                                                          var a;
                                                          +
                                                          + +

                                                          Examples of correct code for this rule:

                                                          + +
                                                          /*eslint vars-on-top: "error"*/

                                                          function doSomething() {
                                                          var first;
                                                          var second; //multiple declarations are allowed at the top
                                                          if (true) {
                                                          first = true;
                                                          }
                                                          }

                                                          function doSomething() {
                                                          var i;
                                                          for (i=0; i<10; i++) {}
                                                          }
                                                          +
                                                          + +
                                                          /*eslint vars-on-top: "error"*/

                                                          var a;
                                                          f();
                                                          +
                                                          + +
                                                          /*eslint vars-on-top: "error"*/

                                                          // Directives may precede variable declarations.
                                                          "use strict";
                                                          var a;
                                                          f();

                                                          // Comments can describe variables.
                                                          function doSomething() {
                                                          // this is the first var.
                                                          var first;
                                                          // this is the second var.
                                                          var second
                                                          }
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.8.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/wrap-iife.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/wrap-iife.html new file mode 100644 index 0000000..506635a --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/wrap-iife.html @@ -0,0 +1,72 @@ + + + +

                                                          Require IIFEs to be Wrapped (wrap-iife)

                                                          + +

                                                          You can immediately invoke function expressions, but not function declarations. A common technique to create an immediately-invoked function expression (IIFE) is to wrap a function declaration in parentheses. The opening parentheses causes the contained function to be parsed as an expression, rather than a declaration.

                                                          + +
                                                          // function expression could be unwrapped
                                                          var x = function () { return { y: 1 };}();

                                                          // function declaration must be wrapped
                                                          function () { /* side effects */ }(); // SyntaxError
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule requires all immediately-invoked function expressions to be wrapped in parentheses.

                                                          + +

                                                          Options

                                                          + +

                                                          The rule takes one option which can enforce a consistent wrapping style:

                                                          + +
                                                            +
                                                          • "outside" enforces always wrapping the call expression. The default is "outside".
                                                          • +
                                                          • "inside" enforces always wrapping the function expression.
                                                          • +
                                                          • "any" enforces always wrapping, but allows either style.
                                                          • +
                                                          + +

                                                          outside

                                                          + +

                                                          Examples of incorrect code for the default "outside" option:

                                                          + +
                                                          /*eslint wrap-iife: ["error", "outside"]*/

                                                          var x = function () { return { y: 1 };}(); // unwrapped
                                                          var x = (function () { return { y: 1 };})(); // wrapped function expression
                                                          +
                                                          + +

                                                          Examples of correct code for the default "outside" option:

                                                          + +
                                                          /*eslint wrap-iife: ["error", "outside"]*/

                                                          var x = (function () { return { y: 1 };}()); // wrapped call expression
                                                          +
                                                          + +

                                                          inside

                                                          + +

                                                          Examples of incorrect code for the "inside" option:

                                                          + +
                                                          /*eslint wrap-iife: ["error", "inside"]*/

                                                          var x = function () { return { y: 1 };}(); // unwrapped
                                                          var x = (function () { return { y: 1 };}()); // wrapped call expression
                                                          +
                                                          + +

                                                          Examples of correct code for the "inside" option:

                                                          + +
                                                          /*eslint wrap-iife: ["error", "inside"]*/

                                                          var x = (function () { return { y: 1 };})(); // wrapped function expression
                                                          +
                                                          + +

                                                          any

                                                          + +

                                                          Examples of incorrect code for the "any" option:

                                                          + +
                                                          /*eslint wrap-iife: ["error", "any"]*/

                                                          var x = function () { return { y: 1 };}(); // unwrapped
                                                          +
                                                          + +

                                                          Examples of correct code for the "any" option:

                                                          + +
                                                          /*eslint wrap-iife: ["error", "any"]*/

                                                          var x = (function () { return { y: 1 };}()); // wrapped call expression
                                                          var x = (function () { return { y: 1 };})(); // wrapped function expression
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.0.9.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/wrap-regex.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/wrap-regex.html new file mode 100644 index 0000000..e2d71c2 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/wrap-regex.html @@ -0,0 +1,36 @@ + + + +

                                                          Require Regex Literals to be Wrapped (wrap-regex)

                                                          + +

                                                          When a regular expression is used in certain situations, it can end up looking like a division operator. For example:

                                                          + +
                                                          function a() {
                                                          return /foo/.test("bar");
                                                          }
                                                          +
                                                          + +

                                                          Rule Details

                                                          + +

                                                          This is used to disambiguate the slash operator and facilitates more readable code.

                                                          + +

                                                          The following patterns are considered problems:

                                                          + +
                                                          /*eslint wrap-regex: "error"*/

                                                          function a() {
                                                          return /foo/.test("bar");
                                                          }
                                                          +
                                                          + +

                                                          The following patterns are not considered problems:

                                                          + +
                                                          /*eslint wrap-regex: "error"*/

                                                          function a() {
                                                          return (/foo/).test("bar");
                                                          }
                                                          +
                                                          + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.1.0.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/yield-star-spacing.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/yield-star-spacing.html new file mode 100644 index 0000000..c1e01c1 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/yield-star-spacing.html @@ -0,0 +1,86 @@ + + + +

                                                          Enforce spacing around the * in yield* expressions (yield-star-spacing)

                                                          + +

                                                          The --fix option on the command line automatically fixes problems reported by this rule.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule enforces spacing around the * in yield* expressions.

                                                          + +

                                                          The rule takes one option, an object, which has two keys before and after having boolean values true or false.

                                                          + +
                                                            +
                                                          • +

                                                            before enforces spacing between the yield and the *. +If true, a space is required, otherwise spaces are disallowed.

                                                            +
                                                          • +
                                                          • +

                                                            after enforces spacing between the * and the argument. +If it is true, a space is required, otherwise spaces are disallowed.

                                                            +
                                                          • +
                                                          + +

                                                          The default is {"before": false, "after": true}.

                                                          + +
                                                          "yield-star-spacing": ["error", {"before": true, "after": false}]
                                                          +
                                                          + +

                                                          The option also has a string shorthand:

                                                          + +
                                                            +
                                                          • {"before": false, "after": true}"after"
                                                          • +
                                                          • {"before": true, "after": false}"before"
                                                          • +
                                                          • {"before": true, "after": true}"both"
                                                          • +
                                                          • {"before": false, "after": false}"neither"
                                                          • +
                                                          + +
                                                          "yield-star-spacing": ["error", "after"]
                                                          +
                                                          + +

                                                          When using "after" this spacing will be enforced:

                                                          + +
                                                          /*eslint yield-star-spacing: ["error", "after"]*/
                                                          /*eslint-env es6*/

                                                          function* generator() {
                                                          yield* other();
                                                          }
                                                          +
                                                          + +

                                                          When using "before" this spacing will be enforced:

                                                          + +
                                                          /*eslint yield-star-spacing: ["error", "before"]*/
                                                          /*eslint-env es6*/

                                                          function *generator() {
                                                          yield *other();
                                                          }
                                                          +
                                                          + +

                                                          When using "both" this spacing will be enforced:

                                                          + +
                                                          /*eslint yield-star-spacing: ["error", "both"]*/
                                                          /*eslint-env es6*/

                                                          function * generator() {
                                                          yield * other();
                                                          }
                                                          +
                                                          + +

                                                          When using "neither" this spacing will be enforced:

                                                          + +
                                                          /*eslint yield-star-spacing: ["error", "neither"]*/
                                                          /*eslint-env es6*/

                                                          function*generator() {
                                                          yield*other();
                                                          }
                                                          +
                                                          + +

                                                          To use this rule you either need to use the es6 environment or +set ecmaVersion to 6 in parserOptions.

                                                          + +

                                                          When Not To Use It

                                                          + +

                                                          If your project will not be using generators or you are not concerned with spacing consistency, you do not need this rule.

                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 2.0.0-alpha-1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/eslint/yoda.html b/sonar-web-frontend-js/src/main/resources/rules/eslint/yoda.html new file mode 100644 index 0000000..80a5ff1 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/eslint/yoda.html @@ -0,0 +1,100 @@ + + + +

                                                          Require or disallow Yoda Conditions (yoda)

                                                          + +

                                                          Yoda conditions are so named because the literal value of the condition comes first while the variable comes second. For example, the following is a Yoda condition:

                                                          + +
                                                          if ("red" === color) {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          This is called a Yoda condition because it reads as, “red is the color”, similar to the way the Star Wars character Yoda speaks. Compare to the other way of arranging the operands:

                                                          + +
                                                          if (color === "red") {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          This typically reads, “color is red”, which is arguably a more natural way to describe the comparison.

                                                          + +

                                                          Proponents of Yoda conditions highlight that it is impossible to mistakenly use = instead of == because you cannot assign to a literal value. Doing so will cause a syntax error and you will be informed of the mistake early on. This practice was therefore very common in early programming where tools were not yet available.

                                                          + +

                                                          Opponents of Yoda conditions point out that tooling has made us better programmers because tools will catch the mistaken use of = instead of == (ESLint will catch this for you). Therefore, they argue, the utility of the pattern doesn’t outweigh the readability hit the code takes while using Yoda conditions.

                                                          + +

                                                          Rule Details

                                                          + +

                                                          This rule aims to enforce consistent style of conditions which compare a variable to a literal value.

                                                          + +

                                                          Options

                                                          + +

                                                          This rule can take a string option:

                                                          + +
                                                            +
                                                          • If it is the default "never", then comparisons must never be Yoda conditions.
                                                          • +
                                                          • If it is "always", then the literal value must always come first.
                                                          • +
                                                          + +

                                                          The default "never" option can have exception options in an object literal:

                                                          + +
                                                            +
                                                          • If the "exceptRange" property is true, the rule allows yoda conditions in range comparisons which are wrapped directly in parentheses, including the parentheses of an if or while condition. The default value is false. A range comparison tests whether a variable is inside or outside the range between two literal values.
                                                          • +
                                                          • If the "onlyEquality" property is true, the rule reports yoda conditions only for the equality operators == and ===. The default value is false.
                                                          • +
                                                          + +

                                                          The onlyEquality option allows a superset of the exceptions which exceptRange allows, thus both options are not useful together.

                                                          + +

                                                          never

                                                          + +

                                                          Examples of incorrect code for the default "never" option:

                                                          + +
                                                          /*eslint yoda: "error"*/

                                                          if ("red" === color) {
                                                          // ...
                                                          }

                                                          if (true == flag) {
                                                          // ...
                                                          }

                                                          if (5 > count) {
                                                          // ...
                                                          }

                                                          if (-1 < str.indexOf(substr)) {
                                                          // ...
                                                          }

                                                          if (0 <= x && x < 1) {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for the default "never" option:

                                                          + +
                                                          /*eslint yoda: "error"*/

                                                          if (5 & value) {
                                                          // ...
                                                          }

                                                          if (value === "red") {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          exceptRange

                                                          + +

                                                          Examples of correct code for the "never", { "exceptRange": true } options:

                                                          + +
                                                          /*eslint yoda: ["error", "never", { "exceptRange": true }]*/

                                                          function isReddish(color) {
                                                          return (color.hue < 60 || 300 < color.hue);
                                                          }

                                                          if (x < -1 || 1 < x) {
                                                          // ...
                                                          }

                                                          if (count < 10 && (0 <= rand && rand < 1)) {
                                                          // ...
                                                          }

                                                          function howLong(arr) {
                                                          return (0 <= arr.length && arr.length < 10) ? "short" : "long";
                                                          }
                                                          +
                                                          + +

                                                          onlyEquality

                                                          + +

                                                          Examples of correct code for the "never", { "onlyEquality": true } options:

                                                          + +
                                                          /*eslint yoda: ["error", "never", { "onlyEquality": true }]*/

                                                          if (x < -1 || 9 < x) {
                                                          }

                                                          if (x !== 'foo' && 'bar' != x) {
                                                          }
                                                          +
                                                          + +

                                                          always

                                                          + +

                                                          Examples of incorrect code for the "always" option:

                                                          + +
                                                          /*eslint yoda: ["error", "always"]*/

                                                          if (color == "blue") {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Examples of correct code for the "always" option:

                                                          + +
                                                          /*eslint yoda: ["error", "always"]*/

                                                          if ("blue" == value) {
                                                          // ...
                                                          }

                                                          if (-1 < str.indexOf(substr)) {
                                                          // ...
                                                          }
                                                          +
                                                          + +

                                                          Further Reading

                                                          + + + +

                                                          Version

                                                          + +

                                                          This rule was introduced in ESLint 0.7.1.

                                                          + +

                                                          Resources

                                                          + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint.css b/sonar-web-frontend-js/src/main/resources/rules/jshint.css index dc73024..5fd44fc 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint.css +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint.css @@ -1 +1,2 @@ -#crd .row{zoom:1}#crd .row:after{content:"";display:table;clear:both}#crd .col-md-6{float:left;width:50%;padding-left:15px;padding-right:15px;position:relative;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}#crd table{width:100%}#crd .pull-right{float:right!important}#crd blockquote{padding:10.5px 21px;border-left:5px solid #ddd;border-left-width:1px;color:#6f6f6f;margin:20px 0;font-size:14px;border-left-color:#e9e9e9;background-color:#f7f7f7}#crd blockquote ol:last-child,#crd blockquote p:last-child,#crd blockquote ul:last-child{margin-bottom:0}#crd code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,"Courier New",monospace}#crd code{padding:2px 4px;font-size:90%;color:#c7254e;background-color:#f9f2f4;white-space:nowrap;border-radius:0}#crd .CodeMirror{font-family:monospace;background-color:#f7f7f7!important;line-height:1.3!important}#crd .CodeMirror+p{margin-top:15px}#crd .CodeMirror-scroll{overflow:auto}#crd .CodeMirror-lines{padding:4px 0}#crd .CodeMirror pre{padding:0 4px!important}#crd .CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{background-color:#fff}#crd .CodeMirror-gutters{border-right:1px solid #ccc;background-color:#e9e9e9;white-space:nowrap}#crd .CodeMirror-linenumber{padding:0 5px;min-width:20px;text-align:right;color:#999;-moz-box-sizing:content-box;box-sizing:content-box}#crd .CodeMirror div.CodeMirror-cursor{border-left:1px solid #000}#crd .CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}#crd .CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor{width:auto;border:0;background:#7e7}#crd .cm-tab{display:inline-block}#crd .CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}#crd .cm-s-default .cm-keyword{color:#708}#crd .cm-s-default .cm-atom{color:#219}#crd .cm-s-default .cm-number{color:#164}#crd .cm-s-default .cm-def{color:#00f}#crd .cm-s-default .cm-variable{color:#000}#crd .cm-s-default .cm-variable-2{color:#05a}#crd .cm-s-default .cm-variable-3{color:#085}#crd .cm-s-default .cm-operator,#crd .cm-s-default .cm-property{color:#000}#crd .cm-s-default .cm-comment{color:#a50}#crd .cm-s-default .cm-string{color:#a11}#crd .cm-s-default .cm-string-2{color:#f50}#crd .cm-s-default .cm-meta,#crd .cm-s-default .cm-qualifier{color:#555}#crd .cm-s-default .cm-builtin{color:#30a}#crd .cm-s-default .cm-bracket{color:#997}#crd .cm-s-default .cm-tag{color:#170}#crd .cm-s-default .cm-attribute{color:#00c}#crd .cm-s-default .cm-header{color:#00f}#crd .cm-s-default .cm-quote{color:#090}#crd .cm-s-default .cm-hr{color:#999}#crd .cm-s-default .cm-link{color:#00c}#crd .cm-negative{color:#d44}#crd .cm-positive{color:#292}#crd .cm-header,#crd .cm-strong{font-weight:700}#crd .cm-em{font-style:italic}#crd .cm-link{text-decoration:underline}#crd .cm-invalidchar,#crd .cm-s-default .cm-error{color:red}#crd div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}#crd div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}#crd .CodeMirror-activeline-background{background:#e8f2ff}#crd .CodeMirror{position:relative;overflow:hidden;background:#fff;color:#000}#crd .CodeMirror-scroll{margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative;-moz-box-sizing:content-box;box-sizing:content-box}#crd .CodeMirror-sizer{position:relative;border-right:30px solid transparent;-moz-box-sizing:content-box;box-sizing:content-box}#crd .CodeMirror-gutter-filler,#crd .CodeMirror-hscrollbar,#crd .CodeMirror-scrollbar-filler,#crd .CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}#crd .CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}#crd .CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}#crd .CodeMirror-scrollbar-filler{right:0;bottom:0}#crd .CodeMirror-gutter-filler{left:0;bottom:0}#crd .CodeMirror-gutters{position:absolute;left:0;top:0;padding-bottom:30px;z-index:3}#crd .CodeMirror-gutter{white-space:normal;height:100%;-moz-box-sizing:content-box;box-sizing:content-box;padding-bottom:30px;margin-bottom:-32px;display:inline-block}#crd .CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}#crd .CodeMirror-lines{cursor:text}#crd .CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0!important;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible}#crd .editor .lint .dropdown-menu button,#crd .editor .lint .dropdown-menu input,#crd .editor .lint .dropdown-menu label,#crd .errors{font-size:14px}#crd .CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}#crd .CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}#crd .CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}#crd .CodeMirror-wrap .CodeMirror-scroll{overflow-x:hidden}#crd .CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}#crd .CodeMirror-measure pre{position:static}#crd .CodeMirror div.CodeMirror-cursor{position:absolute;border-right:none;width:0}#crd div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:1}#crd .CodeMirror-focused div.CodeMirror-cursors{visibility:visible}#crd .CodeMirror-selected{background:#d9d9d9}#crd .CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}#crd .cm-searching{background:#ffa;background:rgba(255,255,0,.4)}#crd .cm-force-border{padding-right:.1px}@media print{#crd .CodeMirror div.CodeMirror-cursors{visibility:hidden}}#crd .editor{margin-top:30px;margin-bottom:30px}#crd .editor iframe{display:none}#crd .editor .lint{color:#fff;padding:8px}#crd .editor .lint.success{background-color:#2e953d}#crd .editor .lint.error{background-color:#c4291e}#crd .editor .lint .glyphicon{margin-top:2px;color:#fff;display:none}#crd .editor .lint .glyphicon:hover{color:#ddd}#crd .editor .lint .dropdown-menu{color:#333;font-size:14px;padding:10px;margin-right:15px;position:absolute;top:40px;display:none}#crd .editor .lint .dropdown-menu form{margin:10px 0}#crd .editor .version{margin-right:10px;margin-top:2px}#crd .editor .versions tr:first-child td{border-top:none}#crd .editor .version-actions .done{color:#aaa;cursor:default}#crd .editor .version-actions .done:hover{text-decoration:none}#crd .errors{margin-bottom:0}#crd .errors td:first-child{width:90px}#crd .errors tr:last-child td{border-bottom:1px solid #ddd} \ No newline at end of file +#crd .row{zoom:1}#crd .row:after{content:"";display:table;clear:both}#crd .col-md-6{float:left;width:50%;padding-left:15px;padding-right:15px;position:relative;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}#crd table{width:100%}#crd .pull-right{float:right!important}#crd blockquote{padding:10.5px 21px;border-left:5px solid #ddd;border-left-width:1px;color:#6f6f6f;margin:20px 0;font-size:14px;border-left-color:#e9e9e9;background-color:#f7f7f7}#crd blockquote ol:last-child,#crd blockquote p:last-child,#crd blockquote ul:last-child{margin-bottom:0}#crd code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,"Courier New",monospace}#crd code{padding:2px 4px;font-size:90%;color:#c7254e;background-color:#f9f2f4;white-space:nowrap;border-radius:0} +#crd .CodeMirror{font-family:monospace;background-color:#f7f7f7!important;line-height:1.3!important}#crd .CodeMirror+p{margin-top:15px}#crd .CodeMirror-scroll{overflow:none}#crd .CodeMirror-lines{padding:4px 0}#crd .CodeMirror pre{padding:0 4px!important}#crd .CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{background-color:#fff}#crd .CodeMirror-gutters{border-right:1px solid #ccc;background-color:#e9e9e9;white-space:nowrap}#crd .CodeMirror-linenumber{padding:0 5px;min-width:20px;text-align:right;color:#999;-moz-box-sizing:content-box;box-sizing:content-box}#crd .CodeMirror div.CodeMirror-cursor{border-left:1px solid #000}#crd .CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}#crd .CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor{width:auto;border:0;background:#7e7}#crd .cm-tab{display:inline-block}#crd .CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}#crd .cm-s-default .cm-keyword{color:#708}#crd .cm-s-default .cm-atom{color:#219}#crd .cm-s-default .cm-number{color:#164}#crd .cm-s-default .cm-def{color:#00f}#crd .cm-s-default .cm-variable{color:#000}#crd .cm-s-default .cm-variable-2{color:#05a}#crd .cm-s-default .cm-variable-3{color:#085}#crd .cm-s-default .cm-operator,#crd .cm-s-default .cm-property{color:#000}#crd .cm-s-default .cm-comment{color:#a50}#crd .cm-s-default .cm-string{color:#a11}#crd .cm-s-default .cm-string-2{color:#f50}#crd .cm-s-default .cm-meta,#crd .cm-s-default .cm-qualifier{color:#555}#crd .cm-s-default .cm-builtin{color:#30a}#crd .cm-s-default .cm-bracket{color:#997}#crd .cm-s-default .cm-tag{color:#170}#crd .cm-s-default .cm-attribute{color:#00c}#crd .cm-s-default .cm-header{color:#00f}#crd .cm-s-default .cm-quote{color:#090}#crd .cm-s-default .cm-hr{color:#999}#crd .cm-s-default .cm-link{color:#00c}#crd .cm-negative{color:#d44}#crd .cm-positive{color:#292}#crd .cm-header,#crd .cm-strong{font-weight:700}#crd .cm-em{font-style:italic}#crd .cm-link{text-decoration:underline}#crd .cm-invalidchar,#crd .cm-s-default .cm-error{color:red}#crd div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}#crd div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}#crd .CodeMirror-activeline-background{background:#e8f2ff}#crd .CodeMirror{position:relative;overflow:hidden;background:#fff;color:#000}#crd .CodeMirror-scroll{margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative;-moz-box-sizing:content-box;box-sizing:content-box}#crd .CodeMirror-sizer{position:relative;border-right:30px solid transparent;-moz-box-sizing:content-box;box-sizing:content-box;min-height:initial !important}#crd .CodeMirror-gutter-filler,#crd .CodeMirror-hscrollbar,#crd .CodeMirror-scrollbar-filler,#crd .CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}#crd .CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}#crd .CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}#crd .CodeMirror-scrollbar-filler{right:0;bottom:0}#crd .CodeMirror-gutter-filler{left:0;bottom:0}#crd .CodeMirror-gutters{position:absolute;left:0;top:0;padding-bottom:30px;z-index:3}#crd .CodeMirror-gutter{white-space:normal;height:100%;-moz-box-sizing:content-box;box-sizing:content-box;padding-bottom:30px;margin-bottom:-32px;display:inline-block}#crd .CodeMirror-gutter-elt{left:-32px !important;position:absolute;cursor:default;z-index:4}#crd .CodeMirror-lines{cursor:text}#crd .CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0!important;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible}#crd .editor .lint .dropdown-menu button,#crd .editor .lint .dropdown-menu input,#crd .editor .lint .dropdown-menu label,#crd .errors{font-size:14px}#crd .CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}#crd .CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}#crd .CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}#crd .CodeMirror-wrap .CodeMirror-scroll{overflow-x:hidden}#crd .CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}#crd .CodeMirror-measure pre{position:static}#crd .CodeMirror div.CodeMirror-cursor{position:absolute;border-right:none;width:0}#crd div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:1}#crd .CodeMirror-focused div.CodeMirror-cursors{visibility:visible}#crd .CodeMirror-selected{background:#d9d9d9}#crd .CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}#crd .cm-searching{background:#ffa;background:rgba(255,255,0,.4)}#crd .cm-force-border{padding-right:.1px}@media print{#crd .CodeMirror div.CodeMirror-cursors{visibility:hidden}}#crd .editor{margin-top:30px;margin-bottom:30px}#crd .editor iframe{display:none}#crd .editor .lint{color:#fff;padding:8px}#crd .editor .lint.success{background-color:#2e953d}#crd .editor .lint.error{background-color:#c4291e}#crd .editor .lint .glyphicon{margin-top:2px;color:#fff;display:none}#crd .editor .lint .glyphicon:hover{color:#ddd}#crd .editor .lint .dropdown-menu{color:#333;font-size:14px;padding:10px;margin-right:15px;position:absolute;top:40px;display:none}#crd .editor .lint .dropdown-menu form{margin:10px 0}#crd .editor .version{margin-right:10px;margin-top:2px}#crd .editor .versions tr:first-child td{border-top:none}#crd .editor .version-actions .done{color:#aaa;cursor:default}#crd .editor .version-actions .done:hover{text-decoration:none}#crd .errors{margin-bottom:0}#crd .errors td:first-child{width:90px}#crd .errors tr:last-child td{border-bottom:1px solid #ddd} diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint.json b/sonar-web-frontend-js/src/main/resources/rules/jshint.json index b9acff6..14df612 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint.json +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint.json @@ -1,1066 +1,2451 @@ -[ - - { - "key":"E001", - "name":"Bad option", - "description":"Bad option: '{a}'.", - "severity":"CRITICAL" - }, - { - "key":"E002", - "name":"Bad option value", - "description":"Bad option value.", - "severity":"CRITICAL" - }, - { - "key":"E003", - "name":"Expected a JSON value", - "description":"Expected a JSON value.", - "severity":"CRITICAL" - }, - { - "key":"E004", - "name":"Input is neither a string nor an array of strings", - "description":"Input is neither a string nor an array of strings.", - "severity":"MAJOR" - }, - { - "key":"E005", - "name":"Input is empty", - "description":"Input is empty.", - "severity":"MAJOR" - }, - { - "key":"E006", - "name":"Unexpected early end of program", - "description":"Unexpected early end of program.", - "severity":"CRITICAL" - }, - { - "key":"E007", - "name":"Missing use strict", - "description":"Missing \"use strict\" statement.", - "severity":"MINOR" - }, - { - "key":"E008", - "name":"strict violation", - "description":"Strict violation.", - "severity":"CRITICAL" - }, - { - "key":"E009", - "name":"validthis", - "description":"Option 'validthis' can't be used in a global scope.", - "severity":"MAJOR" - }, - { - "key":"E010", - "name":"with", - "description":"'with' is not allowed in strict mode.", - "severity":"CRITICAL" - }, - { - "key":"E011", - "name":"const already declared", - "description":"const '{a}' has already been declared.", - "severity":"CRITICAL" - }, - { - "key":"E012", - "name":"const undefined", - "description":"const '{a}' is initialized to 'undefined'.", - "severity":"CRITICAL" - }, - { - "key":"E013", - "name":"override a constant", - "description":"Attempting to override '{a}' which is a constant.", - "severity":"CRITICAL" - }, - { - "key":"E014", - "name":"Regular expression literal", - "description":"A regular expression literal can be confused with '/='.", - "severity":"MINOR" - }, - { - "key":"E015", - "name":"Unclosed regular expression", - "description":"Unclosed regular expression.", - "severity":"CRITICAL" - }, - { - "key":"E016", - "name":"Invalid regular expression", - "description":"Invalid regular expression.", - "severity":"CRITICAL" - }, - { - "key":"E017", - "name":"Unclosed comment", - "description":"Unclosed comment.", - "severity":"CRITICAL" - }, - { - "key":"E018", - "name":"Unbegun comment", - "description":"Unbegun comment.", - "severity":"CRITICAL" - }, - { - "key":"E019", - "name":"Unmatched", - "description":"Unmatched '{a}'.", - "severity":"MAJOR" - }, - { - "key":"E020", - "name":"Expected match", - "description":"Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.", - "severity":"MAJOR" - }, - { - "key":"E021", - "name":"Expected", - "description":"Expected '{a}' and instead saw '{b}'.", - "severity":"MAJOR" - }, - { - "key":"E022", - "name":"Line breaking error", - "description":"Line breaking error '{a}'.", - "severity":"MINOR" - }, - { - "key":"E023", - "name":"Missing", - "description":"Missing '{a}'.", - "severity":"CRITICAL" - }, - { - "key":"E024", - "name":"Unexpected '{a}'", - "description":"Unexpected '{a}'.", - "severity":"CRITICAL" - }, - { - "key":"E025", - "name":"Missing ':'", - "description":"Missing ':' on a case clause.", - "severity":"CRITICAL" - }, - { - "key":"E026", - "name":"Missing '}'", - "description":"Missing '}' to match '{' from line {a}.", - "severity":"CRITICAL" - }, - { - "key":"E027", - "name":"Missing ']'", - "description":"Missing ']' to match '[' from line {a}.", - "severity":"CRITICAL" - }, - { - "key":"E028", - "name":"Illegal comma", - "description":"Illegal comma.", - "severity":"CRITICAL" - }, - { - "key":"E029", - "name":"Unclosed string", - "description":"Unclosed string.", - "severity":"CRITICAL" - }, - { - "key":"E030", - "name":"Expected an identifier", - "description":"Expected an identifier and instead saw '{a}'.", - "severity":"MAJOR" - }, - { - "key":"E031", - "name":"Bad assignment", - "description":"Bad assignment.", - "severity":"CRITICAL" - }, - { - "key":"E032", - "name":"Expected a small integer or 'false'", - "description":"Expected a small integer or 'false' and instead saw '{a}'.", - "severity":"MAJOR" - }, - { - "key":"E033", - "name":"Expected an operator", - "description":"Expected an operator and instead saw '{a}'.", - "severity":"CRITICAL" - }, - { - "key":"E034", - "name":"get/set are ES5 features", - "description":"get/set are ES5 features.", - "severity":"MAJOR" - }, - { - "key":"E035", - "name":"Missing property name", - "description":"Missing property name.", - "severity":"CRITICAL" - }, - { - "key":"E036", - "name":"Expected to see a statement", - "description":"Expected to see a statement and instead saw a block.", - "severity":"CRITICAL" - }, - { - "key":"E037", - "name":"Constant not declared", - "description":"Constant {a} was not declared correctly.", - "severity":"CRITICAL" - }, - { - "key":"E038", - "name":"Variable not declared", - "description":"Variable {a} was not declared correctly.", - "severity":"CRITICAL" - }, - { - "key":"E039", - "name":"Function declarations are not invocable", - "description":"Function declarations are not invocable. Wrap the whole function invocation in parens.", - "severity":"CRITICAL" - }, - { - "key":"E040", - "name":"Each value should have its own case label", - "description":"Each value should have its own case label.", - "severity":"CRITICAL" - }, - { - "key":"E041", - "name":"Unrecoverable syntax error", - "description":"Unrecoverable syntax error.", - "severity":"BLOCKER" - }, - { - "key":"E042", - "name":"Stopping", - "description":"Stopping.", - "severity":"BLOCKER" - }, - { - "key":"E043", - "name":"Too many errors", - "description":"Too many errors.", - "severity":"BLOCKER" - }, - { - "key":"E044", - "name":"var already defined", - "description":"'{a}' is already defined and can't be redefined.", - "severity":"CRITICAL" - }, - { - "key":"E045", - "name":"Invalid for each loop", - "description":"Invalid for each loop.", - "severity":"CRITICAL" - }, - { - "key":"E046", - "name":"A yield statement out of generator", - "description":"A yield statement shall be within a generator function (with syntax: `function*`)", - "severity":"CRITICAL" - }, - { - "key":"E047", - "name":"A generator function shall contain a yield statement.", - "description":"A generator function shall contain a yield statement.", - "severity":"CRITICAL" - }, - { - "key":"E048", - "name":"Let declaration not directly within block", - "description":"Let declaration not directly within block.", - "severity":"CRITICAL" - }, - { - "key":"E049", - "name":"Wrong name", - "description":"A {a} cannot be named '{b}'.", - "severity":"CRITICAL" - }, - { - "key":"E050", - "name":"Yield parenthesis", - "description":"Mozilla requires the yield expression to be parenthesized here.", - "severity":"CRITICAL" - }, - { - "key":"E051", - "name":"Parameters order", - "description":"Regular parameters cannot come after default parameters.", - "severity":"MAJOR" - }, - { - "key":"E052", - "name":"Unclosed template literal", - "description":"Unclosed template literal.", - "severity":"CRITICAL" - }, - { - "key":"W001", - "name":"hasOwnProperty", - "description":"'hasOwnProperty' is a really bad name.", - "severity":"MAJOR" - }, - { - "key":"W002", - "name":"Overwrite value (IE8-)", - "description":"Value of '{a}' may be overwritten in IE 8 and earlier.", - "severity":"MAJOR" - }, - { - "key":"W003", - "name":"Use before definition", - "description":"'{a}' was used before it was defined.", - "severity":"MAJOR" - }, - { - "key":"W004", - "name":"Already defined", - "description":"'{a}' is already defined.", - "severity":"MAJOR" - }, - { - "key":"W005", - "name":"Decimal point ?", - "description":"A dot following a number can be confused with a decimal point.", - "severity":"MAJOR" - }, - { - "key":"W006", - "name":"Confusing minuses", - "description":"Confusing minuses.", - "severity":"MAJOR" - }, - { - "key":"W007", - "name":"Confusing plusses", - "description":"Confusing plusses.", - "severity":"MAJOR" - }, - { - "key":"W008", - "name":"Leading decimal point", - "description":"A leading decimal point can be confused with a dot: '{a}'.", - "severity":"MAJOR" - }, - { - "key":"W009", - "name":"array literal notation", - "description":"The array literal notation [] is preferable.", - "severity":"MAJOR" - }, - { - "key":"W010", - "name":"object literal notation", - "description":"The object literal notation {} is preferable.", - "severity":"MAJOR" - }, - { - "key":"W011", - "name":"Unexpected space after", - "description":"Unexpected space after '{a}'.", - "severity":"CRITICAL" - }, - { - "key":"W012", - "name":"Unexpected space before", - "description":"Unexpected space before '{a}'.", - "severity":"CRITICAL" - }, - { - "key":"W013", - "name":"Missing space after ", - "description":"Missing space after '{a}'.", - "severity":"CRITICAL" - }, - { - "key":"W014", - "name":"Bad line breaking", - "description":"Bad line breaking before '{a}'.", - "severity":"MINOR" - }, - { - "key":"W015", - "name":"Expected correct indentation", - "description":"Expected '{a}' to have an indentation at {b} instead at {c}.", - "severity":"CRITICAL" - }, - { - "key":"W016", - "name":"Unexpected use", - "description":"Unexpected use of '{a}'.", - "severity":"MAJOR" - }, - { - "key":"W017", - "name":"Bad operand", - "description":"Bad operand.", - "severity":"MAJOR" - }, - { - "key":"W018", - "name":"Confusing use", - "description":"Confusing use of '{a}'.", - "severity":"MAJOR" - }, - { - "key":"W019", - "name":"NaN", - "description":"Use the isNaN function to compare with NaN.", - "severity":"MAJOR" - }, - { - "key":"W020", - "name":"Read only", - "description":"Read only.", - "severity":"MAJOR" - }, - { - "key":"W021", - "name":"function", - "description":"'{a}' is a function.", - "severity":"MAJOR" - }, - { - "key":"W022", - "name":"Exception parameter assignment", - "description":"Do not assign to the exception parameter.", - "severity":"MAJOR" - }, - { - "key":"W023", - "name":"Expected an identifier in an assignment", - "description":"Expected an identifier in an assignment and instead saw a function invocation.", - "severity":"MAJOR" - }, - { - "key":"W024", - "name":"Reserved word", - "description":"Expected an identifier and instead saw '{a}' (a reserved word).", - "severity":"MAJOR" - }, - { - "key":"W025", - "name":"Missing name", - "description":"Missing name in function declaration.", - "severity":"MAJOR" - }, - { - "key":"W026", - "name":"Inner functions", - "description":"Inner functions should be listed at the top of the outer function.", - "severity":"MAJOR" - }, - { - "key":"W027", - "name":"Unreachable", - "description":"Unreachable '{a}' after '{b}'.", - "severity":"MAJOR" - }, - { - "key":"W028", - "name":"Label '{a}' on {b} statement", - "description":"Label '{a}' on {b} statement.", - "severity":"MAJOR" - }, - { - "key":"W030", - "name":"Expected an assignment or function call", - "description":"Expected an assignment or function call and instead saw an expression.", - "severity":"MAJOR" - }, - { - "key":"W031", - "name":"Do not use 'new'", - "description":"Do not use 'new' for side effects.", - "severity":"MAJOR" - }, - { - "key":"W032", - "name":"Unnecessary semicolon", - "description":"Unnecessary semicolon.", - "severity":"MAJOR" - }, - { - "key":"W033", - "name":"Missing semicolon", - "description":"Missing semicolon.", - "severity":"MAJOR" - }, - { - "key":"W034", - "name":"Unnecessary directive", - "description":"Unnecessary directive \"{a}\".", - "severity":"MAJOR" - }, - { - "key":"W035", - "name":"Empty block", - "description":"Empty block.", - "severity":"MAJOR" - }, - { - "key":"W036", - "name":"Unexpected /*member", - "description":"Unexpected /*member '{a}'.", - "severity":"MAJOR" - }, - { - "key":"W037", - "name":"statement label", - "description":"'{a}' is a statement label.", - "severity":"MAJOR" - }, - { - "key":"W038", - "name":"used out of scope", - "description":"'{a}' used out of scope.", - "severity":"MAJOR" - }, - { - "key":"W039", - "name":"not allowed", - "description":"'{a}' is not allowed.", - "severity":"MAJOR" - }, - { - "key":"W040", - "name":"Possible strict violation", - "description":"Possible strict violation.", - "severity":"MAJOR" - }, - { - "key":"W041", - "name":"compare", - "description":"Use '{a}' to compare with '{b}'.", - "severity":"MAJOR" - }, - { - "key":"W042", - "name":"Avoid EOL escaping", - "description":"Avoid EOL escaping.", - "severity":"MAJOR" - }, - { - "key":"W043", - "name":"Bad escaping of EOL", - "description":"Bad escaping of EOL. Use option multistr if needed.", - "severity":"MAJOR" - }, - { - "key":"W044", - "name":"Bad or unnecessary escaping", - "description":"Bad or unnecessary escaping.", - "severity":"MAJOR" - }, - { - "key":"W045", - "name":"Bad number", - "description":"Bad number '{a}'.", - "severity":"MAJOR" - }, - { - "key":"W046", - "name":"Don't use extra leading zeros", - "description":"Don't use extra leading zeros '{a}'.", - "severity":"MAJOR" - }, - { - "key":"W047", - "name":"trailing decimal point", - "description":"A trailing decimal point can be confused with a dot: '{a}'.", - "severity":"MAJOR" - }, - { - "key":"W048", - "name":"Unexpected control character", - "description":"Unexpected control character in regular expression.", - "severity":"MAJOR" - }, - { - "key":"W049", - "name":"Unexpected escaped character", - "description":"Unexpected escaped character '{a}' in regular expression.", - "severity":"MAJOR" - }, - { - "key":"W050", - "name":"JavaScript URL", - "description":"JavaScript URL.", - "severity":"MAJOR" - }, - { - "key":"W051", - "name":"Variables should not be deleted", - "description":"Variables should not be deleted.", - "severity":"MAJOR" - }, - { - "key":"W052", - "name":"Unexpected '{a}'", - "description":"Unexpected '{a}'.", - "severity":"MAJOR" - }, - { - "key":"W053", - "name":"constructor", - "description":"Do not use {a} as a constructor.", - "severity":"MAJOR" - }, - { - "key":"W054", - "name":"Function constructor", - "description":"The Function constructor is a form of eval.", - "severity":"MAJOR" - }, - { - "key":"W055", - "name":"Constructor case", - "description":"A constructor name should start with an uppercase letter.", - "severity":"MAJOR" - }, - { - "key":"W056", - "name":"Bad constructor", - "description":"Bad constructor.", - "severity":"MAJOR" - }, - { - "key":"W057", - "name":"Weird construction", - "description":"Weird construction. Is 'new' necessary?", - "severity":"MAJOR" - }, - { - "key":"W058", - "name":"Missing '()'", - "description":"Missing '()' invoking a constructor.", - "severity":"MAJOR" - }, - { - "key":"W059", - "name":"Avoid arguments", - "description":"Avoid arguments.{a}.", - "severity":"MAJOR" - }, - { - "key":"W060", - "name":"document.write", - "description":"document.write can be a form of eval.", - "severity":"MAJOR" - }, - { - "key":"W061", - "name":"eval", - "description":"eval can be harmful.", - "severity":"MAJOR" - }, - { - "key":"W062", - "name":"Reading", - "description":"Wrap an immediate function invocation in parens to assist the reader in understanding that the expression is the result of a function, and not the function itself.", - "severity":"MAJOR" - }, - { - "key":"W063", - "name":"Math is not a function", - "description":"Math is not a function.", - "severity":"MAJOR" - }, - { - "key":"W064", - "name":"Missing 'new'", - "description":"Missing 'new' prefix when invoking a constructor.", - "severity":"MAJOR" - }, - { - "key":"W065", - "name":"Missing radix parameter", - "description":"Missing radix parameter.", - "severity":"MAJOR" - }, - { - "key":"W066", - "name":"Implied eval", - "description":"Implied eval. Consider passing a function instead of a string.", - "severity":"MAJOR" - }, - { - "key":"W067", - "name":"Bad invocation", - "description":"Bad invocation.", - "severity":"MAJOR" - }, - { - "key":"W068", - "name":"non-IIFE function literals", - "description":"Wrapping non-IIFE function literals in parens is unnecessary.", - "severity":"MAJOR" - }, - { - "key":"W069", - "name":"dot notation", - "description":"['{a}'] is better written in dot notation.", - "severity":"MAJOR" - }, - { - "key":"W070", - "name":"Extra comma", - "description":"Extra comma. (it breaks older versions of IE)", - "severity":"MAJOR" - }, - { - "key":"W071", - "name":"too many statements", - "description":"This function has too many statements. ({a})", - "severity":"MAJOR" - }, - { - "key":"W072", - "name":"too many parameters", - "description":"This function has too many parameters. ({a})", - "severity":"MAJOR" - }, - { - "key":"W073", - "name":"too many nested blocks", - "description":"Blocks are nested too deeply. ({a})", - "severity":"MAJOR" - }, - { - "key":"W074", - "name":"cyclomatic complexity", - "description":"This function's cyclomatic complexity is too high. ({a})", - "severity":"MAJOR" - }, - { - "key":"W075", - "name":"Duplicate key", - "description":"Duplicate key '{a}'.", - "severity":"MAJOR" - }, - { - "key":"W076", - "name":"Unexpected parameter", - "description":"Unexpected parameter '{a}' in get {b} function.", - "severity":"MAJOR" - }, - { - "key":"W077", - "name":"Expected a single parameter", - "description":"Expected a single parameter in set {a} function.", - "severity":"MAJOR" - }, - { - "key":"W078", - "name":"Setter/getter", - "description":"Setter is defined without getter.", - "severity":"MAJOR" - }, - { - "key":"W079", - "name":"Redefinition", - "description":"Redefinition of '{a}'.", - "severity":"MAJOR" - }, - { - "key":"W080", - "name":"initialization to undefined", - "description":"It's not necessary to initialize '{a}' to 'undefined'.", - "severity":"MAJOR" - }, - { - "key":"W081", - "name":"Too many var statements.", - "description":"Too many var statements.", - "severity":"CRITICAL" - }, - { - "key":"W082", - "name":"Function declarations", - "description":"Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.", - "severity":"MAJOR" - }, - { - "key":"W083", - "name":"functions within a loop", - "description":"Don't make functions within a loop.", - "severity":"MAJOR" - }, - { - "key":"W084", - "name":"Expected a conditional expression", - "description":"Expected a conditional expression and instead saw an assignment.", - "severity":"MAJOR" - }, - { - "key":"W085", - "name":"Don't use 'with'", - "description":"Don't use 'with'.", - "severity":"MAJOR" - }, - { - "key":"W086", - "name":"Expected a 'break'", - "description":"Expected a 'break' statement before '{a}'.", - "severity":"MAJOR" - }, - { - "key":"W087", - "name":"debugger", - "description":"Forgotten 'debugger' statement?", - "severity":"MAJOR" - }, - { - "key":"W088", - "name":"global 'for' variable", - "description":"Creating global 'for' variable. Should be 'for (var {a} ...'.", - "severity":"MAJOR" - }, - { - "key":"W089", - "name":"for in body", - "description":"The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.", - "severity":"MAJOR" - }, - { - "key":"W090", - "name":"not a statement label", - "description":"'{a}' is not a statement label.", - "severity":"MAJOR" - }, - { - "key":"W091", - "name":"out of scope", - "description":"'{a}' is out of scope.", - "severity":"MAJOR" - }, - { - "key":"W093", - "name":"return a conditional ?", - "description":"Did you mean to return a conditional instead of an assignment?", - "severity":"MAJOR" - }, - { - "key":"W094", - "name":"Unexpected comma", - "description":"Unexpected comma.", - "severity":"MAJOR" - }, - { - "key":"W095", - "name":"Expected a string", - "description":"Expected a string and instead saw {a}.", - "severity":"MAJOR" - }, - { - "key":"W096", - "name":"key may produce unexpected results", - "description":"The '{a}' key may produce unexpected results.", - "severity":"MAJOR" - }, - { - "key":"W097", - "name":"function form of \"use strict\"", - "description":"Use the function form of \"use strict\".", - "severity":"MAJOR" - }, - { - "key":"W098", - "name":"Variable never used", - "description":"'{a}' is defined but never used.", - "severity":"MINOR" - }, - { - "key":"W099", - "name":"Mixed spaces and tabs.", - "description":"Mixed spaces and tabs.", - "severity":"CRITICAL" - }, - { - "key":"W100", - "name":"character silently deleted", - "description":"This character may get silently deleted by one or more browsers.", - "severity":"MAJOR" - }, - { - "key":"W101", - "name":"Line is too long", - "description":"Line is too long.", - "severity":"MAJOR" - }, - { - "key":"W102", - "name":"Trailing whitespace.", - "description":"Trailing whitespace.", - "severity":"MAJOR" - }, - { - "key":"W103", - "name":"deprecated property", - "description":"The '{a}' property is deprecated.", - "severity":"MAJOR" - }, - { - "key":"W104", - "name":"ES6", - "description":"'{a}' is available in ES6 (use esnext option) or Mozilla JS extensions (use moz).", - "severity":"MAJOR" - }, - { - "key":"W105", - "name":"Unexpected {a} in '{b}'", - "description":"Unexpected {a} in '{b}'.", - "severity":"MAJOR" - }, - { - "key":"W106", - "name":"Identifier case", - "description":"Identifier '{a}' is not in camel case.", - "severity":"MAJOR" - }, - { - "key":"W107", - "name":"Script URL", - "description":"Script URL.", - "severity":"MAJOR" - }, - { - "key":"W108", - "name":"Strings must use doublequote", - "description":"Strings must use doublequote.", - "severity":"MAJOR" - }, - { - "key":"W109", - "name":"Strings must use singlequote", - "description":"Strings must use singlequote.", - "severity":"MAJOR" - }, - { - "key":"W110", - "name":"Mixed double and single quotes", - "description":"Mixed double and single quotes.", - "severity":"MAJOR" - }, - { - "key":"W112", - "name":"Unclosed string", - "description":"Unclosed string.", - "severity":"MAJOR" - }, - { - "key":"W113", - "name":"Control character", - "description":"Control character in string: {a}.", - "severity":"MAJOR" - }, - { - "key":"W114", - "name":"Avoid {a}", - "description":"Avoid {a}.", - "severity":"MAJOR" - }, - { - "key":"W115", - "name":"Octal literals", - "description":"Octal literals are not allowed in strict mode.", - "severity":"MAJOR" - }, - { - "key":"W116", - "name":"Expected '{a}' and instead saw '{b}'", - "description":"Expected '{a}' and instead saw '{b}'.", - "severity":"MAJOR" - }, - { - "key":"W117", - "name":"Variable not defined", - "description":"'{a}' is not defined.", - "severity":"CRITICAL" - }, - { - "key":"W118", - "name":"Mozilla only", - "description":"'{a}' is only available in Mozilla JavaScript extensions (use moz option).", - "severity":"MAJOR" - }, - { - "key":"W119", - "name":"ES6 only", - "description":"'{a}' is only available in ES6 (use esnext option).", - "severity":"MAJOR" - }, - { - "key":"W120", - "name":"variable leak", - "description":"You might be leaking a variable ({a}) here.", - "severity":"MAJOR" - }, - { - "key":"W121", - "name":"Extending prototype of native object", - "description":"Extending prototype of native object: '{a}'.", - "severity":"MAJOR" - }, - { - "key":"W122", - "name":"Invalid typeof value", - "description":"Invalid typeof value '{a}'", - "severity":"MAJOR" - }, - { - "key":"W123", - "name":"already defined in outer scope", - "description":"'{a}' is already defined in outer scope.", - "severity":"MAJOR" - }, - { - "key":"W124", - "name":"generator without yield", - "description":"A generator function shall contain a yield statement.", - "severity":"MAJOR" - }, - { - "key":"W125", - "name":"non-breaking spaces", - "description":"This line contains non-breaking spaces: http://jshint.com/doc/options/#nonbsp", - "severity":"MAJOR" - }, - { - "key":"I001", - "name":"Comma warnings", - "description":"Comma warnings can be turned off with 'laxcomma'.", - "severity":"MINOR" - }, - { - "key":"I002", - "name":"Reserved words", - "description":"Reserved words as properties can be used under the 'es5' option.", - "severity":"INFO" - }, - { - "key":"I003", - "name":"ES5 option", - "description":"ES5 option is now set per default", - "severity":"MINOR" - } - -] +[ { + "key" : "E001", + "name" : "Bad option", + "description" : "Bad option: '{a}'.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint-options" ], + "debt" : null +}, { + "key" : "E002", + "name" : "Bad option value", + "description" : "Bad option value.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint-options" ], + "debt" : null +}, { + "key" : "E003", + "name" : "Expected a JSON value", + "description" : "Expected a JSON value.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint" ], + "debt" : null +}, { + "key" : "E004", + "name" : "Input is neither a string nor an array of strings", + "description" : "Input is neither a string nor an array of strings.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint" ], + "debt" : null +}, { + "key" : "E005", + "name" : "Input is empty", + "description" : "Input is empty.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint" ], + "debt" : null +}, { + "key" : "E006", + "name" : "Unexpected early end of program", + "description" : "Unexpected early end of program.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint" ], + "debt" : null +}, { + "key" : "E007", + "name" : "Missing 'use strict' statement", + "description" : "Missing 'use strict' statement", + "severity" : "MINOR", + "status" : null, + "tags" : [ "jshint", "convention", "be-careful" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "E008", + "name" : "strict violation", + "description" : "Strict violation.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint" ], + "debt" : null +}, { + "key" : "E009", + "name" : "Option 'validthis' can't be used in a global scope", + "description" : "Option 'validthis' can't be used in a global scope", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint" ], + "debt" : null +}, { + "key" : "E010", + "name" : "'with' is not allowed in strict mode", + "description" : "'with' is not allowed in strict mode", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "security", "obsolete", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "SECURITY_FEATURES" + } +}, { + "key" : "E011", + "name" : "const '{a}' has already been declared", + "description" : "const '{a}' has already been declared", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "E012", + "name" : "const undefined", + "description" : "const '{a}' is initialized to 'undefined'.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "E013", + "name" : "Attempting to override '{a}' which is a constant", + "description" : "Attempting to override '{a}' which is a constant", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "E014", + "name" : "A regular expression literal can be confused with '/='", + "description" : "A regular expression literal can be confused with '/='", + "severity" : "MINOR", + "status" : null, + "tags" : [ "jshint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "E015", + "name" : "Unclosed regular expression", + "description" : "Unclosed regular expression", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "E016", + "name" : "Invalid regular expression", + "description" : "Invalid regular expression.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "E017", + "name" : "Unclosed comment", + "description" : "Unclosed comment", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "E018", + "name" : "Unbegun comment", + "description" : "Unbegun comment.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "E019", + "name" : "Unmatched", + "description" : "Unmatched '{a}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "E020", + "name" : "Expected match", + "description" : "Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "E021", + "name" : "Expected", + "description" : "Expected '{a}' and instead saw '{b}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "E022", + "name" : "Line breaking error", + "description" : "Line breaking error '{a}'.", + "severity" : "MINOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "E023", + "name" : "Missing", + "description" : "Missing '{a}'.", + "severity" : "CRITICAL", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "E024", + "name" : "Unexpected '{a}'", + "description" : "Unexpected '{a}'.", + "severity" : "CRITICAL", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "E025", + "name" : "Missing ':'", + "description" : "Missing ':' on a case clause.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "E026", + "name" : "Missing '}'", + "description" : "Missing '}' to match '{' from line {a}.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "E027", + "name" : "Missing ']'", + "description" : "Missing ']' to match '[' from line {a}.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "E028", + "name" : "Illegal comma", + "description" : "Illegal comma.", + "severity" : "CRITICAL", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "E029", + "name" : "Unclosed string", + "description" : "Unclosed string", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "E030", + "name" : "Expected an identifier", + "description" : "Expected an identifier and instead saw '{a}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "E031", + "name" : "Bad assignment", + "description" : "Bad assignment", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "E032", + "name" : "Expected a small integer or 'false'", + "description" : "Expected a small integer or 'false' and instead saw '{a}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "E033", + "name" : "Expected an operator", + "description" : "Expected an operator and instead saw '{a}'.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "E034", + "name" : "get/set are ES5 features", + "description" : "get/set are ES5 features", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "cross-browser" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "E035", + "name" : "Missing property name", + "description" : "Missing property name.", + "severity" : "CRITICAL", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "E036", + "name" : "Expected to see a statement", + "description" : "Expected to see a statement and instead saw a block.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "E037", + "name" : "Constant not declared", + "description" : "Constant {a} was not declared correctly.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "E038", + "name" : "Variable not declared", + "description" : "Variable {a} was not declared correctly.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "E039", + "name" : "Function statements are not invocable. Wrap the whole function invocation in parens", + "description" : "Function statements are not invocable. Wrap the whole function invocation in parens", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "E040", + "name" : "Each value should have its own case label", + "description" : "Each value should have its own case label.", + "severity" : "CRITICAL", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "E041", + "name" : "Unrecoverable syntax error", + "description" : "Unrecoverable syntax error.", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1h" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "E042", + "name" : "Stopping. ({a}% scanned)", + "description" : "Stopping. ({a}% scanned)", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1d" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "E043", + "name" : "Too many errors", + "description" : "Too many errors.", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1d" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "E044", + "name" : "var already defined", + "description" : "'{a}' is already defined and can't be redefined.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "E045", + "name" : "Invalid for each loop", + "description" : "Invalid for each loop.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "cross-browser" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "E046", + "name" : "A yield statement out of generator", + "description" : "A yield statement shall be within a generator function (with syntax: `function*`)", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "cross-browser", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "E047", + "name" : "A generator function shall contain a yield statement.", + "description" : "A generator function shall contain a yield statement.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "design", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "RELIABILITY_COMPLIANCE" + } +}, { + "key" : "E048", + "name" : "Let declaration not directly within block", + "description" : "Let declaration not directly within block.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "design" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "E049", + "name" : "Wrong name", + "description" : "A {a} cannot be named '{b}'.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "E050", + "name" : "Yield parenthesis", + "description" : "Mozilla requires the yield expression to be parenthesized here.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "cross-browser", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "E051", + "name" : "Parameters order", + "description" : "Regular parameters cannot come after default parameters.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "E052", + "name" : "Unclosed mega literal", + "description" : "Unclosed mega literal", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W001", + "name" : "'hasOwnProperty' is a really bad name", + "description" : "'hasOwnProperty' is a really bad name", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "clumsy", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "W002", + "name" : "Value of '{a}' may be overwritten in IE8 and earlier", + "description" : "Value of '{a}' may be overwritten in IE8 and earlier", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "cross-browser", "bad-practice", "ie" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "EXCEPTION_HANDLING" + } +}, { + "key" : "W003", + "name" : "Use before definition", + "description" : "'{a}' was used before it was defined.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W004", + "name" : "{a} is already defined", + "description" : "{a} is already defined", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W005", + "name" : "A dot following a number can be confused with a decimal point", + "description" : "A dot following a number can be confused with a decimal point", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "confusing", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W006", + "name" : "Confusing minuses", + "description" : "Confusing minuses", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "confusing", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W007", + "name" : "Confusing pluses", + "description" : "Confusing pluses", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "confusing", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W008", + "name" : "A leading decimal point can be confused with a dot: '{a}'", + "description" : "A leading decimal point can be confused with a dot: '{a}'", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "confusing", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W009", + "name" : "The array literal notation [] is preferrable", + "description" : "The array literal notation [] is preferrable", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W010", + "name" : "The object literal notation {} is preferrable", + "description" : "The object literal notation {} is preferrable", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W011", + "name" : "Unexpected space after", + "description" : "Unexpected space after '{a}'.", + "severity" : "CRITICAL", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W012", + "name" : "Unexpected space before", + "description" : "Unexpected space before '{a}'.", + "severity" : "CRITICAL", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W013", + "name" : "Missing space after ", + "description" : "Missing space after '{a}'.", + "severity" : "CRITICAL", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W014", + "name" : "Bad line breaking", + "description" : "Bad line breaking before '{a}'.", + "severity" : "MINOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W015", + "name" : "Expected correct indentation", + "description" : "Expected '{a}' to have an indentation at {b} instead at {c}.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "format" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W016", + "name" : "Unexpected use", + "description" : "Unexpected use of '{a}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W017", + "name" : "Bad operand", + "description" : "Bad operand.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W018", + "name" : "Confusing use", + "description" : "Confusing use of '{a}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W019", + "name" : "Use the isNaN function to compare with NaN", + "description" : "Use the isNaN function to compare with NaN", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "pitfall", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W020", + "name" : "Read only", + "description" : "Read only", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "pitfall", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W021", + "name" : "function", + "description" : "'{a}' is a function.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W022", + "name" : "Do not assign to the exception parameter", + "description" : "Do not assign to the exception parameter", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "confusing", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "EXCEPTION_HANDLING" + } +}, { + "key" : "W023", + "name" : "Expected an identifier in an assignment", + "description" : "Expected an identifier in an assignment and instead saw a function invocation.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W024", + "name" : "Expected an identifier and instead saw '{a}' (a reserved word)", + "description" : "Expected an identifier and instead saw '{a}' (a reserved word)", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W025", + "name" : "Missing name in function statement", + "description" : "Missing name in function statement", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "W026", + "name" : "Inner functions", + "description" : "Inner functions should be listed at the top of the outer function.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W027", + "name" : "Unreachable", + "description" : "Unreachable '{a}' after '{b}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "dead-code" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W028", + "name" : "Label '{a}' on {b} statement", + "description" : "Label '{a}' on {b} statement.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W030", + "name" : "Expected an assignment or function call and instead saw an expression", + "description" : "Expected an assignment or function call and instead saw an expression", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "suspicious", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W031", + "name" : "Do not use 'new' for side effects", + "description" : "Do not use 'new' for side effects", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W032", + "name" : "Unnecessary semicolon", + "description" : "Unnecessary semicolon", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W033", + "name" : "Missing semicolon", + "description" : "Missing semicolon.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W034", + "name" : "Unnecessary 'use strict'", + "description" : "Unnecessary 'use strict'", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "CHANGEABILITY_COMPLIANCE" + } +}, { + "key" : "W035", + "name" : "Empty block", + "description" : "Empty block.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W036", + "name" : "Unregistered property name '{a}'", + "description" : "Unregistered property name '{a}'", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "suspicious", "typo" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W037", + "name" : "{a} is a statement label", + "description" : "{a} is a statement label", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "pitfall", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W038", + "name" : "{a} used out of scope", + "description" : "{a} used out of scope", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W039", + "name" : "not allowed", + "description" : "'{a}' is not allowed.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W040", + "name" : "Possible strict violation", + "description" : "Possible strict violation.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W041", + "name" : "compare", + "description" : "Use '{a}' to compare with '{b}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W042", + "name" : "Avoid EOL escaping", + "description" : "Avoid EOL escaping.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W043", + "name" : "Bad escapement of EOL. Use option multistr if needed", + "description" : "Bad escapement of EOL. Use option multistr if needed", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "cross-browser" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W044", + "name" : "Bad or unnecessary escaping", + "description" : "Bad or unnecessary escaping.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W045", + "name" : "Bad number", + "description" : "Bad number '{a}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W046", + "name" : "Don't use extra leading zeros", + "description" : "Don't use extra leading zeros '{a}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W047", + "name" : "A trailing decimal point can be confused with a dot: '{a}'", + "description" : "A trailing decimal point can be confused with a dot: '{a}'", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W048", + "name" : "Unexpected control character", + "description" : "Unexpected control character in regular expression.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W049", + "name" : "Unexpected escaped character", + "description" : "Unexpected escaped character '{a}' in regular expression.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W050", + "name" : "JavaScript URL", + "description" : "JavaScript URL.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "performance", "security" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "API_ABUSE" + } +}, { + "key" : "W051", + "name" : "Only properties should be deleted", + "description" : "Only properties should be deleted", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W052", + "name" : "Unexpected '{a}'", + "description" : "Unexpected '{a}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W053", + "name" : "Do not use {a} as a constructor", + "description" : "Do not use {a} as a constructor", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W054", + "name" : "The Function constructor is eval", + "description" : "The Function constructor is eval", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "security", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "API_ABUSE" + } +}, { + "key" : "W055", + "name" : "A constructor name should start with an uppercase letter", + "description" : "A constructor name should start with an uppercase letter", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W056", + "name" : "Bad constructor", + "description" : "Bad constructor", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W057", + "name" : "Weird construction", + "description" : "Weird construction. Is 'new' necessary?", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W058", + "name" : "Missing '()' invoking a constructor", + "description" : "Missing '()' invoking a constructor", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W059", + "name" : "Avoid arguments.{a}", + "description" : "Avoid arguments.{a}", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "deprecated" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "W060", + "name" : "document.write", + "description" : "document.write can be a form of eval.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "security", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "API_ABUSE" + } +}, { + "key" : "W061", + "name" : "eval is evil", + "description" : "eval is evil", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "security", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "API_ABUSE" + } +}, { + "key" : "W062", + "name" : "Wrap an immediate function invocation in parentheses", + "description" : "Wrap an immediate function invocation in parentheses", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention", "confusing", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W063", + "name" : "'{a}' is not a function", + "description" : "'{a}' is not a function", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W064", + "name" : "Missing 'new'", + "description" : "Missing 'new' prefix when invoking a constructor.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W065", + "name" : "Missing radix parameter", + "description" : "Missing radix parameter", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W066", + "name" : "Implied eval is evil. Pass a function instead of a string", + "description" : "Implied eval is evil. Pass a function instead of a string", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "security", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "API_ABUSE" + } +}, { + "key" : "W067", + "name" : "Bad invocation", + "description" : "Bad invocation.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W068", + "name" : "Do not wrap function literals in parens unless they are to be immediately invoked", + "description" : "Do not wrap function literals in parens unless they are to be immediately invoked", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention", "confusing", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W069", + "name" : "['{a}'] is better written in dot notation", + "description" : "['{a}'] is better written in dot notation", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W070", + "name" : "Extra comma. (it breaks older versions of IE)", + "description" : "Extra comma. (it breaks older versions of IE)", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "cross-browser", "pitfall", "ie" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "W071", + "name" : "too many statements", + "description" : "This function has too many statements. ({a})", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "brain-overload" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1h" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W072", + "name" : "This function has too many parameters. ({a})", + "description" : "This function has too many parameters. ({a})", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W073", + "name" : "too many nested blocks", + "description" : "Blocks are nested too deeply. ({a})", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "brain-overload" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1h" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W074", + "name" : "cyclomatic complexity", + "description" : "This function's cyclomatic complexity is too high. ({a})", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "brain-overload" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1h" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W075", + "name" : "Duplicate key '{a}'", + "description" : "Duplicate key '{a}'", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W076", + "name" : "Unexpected parameter '{a}' in get {b} function", + "description" : "Unexpected parameter '{a}' in get {b} function", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W077", + "name" : "Expected a single parameter", + "description" : "Expected a single parameter in set {a} function.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W078", + "name" : "Setter/getter", + "description" : "Setter is defined without getter.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "RELIABILITY_COMPLIANCE" + } +}, { + "key" : "W079", + "name" : "Redefinition of '{a}'", + "description" : "Redefinition of '{a}'", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug", "security", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W080", + "name" : "It is not necessary to initialize '{a}' to 'undefined'", + "description" : "It is not necessary to initialize '{a}' to 'undefined'", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "useless", "dead-code" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W081", + "name" : "Combine this with the previous 'var' statement", + "description" : "Combine this with the previous 'var' statement", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W082", + "name" : "Function statements should not be placed in blocks", + "description" : "Function statements should not be placed in blocks", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "cross-browser", "pitfall", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W083", + "name" : "Don't make functions within a loop", + "description" : "Don't make functions within a loop", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug", "bad-practice", "performance", "scope" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1h" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W084", + "name" : "Unexpected assignment expression", + "description" : "Unexpected assignment expression", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W085", + "name" : "Unexpected 'with'", + "description" : "Unexpected 'with'", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "performance", "cross-browser", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W086", + "name" : "Expected a 'break'", + "description" : "Expected a 'break' statement before '{a}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W087", + "name" : "All 'debugger' statements should be removed", + "description" : "All 'debugger' statements should be removed", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W088", + "name" : "Bad for-in variable '{a}'", + "description" : "Bad for-in variable '{a}'", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug", "pitfall", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W089", + "name" : "The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype", + "description" : "The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention", "pitfall", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W090", + "name" : "'{a}' is not a label", + "description" : "'{a}' is not a label", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W091", + "name" : "out of scope", + "description" : "'{a}' is out of scope.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "scope" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W093", + "name" : "Did you mean to return a conditional instead of an assignment?", + "description" : "Did you mean to return a conditional instead of an assignment?", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "confusing", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W094", + "name" : "Unexpected comma", + "description" : "Unexpected comma.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W095", + "name" : "Expected a string", + "description" : "Expected a string and instead saw {a}.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W096", + "name" : "key may produce unexpected results", + "description" : "The '{a}' key may produce unexpected results.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W097", + "name" : "Use the function form of 'use strict'", + "description" : "Use the function form of 'use strict'", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "W098", + "name" : "Unused '{a}'", + "description" : "Unused '{a}'", + "severity" : "MINOR", + "status" : null, + "tags" : [ "jshint", "dead-code" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W099", + "name" : "Mixed spaces and tabs.", + "description" : "Mixed spaces and tabs.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W100", + "name" : "character silently deleted", + "description" : "This character may get silently deleted by one or more browsers.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W101", + "name" : "Line is too long", + "description" : "Line is too long.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W102", + "name" : "Trailing whitespace.", + "description" : "Trailing whitespace.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W103", + "name" : "deprecated property", + "description" : "The '{a}' property is deprecated.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W104", + "name" : "ES6", + "description" : "'{a}' is available in ES6 (use esnext option) or Mozilla JS extensions (use moz).", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "es6", "cross-browser" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "W105", + "name" : "Unexpected dangling '_' in '{a}'", + "description" : "Unexpected dangling '_' in '{a}'", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W106", + "name" : "Identifier case", + "description" : "Identifier '{a}' is not in camel case.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W107", + "name" : "Script URL", + "description" : "Script URL.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W108", + "name" : "Strings must use {a}quote", + "description" : "Strings must use {a}quote", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W109", + "name" : "Strings must use singlequote", + "description" : "Strings must use singlequote.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W110", + "name" : "Mixed double and single quotes", + "description" : "Mixed double and single quotes", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W112", + "name" : "Unclosed string", + "description" : "Unclosed string.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W113", + "name" : "Control character", + "description" : "Control character in string: {a}.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W114", + "name" : "Avoid {a}", + "description" : "Avoid {a}.", + "severity" : "MAJOR", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W115", + "name" : "Don't use octal: '{a}'. Use '\\u...' instead", + "description" : "Don't use octal: '{a}'. Use '\\u...' instead", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "deprecated", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W116", + "name" : "Expected '{a}' and instead saw '{b}'", + "description" : "Expected '{a}' and instead saw '{b}'.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint" ], + "debt" : null +}, { + "key" : "W117", + "name" : "'{a}' was used before it was defined", + "description" : "'{a}' was used before it was defined", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "pitfall", "confusing" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "W118", + "name" : "Mozilla only", + "description" : "'{a}' is only available in Mozilla JavaScript extensions (use moz option).", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "cross-browser", "mozilla" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "W119", + "name" : "ES6 only", + "description" : "'{a}' is only available in ES6 (use esnext option).", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "cross-browser", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1h" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "W120", + "name" : "Variable {a} was not declared correctly", + "description" : "Variable {a} was not declared correctly", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "W121", + "name" : "Extending prototype of native object: '{a}'", + "description" : "Extending prototype of native object: '{a}'", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1h" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "W122", + "name" : "Invalid typeof value '{a}'", + "description" : "Invalid typeof value '{a}'", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "W123", + "name" : "already defined in outer scope", + "description" : "'{a}' is already defined in outer scope.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "scope", "confusing", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W124", + "name" : "generator without yield", + "description" : "A generator function shall contain a yield statement.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "design", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "RELIABILITY_COMPLIANCE" + } +}, { + "key" : "W125", + "name" : "non-breaking spaces", + "description" : "This line contains non-breaking spaces: http://jshint.com/doc/options/#nonbsp", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "I001", + "name" : "Comma warnings", + "description" : "Comma warnings can be turned off with 'laxcomma'.", + "severity" : "INFO", + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "I002", + "name" : "Reserved words", + "description" : "Reserved words as properties can be used under the 'es5' option.", + "severity" : "INFO", + "status" : null, + "tags" : [ "jshint", "es5" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "I003", + "name" : "ES5 option is now set per default", + "description" : "ES5 option is now set per default", + "severity" : "INFO", + "status" : null, + "tags" : [ "jshint", "es5" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "E057", + "name" : "Invalid meta property: '{a}.{b}'.", + "description" : null, + "severity" : null, + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "E059", + "name" : "Incompatible values for the '{a}' and '{b}' linting options.", + "description" : null, + "severity" : null, + "status" : null, + "tags" : [ "jshint-options" ], + "debt" : null +}, { + "key" : "W132", + "name" : "`var` declarations are forbidden. Use `let` or `const` instead.", + "description" : null, + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "convention", "cross-browser", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "W136", + "name" : "'{a}' must be in function scope.", + "description" : null, + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "pitfall", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W133", + "name" : "Invalid for-{a} loop left-hand-side: {b}.", + "description" : null, + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "E056", + "name" : "'{a}' was used before it was declared, which is illegal for '{b}' variables.", + "description" : null, + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "E054", + "name" : "Class properties must be methods. Expected '(' but instead saw '{a}'.", + "description" : null, + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "jshint", "bug", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "W127", + "name" : "Unexpected use of a comma operator.", + "description" : null, + "severity" : null, + "status" : null, + "tags" : null, + "debt" : null +}, { + "key" : "W137", + "name" : "Empty destructuring.", + "description" : null, + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "pitfall", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W138", + "name" : "Parameters order", + "description" : "Regular parameters should not come after default parameters.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W131", + "name" : "Invalid parameter after rest parameter.", + "description" : null, + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "W126", + "name" : "Unnecessary grouping operator.", + "description" : "You should not use parenthesis when not needed", + "severity" : "MINOR", + "status" : null, + "tags" : [ "jshint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "W135", + "name" : "{a} may not be supported by non-browser environments.", + "description" : null, + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug", "server" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "E053", + "name" : "Export declaration must be in global scope.", + "description" : null, + "severity" : "MAJOR", + "status" : null, + "tags" : [ "jshint", "pitfall", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "MODULARITY" + } +}, { + "key" : "W134", + "name" : "The '{a}' option is only available when linting ECMAScript {b} code.", + "description" : null, + "severity" : null, + "status" : null, + "tags" : [ "jshint-options" ], + "debt" : null +}, { + "key" : "W129", + "name" : "'{a}' is defined in a future version of JavaScript. Use a ", + "description" : null, + "severity" : "MINOR", + "status" : null, + "tags" : [ "jshint", "es-next" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "E055", + "name" : "The '{a}' option cannot be set after any executable code.", + "description" : null, + "severity" : null, + "status" : null, + "tags" : [ "jshint-options" ], + "debt" : null +}, { + "key" : "W128", + "name" : "Empty array elements require elision=true.", + "description" : null, + "severity" : null, + "status" : null, + "tags" : [ "jshint-options" ], + "debt" : null +}, { + "key" : "W130", + "name" : "Invalid element after rest element.", + "description" : null, + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "jshint", "bug", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +} ] \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E007.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E007.html index 2897323..c46fd63 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/E007.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E007.html @@ -1,10 +1,11 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Missing 'use strict' statement" error is thrown when JSLint, JSHint and ESLint encounter a function that does not contain the strict mode directive, and none of whose ancestor scopes contain the strict mode directive. JSHint will only raise this warning if the strict option is set to true. Here's an example of a function that does not run in strict mode:

                                                          -
                                                          x
                                                           
                                                          1
                                                          /*jshint strict: true */
                                                          2
                                                          function example() {
                                                          3
                                                              return true;
                                                          4
                                                          }
                                                          5
                                                          JSLint found 1 errorVersion 2013-04-29
                                                          Line 3:Missing 'use strict' statement.
                                                          +
                                                          x
                                                           
                                                          1
                                                          /*jshint strict: true */
                                                          2
                                                          function example() {
                                                          3
                                                              return true;
                                                          4
                                                          }
                                                          5
                                                          JSLint found 1 errorVersion 2013-04-29
                                                          Line 3:Missing 'use strict' statement.

                                                          Why do I get this error?

                                                          This error is raised to highlight a lack of convention. However, as JavaScript engines move forward, this error will increasingly be helpful as it @@ -27,9 +28,11 @@

                                                          Why do I get this error?

                                                          previous link or the corresponding MDN article for the details of the differences in strict mode. You can fix this error by simply adding a "use strict" directive to the function, or to an ancestor function:

                                                          -
                                                          6
                                                           
                                                          1
                                                          /*jshint strict: true */
                                                          2
                                                          function example() {
                                                          3
                                                              "use strict";
                                                          4
                                                              return true;
                                                          5
                                                          }
                                                          6
                                                          JSLint found no errorsVersion 2013-04-29
                                                          +
                                                          6
                                                           
                                                          1
                                                          /*jshint strict: true */
                                                          2
                                                          function example() {
                                                          3
                                                              "use strict";
                                                          4
                                                              return true;
                                                          5
                                                          }
                                                          6
                                                          JSLint found no errorsVersion 2013-04-29

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. This message is treated as an error by JSHint which means you are unable to prevent it from being issued by ID.

                                                          In ESLint the rule that generates this warning is named strict. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E009.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E009.html index 976aeca..ff00ae0 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/E009.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E009.html @@ -1,9 +1,10 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Option 'validthis' can't be used in a global scope" error is thrown when JSHint encounters the validthis option in a global scope. Here's a silly example in which we declare a function that is intended to be invoked in the context of an object:

                                                          -
                                                          x
                                                           
                                                          1
                                                          /*jshint validthis: true */
                                                          2
                                                          function example() {
                                                          3
                                                              "use strict";
                                                          4
                                                              this.x = 10;
                                                          5
                                                          }
                                                          6
                                                          7
                                                          var obj = {};
                                                          8
                                                          example.call(obj);
                                                          9
                                                          JSHint found 2 errorsVersion 2.5.0
                                                          Line 1:Option 'validthis' can't be used in a global scope.
                                                          Line 4:Possible strict violation.
                                                          +
                                                          x
                                                           
                                                          1
                                                          /*jshint validthis: true */
                                                          2
                                                          function example() {
                                                          3
                                                              "use strict";
                                                          4
                                                              this.x = 10;
                                                          5
                                                          }
                                                          6
                                                          7
                                                          var obj = {};
                                                          8
                                                          example.call(obj);
                                                          9
                                                          JSHint found 2 errorsVersion 2.9.0
                                                          Line 1:Option 'validthis' can't be used in a global scope.
                                                          Line 4:Possible strict violation.

                                                          Why do I get this error?

                                                          This error is raised to highlight a breach of JSHint rules. Your code will most likely run without error if you do not fix this issue, but you are breaking @@ -26,7 +27,9 @@

                                                          Why do I get this error?

                                                          To resolve this issue, you simply need to move the directive including the validthis option into the function. You will need it in each function that runs in strict mode and contains references to this:

                                                          -
                                                          9
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              /*jshint validthis: true */
                                                          3
                                                              "use strict";
                                                          4
                                                              this.x = 10;
                                                          5
                                                          }
                                                          6
                                                          7
                                                          var obj = {};
                                                          8
                                                          example.call(obj);
                                                          9
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          9
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              /*jshint validthis: true */
                                                          3
                                                              "use strict";
                                                          4
                                                              this.x = 10;
                                                          5
                                                          }
                                                          6
                                                          7
                                                          var obj = {};
                                                          8
                                                          example.call(obj);
                                                          9
                                                          JSHint found no errorsVersion 2.9.0

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. Since this message relates to JSHint error rather than a warning it is not possible to disable it.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E010.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E010.html index 74cff42..566c958 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/E010.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E010.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in two forms in JSHint and ESLint. It was introduced in the original version of JSLHnt and has remained in both tools since. It does not feature in JSLint.

                                                          @@ -16,7 +17,7 @@

                                                          When do I get this error?

                                                          mode code may not include a with statement", is thrown when JSHint or ESLint encounters the with statement in code that is running in strict mode. Here's an example:

                                                          -
                                                          x
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              var a = {
                                                          4
                                                                  b: 10
                                                          5
                                                              };
                                                          6
                                                              with (a) {
                                                          7
                                                                  b = 20;
                                                          8
                                                              }
                                                          9
                                                          }
                                                          10
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 6:'with' is not allowed in strict mode.
                                                          +
                                                          x
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              var a = {
                                                          4
                                                                  b: 10
                                                          5
                                                              };
                                                          6
                                                              with (a) {
                                                          7
                                                                  b = 20;
                                                          8
                                                              }
                                                          9
                                                          }
                                                          10
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 6:'with' is not allowed in strict mode.

                                                          Why do I get this error?

                                                          This error is raised to highlight a fatal JavaScript syntax error. Your code will fail to run in any environment that supports strict mode. The ECMAScript 5 @@ -29,13 +30,15 @@

                                                          Why do I get this error?

                                                          You can solve this problem by reworking code that uses with statements to fully qualify the "namespace". The following example will behave in exactly the same way as the first example above:

                                                          -
                                                          8
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              var a = {
                                                          4
                                                                  b: 10
                                                          5
                                                              };
                                                          6
                                                              a.b = 20;
                                                          7
                                                          }
                                                          8
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          8
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              var a = {
                                                          4
                                                                  b: 10
                                                          5
                                                              };
                                                          6
                                                              a.b = 20;
                                                          7
                                                          }
                                                          8
                                                          JSHint found no errorsVersion 2.9.0

                                                          If you rely upon the behaviour of the with statement for a valid use-case, your only option is to ensure your code does not run in strict mode. This results in a different message from JSHint, but one that can be surpressed (in version 1.0.0 and above) with the appropriate warning identifier flag. See the page on the "Don't use with" error for more details:

                                                          -
                                                          9
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              var a = {
                                                          3
                                                                  b: 10
                                                          4
                                                              };
                                                          5
                                                              with (a) {
                                                          6
                                                                  b = 20;
                                                          7
                                                              }
                                                          8
                                                          }
                                                          9
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 5:Don't use 'with'.
                                                          +
                                                          9
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              var a = {
                                                          3
                                                                  b: 10
                                                          4
                                                              };
                                                          5
                                                              with (a) {
                                                          6
                                                                  b = 20;
                                                          7
                                                              }
                                                          8
                                                          }
                                                          9
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 5:Don't use 'with'.

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. Since this message relates to a fatal syntax error you cannot disable it.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E011.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E011.html index 68e9c53..73eade7 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/E011.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E011.html @@ -1,10 +1,11 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "const '{a}' has already been declared" error is thrown when JSHint encounters a constant declaration with an identifier that has already been used in a previous constant declaration. In the following example we declare a constant CONST_1 and then attempt to declare a second constant with the same identifier:

                                                          -
                                                          x
                                                           
                                                          1
                                                          /*jshint esnext: true */
                                                          2
                                                          const CONST_1 = 10;
                                                          3
                                                          const CONST_1 = 20;
                                                          4
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 3:const 'CONST_1' has already been declared.
                                                          +
                                                          x
                                                           
                                                          1
                                                          /*jshint esnext: true */
                                                          2
                                                          const CONST_1 = 10;
                                                          3
                                                          const CONST_1 = 20;
                                                          4
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 3:'CONST_1' has already been declared.

                                                          Notice the use of the esnext option. When relying upon ECMAScript 6 features such as constants you should always set this option so JSHint doesn't raise unnecessary warnings. Also note that ESLint will raise a warning in the same @@ -20,7 +21,7 @@

                                                          Why do I get this error?

                                                          You can fix this issue by ensuring each constant declaration uses a unique identifier:

                                                          -
                                                          4
                                                           
                                                          1
                                                          /*jshint esnext: true */
                                                          2
                                                          const CONST_1 = 10;
                                                          3
                                                          const CONST_2 = 20;
                                                          4
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          4
                                                           
                                                          1
                                                          /*jshint esnext: true */
                                                          2
                                                          const CONST_1 = 10;
                                                          3
                                                          const CONST_2 = 20;
                                                          4
                                                          JSHint found no errorsVersion 2.9.0

                                                          However, since browser support for the const statement is limited and most implementations currently differ significantly from the upcoming ECMAScript 6 specification, it's recommended that you don't use it all, and simply use the @@ -30,3 +31,5 @@

                                                          Why do I get this error?

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. Since this message relates to a fatal syntax error you cannot disable it.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E013.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E013.html index e0d4f9e..fe175e2 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/E013.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E013.html @@ -1,10 +1,11 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Attempting to override '{a}' which is a constant" error is thrown when JSHint encounters an assignment expression with an identifer that has been declared in a constant variable statement. In the following example we declare a constant MY_CONST and assign a value to it, and then attempt to change its value:

                                                          -
                                                          x
                                                           
                                                          1
                                                          /*jshint esnext: true */
                                                          2
                                                          const MY_CONST = 10;
                                                          3
                                                          MY_CONST = 20;
                                                          4
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 3:Attempting to override 'MY_CONST' which is a constant.
                                                          +
                                                          x
                                                           
                                                          1
                                                          /*jshint esnext: true */
                                                          2
                                                          const MY_CONST = 10;
                                                          3
                                                          MY_CONST = 20;
                                                          4
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 3:Attempting to override 'MY_CONST' which is a constant.

                                                          Why do I get this error?

                                                          This error is raised to highlight a fatal JavaScript type error. Your code will fail to run if you do not resolve this error. Mozilla Developer Network @@ -15,14 +16,16 @@

                                                          Why do I get this error?

                                                          You can fix this issue by removing any assignments to constants declared with the const keyword:

                                                          -
                                                          3
                                                           
                                                          1
                                                          /*jshint esnext: true */
                                                          2
                                                          const MY_CONST = 10;
                                                          3
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          3
                                                           
                                                          1
                                                          /*jshint esnext: true */
                                                          2
                                                          const MY_CONST = 10;
                                                          3
                                                          JSHint found no errorsVersion 2.9.0

                                                          However, since browser support for the const statement is limited and most implementations currently differ significantly from the upcoming ECMAScript 6 specification, it's recommended that you don't use it all, and simply use the var statement instead. A common convention to indicate a variable with a value that shouldn't change is to give that variable an identifier made up of uppercase characters, as has been done in the previous examples:

                                                          -
                                                          3
                                                           
                                                          1
                                                          /*jshint esnext: true */
                                                          2
                                                          var MY_CONST = 10; // A fake constant
                                                          3
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          3
                                                           
                                                          1
                                                          /*jshint esnext: true */
                                                          2
                                                          var MY_CONST = 10; // A fake constant
                                                          3
                                                          JSHint found no errorsVersion 2.9.0

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. Since this message relates to a fatal syntax error you cannot disable it.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E014.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E014.html index dbcab29..4e861a4 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/E014.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E014.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning was introduced in the original version of JSLint and existed in the same form in JSHint until version 1.0.0 when it was removed. ESLint has always issued the same warning.

                                                          @@ -8,7 +9,7 @@

                                                          When do I get this error?

                                                          expression literal that begins with the = character. In the following example we attempt to assign a regular expression literal to match the string "=1" to the variable x:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var regex = /=1/;
                                                          2
                                                          JSLint found 3 errorsVersion 2014-02-06
                                                          Line 1:A regular expression literal can be confused with '/='.
                                                          Line 1:Stopping. (50% scanned).
                                                          +
                                                          x
                                                           
                                                          1
                                                          var regex = /=1/;
                                                          2
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Expected '/\=' and instead saw '/='.

                                                          Why do I get this error?

                                                          This error is raised to highlight a potentially confusing piece of code. Your code will run fine if you do not fix this error, but it may be confusing to @@ -19,16 +20,18 @@

                                                          Why do I get this error?

                                                          be interpreted as the division operator. Like most of the arithmetic operators, the division operator can be combined with the assignment operator to produce a shorthand:

                                                          -
                                                          3
                                                           
                                                          1
                                                          var x = 10;
                                                          2
                                                          x /= 5; // Shorthand division-assignment operator
                                                          3
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          3
                                                           
                                                          1
                                                          var x = 10;
                                                          2
                                                          x /= 5; // Shorthand division-assignment operator
                                                          3
                                                          JSLint found no errorsVersion 2015-09-23

                                                          This ambiguity is not a problem because the parser should always be able to differentiate between the two uses. However, you can see why the regular expression example at the top of this page could cause initial confusion.

                                                          To solve this issue, you can simply escape the = character in the regular expression. This will behave in exactly the same way but since the = character is no longer the first, the error is not raised:

                                                          -
                                                          2
                                                           
                                                          1
                                                          var regex = /\=1/;
                                                          2
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          2
                                                           
                                                          1
                                                          var regex = /\=1/;
                                                          2
                                                          JSLint found no errorsVersion 2015-09-23

                                                          Alternatively, you can use the RegExp constructor, which removes the need for the ambiguous delimiting / characters:

                                                          -
                                                          2
                                                           
                                                          1
                                                          var regex = new RegExp("=1");
                                                          2
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          2
                                                           
                                                          1
                                                          var regex = new RegExp("=1");
                                                          2
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In ESLint the rule that generates this warning is named no-div-regex. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E015.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E015.html index b580a47..c955e72 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/E015.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E015.html @@ -1,6 +1,7 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Unclosed regular expression" error is thrown when JSLint or JSHint encounters a regular expression literal with no closing / character. Here's an example:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var regex = /^unclosed$;
                                                          2
                                                          JSLint found 3 errorsVersion 2014-02-06
                                                          Line 1:Unclosed regular expression.
                                                          Line 1:Stopping. (50% scanned).
                                                          +
                                                          x
                                                           
                                                          1
                                                          var regex = /^unclosed$;
                                                          2
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Expected '/' and instead saw ''.

                                                          Why do I get this error?

                                                          This error is raised to highlight a fatal JavaScript syntax error. Your code will not run unless you fix this issue. The ECMAScript 5 specification lists the @@ -14,7 +15,9 @@

                                                          Why do I get this error?

                                                          This production makes it clear that regular expression literal bodies must be terminated by a / character. Not doing so will always cause a syntax error. To fix this issue, simply close the regular expression in question:

                                                          -
                                                          2
                                                           
                                                          1
                                                          var regex = /^closed$/;
                                                          2
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          2
                                                           
                                                          1
                                                          var regex = /^closed$/;
                                                          2
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. Since this message relates to a fatal syntax error you cannot disable it.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E017.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E017.html index c791fa2..1684585 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/E017.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E017.html @@ -1,8 +1,9 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Unclosed comment" error is thrown when JSLint or JSHint encounters a multiline comment that does not end with the character sequence */. Here's an example:

                                                          -
                                                          x
                                                           
                                                          1
                                                          /* This is a comment
                                                          2
                                                           * but I forgot to
                                                          3
                                                           * close it.
                                                          4
                                                          JSLint found 3 errorsVersion 2014-02-06
                                                          Line 5:Unclosed comment.
                                                          Line 5:Stopping. (125% scanned).
                                                          +
                                                          x
                                                           
                                                          1
                                                          /* This is a comment
                                                          2
                                                           * but I forgot to
                                                          3
                                                           * close it.
                                                          4
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 4:Unclosed comment.

                                                          Why do I get this error?

                                                          This error is raised to highlight a fatal JavaScript syntax error. Your code will not run unless you fix this issue. The ECMAScript 5 specification lists the @@ -15,7 +16,7 @@

                                                          Why do I get this error?

                                                          characters. If you have an unclosed multiline comment a syntax error will be thrown when the interpreter reaches the end of the file. Here's the above snippet once more, except we've closed the comment this time:

                                                          -
                                                          4
                                                           
                                                          1
                                                          /* This is a comment
                                                          2
                                                           * but I remembered to
                                                          3
                                                           * close it. */
                                                          4
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          4
                                                           
                                                          1
                                                          /* This is a comment
                                                          2
                                                           * but I remembered to
                                                          3
                                                           * close it. */
                                                          4
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. Since this message relates to a fatal syntax error you cannot disable it.

                                                          @@ -25,3 +26,5 @@

                                                          JSHint bug alert

                                                          large number of the same message appear to get generated for the first unclosed comment, to the point where the parser gives up and tells you that there are too many errors.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E029.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E029.html index d921d62..9c3a3ab 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/E029.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E029.html @@ -1,17 +1,18 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Unclosed string" error is thrown when JSLint or JSHint encounters a a string that is not closed before the next line break or the end of the program. There are numerous situations that could cause this. In this first example, we accidentally forget to close our string:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var myString = "my string,
                                                          2
                                                              myNumber = 10;
                                                          3
                                                          JSLint found 3 errorsVersion 2014-02-06
                                                          Line 3:Unclosed string.
                                                          Line 3:Stopping. (100% scanned).
                                                          +
                                                          x
                                                           
                                                          1
                                                          var myString = "my string,
                                                          2
                                                              myNumber = 10;
                                                          3
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Unclosed string.

                                                          In the next example, we want our string to include a backslash character. The string appears to be closed but actually isn't, due to the backslash character escaping the closing quote:

                                                          -
                                                          3
                                                           
                                                          1
                                                          var myString = "my string\",
                                                          2
                                                              myNumber = 10;
                                                          3
                                                          JSLint found 3 errorsVersion 2014-02-06
                                                          Line 3:Unclosed string.
                                                          Line 3:Stopping. (100% scanned).
                                                          +
                                                          3
                                                           
                                                          1
                                                          var myString = "my string\",
                                                          2
                                                              myNumber = 10;
                                                          3
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Unclosed string.

                                                          And this final example, which makes use of the multiline strings allowed by ECMAScript 5, features a string that has not closed by the end of the program (the previous two examples failed at the first line break):

                                                          -
                                                          3
                                                           
                                                          1
                                                          var myString = "my multiline \
                                                          2
                                                                          string
                                                          3
                                                          JSLint found 4 errorsVersion 2014-02-06
                                                          Line 1:Unexpected '\'.
                                                          Line 3:Unclosed string.
                                                          Line 3:Stopping. (100% scanned).
                                                          +
                                                          3
                                                           
                                                          1
                                                          var myString = "my multiline \
                                                          2
                                                                          string
                                                          3
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Unclosed string.

                                                          Why do I get this error?

                                                          This error is raised to highlight a fatal JavaScript syntax error. Your code will not run unless you fix this issue. The ECMAScript grammar states that any @@ -23,12 +24,14 @@

                                                          Why do I get this error?

                                                              ' SingleStringCharactersopt '

                                                          To fix the error, simply close any unclosed strings:

                                                          -
                                                          3
                                                           
                                                          1
                                                          var myString = "my string",
                                                          2
                                                              myNumber = 10;
                                                          3
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          3
                                                           
                                                          1
                                                          var myString = "my string",
                                                          2
                                                              myNumber = 10;
                                                          3
                                                          JSLint found no errorsVersion 2015-09-23

                                                          The second example above failed because the backslash character was escaping the closing quote, turning it into a literal character rather than a syntactic structure. To include a backslash in a string, you need to escape the backslash itself:

                                                          -
                                                          3
                                                           
                                                          1
                                                          var myString = "my string\\",
                                                          2
                                                              myNumber = 10;
                                                          3
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          3
                                                           
                                                          1
                                                          var myString = "my string\\",
                                                          2
                                                              myNumber = 10;
                                                          3
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. Since this message relates to a fatal syntax error you cannot disable it.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E031.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E031.html index 53ea2df..3db81b8 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/E031.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E031.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                          @@ -16,11 +17,11 @@

                                                          When do I get this error?

                                                          assignment expression in which the left-hand side is a call expression. In the following example we have an if statement with an assignment expression where you would normally expect a conditional:

                                                          -
                                                          x
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              example() = 1;
                                                          4
                                                          }
                                                          5
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 3:Bad assignment.
                                                          +
                                                          x
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              example() = 1;
                                                          4
                                                          }
                                                          5
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 2:Bad assignment to '('.

                                                          JSLint also raises this warning when it encounters an assignment to a property of the arguments object. In this example we attempt to define an x property:

                                                          -
                                                          5
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              arguments.x = 1;
                                                          4
                                                          }
                                                          5
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 3:Bad assignment.
                                                          +
                                                          5
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              arguments.x = 1;
                                                          4
                                                          }
                                                          5
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 2:Unexpected 'arguments'.

                                                          Why do I get this error?

                                                          In the case of assignment to a function call this error is raised to highlight a fatal reference error. Your code will throw an error in all environments if @@ -32,16 +33,18 @@

                                                          Why do I get this error?

                                                          actually trying to perform a comparison rather than an assignment. If that's the case just ensure you're using a comparison operator such as === instead of the assignment operator =:

                                                          -
                                                          7
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              if (example() === 1) { // Comparison
                                                          4
                                                                  return true;
                                                          5
                                                              }
                                                          6
                                                          }
                                                          7
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          7
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              if (example() === 1) { // Comparison
                                                          4
                                                                  return true;
                                                          5
                                                              }
                                                          6
                                                          }
                                                          7
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In the case of assignment to a property of an arguments object this error is raised to highlight a bad practice. The arguments object is notoriously difficult to work with and has behaviour that differs significantly between "normal" and "strict" mode. JSLint has numerous warnings related to abuse of the arguments object but if you're receiving the "Bad assignment" error the chances are you can use a normal variable instead:

                                                          -
                                                          7
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              // arguments.x = 1;
                                                          4
                                                              var x = 1;
                                                          5
                                                              return x;
                                                          6
                                                          }
                                                          7
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          7
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              // arguments.x = 1;
                                                          4
                                                              var x = 1;
                                                          5
                                                              return x;
                                                          6
                                                          }
                                                          7
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. Since this message relates to a fatal reference error you cannot disable it.

                                                          In ESLint this error is generated by the Esprima parser and can therefore not be disabled.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E034.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E034.html index ad8a491..370b4d6 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/E034.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E034.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in two forms across JSLint and JSHint. It was introduced in May 2011 version of JSLint and remained in both tools for a period of time.

                                                          @@ -20,7 +21,7 @@

                                                          When do I get this error?

                                                          feature", is thrown when JSHint or JSLint encounters an object property getter or setter. In the following example we create an object x with a getter and setter. The getter is intended to always return half of the set value:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var x = {
                                                          2
                                                              actual: 10,
                                                          3
                                                              get x () {
                                                          4
                                                                  "use strict";
                                                          5
                                                                  return this.actual / 2;
                                                          6
                                                              },
                                                          7
                                                              set x (value) {
                                                          8
                                                                  "use strict";
                                                          9
                                                                  this.actual = value;
                                                          10
                                                              }
                                                          11
                                                          };
                                                          12
                                                          JSHint found 2 errorsVersion 1.1.0
                                                          Line 3:get/set are ES5 features.
                                                          Line 7:get/set are ES5 features.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var x = {
                                                          2
                                                              actual: 10,
                                                          3
                                                              get x () {
                                                          4
                                                                  "use strict";
                                                          5
                                                                  return this.actual / 2;
                                                          6
                                                              },
                                                          7
                                                              set x (value) {
                                                          8
                                                                  "use strict";
                                                          9
                                                                  this.actual = value;
                                                          10
                                                              }
                                                          11
                                                          };
                                                          12
                                                          JSLint found no errorsVersion 1.1.0

                                                          Why do I get this error?

                                                          This error is raised to highlight the use of a newer language feature that might not be supported in all the environments in which your code should run. @@ -39,4 +40,6 @@

                                                          Why do I get this error?

                                                          If you're sure that your code doesn't need to run in older browsers that don't support the ES5 getter/setter syntax, you can fix this error by setting the es5 option to true:

                                                          -
                                                          14
                                                           
                                                          1
                                                          /*jslint es5: true */
                                                          2
                                                          /*jshint es5: true */
                                                          3
                                                          var x = {
                                                          4
                                                              actual: 10,
                                                          5
                                                              get x () {
                                                          6
                                                                  "use strict";
                                                          7
                                                                  return this.actual / 2;
                                                          8
                                                              },
                                                          9
                                                              set x (value) {
                                                          10
                                                                  "use strict";
                                                          11
                                                                  this.actual = value;
                                                          12
                                                              }
                                                          13
                                                          };
                                                          14
                                                          JSHint found no errorsVersion 1.1.0
                                                          +
                                                          14
                                                           
                                                          1
                                                          /*jslint es5: true */
                                                          2
                                                          /*jshint es5: true */
                                                          3
                                                          var x = {
                                                          4
                                                              actual: 10,
                                                          5
                                                              get x () {
                                                          6
                                                                  "use strict";
                                                          7
                                                                  return this.actual / 2;
                                                          8
                                                              },
                                                          9
                                                              set x (value) {
                                                          10
                                                                  "use strict";
                                                          11
                                                                  this.actual = value;
                                                          12
                                                              }
                                                          13
                                                          };
                                                          14
                                                          JSLint found no errorsVersion 1.1.0
                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E039.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E039.html index 4a4cac8..1d92138 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/E039.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E039.html @@ -1,10 +1,11 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Function statements are not invocable. Wrap the whole function invocation in parens" error (and the alternative "Function declarations are not invocable" error) is thrown when JSLint and JSHint encounter a function declaration followed by a pair of parentheses. In the following example we declare the demo function and then attempt to immediately invoke it:

                                                          -
                                                          x
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return true;
                                                          4
                                                          }();
                                                          5
                                                          JSLint found 3 errorsVersion 2014-02-06
                                                          Line 4:Function statements are not invocable. Wrap the whole function invocation in parens.
                                                          Line 4:Stopping. (80% scanned).
                                                          +
                                                          x
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return true;
                                                          4
                                                          }();
                                                          5
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 3:Unexpected '('.

                                                          Why do I get this error?

                                                          This error is raised to highlight a fatal JavaScript syntax error. Your code will not run if you do not fix this error. The ECMAScript 5 specification gives @@ -31,7 +32,7 @@

                                                          Why do I get this error?

                                                          part of a call expression and can therefore be immediately invoked. To do so, we simply need to wrap the declaration, and (by convention) the invoking parentheses, in another pair of parentheses:

                                                          -
                                                          5
                                                           
                                                          1
                                                          (function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return true;
                                                          4
                                                          }());
                                                          5
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          5
                                                           
                                                          1
                                                          (function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return true;
                                                          4
                                                          }());
                                                          5
                                                          JSLint found no errorsVersion 2015-09-23

                                                          The addition of parentheses force the parser to treat this function as an expression instead of a declaration. Since function expressions can be immediately invoked the code is valid and works as expected.

                                                          @@ -47,3 +48,5 @@

                                                          A note on function statements

                                                          non-standard and it's unlikely you will come across one, so I won't go into detail, but just bear it in mind that when JSLint talks about function statements, it's talking about function declarations.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E042.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E042.html index 7e9cb32..efdabce 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/E042.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E042.html @@ -1,10 +1,11 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Stopping. ({a}% scanned)" error is thrown when JSLint or JSHint encounters a JavaScript syntax error and cannot continue to reliably parse the program. JSHint will only raise this error if the passfail option is set to true. In the following example we have half a variable statement which is invalid and cannot be parsed as a complete JavaScript program:

                                                          -
                                                          x
                                                           
                                                          1
                                                          /*jshint passfail: true */
                                                          2
                                                          var
                                                          3
                                                          JSLint found 3 errorsVersion 2014-02-06
                                                          Line 4:Expected an identifier and instead saw '(end)'.
                                                          Line 4:Stopping. (133% scanned).
                                                          +
                                                          x
                                                           
                                                          1
                                                          /*jshint passfail: true */
                                                          2
                                                          var
                                                          3
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 3:Expected an identifier and instead saw '(end)'.

                                                          Why do I get this error?

                                                          This error is raised to highlight a fatal JavaScript syntax error and the fact that the parser cannot reliably finish parsing your program. Your code @@ -12,7 +13,9 @@

                                                          Why do I get this error?

                                                          program, but other errors are usually raised along side this one that should guide you to the problem with your code. In our example, the variable statement is missing an identifier:

                                                          -
                                                          3
                                                           
                                                          1
                                                          /*jshint passfail: true */
                                                          2
                                                          var a;
                                                          3
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          3
                                                           
                                                          1
                                                          /*jshint passfail: true */
                                                          2
                                                          var a;
                                                          3
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. Since this message relates to a fatal syntax error you cannot disable it.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/E052.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/E052.html new file mode 100644 index 0000000..cad2b86 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/E052.html @@ -0,0 +1,35 @@ + +

                                                          When do I get this error?

                                                          +

                                                          The "Unclosed mega literal" error is thrown when JSLint encounters an unclosed +template string literal. JSHint raises the "Unclosed template literal" error +in the same situation. Note that because template string literals are an +ES2015 (ES6) feature this error should only appear when linting ES2015 code with +the appropriate option set in the linter.

                                                          +

                                                          In the following example we attempt to assign an unclosed template string +literal to a:

                                                          +
                                                          /*jslint es6: true */
                                                          +let x = `unclosed;
                                                          +
                                                          +

                                                          Why do I get this error?

                                                          +

                                                          This error is raised to highlight a fatal JavaScript syntax error. Your code +will not run unless you fix this issue. The ECMAScript grammar states that any +template literal must be closed by the backtick character (ES2015 §11.8.68):

                                                          +
                                                          +

                                                          Template ::
                                                          +    NoSubstitutionTemplate
                                                          +    TemplateHead

                                                          +NoSubstitutionTemplate ::
                                                          +    ` TemplateCharactersopt `

                                                          +
                                                          +

                                                          The grammar for NoSubstitutionTemplate is straightforward and shows the +necessary backticks. The second production is far more complicated and beyond +the scope of this article but does also require an opening and closing backtick.

                                                          +

                                                          To fix the error, simply close any unclosed template strings:

                                                          +
                                                          /*jslint es6: true */
                                                          +let x = `unclosed`;
                                                          +
                                                          +

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a +special option syntax. Since this message relates to a fatal +syntax error you cannot disable it.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/I003.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/I003.html index ae6650b..aa2c288 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/I003.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/I003.html @@ -1,9 +1,10 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "ES5 option is now set per default" error is thrown when JSHint (version 2.0.0 and above only) encounters the es5 option with a value of true. Here's an example in which we set the es5 option so we can use reserved words as property identifers (which was not allowed in ES3):

                                                          -
                                                          x
                                                           
                                                          1
                                                          /*jshint es5: true */
                                                          2
                                                          var x = {
                                                          3
                                                              default: 10
                                                          4
                                                          };
                                                          5
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 1:ES5 option is now set per default
                                                          +
                                                          x
                                                           
                                                          1
                                                          /*jshint es5: true */
                                                          2
                                                          var x = {
                                                          3
                                                              default: 10
                                                          4
                                                          };
                                                          5
                                                          JSHint found no errorsVersion 2.9.0

                                                          Why do I get this error?

                                                          This error is raised to highlight a *pointless piece of code. If you're using JSHint 2.0.0 or above, the es5 option will be set to true by default, due to @@ -11,7 +12,9 @@

                                                          Why do I get this error?

                                                          You can simply remove the option from any JSHint directives or .jshintrc files. Select JSHint version 1.1.0 or below in the following example to see the difference from when the es5 option was not on by default:

                                                          -
                                                          4
                                                           
                                                          1
                                                          var x = {
                                                          2
                                                              default: 10
                                                          3
                                                          };
                                                          4
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          4
                                                           
                                                          1
                                                          var x = {
                                                          2
                                                              default: 10
                                                          3
                                                          };
                                                          4
                                                          JSHint found no errorsVersion 2.9.0

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. Since this is an informational JSHint message, it cannot be disabled.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W001.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W001.html index 8ea3724..2aab1eb 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W001.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W001.html @@ -1,10 +1,11 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "'hasOwnProperty' is a really bad name" error is thrown when JSHint encounters an assignment to an object property with the identifier hasOwnProperty. This applies to both object literals and to normal assignment statements. In the following example we define an object with a property called hasOwnProperty:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var demo = {
                                                          2
                                                              hasOwnProperty: 1
                                                          3
                                                          };
                                                          4
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 2:'hasOwnProperty' is a really bad name.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var demo = {
                                                          2
                                                              hasOwnProperty: 1
                                                          3
                                                          };
                                                          4
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 2:'hasOwnProperty' is a really bad name.

                                                          Why do I get this error?

                                                          This error is raised to highlight confusing code that could cause problems in the future. Your code may run as expected but it's likely to cause issues with @@ -17,7 +18,7 @@

                                                          Why do I get this error?

                                                          chain. See the somewhat related "The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype" error for more details:

                                                          -
                                                          12
                                                           
                                                          1
                                                          /*global doSomething */
                                                          2
                                                          var me = {
                                                          3
                                                              name: "James",
                                                          4
                                                              age: 23
                                                          5
                                                          };
                                                          6
                                                          7
                                                          for (var prop in me) {
                                                          8
                                                              if (me.hasOwnProperty(prop)) {
                                                          9
                                                                  doSomething(prop);
                                                          10
                                                              }
                                                          11
                                                          }
                                                          12
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          12
                                                           
                                                          1
                                                          /*global doSomething */
                                                          2
                                                          var me = {
                                                          3
                                                              name: "James",
                                                          4
                                                              age: 23
                                                          5
                                                          };
                                                          6
                                                          7
                                                          for (var prop in me) {
                                                          8
                                                              if (me.hasOwnProperty(prop)) {
                                                          9
                                                                  doSomething(prop);
                                                          10
                                                              }
                                                          11
                                                          }
                                                          12
                                                          JSHint found no errorsVersion 2.9.0

                                                          In that example, were you to add a property hasOwnProperty: 1 to me, the guard in the for...in loop would fail with an error telling you that hasOwnProperty is not a function. If the value of your custom hasOwnProperty @@ -27,8 +28,10 @@

                                                          Why do I get this error?

                                                          identifer. If you are concerned that the value of hasOwnProperty is no longer the native function you may want to call the native function in the context of your object in for...in loop guards:

                                                          -
                                                           
                                                          1
                                                          /*global doSomething */
                                                          2
                                                          var me = {
                                                          3
                                                              name: "James",
                                                          4
                                                              age: 23,
                                                          5
                                                              hasOwnProperty: 1 // This would cause the previous example to fail
                                                          6
                                                          };
                                                          7
                                                          8
                                                          for (var prop in me) {
                                                          9
                                                              if (Object.hasOwnProperty.call(me, prop)) { // Use the real hasOwnProperty
                                                          10
                                                                  doSomething(prop);
                                                          11
                                                              }
                                                          12
                                                          }
                                                          13
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 5:'hasOwnProperty' is a really bad name.
                                                          +
                                                          13
                                                           
                                                          1
                                                          /*global doSomething */
                                                          2
                                                          var me = {
                                                          3
                                                              name: "James",
                                                          4
                                                              age: 23,
                                                          5
                                                              hasOwnProperty: 1 // This would cause the previous example to fail
                                                          6
                                                          };
                                                          7
                                                          8
                                                          for (var prop in me) {
                                                          9
                                                              if (Object.hasOwnProperty.call(me, prop)) { // Use the real hasOwnProperty
                                                          10
                                                                  doSomething(prop);
                                                          11
                                                              }
                                                          12
                                                          }
                                                          13
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 5:'hasOwnProperty' is a really bad name.

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W001. This means you can tell JSHint to not issue this warning with the /*jshint -W001 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W002.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W002.html index 166893b..785a2be 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W002.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W002.html @@ -1,11 +1,12 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Value of '{a}' may be overwritten in IE8 and earlier" error is thrown when JSHint or ESLint encounters a try...catch statement in which the catch identifier is the same as a variable or function identifer. The error is only raised when the identifer in question is declared in the same scope as the catch. In the following example we declare a variable, a, and then use a as the identifier in the catch block:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var a = 1;
                                                          2
                                                          try {
                                                          3
                                                              b();
                                                          4
                                                          } catch (a) {}
                                                          5
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 4:Value of 'a' may be overwritten in IE 8 and earlier.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var a = 1;
                                                          2
                                                          try {
                                                          3
                                                              b();
                                                          4
                                                          } catch (a) {}
                                                          5
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 4:Value of 'a' may be overwritten in IE 8 and earlier.

                                                          JSLint will also raise an error in this situation but it uses the more generic "'{a}' is already defined" message.

                                                          Why do I get this error?

                                                          @@ -47,8 +48,10 @@

                                                          Why do I get this error?

                                                          Alman.

                                                          To resolve this issue simply ensure your exception parameter has an identifier unique to its scope:

                                                          -
                                                          5
                                                           
                                                          1
                                                          var a = 1;
                                                          2
                                                          try {
                                                          3
                                                              b();
                                                          4
                                                          } catch (e) {}
                                                          5
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          5
                                                           
                                                          1
                                                          var a = 1;
                                                          2
                                                          try {
                                                          3
                                                              b();
                                                          4
                                                          } catch (e) {}
                                                          5
                                                          JSHint found no errorsVersion 2.9.0

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W002. This means you can tell JSHint to not issue this warning with the /*jshint -W002 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W004.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W004.html index 94abc5e..4ac0670 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W004.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W004.html @@ -1,3 +1,18 @@ + +

                                                          History

                                                          +

                                                          This warning has existed in two forms across JSLint and JSHint. It was +introduced in the original version of JSLint and has remained in both tools +ever since.

                                                          +
                                                            +
                                                          • In JSLint releases prior to May 2015 and all versions of JSHint the warning +given is "{a} is already defined"

                                                            +
                                                          • +
                                                          • In JSLint releases from May 2015 and later the warning is "Redefinition of +'{a}' from line {b}"

                                                            +
                                                          • +
                                                          +

                                                          The situations that produce the warning have not changed despite changes to the +text of the warning itself.

                                                          When do I get this error?

                                                          The "{a} is already defined" error is thrown when JSLint or JSHint encounters a declaration with an identifier that has been used in a previous @@ -5,7 +20,7 @@

                                                          When do I get this error?

                                                          it only applies when the declarations appear within the scope of a function rather than the global scope. In the following example we attempt to declare the variable x twice within the same scope:

                                                          -
                                                          x
                                                           
                                                          1
                                                          function test() {
                                                          2
                                                              "use strict";
                                                          3
                                                              var a = 1,
                                                          4
                                                                  a = 2;
                                                          5
                                                              return a;
                                                          6
                                                          }
                                                          7
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 4:'a' is already defined.
                                                          +
                                                          x
                                                           
                                                          1
                                                          function test() {
                                                          2
                                                              "use strict";
                                                          3
                                                              var a = 1,
                                                          4
                                                                  a = 2;
                                                          5
                                                              return a;
                                                          6
                                                          }
                                                          7
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 4:'a' is already defined.

                                                          Why do I get this error?

                                                          This error is raised to highlight a probable bug. Your code will most likely fail to work as expected if you do not resolve this issue.

                                                          @@ -17,11 +32,13 @@

                                                          Why do I get this error?

                                                          identifier of one of the variables. There are no situations in which it makes sense or is useful to redeclare a variable. Simply rename one of them appropriately:

                                                          -
                                                          6
                                                           
                                                          1
                                                          function test() {
                                                          2
                                                              "use strict";
                                                          3
                                                              var a = 1,
                                                          4
                                                                  b = 2;
                                                          5
                                                          }
                                                          6
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          6
                                                           
                                                          1
                                                          function test() {
                                                          2
                                                              "use strict";
                                                          3
                                                              var a = 1,
                                                          4
                                                                  b = 2;
                                                          5
                                                          }
                                                          6
                                                          JSHint found no errorsVersion 2.9.0

                                                          Alternatively, you may have intended to have two assignments and simply mistyped a semicolon as a comma. In that case it's also an obvious fix:

                                                          -
                                                          6
                                                           
                                                          1
                                                          function test() {
                                                          2
                                                              "use strict";
                                                          3
                                                              var a = 1;
                                                          4
                                                              a = 2;
                                                          5
                                                          }
                                                          6
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          6
                                                           
                                                          1
                                                          function test() {
                                                          2
                                                              "use strict";
                                                          3
                                                              var a = 1;
                                                          4
                                                              a = 2;
                                                          5
                                                          }
                                                          6
                                                          JSHint found no errorsVersion 2.9.0

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W004. This means you can tell JSHint to not issue this warning with the /*jshint -W004 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W005.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W005.html index a6fad8a..52e2af3 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W005.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W005.html @@ -1,9 +1,10 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "A dot following a number can be confused with a decimal point" error is thrown when JSHint encounters a numeric literal containing a decimal point as the left-hand-side of a member expression. In the following example we attempt to assign the string representation of a number to a variable:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var a = 5.4.toString();
                                                          2
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 1:A dot following a number can be confused with a decimal point.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var a = 5.4.toString();
                                                          2
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 1:A dot following a number can be confused with a decimal point.

                                                          Note that this is slightly different to closely related "A trailing decimal point can be consued with a dot" error, although JSLint will use that message in this situation too.

                                                          @@ -17,8 +18,10 @@

                                                          Why do I get this error?

                                                          of the . character is removed. However the construct can appear confusing at first glance.

                                                          The best solution in this case is to wrap the number in parentheses:

                                                          -
                                                          2
                                                           
                                                          1
                                                          var a = (5.4).toString();
                                                          2
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          2
                                                           
                                                          1
                                                          var a = (5.4).toString();
                                                          2
                                                          JSHint found no errorsVersion 2.9.0

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W005. This means you can tell JSHint to not issue this warning with the /*jshint -W005 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W006.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W006.html index ba5f9f0..1d84c17 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W006.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W006.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in a few forms in both JSLint and JSHint. It was introduced in the original version of JSLint and has remained in both tools ever since.

                                                          @@ -17,7 +18,7 @@

                                                          When do I get this error?

                                                          operator in which the right-hand-side expression is preceded by the unary - operator
                                                          . In the following example we attempt to compute the addition of a numeric literal and the numeric value of a variable:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var a = "10",
                                                          2
                                                              b = 5 - -a;
                                                          3
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 2:Confusing minuses.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var a = "10",
                                                          2
                                                              b = 5 - -a;
                                                          3
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 2:Confusing minuses.

                                                          Why do I get this error?

                                                          This error is raised to highlight a potentially confusing piece of code. Your code will most likely run as expected but it could cause issues with @@ -49,8 +50,10 @@

                                                          Why do I get this error?

                                                          operand. This makes the above example slightly confusing on first glance.

                                                          To resolve this issue the easiest fix is to wrap the unary expression in parentheses to disambiguate the - characters:

                                                          -
                                                          3
                                                           
                                                          1
                                                          var a = "10",
                                                          2
                                                              b = 5 - (-a);
                                                          3
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          3
                                                           
                                                          1
                                                          var a = "10",
                                                          2
                                                              b = 5 - (-a);
                                                          3
                                                          JSHint found no errorsVersion 2.9.0

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W006. This means you can tell JSHint to not issue this warning with the /*jshint -W006 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W007.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W007.html index 9ad0aa0..3dc9dcc 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W007.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W007.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in a few forms in both JSLint and JSHint. It was introduced in the original version of JSLint and has remained in both tools ever since.

                                                          @@ -17,7 +18,7 @@

                                                          When do I get this error?

                                                          operator in which the right-hand-side expression is preceded by the unary + operator. In the following example we attempt to compute the addition of a numeric literal and the numeric value of a variable:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var a = "5",
                                                          2
                                                              b = 5 + +a;
                                                          3
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 2:Confusing plusses.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var a = "5",
                                                          2
                                                              b = 5 + +a;
                                                          3
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 2:Confusing plusses.

                                                          Why do I get this error?

                                                          This error is raised to highlight a potentially confusing piece of code. Your code will most likely run as expected but it could cause issues with @@ -46,8 +47,10 @@

                                                          Why do I get this error?

                                                          ++ operator is far more commonly used than the unary + operator.

                                                          To resolve this issue the easiest fix is to wrap the unary expression in parentheses to disambiguate the + characters:

                                                          -
                                                          3
                                                           
                                                          1
                                                          var a = "5",
                                                          2
                                                              b = 5 + (+a);
                                                          3
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          3
                                                           
                                                          1
                                                          var a = "5",
                                                          2
                                                              b = 5 + (+a);
                                                          3
                                                          JSHint found no errorsVersion 2.9.0

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W007. This means you can tell JSHint to not issue this warning with the /*jshint -W007 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W008.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W008.html index c5de132..0ce7953 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W008.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W008.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                          @@ -20,7 +21,7 @@

                                                          When do I get this error?

                                                          JSLint, JSHint and ESLint encounter a numeric literal preceded by a . token which itself is not preceded by a decimal integer literal. Here's an example in which we attempt to assign the value 0.5 to the variable x:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var x = .5;
                                                          2
                                                          JSLint found 1 errorVersion 2013-04-29
                                                          Line 1:A leading decimal point can be confused with a dot: '.5'.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var x = .5;
                                                          2
                                                          JSLint found 1 errorVersion 2013-04-29
                                                          Line 1:A leading decimal point can be confused with a dot: '.5'.

                                                          Why do I get this error?

                                                          This error is raised to highlight a potentially confusing piece of code. Your code will run without error if you do not address this issue but it could @@ -41,10 +42,12 @@

                                                          Why do I get this error?

                                                          explicit first production from the above grammar, just to make your code easier to understand. Therefore to fix this error you can simply prepend a 0 to your number:

                                                          -
                                                          2
                                                           
                                                          1
                                                          var x = 0.5;
                                                          2
                                                          JSLint found no errorsVersion 2013-04-29
                                                          +
                                                          2
                                                           
                                                          1
                                                          var x = 0.5;
                                                          2
                                                          JSLint found no errorsVersion 2013-04-29

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W008. This means you can tell JSHint to not issue this warning with the /*jshint -W008 */ directive.

                                                          In ESLint the rule that generates this warning is named no-floating-decimal. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W009.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W009.html index 203d93d..99e03d0 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W009.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W009.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                          @@ -21,7 +22,7 @@

                                                          When do I get this error?

                                                          encounter a call to the Array constructor preceded by the new operator with no arguments or more than one argument or a single argument that is not a number. Here's an example:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var x = new Array(),
                                                          2
                                                              y = new Array(1, 2, 3),
                                                          3
                                                              z = new Array("not a number");
                                                          4
                                                          JSLint found 3 errorsVersion 2014-02-06
                                                          Line 1:Use the array literal notation [].
                                                          Line 2:Use the array literal notation [].
                                                          Line 3:Use the array literal notation [].
                                                          +
                                                          x
                                                           
                                                          1
                                                          var x = new Array(),
                                                          2
                                                              y = new Array(1, 2, 3),
                                                          3
                                                              z = new Array("not a number");
                                                          4
                                                          JSLint found 3 errorsVersion 2015-09-23
                                                          Line 0:Expected '[]' and instead saw 'new Array'.
                                                          Line 1:Expected '[]' and instead saw 'new Array'.
                                                          Line 2:Expected '[]' and instead saw 'new Array'.

                                                          ESLint is slightly more accurate and also warns when it encounters a call to the Array constructor with no arguments, regardless of whether the new operator is present or not. This makes sense because the Array constructor @@ -37,7 +38,7 @@

                                                          Why do I get this error?

                                                          verbose piece of code. Before we look at why that above snippet is potentially dangerous, here's a rewritten version using array literal notation that passes all three linters. Notice that it's significantly shorter:

                                                          -
                                                          2
                                                           
                                                          1
                                                          var x = [];
                                                          2
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          2
                                                           
                                                          1
                                                          var x = [];
                                                          2
                                                          JSLint found no errorsVersion 2015-09-23

                                                          Since the Array constructor is actually just a property of the global object, it can be overwritten. If it has been overwritten, then it's possible the first example above will generate a type error. For example, if you had run something @@ -46,16 +47,18 @@

                                                          Why do I get this error?

                                                          Here's an example in which we overwrite the Array constructor. Note that JSLint, JSHint and ESLint do not know that's what has happened. Therefore, they take the safe approach and forbid the use of the Array constructor completely:

                                                          -
                                                          3
                                                           
                                                          1
                                                          Array = 50;
                                                          2
                                                          var x = new Array(); //TypeError: Array is not a function
                                                          3
                                                          JSLint found 2 errorsVersion 2014-02-06
                                                          Line 1:Read only.
                                                          Line 2:Use the array literal notation [].
                                                          +
                                                          3
                                                           
                                                          1
                                                          Array = 50;
                                                          2
                                                          var x = new Array(); //TypeError: Array is not a function
                                                          3
                                                          JSLint found 2 errorsVersion 2015-09-23
                                                          Line 0:Bad assignment to 'Array'.
                                                          Line 1:Expected '[]' and instead saw 'new Array'.

                                                          However there is one relatively common situation in which the Array constructor is correctly used and that's when you need to create an array of specific length. The array literal notation provides no mechanism to do this. All three linters cover this use case and do not warn when they encounter a call to the Array constructor with a single numeric argument:

                                                          -
                                                          2
                                                           
                                                          1
                                                          var x = new Array(10);
                                                          2
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          2
                                                           
                                                          1
                                                          var x = new Array(10);
                                                          2
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Expected '[]' and instead saw 'new Array'.

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W009. This means you can tell JSHint to not issue this warning with the /*jshint -W009 */ directive.

                                                          In ESLint the rule that generates this warning is named no-array-constructor. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W010.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W010.html index 10d3b60..43e2642 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W010.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W010.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in various forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                          @@ -24,13 +25,13 @@

                                                          When do I get this error?

                                                          Object.create(null)" error) are thrown when JSLint, JSHint and ESLint encounter a call to the Object constructor preceded by the new operator. Here's an example:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var x = new Object();
                                                          2
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 1:Use the object literal notation {} or Object.create(null).
                                                          +
                                                          x
                                                           
                                                          1
                                                          var x = new Object();
                                                          2
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Expected 'Object.create(null)' and instead saw 'new Object'.

                                                          Why do I get this error?

                                                          This error is raised to highlight a potentially dangerous and unnecessarily verbose piece of code. Before we look at why that above snippet is potentially dangerous, here's a rewritten version using object literal notation that passes all three linters. Notice that it's significantly shorter:

                                                          -
                                                          2
                                                           
                                                          1
                                                          var x = {};
                                                          2
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          2
                                                           
                                                          1
                                                          var x = {};
                                                          2
                                                          JSLint found no errorsVersion 2015-09-23

                                                          Since the Object constructor is actually just a property of the global object, it can be overwritten. If it has been overwritten, then it's possible the first example above will generate a type error. For example, if you had run something @@ -39,7 +40,7 @@

                                                          Why do I get this error?

                                                          Here's an example in which we overwrite the Object constructor. Note that JSLint, JSHint and ESLint do not know that's what has happened. Therefore, they take the safe approach and forbid the use of the Object constructor completely:

                                                          -
                                                          3
                                                           
                                                          1
                                                          Object = 50;
                                                          2
                                                          var x = new Object(); //TypeError: Array is not a function
                                                          3
                                                          JSLint found 2 errorsVersion 2014-02-06
                                                          Line 1:Read only.
                                                          Line 2:Use the object literal notation {} or Object.create(null).
                                                          +
                                                          3
                                                           
                                                          1
                                                          Object = 50;
                                                          2
                                                          var x = new Object(); //TypeError: Array is not a function
                                                          3
                                                          JSLint found 2 errorsVersion 2015-09-23
                                                          Line 0:Bad assignment to 'Object'.
                                                          Line 1:Expected 'Object.create(null)' and instead saw 'new Object'.

                                                          Always using the literal form prevents running into problems like this, however unlikely they may be. Note that the literal form is identical to the constructor form (ES5 §11.1.5):

                                                          @@ -60,8 +61,10 @@

                                                          A note on Object.create(null)Object.prototype. If that's the case you can create an object that doesn't have a prototype chain:

                                                          -
                                                          2
                                                           
                                                          1
                                                          var x = Object.create(null);
                                                          2
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          2
                                                           
                                                          1
                                                          var x = Object.create(null);
                                                          2
                                                          JSLint found no errorsVersion 2015-09-23

                                                          It's important to remember that this is not identical to an object literal. An object literal inherits from Object.prototype but an object created with Object.create(null) does not. This is useful when all you need is a simple key-value store.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W019.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W019.html index dee5645..59957c8 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W019.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W019.html @@ -1,10 +1,11 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Use the isNaN function to compare with NaN" error is thrown when JSLint, JSHint and ESLint encounter a comparison in which one side is NaN. In the following example we attempt to convert a string into a number with the parseInt function, which returns NaN when it can't perform such a conversion:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var x = parseInt("myString", 10);
                                                          2
                                                          if (x === NaN) {
                                                          3
                                                              x = 10;
                                                          4
                                                          }
                                                          5
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 2:Use the isNaN function to compare with NaN.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var x = parseInt("myString", 10);
                                                          2
                                                          if (x === NaN) {
                                                          3
                                                              x = 10;
                                                          4
                                                          }
                                                          5
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 1:Use the isNaN function to compare with NaN.

                                                          Why do I get this error?

                                                          This error is raised to highlight code that doesn't work as you expect it to. Your code will run without error, but will not behave as you expect. NaN @@ -33,10 +34,12 @@

                                                          Why do I get this error?

                                                          which is a built-in property of the global object. It's defined in ES5 §15.1.2.4 and simply returns true if its argument coerces to NaN, and false if it does not:

                                                          -
                                                          5
                                                           
                                                          1
                                                          var x = parseInt("myString", 10);
                                                          2
                                                          if (isNaN(x)) {
                                                          3
                                                              x = 10;
                                                          4
                                                          }
                                                          5
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          5
                                                           
                                                          1
                                                          var x = parseInt("myString", 10);
                                                          2
                                                          if (isNaN(x)) {
                                                          3
                                                              x = 10;
                                                          4
                                                          }
                                                          5
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W019. This means you can tell JSHint to not issue this warning with the /*jshint -W019 */ directive.

                                                          In ESLint the rule that generates this warning is named use-isnan. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W020.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W020.html index b51421b..348f9cc 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W020.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W020.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained (in a way) in all three tools ever since.

                                                          @@ -15,14 +16,14 @@

                                                          When do I get this error?

                                                          is thrown when JSLint, JSHint or ESLint encounters assign a value to built-in native object. In the following example we attempt to overwrite the native global String constructor function:

                                                          -
                                                          x
                                                           
                                                          1
                                                          String = function () {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "Overwritten";
                                                          4
                                                          };
                                                          5
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 1:Read only.
                                                          +
                                                          x
                                                           
                                                          1
                                                          String = function () {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "Overwritten";
                                                          4
                                                          };
                                                          5
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Bad assignment to 'String'.

                                                          Between April 2013 and August 2013 JSLint also produced this message when it encountered an assignment inside a catch block to the identifer associated -with that block. This message was used instead of the older "Do not assign to +with that block. This message was used instead of the older "Do not assign to the exception parameter" warning. Please see the page for that message for more details. The rest of this article will apply only to the above cause. In August 2013 this functionality was removed from JSLint:

                                                          -
                                                          7
                                                           
                                                          1
                                                          try {
                                                          2
                                                              // Some code that might throw an exception
                                                          3
                                                              throw new Error();
                                                          4
                                                          } catch (e) {
                                                          5
                                                              e = 10;
                                                          6
                                                          }
                                                          7
                                                          JSLint found 1 errorVersion 2013-03-28
                                                          Line 5:Do not assign to the exception parameter.
                                                          +
                                                          7
                                                           
                                                          1
                                                          try {
                                                          2
                                                              // Some code that might throw an exception
                                                          3
                                                              throw new Error();
                                                          4
                                                          } catch (e) {
                                                          5
                                                              e = 10;
                                                          6
                                                          }
                                                          7
                                                          JSLint found 1 errorVersion 2013-03-28
                                                          Line 5:Do not assign to the exception parameter.

                                                          Why do I get this error?

                                                          This error is raised to highlight a potentially dangerous piece of code. Your code may work properly if you do not fix this error, but it may be @@ -78,3 +79,5 @@

                                                          Why do I get this error?

                                                          special option syntax. The identifier of this warning is W020. This means you can tell JSHint to not issue this warning with the /*jshint -W020 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W022.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W022.html index ad498f5..bce217d 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W022.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W022.html @@ -1,9 +1,10 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Do not assign to the exception parameter" error is thrown when JSLint, JSHint or ESLint encounters an assignment inside a catch block to the identifer associated with that block. In the following example we attempt to assign a new value to the exception parameter e:

                                                          -
                                                          x
                                                           
                                                          1
                                                          try {
                                                          2
                                                              // Some code that might throw an exception
                                                          3
                                                              throw new Error();
                                                          4
                                                          } catch (e) {
                                                          5
                                                              e = 10;
                                                          6
                                                          }
                                                          7
                                                          JSLint found 1 errorVersion 2013-03-28
                                                          Line 5:Do not assign to the exception parameter.
                                                          +
                                                          x
                                                           
                                                          1
                                                          try {
                                                          2
                                                              // Some code that might throw an exception
                                                          3
                                                              throw new Error();
                                                          4
                                                          } catch (e) {
                                                          5
                                                              e = 10;
                                                          6
                                                          }
                                                          7
                                                          JSLint found 1 errorVersion 2013-03-28
                                                          Line 5:Do not assign to the exception parameter.

                                                          In April 2013 the message given by JSLint in this situation changed from "Do not assign to the exception parameter" to the more generic "Read only", which is given in numerous other scenarios. As of August 2013 this functionality is no @@ -55,3 +56,5 @@

                                                          A note regarding the exception value to the exception parameter, rather than a variable with the same identifier in an outer scope. For more information, have a read of this excellent article by Ben Alman.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W024.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W024.html index 0e2777a..01f298b 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W024.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W024.html @@ -1,16 +1,17 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Expected an identifier and instead saw '{a}' (a reserved word)" error is thrown when JSLint or JSHint encounters a reference to what should be an identifier but is actually a keyword that is reserved by the language. In the following example we attempt to declare a variable with the identifier default which is a reserved word:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var default = 10;
                                                          2
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 1:Expected an identifier and instead saw 'default' (a reserved word).
                                                          +
                                                          x
                                                           
                                                          1
                                                          var default = 10;
                                                          2
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Reserved name 'default'.

                                                          JSLint prior to September 2013 and JSHint prior to version 2.0.0 would also raise this error when it encountered an object property identifier that is a reserved word. This is valid in the ECMAScript 5 specification, but was not valid previously. In this example we attempt to declare an object property with the identifier default:

                                                          -
                                                          4
                                                           
                                                          1
                                                          var x = {
                                                          2
                                                              default: "a default value"
                                                          3
                                                          };
                                                          4
                                                          JSHint found 1 errorVersion 1.1.0
                                                          Line 2:Expected an identifier and instead saw 'default' (a reserved word).
                                                          +
                                                          4
                                                           
                                                          1
                                                          var x = {
                                                          2
                                                              default: "a default value"
                                                          3
                                                          };
                                                          4
                                                          JSLint found no errorsVersion 1.1.0

                                                          Why do I get this error?

                                                          This error is raised to highlight a fatal JavaScript syntax error. Your code will not run if you do not fix this error. Reserved words are special @@ -83,12 +84,14 @@

                                                          Why do I get this error?

                                                          you do not care about these older browsers, you can tell JSLint to ignore this syntax by using the es5 directive (or updating to a more recent version of JSLint):

                                                          -
                                                          5
                                                           
                                                          1
                                                          /*jshint es5: true */
                                                          2
                                                          var x = {
                                                          3
                                                              default: "a default value"
                                                          4
                                                          };
                                                          5
                                                          JSHint found no errorsVersion 1.1.0
                                                          +
                                                          5
                                                           
                                                          1
                                                          /*jshint es5: true */
                                                          2
                                                          var x = {
                                                          3
                                                              default: "a default value"
                                                          4
                                                          };
                                                          5
                                                          JSLint found no errorsVersion 1.1.0

                                                          However, if you do need your code to run in older browsers, you will need to change your syntax slightly and quote the identifier so it's treated as a string rather than a reserved word:

                                                          -
                                                          4
                                                           
                                                          1
                                                          var x = {
                                                          2
                                                              "default": "a default value"
                                                          3
                                                          };
                                                          4
                                                          JSHint found no errorsVersion 1.1.0
                                                          +
                                                          4
                                                           
                                                          1
                                                          var x = {
                                                          2
                                                              "default": "a default value"
                                                          3
                                                          };
                                                          4
                                                          JSLint found no errorsVersion 1.1.0

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W024. This means you can tell JSHint to not issue this warning with the /*jshint -W024 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W025.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W025.html index d84b76d..52026b8 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W025.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W025.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in three forms across the three main linters. It was introduced in the original version of JSLint and has remained (in a way) in all three tools ever since.

                                                          @@ -20,7 +21,7 @@

                                                          When do I get this error?

                                                          the function keyword, where it would normally be parsed as a statement, followed immediately by an opening parenthesis. In the following example we attempt to define a function but forget to give it an identifier:

                                                          -
                                                          x
                                                           
                                                          1
                                                          function () {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "something";
                                                          4
                                                          }
                                                          5
                                                          JSLint found 3 errorsVersion 2014-02-06
                                                          Line 1:Missing name in function statement.
                                                          Line 1:Stopping. (20% scanned).
                                                          +
                                                          x
                                                           
                                                          1
                                                          function () {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "something";
                                                          4
                                                          }
                                                          5
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Expected an identifier and instead saw '('.

                                                          Why do I get this error?

                                                          This error is raised to highlight a fatal JavaScript syntax error. Your code will not run unless you fix this issue. The ECMAScript grammar states that a @@ -42,13 +43,15 @@

                                                          Why do I get this error?

                                                          function expressions is what makes it possible to create anonymous functions. However, in our example above, the code is parsed as a statement rather than an expression. To fix the issue, give the function an identifier:

                                                          -
                                                          5
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "something";
                                                          4
                                                          }
                                                          5
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          5
                                                           
                                                          1
                                                          function example() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "something";
                                                          4
                                                          }
                                                          5
                                                          JSLint found no errorsVersion 2015-09-23

                                                          Alternatively, make sure the code is parsed as an expression, rather than a statement. There are numerous way of doing this, but in our example the only one that really makes sense is to assign the anonymous function to a variable (don't forget the semi-colon):

                                                          -
                                                          5
                                                           
                                                          1
                                                          var example = function () {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "something";
                                                          4
                                                          }
                                                          5
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 4:Expected ';' and instead saw '(end)'.
                                                          +
                                                          5
                                                           
                                                          1
                                                          var example = function () {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "something";
                                                          4
                                                          }
                                                          5
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 3:Expected ';' and instead saw '(end)'.

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W025. This means you can tell JSHint to not issue this warning with the /*jshint -W025 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W030.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W030.html index ac1ff93..48bf48e 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W030.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W030.html @@ -1,19 +1,22 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Expected an assignment or function call and instead saw an expression" error is thrown when JSLint, JSHint or ESLint encounters an expression with no effect. In the following example we have a conditional expression that will evaluate to true but has no other effect on the program:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var x = 1;
                                                          2
                                                          x === 1; // Evaluates to 'true'
                                                          3
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 2:Expected an assignment or function call and instead saw an expression.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var x = 1;
                                                          2
                                                          x === 1; // Evaluates to 'true'
                                                          3
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 1:Unexpected expression '===' in statement position.

                                                          Why do I get this error?

                                                          This error is raised to highlight a piece of useless and unnecessary code. The code will work as expected but since a lone floating expression has no effect on anything there is no point in it being there at all.

                                                          In general you would expect to see a statement which has an effect, such as assigning a value to a variable or invoking a function:

                                                          -
                                                          3
                                                           
                                                          1
                                                          var x = 1;
                                                          2
                                                          x = 2; // Assignment instead of unused expression
                                                          3
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          3
                                                           
                                                          1
                                                          var x = 1;
                                                          2
                                                          x = 2; // Assignment instead of unused expression
                                                          3
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W030. This means you can tell JSHint to not issue this warning with the /*jshint -W030 */ directive.

                                                          In ESLint the rule that generates this warning is named no-unused-expressions. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W031.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W031.html index 7dfd651..17bfa5f 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W031.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W031.html @@ -1,11 +1,12 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Do not use 'new' for side effects" error is thrown when JSLint, JSHint or ESLint encounters a function invocation preceded by the new operator when not part of an assignment or comparison expression. JSHint will only issue this warning if the nonew option is set to true. In the following example we call the built-in Date function as a constructor but don't assign the returned instance to anything:

                                                          -
                                                          x
                                                           
                                                          1
                                                          /*jshint nonew: true */
                                                          2
                                                          new Date();
                                                          3
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 2:Do not use 'new' for side effects.
                                                          +
                                                          x
                                                           
                                                          1
                                                          /*jshint nonew: true */
                                                          2
                                                          new Date();
                                                          3
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 1:Unexpected expression 'new' in statement position.

                                                          Why do I get this error?

                                                          This error is raised to highlight a a lack of convention. While the code is perfectly valid it contravenes best practice, and in the case of the example @@ -20,15 +21,17 @@

                                                          Why do I get this error?

                                                          consider reworking your code to allow you to call the function normally, without the new operator. In the following simple example the side effect of calling the constructor is the incrementation of a variable:

                                                          -
                                                          12
                                                           
                                                          1
                                                          /*jshint nonew: true */
                                                          2
                                                          var counter = 0;
                                                          3
                                                          4
                                                          function Person(name) {
                                                          5
                                                              "use strict";
                                                          6
                                                              this.name = name;
                                                          7
                                                              counter += 1;
                                                          8
                                                          }
                                                          9
                                                          10
                                                          var me = new Person("James");
                                                          11
                                                          new Person(); // Increments 'counter' as a side-effect
                                                          12
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 11:Do not use 'new' for side effects.
                                                          +
                                                          12
                                                           
                                                          1
                                                          /*jshint nonew: true */
                                                          2
                                                          var counter = 0;
                                                          3
                                                          4
                                                          function Person(name) {
                                                          5
                                                              "use strict";
                                                          6
                                                              this.name = name;
                                                          7
                                                              counter += 1;
                                                          8
                                                          }
                                                          9
                                                          10
                                                          var me = new Person("James");
                                                          11
                                                          new Person(); // Increments 'counter' as a side-effect
                                                          12
                                                          JSLint found 2 errorsVersion 2015-09-23
                                                          Line 5:Unexpected 'this'.
                                                          Line 10:Unexpected expression 'new' in statement position.

                                                          In the above example we create two instances of Person but only keep the reference to one. The second call is simply there for the side effect of incrementing the counter. This example could be reworked to increment the counter without calling the constructor:

                                                          -
                                                          12
                                                           
                                                          1
                                                          /*jshint nonew: true */
                                                          2
                                                          var counter = 0;
                                                          3
                                                          4
                                                          function Person(name) {
                                                          5
                                                              "use strict";
                                                          6
                                                              this.name = name;
                                                          7
                                                              counter += 1;
                                                          8
                                                          }
                                                          9
                                                          10
                                                          var me = new Person("James");
                                                          11
                                                          counter += 1; // Don't use the constructor
                                                          12
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          12
                                                           
                                                          1
                                                          /*jshint nonew: true */
                                                          2
                                                          var counter = 0;
                                                          3
                                                          4
                                                          function Person(name) {
                                                          5
                                                              "use strict";
                                                          6
                                                              this.name = name;
                                                          7
                                                              counter += 1;
                                                          8
                                                          }
                                                          9
                                                          10
                                                          var me = new Person("James");
                                                          11
                                                          counter += 1; // Don't use the constructor
                                                          12
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 5:Unexpected 'this'.

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W031. This means you can tell JSHint to not issue this warning with the /*jshint -W031 */ directive.

                                                          In ESLint the rule that generates this warning is named no-new. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W032.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W032.html index 169644f..7e8a01c 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W032.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W032.html @@ -1,6 +1,7 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Unnecessary semicolon" error is thrown when JSHint or ESLint encounters a semicolon following a block statement or function declaration. In the following example we mistakenly include a semicolon after an if statement body (which is a block statement), and another after a function declaration:

                                                          -
                                                          x
                                                           
                                                          1
                                                          function example(a) {
                                                          2
                                                              "use strict";
                                                          3
                                                              if (a) {
                                                          4
                                                                  return true;
                                                          5
                                                              };
                                                          6
                                                          };
                                                          7
                                                          JSHint found 2 errorsVersion 2.5.0
                                                          Line 5:Unnecessary semicolon.
                                                          Line 6:Unnecessary semicolon.
                                                          +
                                                          x
                                                           
                                                          1
                                                          function example(a) {
                                                          2
                                                              "use strict";
                                                          3
                                                              if (a) {
                                                          4
                                                                  return true;
                                                          5
                                                              };
                                                          6
                                                          };
                                                          7
                                                          JSHint found 2 errorsVersion 2.9.0
                                                          Line 5:Unnecessary semicolon.
                                                          Line 6:Unnecessary semicolon.

                                                          Why do I get this error?

                                                          This error is raised to highlight a pointless piece of code. Semicolons are not required after block statements or function declarations. The specification @@ -18,10 +19,12 @@

                                                          Why do I get this error?

                                                          This time there is no semicolon which means its safe to remove the extra semicolons from the previous example. This will resolve the issue:

                                                          -
                                                          7
                                                           
                                                          1
                                                          function example(a) {
                                                          2
                                                              "use strict";
                                                          3
                                                              if (a) {
                                                          4
                                                                  return true;
                                                          5
                                                              }
                                                          6
                                                          }
                                                          7
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          7
                                                           
                                                          1
                                                          function example(a) {
                                                          2
                                                              "use strict";
                                                          3
                                                              if (a) {
                                                          4
                                                                  return true;
                                                          5
                                                              }
                                                          6
                                                          }
                                                          7
                                                          JSHint found no errorsVersion 2.9.0

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W032. This means you can tell JSHint to not issue this warning with the /*jshint -W032 */ directive.

                                                          In ESLint the rule that generates this warning is named no-extra-semi. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W034.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W034.html index 99e6e38..38541fe 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W034.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W034.html @@ -1,10 +1,11 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Unnecessary 'use strict'" error (and the alternative "Unnecessary directive '{a}'" error) is thrown when JSLint, JSHint or ESLint encounters a "use strict" directive in code that is already running in strict mode. The following example features a factory function that runs in strict mode and returns another function that has its own strict mode directive:

                                                          -
                                                          x
                                                           
                                                          1
                                                          function factory() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return function () {
                                                          4
                                                                  "use strict";
                                                          5
                                                                  return true;
                                                          6
                                                              };
                                                          7
                                                          }
                                                          8
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 4:Unnecessary 'use strict'.
                                                          +
                                                          x
                                                           
                                                          1
                                                          function factory() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return function () {
                                                          4
                                                                  "use strict";
                                                          5
                                                                  return true;
                                                          6
                                                              };
                                                          7
                                                          }
                                                          8
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 3:Unexpected expression 'use strict' in statement position.

                                                          Why do I get this error?

                                                          This error is raised to highlight a completely pointless piece of code. The "use strict" directive applies to the scope in which it appears, and any @@ -20,10 +21,12 @@

                                                          Why do I get this error?

                                                          If you're receiving this error you can safely remove the highlighted instances of the "use strict" directive and be sure that the function in question will still run in strict mode:

                                                          -
                                                          7
                                                           
                                                          1
                                                          function factory() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return function () {
                                                          4
                                                                  return true;
                                                          5
                                                              };
                                                          6
                                                          }
                                                          7
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          7
                                                           
                                                          1
                                                          function factory() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return function () {
                                                          4
                                                                  return true;
                                                          5
                                                              };
                                                          6
                                                          }
                                                          7
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W034. This means you can tell JSHint to not issue this warning with the /*jshint -W034 */ directive.

                                                          In ESLint the rule that generates this warning is named no-extra-strict. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W036.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W036.html new file mode 100644 index 0000000..a359322 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W036.html @@ -0,0 +1,42 @@ + +

                                                          History

                                                          +

                                                          This warning has existed in a number of forms in both JSLint and JSHint. It was +introduced in the original version of both and has remained ever since.

                                                          +
                                                            +
                                                          • In JSLint versions dated before May 2015 the warning given is "Unexpected +/*property*/ '{a}'"

                                                            +
                                                          • +
                                                          • In more recent versions the message has changed to "Unregistered property +name '{a}'"

                                                            +
                                                          • +
                                                          • In JSHint the message has always been "Unexpected /*member '{a}'"

                                                            +
                                                          • +
                                                          +

                                                          The situations that produce the warning have not changed despite changes to the +text of the warning itself.

                                                          +

                                                          When do I get this error?

                                                          +

                                                          The "Unregistered property name '{a}'" error (and the alternatives, "Unexpected +/*property*/ '{a}'" and "Unexpected /*member '{a}'") is thrown when JSLint or +JSHint encounters a non-whitelisted property identifier. In the following +example we are attempting to create an object literal with a property named x:

                                                          +
                                                          x
                                                           
                                                          1
                                                          /*property y, z */
                                                          2
                                                          var obj = {
                                                          3
                                                              x: 1
                                                          4
                                                          };
                                                          5
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 2:Unregistered property name 'x'.
                                                          +

                                                          Why do I get this error?

                                                          +

                                                          This error is raised to highlight a possible typo or a deviation from a +code style guide. Unless the message is indicating a typo it's likely that +your code will work without fault but you may be breaking rules set by your +organization.

                                                          +

                                                          This error will only be thrown if the linter configuration specifies a property +name whitelist. In JSLint this is likely to appear in the form of a /*property +*/ directive at the top of the file. In older versions of JSLint /*properties +*/ was also accepted. In JSHint the relevant directive is /*members */. Note +that the /*members */ directive in JSHint is deprecated and this functionality +is likely to be removed in a future version.

                                                          +

                                                          To resolve the issue ensure you are only referencing properties that are +whitelisted. Alternatively, add the property identifier in question to the list.

                                                          +
                                                          5
                                                           
                                                          1
                                                          /*property x, y, z */
                                                          2
                                                          var obj = {
                                                          3
                                                              x: 1
                                                          4
                                                          };
                                                          5
                                                          JSLint found no errorsVersion 2015-09-23
                                                          +

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a +special option syntax. The identifier of this warning is W036. +This means you can tell JSHint to not issue this warning with the /*jshint +-W036 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W037.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W037.html index 03cf437..229ea4c 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W037.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W037.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                          @@ -20,11 +21,11 @@

                                                          When do I get this error?

                                                          global execution context with the identifier x. Inside the test function, there is a for statement with a label that also has the identifier x. JSLint and JSHint throw this error when we attempt to refer to the x variable:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var x = 0; // Variable with identifier 'x'
                                                          2
                                                          3
                                                          function test(i) {
                                                          4
                                                          5
                                                              "use strict";
                                                          6
                                                          7
                                                          x: // Label with identifier 'x'
                                                          8
                                                              while (i) {
                                                          9
                                                                  i -= 1;
                                                          10
                                                                  x = i; // Reference to variable 'x'
                                                          11
                                                                  if (i === 5) {
                                                          12
                                                                      break x; // Reference to label 'x'
                                                          13
                                                                  }
                                                          14
                                                              }
                                                          15
                                                          }
                                                          16
                                                          17
                                                          test(10);
                                                          18
                                                          JSLint found 3 errorsVersion 2014-02-06
                                                          Line 10:'x' is a statement label.
                                                          Line 12:Unexpected 'x'.
                                                          Line 7:Unused 'x'.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var x = 0; // Variable with identifier 'x'
                                                          2
                                                          3
                                                          function test(i) {
                                                          4
                                                          5
                                                              "use strict";
                                                          6
                                                          7
                                                          x: // Label with identifier 'x'
                                                          8
                                                              while (i) {
                                                          9
                                                                  i -= 1;
                                                          10
                                                                  x = i; // Reference to variable 'x'
                                                          11
                                                                  if (i === 5) {
                                                          12
                                                                      break x; // Reference to label 'x'
                                                          13
                                                                  }
                                                          14
                                                              }
                                                          15
                                                          }
                                                          16
                                                          17
                                                          test(10);
                                                          18
                                                          JSLint found 2 errorsVersion 2015-09-23
                                                          Line 6:Redefinition of 'x' from line 0.
                                                          Line 9:'x' is a statement label.

                                                          ESLint raises its equivalent "Found identifier with the same name as label" error a little more readily. All it needs to find is a variable and label with the same identifier:

                                                          -
                                                          4
                                                           
                                                          1
                                                          var x = 0;
                                                          2
                                                          x:
                                                          3
                                                          for (; x < 10; x++);
                                                          4
                                                          ESLint found 4 errorsVersion 0.6.2
                                                          Line 2:Unexpected labeled statement.
                                                          Line 2:Found identifier with same name as label.
                                                          Line 3:Expected { after 'for' condition.
                                                          Line 3:Unnecessary semicolon.
                                                          +
                                                          4
                                                           
                                                          1
                                                          var x = 0;
                                                          2
                                                          x:
                                                          3
                                                          for (; x < 10; x++);
                                                          4
                                                          JSLint found no errorsVersion v0.16.1

                                                          Why do I get this error?

                                                          This error is raised to help improve the readability of your code. It may be confusing to others (and to you, if you revisit your code some time in the @@ -48,10 +49,12 @@

                                                          Why do I get this error?

                                                          purely to make your code clearer and easier to follow.

                                                          You can prevent it by simply using different identifiers for labels and variables:

                                                          -
                                                          4
                                                           
                                                          1
                                                          var x = 0;
                                                          2
                                                          y:
                                                          3
                                                          for (; x < 10; x++);
                                                          4
                                                          ESLint found 3 errorsVersion 0.6.2
                                                          Line 2:Unexpected labeled statement.
                                                          Line 3:Expected { after 'for' condition.
                                                          Line 3:Unnecessary semicolon.
                                                          +
                                                          4
                                                           
                                                          1
                                                          var x = 0;
                                                          2
                                                          y:
                                                          3
                                                          for (; x < 10; x++);
                                                          4
                                                          JSLint found no errorsVersion v0.16.1

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W037. This means you can tell JSHint to not issue this warning with the /*jshint -W037 */ directive.

                                                          In ESLint the rule that generates this warning is named no-label-var. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W038.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W038.html index 3163e3d..0c57905 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W038.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W038.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                          @@ -17,7 +18,7 @@

                                                          When do I get this error?

                                                          reference to a variable declared in an inner block. In the following example we declare the variable x in the body of an if statement and then attempt to return it from the enclosing function:

                                                          -
                                                          x
                                                           
                                                          1
                                                          function test(a) {
                                                          2
                                                              "use strict";
                                                          3
                                                              if (a) {
                                                          4
                                                                  var x = 1;
                                                          5
                                                              }
                                                          6
                                                              return x;
                                                          7
                                                          }
                                                          8
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 6:'x' used out of scope.
                                                          +
                                                          x
                                                           
                                                          1
                                                          function test(a) {
                                                          2
                                                              "use strict";
                                                          3
                                                              if (a) {
                                                          4
                                                                  var x = 1;
                                                          5
                                                              }
                                                          6
                                                              return x;
                                                          7
                                                          }
                                                          8
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 5:'x' is out of scope.

                                                          Why do I get this error?

                                                          This error is raised to highlight a possible misunderstanding of the language. Your code will most likely work as expected if you do not resolve @@ -39,10 +40,12 @@

                                                          Why do I get this error?

                                                          assignment still occurs within the if statement body but by moving the declaration up to the top of the function body our code more closely represents the way the JavaScript engine will interpret it:

                                                          -
                                                          9
                                                           
                                                          1
                                                          function test(a) {
                                                          2
                                                              "use strict";
                                                          3
                                                              var x;
                                                          4
                                                              if (a) {
                                                          5
                                                                  x = 1;
                                                          6
                                                              }
                                                          7
                                                              return x;
                                                          8
                                                          }
                                                          9
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          9
                                                           
                                                          1
                                                          function test(a) {
                                                          2
                                                              "use strict";
                                                          3
                                                              var x;
                                                          4
                                                              if (a) {
                                                          5
                                                                  x = 1;
                                                          6
                                                              }
                                                          7
                                                              return x;
                                                          8
                                                          }
                                                          9
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W038. This means you can tell JSHint to not issue this warning with the /*jshint -W038 */ directive.

                                                          In ESLint the rule that generates this warning is named block-scoped-var. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W043.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W043.html index 87a4227..13c3d52 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W043.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W043.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in various forms across the three main linters. It was introduced in the original version of JSHint and has remained (in a way) in all three tools from some point since.

                                                          @@ -29,7 +30,7 @@

                                                          When do I get this error?

                                                          issue this warning the the multistr option is not set to true. In the following example we attempt to assign a multiline string to the variable myString:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var myString = "Line 1 \
                                                          2
                                                                          Line 2";
                                                          3
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 1:Bad escaping of EOL. Use option multistr if needed.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var myString = "Line 1 \
                                                          2
                                                                          Line 2";
                                                          3
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 1:Bad escaping of EOL. Use option multistr if needed.

                                                          Why do I get this error?

                                                          This error is raised to highlight the use of a newer language feature that might not be supported in all the environments in which your code should run. @@ -45,13 +46,15 @@

                                                          Why do I get this error?

                                                          If you're receiving this error in JSHint you can listen to the message and set the multistr option to allow the use of multiline strings:

                                                          -
                                                          4
                                                           
                                                          1
                                                          /*jshint multistr: true */
                                                          2
                                                          var myString = "Line 1 \
                                                          3
                                                                          Line 2";
                                                          4
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          4
                                                           
                                                          1
                                                          /*jshint multistr: true */
                                                          2
                                                          var myString = "Line 1 \
                                                          3
                                                                          Line 2";
                                                          4
                                                          JSHint found no errorsVersion 2.9.0

                                                          If you're using a version of JSLint from between May 2011 and August 2013 you can avoid this warning by setting the es5 option:

                                                          -
                                                          4
                                                           
                                                          1
                                                          /*jslint es5: true */
                                                          2
                                                          var myString = "Line 1 \
                                                          3
                                                                          Line 2";
                                                          4
                                                          JSLint found no errorsVersion 2013-05-31
                                                          +
                                                          4
                                                           
                                                          1
                                                          /*jslint es5: true */
                                                          2
                                                          var myString = "Line 1 \
                                                          3
                                                                          Line 2";
                                                          4
                                                          JSLint found no errorsVersion 2013-05-31

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W043. This means you can tell JSHint to not issue this warning with the /*jshint -W043 */ directive.

                                                          In ESLint the rule that generates this warning is named no-multi-str. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W047.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W047.html index cf8d9c9..b5cb703 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W047.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W047.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                          @@ -20,7 +21,7 @@

                                                          When do I get this error?

                                                          JSLint, JSHint and ESLint encounter a numeric literal followed by a . token which itself is not followed by a decimal integer literal. Here's an example in which we attempt to assign the value 5.0 to the variable x:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var x = 5.;
                                                          2
                                                          JSLint found 1 errorVersion 2013-04-29
                                                          Line 1:A trailing decimal point can be confused with a dot: '.5.'.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var x = 5.;
                                                          2
                                                          JSLint found 1 errorVersion 2013-04-29
                                                          Line 1:A trailing decimal point can be confused with a dot: '.5.'.

                                                          Why do I get this error?

                                                          This error is raised to highlight a potentially confusing piece of code. Your code will run without error if you do not address this issue but it could @@ -40,10 +41,12 @@

                                                          Why do I get this error?

                                                          to access a property of an object), JSLint, JSHint and ESLint prefer the explicit third production from the above grammar, just to make your code easier to understand. Therefore to fix this error you can simply remove the .:

                                                          -
                                                          2
                                                           
                                                          1
                                                          var x = 5;
                                                          2
                                                          JSLint found no errorsVersion 2013-04-29
                                                          +
                                                          2
                                                           
                                                          1
                                                          var x = 5;
                                                          2
                                                          JSLint found no errorsVersion 2013-04-29

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W047. This means you can tell JSHint to not issue this warning with the /*jshint -W047 */ directive.

                                                          In ESLint the rule that generates this warning is named no-floating-decimal. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W051.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W051.html index b4e0af9..87e477c 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W051.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W051.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in two forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                          @@ -16,14 +17,14 @@

                                                          When do I get this error?

                                                          should not be deleted" error, is thrown when JSLint, JSHint or ESLint encounters the delete operator followed by a single identifier. In the following example we declare a variable x and then attempt to delete it:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var x = 10;
                                                          2
                                                          delete x;
                                                          3
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 2:Only properties should be deleted.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var x = 10;
                                                          2
                                                          delete x;
                                                          3
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 1:Expected '.' and instead saw 'x'.

                                                          Why do I get this error?

                                                          This error is raised to highlight code that probably doesn't work as you expect it to. It can also indicate a fatal syntax error. The delete operator will only delete properties of objects. It cannot "delete" variables or anything else. Here's a valid use of the delete operator. Notice how this time there are no JSLint errors:

                                                          -
                                                          5
                                                           
                                                          1
                                                          var x = {
                                                          2
                                                              prop: 10
                                                          3
                                                          };
                                                          4
                                                          delete x.prop;
                                                          5
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          5
                                                           
                                                          1
                                                          var x = {
                                                          2
                                                              prop: 10
                                                          3
                                                          };
                                                          4
                                                          delete x.prop;
                                                          5
                                                          JSHint found no errorsVersion 2.9.0

                                                          The ECMAScript 5 specification details the behaviour of the delete operator (ES5 §11.4.1). When the operand is a reference to an object property this is what happens:

                                                          @@ -47,3 +48,5 @@

                                                          Why do I get this error?

                                                          special option syntax. The identifier of this warning is W051. This means you can tell JSHint to not issue this warning with the /*jshint -W051 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W053.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W053.html index 71794bd..f81ceb5 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W053.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W053.html @@ -1,9 +1,10 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Do not use {a} as a constructor" error is thrown when JSLint, JSHint or ESLint encounters a call to String, Number, Boolean, Math or JSON preceded by the new operator. In the following example we attempt to assign some values to variables by invoking these functions as constructors:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var str = new String("hello"),
                                                          2
                                                              num = new Number(10),
                                                          3
                                                              bool = new Boolean(false),
                                                          4
                                                              math = new Math(),
                                                          5
                                                              json = new JSON({ myProp: 10 });
                                                          6
                                                          JSLint found 5 errorsVersion 2014-02-06
                                                          Line 1:Do not use String as a constructor.
                                                          Line 2:Do not use Number as a constructor.
                                                          Line 3:Do not use Boolean as a constructor.
                                                          Line 4:Do not use Math as a constructor.
                                                          Line 5:Do not use JSON as a constructor.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var str = new String("hello"),
                                                          2
                                                              num = new Number(10),
                                                          3
                                                              bool = new Boolean(false),
                                                          4
                                                              math = new Math(),
                                                          5
                                                              json = new JSON({ myProp: 10 });
                                                          6
                                                          JSLint found 5 errorsVersion 2015-09-23
                                                          Line 0:Unexpected 'new'.
                                                          Line 1:Unexpected 'new'.
                                                          Line 2:Unexpected 'new'.
                                                          Line 4:Unexpected space between '{' and 'myProp'.
                                                          Line 4:Unexpected space between '10' and '}'.

                                                          Why do I get this error?

                                                          This error is raised to highlight a bad practice and a piece of code that may not work as you intend it to. It can also highlight a possible fatal @@ -16,18 +17,20 @@

                                                          Why do I get this error?

                                                          object to a literal will always return false. In the case of these objects, to fix this error, use literal values rather than their corresponding wrapper objects:

                                                          -
                                                          4
                                                           
                                                          1
                                                          var str = "hello",
                                                          2
                                                              num = 10,
                                                          3
                                                              bool = false;
                                                          4
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          4
                                                           
                                                          1
                                                          var str = "hello",
                                                          2
                                                              num = 10,
                                                          3
                                                              bool = false;
                                                          4
                                                          JSLint found no errorsVersion 2015-09-23

                                                          Note that this does not cause you to lose any functionality, since literal values are internally cast to instances of the appropriate type when you call a method on them. Also note that you are free to use these functions to perform type conversions i.e. by invoking them without the new operator:

                                                          -
                                                          4
                                                           
                                                          1
                                                          var str = String(10),    // "10"
                                                          2
                                                              num = Number("123"), // 123
                                                          3
                                                              bool = Boolean("");  // false
                                                          4
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          4
                                                           
                                                          1
                                                          var str = String(10),    // "10"
                                                          2
                                                              num = Number("123"), // 123
                                                          3
                                                              bool = Boolean("");  // false
                                                          4
                                                          JSLint found no errorsVersion 2015-09-23

                                                          The case is a little different for the Math and JSON objects. These two objects are not functions, and cannot be constructed. Attempts to instantiate them will result in a type error. If you're trying to serialize an object into a JSON string, you need to use the JSON.stringify method instead:

                                                          -
                                                          2
                                                           
                                                          1
                                                          var json = JSON.stringify({ myProp: 10 });
                                                          2
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          2
                                                           
                                                          1
                                                          var json = JSON.stringify({ myProp: 10 });
                                                          2
                                                          JSLint found 2 errorsVersion 2015-09-23
                                                          Line 0:Unexpected space between '{' and 'myProp'.
                                                          Line 0:Unexpected space between '10' and '}'.

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W053. This means you can tell JSHint to not issue this warning with the /*jshint -W053 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W054.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W054.html index 89ba6fc..a947080 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W054.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W054.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in two forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three linters ever since.

                                                          @@ -17,7 +18,7 @@

                                                          When do I get this error?

                                                          constructor is a form of eval" error) is thrown when JSLint, JSHint or ESLint encounters a call to the Function constructor preceded by the new operator. Here's a simple example which defines a function to add two numbers:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var add = new Function("a", "b", "return a + b");
                                                          2
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 1:The Function constructor is eval.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var add = new Function("a", "b", "return a + b");
                                                          2
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Unexpected 'new Function'.

                                                          Why do I get this error?

                                                          This error is raised to highlight a bad practice. By passing a string to the Function constructor you are requiring the engine to parse that string much in @@ -26,14 +27,16 @@

                                                          Why do I get this error?

                                                          message.

                                                          In simple cases like that of our example above, you can fix the issue by using a function declaration or function expression:

                                                          -
                                                          5
                                                           
                                                          1
                                                          var add = function (a, b) {
                                                          2
                                                              "use strict";
                                                          3
                                                              return a + b;
                                                          4
                                                          };
                                                          5
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          5
                                                           
                                                          1
                                                          var add = function (a, b) {
                                                          2
                                                              "use strict";
                                                          3
                                                              return a + b;
                                                          4
                                                          };
                                                          5
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In more advanced cases where you really need to use the Function constructor, you can set the evil option to true to prevent both JSLint and JSHint from complaining about it:

                                                          -
                                                          3
                                                           
                                                          1
                                                          /*jslint evil: true */
                                                          2
                                                          var add = new Function("a", "b", "return a + b");
                                                          3
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          3
                                                           
                                                          1
                                                          /*jslint evil: true */
                                                          2
                                                          var add = new Function("a", "b", "return a + b");
                                                          3
                                                          JSLint found 2 errorsVersion 2015-09-23
                                                          Line 0:Bad option 'evil'.
                                                          Line 1:Unexpected 'new Function'.

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W054. This means you can tell JSHint to not issue this warning with the /*jshint -W054 */ directive.

                                                          In ESLint the rule that generates this warning is named no-new-func. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W055.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W055.html index 07f51d9..0056a3d 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W055.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W055.html @@ -1,14 +1,15 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "A constructor name should start with an uppercase letter" error is thrown when JSLint, JSHint or ESLint encounters an identifier, preceded by the new operator, whose first character is a lowercase letter. JSHint will only raise this warning when the newcap option is set to true. In the following example we declare a constructor function myConstructor and then attempt to instantiate it:

                                                          -
                                                          x
                                                           
                                                          1
                                                          /*jshint newcap: true */
                                                          2
                                                          function myConstructor() {
                                                          3
                                                              "use strict";
                                                          4
                                                              this.property = "Something";
                                                          5
                                                          }
                                                          6
                                                          7
                                                          var myInstance = new myConstructor();
                                                          8
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 7:A constructor name 'myConstructor' should start with an uppercase letter.
                                                          +
                                                          x
                                                           
                                                          1
                                                          /*jshint newcap: true */
                                                          2
                                                          function myConstructor() {
                                                          3
                                                              "use strict";
                                                          4
                                                              this.property = "Something";
                                                          5
                                                          }
                                                          6
                                                          7
                                                          var myInstance = new myConstructor();
                                                          8
                                                          JSLint found 2 errorsVersion 2015-09-23
                                                          Line 3:Unexpected 'this'.
                                                          Line 6:Unexpected 'new'.

                                                          Why do I get this error?

                                                          This error is raised to highlight a lack of convention. It is common practice for constructor function identifiers to begin with an uppercase letter. JSLint simply enforces this convention. Here's the above snippet rewritten to pass JSLint. Notice that the only difference is the uppercase "M":

                                                          -
                                                          8
                                                           
                                                          1
                                                          /*jshint newcap: true */
                                                          2
                                                          function MyClass() {
                                                          3
                                                              "use strict";
                                                          4
                                                              this.property = "Something";
                                                          5
                                                          }
                                                          6
                                                          7
                                                          var myInstance = new MyClass();
                                                          8
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          8
                                                           
                                                          1
                                                          /*jshint newcap: true */
                                                          2
                                                          function MyClass() {
                                                          3
                                                              "use strict";
                                                          4
                                                              this.property = "Something";
                                                          5
                                                          }
                                                          6
                                                          7
                                                          var myInstance = new MyClass();
                                                          8
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 3:Unexpected 'this'.

                                                          It is worth bearing in mind that this is only a convention and is not required by the language in any way. You can safely ignore this error if you prefer to name your constructor functions differently. By setting the newcap option, you @@ -17,3 +18,5 @@

                                                          Why do I get this error?

                                                          special option syntax. The identifier of this warning is W055. This means you can tell JSHint to not issue this warning with the /*jshint -W055 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W056.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W056.html index 5d4a1db..2b9e97e 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W056.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W056.html @@ -1,8 +1,9 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Bad constructor" error is thrown when JSLint or JSHint encounters the new operator followed by a literal value. In the following example we are attempting to apply the new operator to a numeric literal:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var num = new 5();
                                                          2
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 1:Bad constructor.
                                                          +
                                                          x
                                                           
                                                          1
                                                          var num = new 5();
                                                          2
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Unexpected '('.

                                                          Why do I get this error?

                                                          In the case of assignment to a function call this error is raised to highlight a fatal type error. Your code will throw an error in all environments if @@ -29,7 +30,7 @@

                                                          Why do I get this error?

                                                        • JSLint and JSHint can detect this to a point and will issue the same "Bad constructor" warning if you attempt to apply new to an object literal:
                                                      -
                                                      2
                                                       
                                                      1
                                                      var num = new {}();
                                                      2
                                                      JSLint found 2 errorsVersion 2014-02-06
                                                      Line 1:Bad constructor.
                                                      Line 1:Unexpected 'new'.
                                                      +
                                                      2
                                                       
                                                      1
                                                      var num = new {}();
                                                      2
                                                      JSLint found 2 errorsVersion 2015-09-23
                                                      Line 0:Unexpected space between 'new' and '{'.
                                                      Line 0:Unexpected '('.

                                                      To avoid this warning simply stop attempting to misuse the new operator. It is only useful for creating instances of a constructor function and has no sensible meaning when applied to non-function objects or literals.

                                                      @@ -37,3 +38,5 @@

                                                      Why do I get this error?

                                                      special option syntax. The identifier of this warning is W056. This means you can tell JSHint to not issue this warning with the /*jshint -W056 */ directive.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W058.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W058.html index 83dcd70..cd0d43f 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W058.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W058.html @@ -1,4 +1,5 @@ -

                                                      History

                                                      + +

                                                      History

                                                      This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                      @@ -16,7 +17,7 @@

                                                      When do I get this error?

                                                      and ESLint encounter a new expression that is not immediately followed by a pair of parentheses. In the following example we create an instance of the built-in Date constructor:

                                                      -
                                                      x
                                                       
                                                      1
                                                      var d = new Date;
                                                      2
                                                      JSLint found 1 errorVersion 2013-04-29
                                                      Line 1:Missing '()'.
                                                      +
                                                      x
                                                       
                                                      1
                                                      var d = new Date;
                                                      2
                                                      JSLint found 1 errorVersion 2013-04-29
                                                      Line 1:Missing '()'.

                                                      Why do I get this error?

                                                      This error is raised to highlight a lack of convention. Your code will work without error if you do not resolve this issue but you may be contravening @@ -45,10 +46,12 @@

                                                      Why do I get this error?

                                                      function, rather than the return value of it. By missing the parentheses on a constructor call your code may be less self-explanatory. To fix the issue you can simply add the missing parentheses:

                                                      -
                                                      2
                                                       
                                                      1
                                                      var d = new Date();
                                                      2
                                                      JSLint found no errorsVersion 2013-04-29
                                                      +
                                                      2
                                                       
                                                      1
                                                      var d = new Date();
                                                      2
                                                      JSLint found no errorsVersion 2013-04-29

                                                      In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W058. This means you can tell JSHint to not issue this warning with the /*jshint -W058 */ directive.

                                                      In ESLint the rule that generates this warning is named new-parens. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W059.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W059.html index 61ea2f5..510403d 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W059.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W059.html @@ -1,4 +1,5 @@ -

                                                      When do I get this error?

                                                      + +

                                                      When do I get this error?

                                                      The "Avoid arguments.{a}" error is thrown when JSLint, JSHint or ESLint encounters a reference to the callee or caller property of an arguments object. The text of this warning can therefore be either "Avoid @@ -6,7 +7,7 @@

                                                      When do I get this error?

                                                      warning if the noarg option is set to true. In the following example we have a simple function that calculates the factorial of each number in an array. It uses arguments.callee to call itself recursively:

                                                      -
                                                      x
                                                       
                                                      1
                                                      var numbers = [1, 2, 3, 4, 5];
                                                      2
                                                      numbers.map(function (n) {
                                                      3
                                                          return n < 1 ? 1 : n * arguments.callee(n - 1);
                                                      4
                                                      });
                                                      5
                                                      // Returns [1, 2, 6, 24, 120]
                                                      6
                                                      JSLint found 2 errorsVersion 2014-02-06
                                                      Line 3:Missing 'use strict' statement.
                                                      Line 3:Avoid 'arguments.callee'.
                                                      +
                                                      x
                                                       
                                                      1
                                                      var numbers = [1, 2, 3, 4, 5];
                                                      2
                                                      numbers.map(function (n) {
                                                      3
                                                          return n < 1 ? 1 : n * arguments.callee(n - 1);
                                                      4
                                                      });
                                                      5
                                                      // Returns [1, 2, 6, 24, 120]
                                                      6
                                                      JSLint found 4 errorsVersion 2015-09-23
                                                      Line 2:Expected 'use strict' before 'return'.
                                                      Line 2:Expected '?' at column 8, not column 17.
                                                      Line 2:Expected ':' at column 8, not column 21.
                                                      Line 2:Unexpected 'arguments'.

                                                      Why do I get this error?

                                                      This error is raised to highlight the use of a deprecated language feature. The code will work as expected in most environments at the moment but support @@ -18,7 +19,7 @@

                                                      Why do I get this error?

                                                      value of this to change within the function.

                                                      To solve these problems ECMAScript 3 introduced the concept of named function expressions. To avoid this warning modify your code to use them instead:

                                                      -
                                                      7
                                                       
                                                      1
                                                      var numbers = [1, 2, 3, 4, 5];
                                                      2
                                                      numbers.map(function factorial(n) {
                                                      3
                                                          "use strict";
                                                      4
                                                          return n < 1 ? 1 : n * factorial(n - 1);
                                                      5
                                                      });
                                                      6
                                                      // Returns [1, 2, 6, 24, 120]
                                                      7
                                                      JSLint found no errorsVersion 2014-02-06
                                                      +
                                                      7
                                                       
                                                      1
                                                      var numbers = [1, 2, 3, 4, 5];
                                                      2
                                                      numbers.map(function factorial(n) {
                                                      3
                                                          "use strict";
                                                      4
                                                          return n < 1 ? 1 : n * factorial(n - 1);
                                                      5
                                                      });
                                                      6
                                                      // Returns [1, 2, 6, 24, 120]
                                                      7
                                                      JSLint found 2 errorsVersion 2015-09-23
                                                      Line 3:Expected '?' at column 8, not column 17.
                                                      Line 3:Expected ':' at column 8, not column 21.

                                                      Notice the addition of the "use strict" directive in that example. In ECMAScript 5 the use of arguments.callee and arguments.caller were deprecated and removed from strict mode. Attempting to reference either property @@ -29,3 +30,5 @@

                                                      Why do I get this error?

                                                      -W059 */ directive.

                                                      In ESLint the rule that generates this warning is named no-caller. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W061.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W061.html index 38f64db..703d21b 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W061.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W061.html @@ -1,4 +1,5 @@ -

                                                      History

                                                      + +

                                                      History

                                                      This warning has existed in two forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                      @@ -18,7 +19,7 @@

                                                      When do I get this error?

                                                      thrown when JSLint, JSHint or ESLint encounters a call to the eval function. Here's an example in which we use eval to access an object property by a computed name:

                                                      -
                                                      x
                                                       
                                                      1
                                                      var myString = "x",
                                                      2
                                                          myObject = {
                                                      3
                                                              x: 10
                                                      4
                                                          },
                                                      5
                                                          value = eval("myObject." + myString);
                                                      6
                                                      JSLint found 1 errorVersion 2014-02-06
                                                      Line 5:eval is evil.
                                                      +
                                                      x
                                                       
                                                      1
                                                      var myString = "x",
                                                      2
                                                          myObject = {
                                                      3
                                                              x: 10
                                                      4
                                                          },
                                                      5
                                                          value = eval("myObject." + myString);
                                                      6
                                                      JSLint found 1 errorVersion 2015-09-23
                                                      Line 4:Unexpected 'eval'.

                                                      Why do I get this error?

                                                      There are numerous reasons for this error. Some of the major ones include potentially dangerous code and a likelihood of a misunderstanding of the @@ -30,7 +31,7 @@

                                                      Why do I get this error?

                                                      are trying to do something like our example above - access an object property with a string. There's a much better way to do that, using the square bracket syntax to access properties with a variable:

                                                      -
                                                      6
                                                       
                                                      1
                                                      var myString = "x",
                                                      2
                                                          myObject = {
                                                      3
                                                              x: 10
                                                      4
                                                          },
                                                      5
                                                          value = myObject[myString];
                                                      6
                                                      JSLint found no errorsVersion 2014-02-06
                                                      +
                                                      6
                                                       
                                                      1
                                                      var myString = "x",
                                                      2
                                                          myObject = {
                                                      3
                                                              x: 10
                                                      4
                                                          },
                                                      5
                                                          value = myObject[myString];
                                                      6
                                                      JSLint found no errorsVersion 2015-09-23

                                                      The eval function is slow. If you're using it unecessarily, you're slowing down your program for no reason. One cause of this is the fact that the engine has to parse the argument as a complete new program (ES5 @@ -50,10 +51,12 @@

                                                      Why do I get this error?

                                                      However, in the situation where you absolutely have to use eval, you can tell both JSLint and JSHint to allow it. But you should only do this as a last resort. Just set the evil option to true:

                                                      -
                                                      7
                                                       
                                                      1
                                                      /*jslint evil: true */
                                                      2
                                                      var myString = "x",
                                                      3
                                                          myObject = {
                                                      4
                                                              x: 10
                                                      5
                                                          },
                                                      6
                                                          value = eval("myObject." + myString);
                                                      7
                                                      JSLint found no errorsVersion 2014-02-06
                                                      +
                                                      7
                                                       
                                                      1
                                                      /*jslint evil: true */
                                                      2
                                                      var myString = "x",
                                                      3
                                                          myObject = {
                                                      4
                                                              x: 10
                                                      5
                                                          },
                                                      6
                                                          value = eval("myObject." + myString);
                                                      7
                                                      JSLint found 2 errorsVersion 2015-09-23
                                                      Line 0:Bad option 'evil'.
                                                      Line 5:Unexpected 'eval'.

                                                      In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W061. This means you can tell JSHint to not issue this warning with the /*jshint -W061 */ directive.

                                                      In ESLint the rule that generates this warning is named no-eval. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W062.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W062.html index 120604e..e755609 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W062.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W062.html @@ -1,10 +1,11 @@ -

                                                      When do I get this error?

                                                      + +

                                                      When do I get this error?

                                                      The "Wrap an immediate function invocation in parentheses" error is thrown when JSLint, JSHint and ESLint encounter an immediately invoked function expression that is not wrapped in parentheses. JSHint will only raise this warning if the immed option is set to true. In the following example we assign the return value of the anonymous function the variable x:

                                                      -
                                                      x
                                                       
                                                      1
                                                      /*jshint immed: true */
                                                      2
                                                      var x = function () {
                                                      3
                                                          "use strict";
                                                      4
                                                          return {
                                                      5
                                                              y: 1
                                                      6
                                                          };
                                                      7
                                                      }();
                                                      8
                                                      JSLint found 1 errorVersion 2013-04-29
                                                      Line 7:Wrap an immediate function invocation in parentheses to assist the reader in understanding that the expression is the result of a function, and not the function itself.
                                                      +
                                                      x
                                                       
                                                      1
                                                      /*jshint immed: true */
                                                      2
                                                      var x = function () {
                                                      3
                                                          "use strict";
                                                      4
                                                          return {
                                                      5
                                                              y: 1
                                                      6
                                                          };
                                                      7
                                                      }();
                                                      8
                                                      JSLint found 1 errorVersion 2013-04-29
                                                      Line 7:Wrap an immediate function invocation in parentheses to assist the reader in understanding that the expression is the result of a function, and not the function itself.

                                                      Why do I get this error?

                                                      This error is raised to highlight a lack of convention. Your code will run fine if you do not fix this error, but it may be confusing to others. Since @@ -13,7 +14,7 @@

                                                      Why do I get this error?

                                                      is to simply wrap a function statement in parentheses. The opening parenthesis causes the contained function to be parsed as an expression, rather than a declaration:

                                                      -
                                                      6
                                                       
                                                      1
                                                      var x;
                                                      2
                                                      (function () {
                                                      3
                                                          "use strict";
                                                      4
                                                          x = 10;
                                                      5
                                                      }());
                                                      6
                                                      JSLint found no errorsVersion 2013-04-29
                                                      +
                                                      6
                                                       
                                                      1
                                                      var x;
                                                      2
                                                      (function () {
                                                      3
                                                          "use strict";
                                                      4
                                                          x = 10;
                                                      5
                                                      }());
                                                      6
                                                      JSLint found no errorsVersion 2013-04-29

                                                      If you remove the wrapping parentheses from the above example, you will end up with a syntax error. For that reason, when immediately invoking a function expression that doesn't require any special treatment to turn it into an @@ -21,10 +22,12 @@

                                                      Why do I get this error?

                                                      wrap it in parentheses anyway, for consistency and to make it clearer that the resulting value of the overall expression is the return value of the function, rather than a reference to the function itself:

                                                      -
                                                      8
                                                       
                                                      1
                                                      /*jshint immed: true */
                                                      2
                                                      var x = (function () {
                                                      3
                                                          "use strict";
                                                      4
                                                          return {
                                                      5
                                                              y: 1
                                                      6
                                                          };
                                                      7
                                                      }());
                                                      8
                                                      JSLint found no errorsVersion 2013-04-29
                                                      +
                                                      8
                                                       
                                                      1
                                                      /*jshint immed: true */
                                                      2
                                                      var x = (function () {
                                                      3
                                                          "use strict";
                                                      4
                                                          return {
                                                      5
                                                              y: 1
                                                      6
                                                          };
                                                      7
                                                      }());
                                                      8
                                                      JSLint found no errorsVersion 2013-04-29

                                                      In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W062. This means you can tell JSHint to not issue this warning with the /*jshint -W062 */ directive. You can also set the immed option to false.

                                                      In ESLint the rule that generates this warning is named wrap-iife. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W063.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W063.html index 40b4278..053db10 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W063.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W063.html @@ -1,9 +1,10 @@ -

                                                      When do I get this error?

                                                      + +

                                                      When do I get this error?

                                                      The "'{a}' is not a function" error is thrown when JSLint, JSHint or ESLint encounters an attempt to invoke the Math object as a function. JSLint and ESLint (but not JSHint) will also raise this warning when they encounter an attempt to invoke the JSON object as a function. Here's an example:

                                                      -
                                                      x
                                                       
                                                      1
                                                      var x = Math(),
                                                      2
                                                          y = JSON();
                                                      3
                                                      JSLint found 2 errorsVersion 2014-02-06
                                                      Line 1:'Math' is not a function.
                                                      Line 2:'JSON' is not a function.
                                                      +
                                                      x
                                                       
                                                      1
                                                      var x = Math(),
                                                      2
                                                          y = JSON();
                                                      3
                                                      JSLint found 2 errorsVersion 2015-09-23
                                                      Line 0:Expected 'new' before 'Math'.
                                                      Line 1:Expected 'new' before 'JSON'.

                                                      Why do I get this error?

                                                      This error is raised to highlight what is most likely a misunderstanding of the language. The Math property of the global object is described in the @@ -29,10 +30,12 @@

                                                      Why do I get this error?

                                                      accessed in the normal way. If you're receiving this error the chances are you intended to invoke one of the function properties instead of the object itself. For example:

                                                      -
                                                      3
                                                       
                                                      1
                                                      var x = Math.random(),
                                                      2
                                                          y = JSON.stringify({});
                                                      3
                                                      JSLint found no errorsVersion 2014-02-06
                                                      +
                                                      3
                                                       
                                                      1
                                                      var x = Math.random(),
                                                      2
                                                          y = JSON.stringify({});
                                                      3
                                                      JSLint found no errorsVersion 2015-09-23

                                                      In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W063. This means you can tell JSHint to not issue this warning with the /*jshint -W063 */ directive.

                                                      In ESLint the rule that generates this warning is named no-obj-calls. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W065.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W065.html index 353bb53..41aa649 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W065.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W065.html @@ -1,9 +1,10 @@ -

                                                      When do I get this error?

                                                      + +

                                                      When do I get this error?

                                                      The "Missing radix parameter" error is thrown when JSLint, JSHint or ESLint encounters a call to the parseInt function that only has one argument. As of JSHint 2.3.0 the warning will only be issued if the es3 option is set to true. Here's an example:

                                                      -
                                                      x
                                                       
                                                      1
                                                      parseInt("10");
                                                      2
                                                      JSLint found 1 errorVersion 2014-02-06
                                                      Line 1:Missing radix parameter.
                                                      +
                                                      x
                                                       
                                                      1
                                                      parseInt("10");
                                                      2
                                                      JSLint found no errorsVersion 2015-09-23

                                                      Why do I get this error?

                                                      This error is raised to highlight a potential oversight that could lead to problems. The second argument of the parseInt function is used to specify a @@ -22,8 +23,10 @@

                                                      Why do I get this error?

                                                      As of ECMAScript 5, this quirk of parseInt has been removed. However, since it's likely you will want your code to run successfully in older environments that do not support ES5, you should always pass a radix to parseInt:

                                                      -
                                                      2
                                                       
                                                      1
                                                      parseInt("10", 10);
                                                      2
                                                      JSLint found no errorsVersion 2014-02-06
                                                      +
                                                      2
                                                       
                                                      1
                                                      parseInt("10", 10);
                                                      2
                                                      JSLint found no errorsVersion 2015-09-23

                                                      In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W065. This means you can tell JSHint to not issue this warning with the /*jshint -W065 */ directive.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W066.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W066.html index 7c92769..73d95d7 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W066.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W066.html @@ -1,4 +1,5 @@ -

                                                      History

                                                      + +

                                                      History

                                                      This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                      @@ -21,7 +22,7 @@

                                                      When do I get this error?

                                                      string" error) is thrown when JSLint, JSHint and ESLint encounter a call to setTimeout or setInterval in which the first argument is a string. Here's an example that should pop up a browser alert after one second:

                                                      -
                                                      x
                                                       
                                                      1
                                                      /*jslint browser: true */
                                                      2
                                                      setTimeout("alert('Hello!');", 1000);
                                                      3
                                                      JSLint found 1 errorVersion 2014-02-06
                                                      Line 2:Implied eval is evil. Pass a function instead of a string.
                                                      +
                                                      x
                                                       
                                                      1
                                                      /*jslint browser: true */
                                                      2
                                                      setTimeout("alert('Hello!');", 1000);
                                                      3
                                                      JSLint found no errorsVersion 2015-09-23

                                                      Why do I get this error?

                                                      This error is raised to highlight a bad practice and a possible misunderstanding of the language. By passing a string to setTimeout or @@ -32,10 +33,12 @@

                                                      Why do I get this error?

                                                      You can fix this issue by simply passing a function to setTimeout or setInterval instead of a string. In a situation like that of the example above, you can achieve this by passing an anonymous function:

                                                      -
                                                      6
                                                       
                                                      1
                                                      /*jslint browser: true, devel: true */
                                                      2
                                                      setTimeout(function () {
                                                      3
                                                          "use strict";
                                                      4
                                                          alert('Hello!');
                                                      5
                                                      }, 1000);
                                                      6
                                                      JSLint found no errorsVersion 2014-02-06
                                                      +
                                                      6
                                                       
                                                      1
                                                      /*jslint browser: true, devel: true */
                                                      2
                                                      setTimeout(function () {
                                                      3
                                                          "use strict";
                                                      4
                                                          alert('Hello!');
                                                      5
                                                      }, 1000);
                                                      6
                                                      JSLint found no errorsVersion 2015-09-23

                                                      In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W066. This means you can tell JSHint to not issue this warning with the /*jshint -W066 */ directive.

                                                      In ESLint the rule that generates this warning is named no-implied-eval. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W068.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W068.html index 974b3ac..7ad9a09 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W068.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W068.html @@ -1,4 +1,5 @@ -

                                                      History

                                                      + +

                                                      History

                                                      This warning has existed in two forms across the three main linters. It was introduced in a very early version of JSLint and has remained in all three tools ever since.

                                                      @@ -25,13 +26,13 @@

                                                      When do I get this error?

                                                      invoking parentheses
                                                      . JSHint will throw this error in the same situation, but only if the immed option is set to true. In the following example we assign a function expression to a variable x:

                                                      -
                                                      x
                                                       
                                                      1
                                                      /*jshint immed: true */
                                                      2
                                                      var x = (function () {
                                                      3
                                                          "use strict";
                                                      4
                                                          return 10;
                                                      5
                                                      });
                                                      6
                                                      JSLint found 1 errorVersion 2014-02-06
                                                      Line 2:Do not wrap function literals in parens unless they are to be immediately invoked.
                                                      +
                                                      x
                                                       
                                                      1
                                                      /*jshint immed: true */
                                                      2
                                                      var x = (function () {
                                                      3
                                                          "use strict";
                                                      4
                                                          return 10;
                                                      5
                                                      });
                                                      6
                                                      JSLint found 1 errorVersion 2015-09-23
                                                      Line 1:Don't wrap function literals in parens.

                                                      Why do I get this error?

                                                      This error is raised to highlight a potentially confusing piece of code. It is common in JavaScript to see immediately invoked function expressions. Here's the above snippet again, this time with the invoking parentheses. Notice how subtle the difference is:

                                                      -
                                                      5
                                                       
                                                      1
                                                      var x = (function () {
                                                      2
                                                          "use strict";
                                                      3
                                                          return 10;
                                                      4
                                                      }());
                                                      5
                                                      JSLint found no errorsVersion 2014-02-06
                                                      +
                                                      5
                                                       
                                                      1
                                                      var x = (function () {
                                                      2
                                                          "use strict";
                                                      3
                                                          return 10;
                                                      4
                                                      }());
                                                      5
                                                      JSLint found no errorsVersion 2015-09-23

                                                      While the difference may not look like much, the two snippets are completely different in their behaviour. The first example (which does not pass JSLint) will result in a function expression assigned to x. The second snippet will @@ -45,3 +46,5 @@

                                                      Why do I get this error?

                                                      -W068 */ directive.

                                                      In ESLint the rule that generates this warning is named no-wrap-func. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W069.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W069.html index bd03656..6e99c1f 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W069.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W069.html @@ -1,10 +1,11 @@ -

                                                      When do I get this error?

                                                      + +

                                                      When do I get this error?

                                                      The "['{a}'] is better written in dot notation" error is thrown when JSLint, JSHint or ESLint encounters an attempt to access a property using a string literal within a pair of square brackets when the property name is not a reserved word. In the following example we attempt to access the prop property of the x object:

                                                      -
                                                      x
                                                       
                                                      1
                                                      var x = {
                                                      2
                                                              prop: 10
                                                      3
                                                          },
                                                      4
                                                          y = x["prop"];
                                                      5
                                                      JSLint found 1 errorVersion 2014-02-06
                                                      Line 4:['prop'] is better written in dot notation.
                                                      +
                                                      x
                                                       
                                                      1
                                                      var x = {
                                                      2
                                                              prop: 10
                                                      3
                                                          },
                                                      4
                                                          y = x["prop"];
                                                      5
                                                      JSLint found 1 errorVersion 2015-09-23
                                                      Line 3:['prop'] is better written in dot notation.

                                                      Why do I get this error?

                                                      This error is raised to highlight a unnecessarily verbose and potentially confusing piece of code. It is very common in many programming languages to @@ -12,16 +13,18 @@

                                                      Why do I get this error?

                                                      with either syntax, and both will work in all environments. However, by using dot notation where possible, you can save three characters every time. Here's the above snippet, this time with dot notation:

                                                      -
                                                      5
                                                       
                                                      1
                                                      var x = {
                                                      2
                                                              prop: 10
                                                      3
                                                          },
                                                      4
                                                          y = x.prop;
                                                      5
                                                      JSLint found no errorsVersion 2014-02-06
                                                      +
                                                      5
                                                       
                                                      1
                                                      var x = {
                                                      2
                                                              prop: 10
                                                      3
                                                          },
                                                      4
                                                          y = x.prop;
                                                      5
                                                      JSLint found no errorsVersion 2015-09-23

                                                      However, it's important to remember that you have to use the square bracket notation if you want to access a property whose identifier is a reserved word. JSLint and JSHint will not raise this error in that situation. In the following example, x has a property with the identifier class. Notice that JSLint does not throw an error, even though we are using square bracket notation:

                                                      -
                                                      5
                                                       
                                                      1
                                                      var x = {
                                                      2
                                                              "class": 10
                                                      3
                                                          },
                                                      4
                                                          y = x["class"];
                                                      5
                                                      JSLint found no errorsVersion 2014-02-06
                                                      +
                                                      5
                                                       
                                                      1
                                                      var x = {
                                                      2
                                                              "class": 10
                                                      3
                                                          },
                                                      4
                                                          y = x["class"];
                                                      5
                                                      JSLint found 2 errorsVersion 2015-09-23
                                                      Line 1:Quotes are not needed around 'class'.
                                                      Line 3:['class'] is better written in dot notation.

                                                      In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W069. This means you can tell JSHint to not issue this warning with the /*jshint -W069 */ directive. You can also set the sub option to true.

                                                      In ESLint the rule that generates this warning is named dot-notation. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W070.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W070.html index 9dd9c57..cb285be 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W070.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W070.html @@ -1,4 +1,5 @@ -

                                                      History

                                                      + +

                                                      History

                                                      This warning has existed in various forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                      @@ -20,7 +21,7 @@

                                                      When do I get this error?

                                                      a comma following the final value in an object literal. Since version 2.0.0 JSHint will only raise this warning if the es3 option is set to true. Here's an example:

                                                      -
                                                      x
                                                       
                                                      1
                                                      /*jshint es3: true */
                                                      2
                                                      var x = {
                                                      3
                                                          prop1: 10,
                                                      4
                                                          prop2: 20,
                                                      5
                                                      };
                                                      6
                                                      JSHint found 1 errorVersion 2.5.0
                                                      Line 4:Extra comma. (it breaks older versions of IE)
                                                      +
                                                      x
                                                       
                                                      1
                                                      /*jshint es3: true */
                                                      2
                                                      var x = {
                                                      3
                                                          prop1: 10,
                                                      4
                                                          prop2: 20,
                                                      5
                                                      };
                                                      6
                                                      JSHint found 1 errorVersion 2.9.0
                                                      Line 4:Extra comma. (it breaks older versions of IE)

                                                      Why do I get this error?

                                                      This error is raised to highlight a potential fatal syntax error. When it comes to object literals, the difference in the ECMAScript specification from @@ -46,7 +47,7 @@

                                                      Why do I get this error?

                                                      In environments that do not support ECMAScript 5, the above code will cause a syntax error. Therefore, if you may need to support such environments, it's best to remove the trailing comma:

                                                      -
                                                      6
                                                       
                                                      1
                                                      /*jshint es3: true */
                                                      2
                                                      var x = {
                                                      3
                                                          prop1: 10,
                                                      4
                                                          prop2: 20
                                                      5
                                                      };
                                                      6
                                                      JSHint found no errorsVersion 2.5.0
                                                      +
                                                      6
                                                       
                                                      1
                                                      /*jshint es3: true */
                                                      2
                                                      var x = {
                                                      3
                                                          prop1: 10,
                                                      4
                                                          prop2: 20
                                                      5
                                                      };
                                                      6
                                                      JSHint found no errorsVersion 2.9.0

                                                      In the case of array literals the situation is a bit less clear. The specification does not differ from ECMAScript 3 to 5 and has always allowed the use of a trailing comma (ES5 §11.1.4):

                                                      @@ -61,7 +62,7 @@

                                                      Why do I get this error?

                                                      valid, as per the spec. As with object literals, if your code might need to run is pre-ES5 environments, it's highly recommended that you remove any trailing commas:

                                                      -
                                                      6
                                                       
                                                      1
                                                      /*jshint es3: true */
                                                      2
                                                      var x = [
                                                      3
                                                          "element1",
                                                      4
                                                          "element2"
                                                      5
                                                      ];
                                                      6
                                                      JSHint found no errorsVersion 2.5.0
                                                      +
                                                      6
                                                       
                                                      1
                                                      /*jshint es3: true */
                                                      2
                                                      var x = [
                                                      3
                                                          "element1",
                                                      4
                                                          "element2"
                                                      5
                                                      ];
                                                      6
                                                      JSHint found no errorsVersion 2.9.0

                                                      If you are using an older version of JSHint (pre-2.0.0) and you want to use trailing commas you will have to set the es5 option to true. As of version 2.0.0 JSHint will treat all code as valid ES5 code. In JSHint 1.0.0 and above @@ -71,3 +72,5 @@

                                                      Why do I get this error?

                                                      directive.

                                                      In ESLint the rule that generates this warning is named no-comma-dangle. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W072.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W072.html index 604f0ec..5378045 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W072.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W072.html @@ -1,4 +1,5 @@ -

                                                      History

                                                      + +

                                                      History

                                                      This warning has existed in two forms in JSHint and ESLint. It has never existing in JSLint. It was introduced in the r11 version of JSHint and has remained both JSHint and ESLint ever since.

                                                      @@ -22,7 +23,7 @@

                                                      When do I get this error?

                                                      parameters than specified by the configuration
                                                      . In JSHint the configuration is controlled by the maxparams option. In ESLint it's max-params. Here's an example in which we attempt to declare a function that takes 3 arguments:

                                                      -
                                                      x
                                                       
                                                      1
                                                      /*jshint maxparams: 2 */
                                                      2
                                                      /*eslint max-params: [1, 2] */
                                                      3
                                                      function Person(name, age, gender) {
                                                      4
                                                          "use strict";
                                                      5
                                                          this.name = name;
                                                      6
                                                          this.age = age;
                                                      7
                                                          this.gender = gender;
                                                      8
                                                      }
                                                      9
                                                      JSHint found 1 errorVersion 2.5.0
                                                      Line 3:This function has too many parameters. (3)
                                                      +
                                                      x
                                                       
                                                      1
                                                      /*jshint maxparams: 2 */
                                                      2
                                                      /*eslint max-params: [1, 2] */
                                                      3
                                                      function Person(name, age, gender) {
                                                      4
                                                          "use strict";
                                                      5
                                                          this.name = name;
                                                      6
                                                          this.age = age;
                                                      7
                                                          this.gender = gender;
                                                      8
                                                      }
                                                      9
                                                      JSHint found 1 errorVersion 2.9.0
                                                      Line 3:This function has too many parameters. (3)

                                                      Why do I get this error?

                                                      This error is raised to highlight a deviation from a coding style. The ECMAScript standard does not specify a minimum or maximum number of arguments a @@ -43,10 +44,12 @@

                                                      Why do I get this error?

                                                      e.g. options, which is usually an object with various properties. We could rewrite our Person constructor from the example above to use a single named parameter and therefore conform to the specified coding style:

                                                      -
                                                      9
                                                       
                                                      1
                                                      /*jshint maxparams: 2 */
                                                      2
                                                      /*eslint max-params: [1, 2] */
                                                      3
                                                      function Person(options) {
                                                      4
                                                          "use strict";
                                                      5
                                                          this.name = options.name;
                                                      6
                                                          this.age = options.age;
                                                      7
                                                          this.gender = options.gender;
                                                      8
                                                      }
                                                      9
                                                      JSHint found no errorsVersion 2.5.0
                                                      +
                                                      9
                                                       
                                                      1
                                                      /*jshint maxparams: 2 */
                                                      2
                                                      /*eslint max-params: [1, 2] */
                                                      3
                                                      function Person(options) {
                                                      4
                                                          "use strict";
                                                      5
                                                          this.name = options.name;
                                                      6
                                                          this.age = options.age;
                                                      7
                                                          this.gender = options.gender;
                                                      8
                                                      }
                                                      9
                                                      JSHint found no errorsVersion 2.9.0

                                                      In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W072. This means you can tell JSHint to not issue this warning with the /*jshint -W072 */ directive.

                                                      In ESLint the rule that generates this warning is named max-params. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W075.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W075.html index f2e85bf..54c5bb3 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W075.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W075.html @@ -1,4 +1,5 @@ -

                                                      History

                                                      + +

                                                      History

                                                      This warning has existed in three forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three linters ever since.

                                                      @@ -17,7 +18,7 @@

                                                      When do I get this error?

                                                      an object literal that contains more than one property with the same identifier. In the following example we attempt to assign an object containing two properties with the identifier y to a variable x:

                                                      -
                                                      x
                                                       
                                                      1
                                                      var x = {
                                                      2
                                                          y: 10,
                                                      3
                                                          y: 20
                                                      4
                                                      };
                                                      5
                                                      JSHint found 1 errorVersion 2.5.0
                                                      Line 3:Duplicate key 'y'.
                                                      +
                                                      x
                                                       
                                                      1
                                                      var x = {
                                                      2
                                                          y: 10,
                                                      3
                                                          y: 20
                                                      4
                                                      };
                                                      5
                                                      JSHint found 1 errorVersion 2.9.0
                                                      Line 3:Duplicate key 'y'.

                                                      Why do I get this error?

                                                      This error is raised to highlight code that may not work as you expect and could possibly cause a fatal JavaScript syntax error. In strict mode, your @@ -45,3 +46,5 @@

                                                      Why do I get this error?

                                                      -W075 */ directive.

                                                      In ESLint the rule that generates this warning is named no-dupe-keys. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W076.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W076.html index b94443d..6555146 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W076.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W076.html @@ -1,4 +1,5 @@ -

                                                      History

                                                      + +

                                                      History

                                                      This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained (in a way) in all three tools ever since.

                                                      @@ -17,7 +18,7 @@

                                                      When do I get this error?

                                                      encounters a named parameter in the signature of a property getter function. In the following example we create an object x with a getter and setter. The getter will always return half of the set value:

                                                      -
                                                      x
                                                       
                                                      1
                                                      var x = {
                                                      2
                                                          actual: 10,
                                                      3
                                                          get x (value) {
                                                      4
                                                              "use strict";
                                                      5
                                                              return this.actual / 2;
                                                      6
                                                          },
                                                      7
                                                          set x (value) {
                                                      8
                                                              "use strict";
                                                      9
                                                              this.actual = value;
                                                      10
                                                          }
                                                      11
                                                      };
                                                      12
                                                      JSLint found 2 errorsVersion 2014-02-06
                                                      Line 3:Unused 'value'.
                                                      Line 3:Unexpected parameter 'value' in get x function.
                                                      +
                                                      x
                                                       
                                                      1
                                                      var x = {
                                                      2
                                                          actual: 10,
                                                      3
                                                          get x (value) {
                                                      4
                                                              "use strict";
                                                      5
                                                              return this.actual / 2;
                                                      6
                                                          },
                                                      7
                                                          set x (value) {
                                                      8
                                                              "use strict";
                                                      9
                                                              this.actual = value;
                                                      10
                                                          }
                                                      11
                                                      };
                                                      12
                                                      JSLint found 8 errorsVersion 2015-09-23
                                                      Line 2:Redefinition of 'x' from line 0.
                                                      Line 2:A get function takes no parameters.
                                                      Line 2:Unexpected space between 'x' and '('.
                                                      Line 2:Unused 'value'.
                                                      Line 4:Unexpected 'this'.
                                                      Line 6:Redefinition of 'x' from line 0.
                                                      Line 6:Unexpected space between 'x' and '('.
                                                      Line 8:Unexpected 'this'.

                                                      Why do I get this error?

                                                      This error is raised to highlight a completely pointless and potentially confusing piece of code. Your code will run without error if you do not change @@ -33,8 +34,10 @@

                                                      Why do I get this error?

                                                      Since the runtime will never pass any arguments to the getter function, there is no need to provide any named parameters in the function signature. Simply remove them to fix the error:

                                                      -
                                                      12
                                                       
                                                      1
                                                      var x = {
                                                      2
                                                          actual: 10,
                                                      3
                                                          get x () {
                                                      4
                                                              "use strict";
                                                      5
                                                              return this.actual / 2;
                                                      6
                                                          },
                                                      7
                                                          set x (value) {
                                                      8
                                                              "use strict";
                                                      9
                                                              this.actual = value;
                                                      10
                                                          }
                                                      11
                                                      };
                                                      12
                                                      JSLint found no errorsVersion 2014-02-06
                                                      +
                                                      12
                                                       
                                                      1
                                                      var x = {
                                                      2
                                                          actual: 10,
                                                      3
                                                          get x () {
                                                      4
                                                              "use strict";
                                                      5
                                                              return this.actual / 2;
                                                      6
                                                          },
                                                      7
                                                          set x (value) {
                                                      8
                                                              "use strict";
                                                      9
                                                              this.actual = value;
                                                      10
                                                          }
                                                      11
                                                      };
                                                      12
                                                      JSLint found 6 errorsVersion 2015-09-23
                                                      Line 2:Redefinition of 'x' from line 0.
                                                      Line 2:Unexpected space between 'x' and '('.
                                                      Line 4:Unexpected 'this'.
                                                      Line 6:Redefinition of 'x' from line 0.
                                                      Line 6:Unexpected space between 'x' and '('.
                                                      Line 8:Unexpected 'this'.

                                                      In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W076. This means you can tell JSHint to not issue this warning with the /*jshint -W076 */ directive.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W079.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W079.html index 14e44ac..85a2c61 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W079.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W079.html @@ -1,9 +1,10 @@ -

                                                      When do I get this error?

                                                      + +

                                                      When do I get this error?

                                                      The "Redefinition of '{a}'" error is thrown when JSHint or ESLint encounters a variable declaration with an identifier that is the same as that of a built-in native object. In the following example we attempt to declare a variable with the identifier String:

                                                      -
                                                      x
                                                       
                                                      1
                                                      var String = "My String";
                                                      2
                                                      JSHint found 1 errorVersion 2.5.0
                                                      Line 1:Redefinition of 'String'.
                                                      +
                                                      x
                                                       
                                                      1
                                                      var String = "My String";
                                                      2
                                                      JSHint found 1 errorVersion 2.9.0
                                                      Line 1:Redefinition of 'String'.

                                                      This warning will often appear alongside the related "Read only" message so you may find it useful to read the explanations of that one too.

                                                      Why do I get this error?

                                                      @@ -58,3 +59,5 @@

                                                      Why do I get this error?

                                                      -W079 */ directive.

                                                      In ESLint the rule that generates this warning is named no-native-reassign. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W080.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W080.html index 8d55016..97c7ac0 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W080.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W080.html @@ -1,9 +1,10 @@ -

                                                      When do I get this error?

                                                      + +

                                                      When do I get this error?

                                                      The "It is not necessary to initialize '{a}' to 'undefined'" error is thrown when JSLint, JSHint or ESLint encounters a variable statement in which the variable is explicitly initialised to undefined. Here's an example in which we attempt to declare a variable x and assign undefined to it:

                                                      -
                                                      x
                                                       
                                                      1
                                                      var x = undefined;
                                                      2
                                                      JSLint found 1 errorVersion 2014-02-06
                                                      Line 1:It is not necessary to initialize 'x' to 'undefined'.
                                                      +
                                                      x
                                                       
                                                      1
                                                      var x = undefined;
                                                      2
                                                      JSLint found no errorsVersion 2015-09-23

                                                      Why do I get this error?

                                                      This error is raised to highlight a completely pointless piece of code. Your code will run without error if you do not change it, but you're needlessly @@ -37,15 +38,17 @@

                                                      Why do I get this error?

                                                      You can fix the error by simply removing the assignment expression from the variable statement. The variable will still have the same value:

                                                      -
                                                      2
                                                       
                                                      1
                                                      var x;
                                                      2
                                                      JSLint found no errorsVersion 2014-02-06
                                                      +
                                                      2
                                                       
                                                      1
                                                      var x;
                                                      2
                                                      JSLint found no errorsVersion 2015-09-23

                                                      If, for whatever reason, you have to assign the undefined value to the variable, you can replace undefined with something that returns the undefined value. The simplest example of that is the void operator (although as of September 2013 JSLint will raise a new error for this):

                                                      -
                                                      2
                                                       
                                                      1
                                                      var x = void 0;
                                                      2
                                                      JSLint found 1 errorVersion 2014-02-06
                                                      Line 1:Expected 'undefined' and instead saw 'void'.
                                                      +
                                                      2
                                                       
                                                      1
                                                      var x = void 0;
                                                      2
                                                      JSLint found 1 errorVersion 2015-09-23
                                                      Line 0:Unexpected 'void'.

                                                      In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W080. This means you can tell JSHint to not issue this warning with the /*jshint -W080 */ directive.

                                                      In ESLint the rule that generates this warning is named no-undef-init. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                      + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W081.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W081.html index 5e800b2..fc0e228 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W081.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W081.html @@ -1,4 +1,5 @@ -

                                                      History

                                                      + +

                                                      History

                                                      This warning has existed in two forms in JSLint and JSHint. It was introduced in JSLint in June 2011 and has remained in both tools ever since.

                                                        @@ -15,7 +16,7 @@

                                                        When do I get this error?

                                                        when it encounters multiple variable statements within a function. Here's an example in which we attempt to declare two variables, x and y, with two separate var statements:

                                                        -
                                                        x
                                                         
                                                        1
                                                        /*jshint onevar: true */
                                                        2
                                                        function example() {
                                                        3
                                                            "use strict";
                                                        4
                                                            var x = 10;
                                                        5
                                                            var y = 20;
                                                        6
                                                        }
                                                        7
                                                        JSLint found 2 errorsVersion 2014-02-06
                                                        Line 5:Combine this with the previous 'var' statement.
                                                        Line 4:Unused 'x'.
                                                        +
                                                        x
                                                         
                                                        1
                                                        /*jshint onevar: true */
                                                        2
                                                        function example() {
                                                        3
                                                            "use strict";
                                                        4
                                                            var x = 10;
                                                        5
                                                            var y = 20;
                                                        6
                                                        }
                                                        7
                                                        JSLint found 2 errorsVersion 2015-09-23
                                                        Line 3:Unused 'x'.
                                                        Line 4:Unused 'y'.

                                                        Why do I get this error?

                                                        This error is raised to highlight a lack of convention and could also indicate a misunderstanding of how the language works. In many languages, @@ -24,7 +25,7 @@

                                                        Why do I get this error?

                                                        Instead, it has function scope, in which variables can only be scoped to a function. This error is raised to help prevent the misunderstanding of code like this:

                                                        -
                                                        10
                                                         
                                                        1
                                                        /*jshint onevar: true */
                                                        2
                                                        function example() {
                                                        3
                                                            "use strict";
                                                        4
                                                            var x = 10;
                                                        5
                                                            if (x === 10) {
                                                        6
                                                                var y = 20;
                                                        7
                                                            }
                                                        8
                                                            return y; // Able to return y because of function scoping
                                                        9
                                                        }
                                                        10
                                                        JSHint found 1 errorVersion 2.5.0
                                                        Line 8:'y' used out of scope.
                                                        +
                                                        10
                                                         
                                                        1
                                                        /*jshint onevar: true */
                                                        2
                                                        function example() {
                                                        3
                                                            "use strict";
                                                        4
                                                            var x = 10;
                                                        5
                                                            if (x === 10) {
                                                        6
                                                                var y = 20;
                                                        7
                                                            }
                                                        8
                                                            return y; // Able to return y because of function scoping
                                                        9
                                                        }
                                                        10
                                                        JSHint found 1 errorVersion 2.9.0
                                                        Line 8:'y' used out of scope.

                                                        In the above example, the variable y is declared regardless of whether the if statement body is executed or not. It is only assigned a value when the if statement body is executed, but it's declared (and will have a value of @@ -33,7 +34,7 @@

                                                        Why do I get this error?

                                                        JSLint and JSHint will raise this warning to get you to declare all variables at once. You can fix it by moving the declaration of y out of the block and combining it with the declaration of x:

                                                        -
                                                         
                                                        1
                                                        /*jshint onevar: true */
                                                        2
                                                        function example() {
                                                        3
                                                            "use strict";
                                                        4
                                                            var x = 10,
                                                        5
                                                                y;
                                                        6
                                                            if (x === 10) {
                                                        7
                                                                y = 20;
                                                        8
                                                            }
                                                        9
                                                            return y; // Able to return y because of function scoping
                                                        10
                                                        }
                                                        11
                                                        JSHint found no errorsVersion 2.5.0
                                                        +
                                                        11
                                                         
                                                        1
                                                        /*jshint onevar: true */
                                                        2
                                                        function example() {
                                                        3
                                                            "use strict";
                                                        4
                                                            var x = 10,
                                                        5
                                                                y;
                                                        6
                                                            if (x === 10) {
                                                        7
                                                                y = 20;
                                                        8
                                                            }
                                                        9
                                                            return y; // Able to return y because of function scoping
                                                        10
                                                        }
                                                        11
                                                        JSHint found no errorsVersion 2.9.0

                                                        The fact that JSLint does not allow you to simply have multiple variable statements outside of the block is just the coding convention preferred by the author, Douglas Crockford. The use of the comma to group variable declarations @@ -53,3 +54,5 @@

                                                        Why do I get this error?

                                                        special option syntax. The identifier of this warning is W081. This means you can tell JSHint to not issue this warning with the /*jshint -W081 */ directive.

                                                        + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W082.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W082.html index caf65f2..2502948 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W082.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W082.html @@ -1,10 +1,11 @@ -

                                                        When do I get this error?

                                                        + +

                                                        When do I get this error?

                                                        The "Function statements should not be placed in blocks" error (and the alternative "Function declarations should not be placed in blocks" error) is thrown when JSLint or JSHint encounters a function declaration inside a block statement. In the following example we attempt to declare the example function only if some condition is true:

                                                        -
                                                        x
                                                         
                                                        1
                                                        var x = true;
                                                        2
                                                        if (x) {
                                                        3
                                                            function example() {
                                                        4
                                                                "use strict";
                                                        5
                                                                return true;
                                                        6
                                                            }
                                                        7
                                                        }
                                                        8
                                                        JSLint found 1 errorVersion 2014-02-06
                                                        Line 3:Function statements should not be placed in blocks.Use a function expression or move the statement to the top of the outer function.
                                                        +
                                                        x
                                                         
                                                        1
                                                        var x = true;
                                                        2
                                                        if (x) {
                                                        3
                                                            function example() {
                                                        4
                                                                "use strict";
                                                        5
                                                                return true;
                                                        6
                                                            }
                                                        7
                                                        }
                                                        8
                                                        JSLint found 1 errorVersion 2015-09-23
                                                        Line 2:Unexpected 'function'.

                                                        Why do I get this error?

                                                        This error is raised to highlight code that may not work as you expect it to. In most environments Your code will run without error, but maybe not in @@ -16,7 +17,7 @@

                                                        Why do I get this error?

                                                        §10.5). Therefore, it is not possible to conditionally declare a function with a function statement. The above example is actually interpreted as follows:

                                                        -
                                                        7
                                                         
                                                        1
                                                        function example() {
                                                        2
                                                            "use strict";
                                                        3
                                                            return true;
                                                        4
                                                        }
                                                        5
                                                        var x = true;
                                                        6
                                                        if (x) {}
                                                        7
                                                        JSLint found 1 errorVersion 2014-02-06
                                                        Line 6:Empty block.
                                                        +
                                                        7
                                                         
                                                        1
                                                        function example() {
                                                        2
                                                            "use strict";
                                                        3
                                                            return true;
                                                        4
                                                        }
                                                        5
                                                        var x = true;
                                                        6
                                                        if (x) {}
                                                        7
                                                        JSLint found 1 errorVersion 2015-09-23
                                                        Line 5:Empty block.

                                                        As you can see, regardless of the result of the condition, the example function is always declared. If you were to, for example, declare it twice (once in an if block and once in the corresponding else block) you would actually end up with @@ -26,7 +27,7 @@

                                                        Why do I get this error?

                                                        want to declare a function conditionally, you can use a function expression, instead of a function declaration. A function expression can easily by produced by assigning a function to a variable:

                                                        -
                                                        10
                                                         
                                                        1
                                                        var x = true,
                                                        2
                                                            example;
                                                        3
                                                        4
                                                        if (x) {
                                                        5
                                                            example = function () {
                                                        6
                                                                "use strict";
                                                        7
                                                                return true;
                                                        8
                                                            };
                                                        9
                                                        }
                                                        10
                                                        JSLint found no errorsVersion 2014-02-06
                                                        +
                                                        10
                                                         
                                                        1
                                                        var x = true,
                                                        2
                                                            example;
                                                        3
                                                        4
                                                        if (x) {
                                                        5
                                                            example = function () {
                                                        6
                                                                "use strict";
                                                        7
                                                                return true;
                                                        8
                                                            };
                                                        9
                                                        }
                                                        10
                                                        JSLint found no errorsVersion 2015-09-23

                                                        Syntax errors

                                                        It's important to note that there is no support in the ECMAScript 5 specification for function declarations within block statements. However, most @@ -53,3 +54,5 @@

                                                        Syntax errors

                                                        special option syntax. The identifier of this warning is W082. This means you can tell JSHint to not issue this warning with the /*jshint -W082 */ directive.

                                                        + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W083.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W083.html index 0efd14f..643ccbb 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W083.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W083.html @@ -1,11 +1,12 @@ -

                                                        When do I get this error?

                                                        + +

                                                        When do I get this error?

                                                        The "Don't make functions within a loop" error is thrown when JSLint, JSHint and ESLint encounter a function expression in a for, while or do statement body. In the following example we attempt to add a click event listener to each element with a given class name. The event handler is intended to overwrite the contents of the clicked element with the value of i at a specific iteration of the loop:

                                                        -
                                                         
                                                        1
                                                        /*jslint browser: true, plusplus: true */
                                                        2
                                                        3
                                                        var elems = document.getElementsByClassName("myClass"), i;
                                                        4
                                                        5
                                                        for (i = 0; i < elems.length; i++) {
                                                        6
                                                            elems[i].addEventListener("click", function () {
                                                        7
                                                                "use strict";
                                                        8
                                                                this.innerHTML = i;
                                                        9
                                                            });
                                                        10
                                                        }
                                                        11
                                                        JSLint found 1 errorVersion 2014-02-06
                                                        Line 6:Don't make functions within a loop.
                                                        +
                                                        x
                                                         
                                                        1
                                                        /*jslint browser: true, plusplus: true */
                                                        2
                                                        3
                                                        var elems = document.getElementsByClassName("myClass"), i;
                                                        4
                                                        5
                                                        for (i = 0; i < elems.length; i++) {
                                                        6
                                                            elems[i].addEventListener("click", function () {
                                                        7
                                                                "use strict";
                                                        8
                                                                this.innerHTML = i;
                                                        9
                                                            });
                                                        10
                                                        }
                                                        11
                                                        JSLint found 5 errorsVersion 2015-09-23
                                                        Line 0:Bad option 'plusplus'.
                                                        Line 4:Unexpected 'for'.
                                                        Line 4:Expected '+= 1' and instead saw '++'.
                                                        Line 5:Don't make functions within a loop.
                                                        Line 7:Unexpected 'this'.

                                                        Why do I get this error?

                                                        This error is raised to highlight code that may not work as you expect it to and could also indicate misunderstanding of how the language works. Your @@ -19,7 +20,7 @@

                                                        Why do I get this error?

                                                        This happens because each function retains a reference to the same copy of i. We can get around this by forcing each function to take its own copy of i at whatever value it has at that time:

                                                        -
                                                        13
                                                         
                                                        1
                                                        /*jslint browser: true, plusplus: true */
                                                        2
                                                        3
                                                        var elems = document.getElementsByClassName("myClass"), i;
                                                        4
                                                        5
                                                        for (i = 0; i < elems.length; i++) {
                                                        6
                                                            (function (iCopy) {
                                                        7
                                                                "use strict";
                                                        8
                                                                elems[i].addEventListener("click", function () {
                                                        9
                                                                    this.innerHTML = iCopy;
                                                        10
                                                                });
                                                        11
                                                            }(i));
                                                        12
                                                        }
                                                        13
                                                        JSLint found 1 errorVersion 2014-02-06
                                                        Line 6:Don't make functions within a loop.
                                                        +
                                                        13
                                                         
                                                        1
                                                        /*jslint browser: true, plusplus: true */
                                                        2
                                                        3
                                                        var elems = document.getElementsByClassName("myClass"), i;
                                                        4
                                                        5
                                                        for (i = 0; i < elems.length; i++) {
                                                        6
                                                            (function (iCopy) {
                                                        7
                                                                "use strict";
                                                        8
                                                                elems[i].addEventListener("click", function () {
                                                        9
                                                                    this.innerHTML = iCopy;
                                                        10
                                                                });
                                                        11
                                                            }(i));
                                                        12
                                                        }
                                                        13
                                                        JSLint found 5 errorsVersion 2015-09-23
                                                        Line 0:Bad option 'plusplus'.
                                                        Line 4:Unexpected 'for'.
                                                        Line 4:Expected '+= 1' and instead saw '++'.
                                                        Line 5:Don't make functions within a loop.
                                                        Line 8:Unexpected 'this'.

                                                        What we have now captures the value of i at each iteration of the loop. This happens because JavaScript passes arguments to functions by value. This means that iCopy within the capturing function is not related to i in any way @@ -35,10 +36,12 @@

                                                        Why do I get this error?

                                                        create multiple function instances, which can cause unexpected behavior and performance problems. To fix the issue, we need to move the function out of the loop:

                                                        -
                                                        15
                                                         
                                                        1
                                                        /*jslint browser: true, plusplus: true */
                                                        2
                                                        3
                                                        var elems = document.getElementsByClassName("myClass"), i;
                                                        4
                                                        5
                                                        function makeClickHandler(i) {
                                                        6
                                                            "use strict";
                                                        7
                                                            return function () {
                                                        8
                                                                this.innerHTML = i;
                                                        9
                                                            };
                                                        10
                                                        }
                                                        11
                                                        12
                                                        for (i = 0; i < elems.length; i++) {
                                                        13
                                                            elems[i].addEventListener("click", makeClickHandler(i));
                                                        14
                                                        }
                                                        15
                                                        JSLint found no errorsVersion 2014-02-06
                                                        +
                                                        15
                                                         
                                                        1
                                                        /*jslint browser: true, plusplus: true */
                                                        2
                                                        3
                                                        var elems = document.getElementsByClassName("myClass"), i;
                                                        4
                                                        5
                                                        function makeClickHandler(i) {
                                                        6
                                                            "use strict";
                                                        7
                                                            return function () {
                                                        8
                                                                this.innerHTML = i;
                                                        9
                                                            };
                                                        10
                                                        }
                                                        11
                                                        12
                                                        for (i = 0; i < elems.length; i++) {
                                                        13
                                                            elems[i].addEventListener("click", makeClickHandler(i));
                                                        14
                                                        }
                                                        15
                                                        JSLint found 4 errorsVersion 2015-09-23
                                                        Line 0:Bad option 'plusplus'.
                                                        Line 7:Unexpected 'this'.
                                                        Line 11:Unexpected 'for'.
                                                        Line 11:Expected '+= 1' and instead saw '++'.

                                                        In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W083. This means you can tell JSHint to not issue this warning with the /*jshint -W083 */ directive. You can also set the loopfunc option to true.

                                                        In ESLint the rule that generates this warning is named no-loop-func. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                        + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W084.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W084.html index 98d44da..e61258d 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W084.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W084.html @@ -1,4 +1,5 @@ -

                                                        History

                                                        + +

                                                        History

                                                        This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                        @@ -22,7 +23,7 @@

                                                        When do I get this error?

                                                        or while statement initializer. In the following example we have an if statement with an assignment expression where you would normally expect a conditional:

                                                        -
                                                        x
                                                         
                                                        1
                                                        var x, y;
                                                        2
                                                        if (x = 0) {
                                                        3
                                                            y = 1;
                                                        4
                                                        }
                                                        5
                                                        JSLint found 1 errorVersion 2014-02-06
                                                        Line 2:Unexpected assignment expression.
                                                        +
                                                        x
                                                         
                                                        1
                                                        var x, y;
                                                        2
                                                        if (x = 0) {
                                                        3
                                                            y = 1;
                                                        4
                                                        }
                                                        5
                                                        JSLint found 1 errorVersion 2015-09-23
                                                        Line 1:Unexpected statement '=' in expression position.

                                                        Since May 2013 JSLint will also generate this warning when it encounters a return statement containing an assignment expression. If that's the case in your code you'll want to read the page concerning the "Did you mean to return a @@ -37,21 +38,23 @@

                                                        Why do I get this error?

                                                        falsy.

                                                        In the above case it's obvious we've made a mistake and the fix is to simply ensure the use of a comparison rather than an assignment:

                                                        -
                                                        5
                                                         
                                                        1
                                                        var x, y;
                                                        2
                                                        if (x === 0) {
                                                        3
                                                            y = 1;
                                                        4
                                                        }
                                                        5
                                                        JSLint found no errorsVersion 2014-02-06
                                                        +
                                                        5
                                                         
                                                        1
                                                        var x, y;
                                                        2
                                                        if (x === 0) {
                                                        3
                                                            y = 1;
                                                        4
                                                        }
                                                        5
                                                        JSLint found no errorsVersion 2015-09-23

                                                        There are some legitimate situations that can produce this error too. Consider the following example which is a common pattern for traversing a DOM node heirarchy:

                                                        -
                                                        7
                                                         
                                                        1
                                                        function setHeight(someNode) {
                                                        2
                                                            "use strict";
                                                        3
                                                            do {
                                                        4
                                                                someNode.height = '100px';
                                                        5
                                                            } while (someNode = someNode.parentNode);
                                                        6
                                                        }
                                                        7
                                                        JSHint found 1 errorVersion 2.5.0
                                                        Line 5:Expected a conditional expression and instead saw an assignment.
                                                        +
                                                        7
                                                         
                                                        1
                                                        function setHeight(someNode) {
                                                        2
                                                            "use strict";
                                                        3
                                                            do {
                                                        4
                                                                someNode.height = '100px';
                                                        5
                                                            } while (someNode = someNode.parentNode);
                                                        6
                                                        }
                                                        7
                                                        JSHint found 1 errorVersion 2.9.0
                                                        Line 5:Expected a conditional expression and instead saw an assignment.

                                                        In this case you can disable the warning (if you're using JSHint or ESLint) or force the expression to become conditional, but only if you're using JSHint, ESLint or a version JSLint from before July 2013 (the message will be "Expected a conditional expression and instead saw an assignment"). If you're using a more recent version there appears to be no way to supress the "Unexpected assignment expression" warning:

                                                        -
                                                        7
                                                         
                                                        1
                                                        function setHeight(someNode) {
                                                        2
                                                            "use strict";
                                                        3
                                                            do {
                                                        4
                                                                someNode.height = '100px';
                                                        5
                                                            } while ((someNode = someNode.parentNode) !== null);
                                                        6
                                                        }
                                                        7
                                                        JSLint found no errorsVersion 2013-05-31
                                                        +
                                                        7
                                                         
                                                        1
                                                        function setHeight(someNode) {
                                                        2
                                                            "use strict";
                                                        3
                                                            do {
                                                        4
                                                                someNode.height = '100px';
                                                        5
                                                            } while ((someNode = someNode.parentNode) !== null);
                                                        6
                                                        }
                                                        7
                                                        JSLint found no errorsVersion 2013-05-31

                                                        In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W084. This means you can tell JSHint to not issue this warning with the /*jshint -W084 */ directive.

                                                        In ESLint the rule that generates this warning is named no-cond-assign. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                        + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W085.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W085.html index 0e26cee..0747ae5 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W085.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W085.html @@ -1,4 +1,5 @@ -

                                                        History

                                                        + +

                                                        History

                                                        This warning has existed in two forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three linters ever since.

                                                        @@ -21,7 +22,7 @@

                                                        When do I get this error?

                                                        "Unexpected use of 'with' statement", is thrown when JSLint, JSHint or ESLint encounters the with statement in code that is not running in strict mode. Here's an example:

                                                        -
                                                        x
                                                         
                                                        1
                                                        function example() {
                                                        2
                                                            var a = {
                                                        3
                                                                    b: 10
                                                        4
                                                                },
                                                        5
                                                                c = 20;
                                                        6
                                                            with (a) {
                                                        7
                                                                b = 30;
                                                        8
                                                                c = 40;
                                                        9
                                                            }
                                                        10
                                                        }
                                                        11
                                                        JSHint found 1 errorVersion 2.5.0
                                                        Line 6:Don't use 'with'.
                                                        +
                                                        x
                                                         
                                                        1
                                                        function example() {
                                                        2
                                                            var a = {
                                                        3
                                                                    b: 10
                                                        4
                                                                },
                                                        5
                                                                c = 20;
                                                        6
                                                            with (a) {
                                                        7
                                                                b = 30;
                                                        8
                                                                c = 40;
                                                        9
                                                            }
                                                        10
                                                        }
                                                        11
                                                        JSHint found 1 errorVersion 2.9.0
                                                        Line 6:Don't use 'with'.

                                                        Why do I get this error?

                                                        This error is raised to highlight a lack of convention and the use of a bad practice. Your code may work as expected but you're doing something that @@ -42,8 +43,10 @@

                                                        Why do I get this error?

                                                        syntax error (see the article regarding the related "'with' is not allowed in strict mode" message for more information). There are much better ways to achieve the same thing:

                                                        -
                                                        8
                                                         
                                                        1
                                                        function example() {
                                                        2
                                                            var a = {
                                                        3
                                                                b: 10
                                                        4
                                                            };
                                                        5
                                                            a.b = 30;
                                                        6
                                                            a.c = 40;
                                                        7
                                                        }
                                                        8
                                                        JSHint found no errorsVersion 2.5.0
                                                        +
                                                        8
                                                         
                                                        1
                                                        function example() {
                                                        2
                                                            var a = {
                                                        3
                                                                b: 10
                                                        4
                                                            };
                                                        5
                                                            a.b = 30;
                                                        6
                                                            a.c = 40;
                                                        7
                                                        }
                                                        8
                                                        JSHint found no errorsVersion 2.9.0

                                                        In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W085. This means you can tell JSHint to not issue this warning with the /*jshint -W085 */ directive.

                                                        + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W087.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W087.html index 8c05b81..f6a5bec 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W087.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W087.html @@ -1,4 +1,5 @@ -

                                                        History

                                                        + +

                                                        History

                                                        This warning has existed in various forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three linters ever since.

                                                        @@ -22,7 +23,7 @@

                                                        When do I get this error?

                                                        JSLint, JSHint or ESLint encounters a debugger statement. The following example is completely useless but is the minimum program that will generate this error:

                                                        -
                                                        x
                                                         
                                                        1
                                                        debugger;
                                                        2
                                                        JSLint found 1 errorVersion 2014-02-06
                                                        Line 1:Unexpected 'debugger'.
                                                        +
                                                        x
                                                         
                                                        1
                                                        debugger;
                                                        2
                                                        JSLint found 1 errorVersion 2015-09-23
                                                        Line 0:Unexpected 'debugger'.

                                                        Why do I get this error?

                                                        This error is raised to highlight a lack of convention and a possible oversight. Your code will run without error but it will probably not behave @@ -44,3 +45,5 @@

                                                        Why do I get this error?

                                                        -W087 */ directive.

                                                        In ESLint the rule that generates this warning is named no-debugger. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                        + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W088.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W088.html index f29853b..bffdcbf 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W088.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W088.html @@ -1,4 +1,5 @@ -

                                                        History

                                                        + +

                                                        History

                                                        This warning has existed in several forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                        @@ -19,12 +20,12 @@

                                                        When do I get this error?

                                                        JSLint, JSHint or ESLint encounters a for-in statement in which the initializer contains a literal value. In the following example we have a for- in statement in which we attempt to assign each property to a string literal:

                                                        -
                                                        x
                                                         
                                                        1
                                                        function test() {
                                                        2
                                                            "use strict";
                                                        3
                                                            var y = {};
                                                        4
                                                            for ("a" in y) {
                                                        5
                                                                // ...
                                                        6
                                                            }
                                                        7
                                                        }
                                                        8
                                                        JSLint found 3 errorsVersion 2014-02-06
                                                        Line 4:Bad for in variable 'a'.
                                                        Line 4:Stopping. (50% scanned).
                                                        +
                                                        x
                                                         
                                                        1
                                                        function test() {
                                                        2
                                                            "use strict";
                                                        3
                                                            var y = {};
                                                        4
                                                            for ("a" in y) {
                                                        5
                                                                // ...
                                                        6
                                                            }
                                                        7
                                                        }
                                                        8
                                                        JSLint found 3 errorsVersion 2015-09-23
                                                        Line 3:Unexpected 'for'.
                                                        Line 3:Bad assignment to 'a'.
                                                        Line 3:Empty block.

                                                        JSLint and JSHint also raise this warning when it encounters a for-in statement in which the initializer contains an undefined variable reference. In this example the for-in statement will assign each property to x which has not been declared:

                                                        -
                                                        8
                                                         
                                                        1
                                                        function test() {
                                                        2
                                                            "use strict";
                                                        3
                                                            var y = {};
                                                        4
                                                            for (x in y) {
                                                        5
                                                                // ...
                                                        6
                                                            }
                                                        7
                                                        }
                                                        8
                                                        JSHint found 1 errorVersion 2.5.0
                                                        Line 4:Creating global 'for' variable. Should be 'for (var x ...'.
                                                        +
                                                        8
                                                         
                                                        1
                                                        function test() {
                                                        2
                                                            "use strict";
                                                        3
                                                            var y = {};
                                                        4
                                                            for (x in y) {
                                                        5
                                                                // ...
                                                        6
                                                            }
                                                        7
                                                        }
                                                        8
                                                        JSHint found 1 errorVersion 2.9.0
                                                        Line 4:Creating global 'for' variable. Should be 'for (var x ...'.

                                                        Why do I get this error?

                                                        In the case of non-identifiers like the string literal in the first example above this error is raised to highlight a fatal reference error. Your code @@ -39,10 +40,12 @@

                                                        Why do I get this error?

                                                        expression has not been declared it will be created as a property of the global object. You can resolve this issue by simply declaring the variable before the for-in statement:

                                                        -
                                                        9
                                                         
                                                        1
                                                        function test() {
                                                        2
                                                            "use strict";
                                                        3
                                                            var y = {},
                                                        4
                                                                x;
                                                        5
                                                            for (x in y) {
                                                        6
                                                                // ...
                                                        7
                                                            }
                                                        8
                                                        }
                                                        9
                                                        JSHint found no errorsVersion 2.5.0
                                                        +
                                                        9
                                                         
                                                        1
                                                        function test() {
                                                        2
                                                            "use strict";
                                                        3
                                                            var y = {},
                                                        4
                                                                x;
                                                        5
                                                            for (x in y) {
                                                        6
                                                                // ...
                                                        7
                                                            }
                                                        8
                                                        }
                                                        9
                                                        JSHint found no errorsVersion 2.9.0

                                                        In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W088. This means you can tell JSHint to not issue this warning with the /*jshint -W088 */ directive.

                                                        In ESLint this error is generated by the Esprima parser and can therefore not be disabled.

                                                        + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W089.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W089.html index bc3f24e..23f3467 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W089.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W089.html @@ -1,4 +1,5 @@ -

                                                        When do I get this error?

                                                        + +

                                                        When do I get this error?

                                                        The "The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype" error is thrown when JSLint encounters a for-in statement in which the first statement is not an if statement @@ -7,7 +8,7 @@

                                                        When do I get this error?

                                                        warn when they encounter a for-in statement in which the first statement is not an if statement, regardless of the condition of that if statement. Here's an example in which we attempt to enumerate the properties of an object:

                                                        -
                                                        x
                                                         
                                                        1
                                                        /*jshint forin: true */
                                                        2
                                                        /*eslint guard-for-in: 1 */
                                                        3
                                                        /*global doSomething */
                                                        4
                                                        5
                                                        var me = {
                                                        6
                                                                name: "James",
                                                        7
                                                                age: 23
                                                        8
                                                            },
                                                        9
                                                            prop;
                                                        10
                                                        11
                                                        for (prop in me) {
                                                        12
                                                            doSomething(prop);
                                                        13
                                                        }
                                                        14
                                                        JSLint found 1 errorVersion 2014-02-06
                                                        Line 11:The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.
                                                        +
                                                        x
                                                         
                                                        1
                                                        /*jshint forin: true */
                                                        2
                                                        /*eslint guard-for-in: 1 */
                                                        3
                                                        /*global doSomething */
                                                        4
                                                        5
                                                        var me = {
                                                        6
                                                                name: "James",
                                                        7
                                                                age: 23
                                                        8
                                                            },
                                                        9
                                                            prop;
                                                        10
                                                        11
                                                        for (prop in me) {
                                                        12
                                                            doSomething(prop);
                                                        13
                                                        }
                                                        14
                                                        JSLint found 1 errorVersion 2015-09-23
                                                        Line 10:Unexpected 'for'.

                                                        Why do I get this error?

                                                        This error is raised to highlight bad practice and code that may not work as you expect it to. Your code may run without error, depending on whether @@ -18,7 +19,7 @@

                                                        Why do I get this error?

                                                        whether they belong to the object itself or an object in its prototype chain. Consider the following example, in which we add a completely useless random method to Object.prototype:

                                                        -
                                                        5
                                                         
                                                        1
                                                        Object.prototype.random = function () {
                                                        2
                                                            "use strict";
                                                        3
                                                            return Math.random();
                                                        4
                                                        };
                                                        5
                                                        JSLint found no errorsVersion 2014-02-06
                                                        +
                                                        5
                                                         
                                                        1
                                                        Object.prototype.random = function () {
                                                        2
                                                            "use strict";
                                                        3
                                                            return Math.random();
                                                        4
                                                        };
                                                        5
                                                        JSLint found no errorsVersion 2015-09-23

                                                        After the above snippet has executed, all objects in our script will have access to that random method (via their prototype chain, all the way down to Object.prototype). Since we have not defined our method as non-enumerable @@ -43,10 +44,12 @@

                                                        Why do I get this error?

                                                        In our example, since the random method would be accessible (via inheritance) to the me object, but isn't an "own property" of it, we would need to use the hasOwnProperty method to ensure we don't mistakenly handle it:

                                                        -
                                                        16
                                                         
                                                        1
                                                        /*jshint forin: true */
                                                        2
                                                        /*eslint guard-for-in: 1 */
                                                        3
                                                        /*global doSomething */
                                                        4
                                                        5
                                                        var me = {
                                                        6
                                                                name: "James",
                                                        7
                                                                age: 23
                                                        8
                                                            },
                                                        9
                                                            prop;
                                                        10
                                                        11
                                                        for (prop in me) {
                                                        12
                                                            if (me.hasOwnProperty(prop)) {
                                                        13
                                                                doSomething(prop);
                                                        14
                                                            }
                                                        15
                                                        }
                                                        16
                                                        JSLint found no errorsVersion 2014-02-06
                                                        +
                                                        16
                                                         
                                                        1
                                                        /*jshint forin: true */
                                                        2
                                                        /*eslint guard-for-in: 1 */
                                                        3
                                                        /*global doSomething */
                                                        4
                                                        5
                                                        var me = {
                                                        6
                                                                name: "James",
                                                        7
                                                                age: 23
                                                        8
                                                            },
                                                        9
                                                            prop;
                                                        10
                                                        11
                                                        for (prop in me) {
                                                        12
                                                            if (me.hasOwnProperty(prop)) {
                                                        13
                                                                doSomething(prop);
                                                        14
                                                            }
                                                        15
                                                        }
                                                        16
                                                        JSLint found 1 errorVersion 2015-09-23
                                                        Line 10:Unexpected 'for'.

                                                        In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W089. This means you can tell JSHint to not issue this warning with the /*jshint -W089 */ directive.

                                                        In ESLint the rule that generates this warning is named guard-for-in. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                        + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W090.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W090.html index c0ce3f2..b4631c0 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W090.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W090.html @@ -1,4 +1,5 @@ -

                                                        History

                                                        + +

                                                        History

                                                        This warning has existed in three forms across the three main linters. It was introduced in the original version of JSLint and has remained (in a way) in all three tools ever since.

                                                        @@ -19,7 +20,7 @@

                                                        When do I get this error?

                                                        encounters a break or continue statement referencing a label that does not exist. In the following example we try to break out of a for loop to the non-existent example label:

                                                        -
                                                        x
                                                         
                                                        1
                                                        function demo() {
                                                        2
                                                            "use strict";
                                                        3
                                                            var i;
                                                        4
                                                            for (i = 0; i < 10; i += 1) {
                                                        5
                                                                if (i === 5) {
                                                        6
                                                                    break example;
                                                        7
                                                                }
                                                        8
                                                            }
                                                        9
                                                        }
                                                        10
                                                        JSLint found 1 errorVersion 2014-02-06
                                                        Line 6:'example' is not a label.
                                                        +
                                                        x
                                                         
                                                        1
                                                        function demo() {
                                                        2
                                                            "use strict";
                                                        3
                                                            var i;
                                                        4
                                                            for (i = 0; i < 10; i += 1) {
                                                        5
                                                                if (i === 5) {
                                                        6
                                                                    break example;
                                                        7
                                                                }
                                                        8
                                                            }
                                                        9
                                                        }
                                                        10
                                                        JSLint found 2 errorsVersion 2015-09-23
                                                        Line 3:Unexpected 'for'.
                                                        Line 5:'example' is not a label.

                                                        Why do I get this error?

                                                        This error is raised to highlight a fatal JavaScript syntax error. It is not valid to reference an identifier that does not appear in the label set of the @@ -37,13 +38,15 @@

                                                        Why do I get this error?

                                                        therefore there is no label in its label set with the identifier example. When the interpreter reaches the break statement a syntax error will be thrown. This can be avoided by removing the identifier from the break statement:

                                                        -
                                                        10
                                                         
                                                        1
                                                        function demo() {
                                                        2
                                                            "use strict";
                                                        3
                                                            var i;
                                                        4
                                                            for (i = 0; i < 10; i += 1) {
                                                        5
                                                                if (i === 5) {
                                                        6
                                                                    break;
                                                        7
                                                                }
                                                        8
                                                            }
                                                        9
                                                        }
                                                        10
                                                        JSLint found no errorsVersion 2014-02-06
                                                        +
                                                        10
                                                         
                                                        1
                                                        function demo() {
                                                        2
                                                            "use strict";
                                                        3
                                                            var i;
                                                        4
                                                            for (i = 0; i < 10; i += 1) {
                                                        5
                                                                if (i === 5) {
                                                        6
                                                                    break;
                                                        7
                                                                }
                                                        8
                                                            }
                                                        9
                                                        }
                                                        10
                                                        JSLint found 1 errorVersion 2015-09-23
                                                        Line 3:Unexpected 'for'.

                                                        Or alternatively by adding a label with the correct identifer to the label set of the for statement (although since November 2013 this will cause JSLint to raise a different warning, because it is now of the opinion that label statements should not be used at all):

                                                        -
                                                        11
                                                         
                                                        1
                                                        function demo() {
                                                        2
                                                            "use strict";
                                                        3
                                                            var i;
                                                        4
                                                        example:
                                                        5
                                                            for (i = 0; i < 10; i += 1) {
                                                        6
                                                                if (i === 5) {
                                                        7
                                                                    break example;
                                                        8
                                                                }
                                                        9
                                                            }
                                                        10
                                                        }
                                                        11
                                                        JSLint found 1 errorVersion 2014-02-06
                                                        Line 7:Unexpected 'example'.
                                                        +
                                                        11
                                                         
                                                        1
                                                        function demo() {
                                                        2
                                                            "use strict";
                                                        3
                                                            var i;
                                                        4
                                                        example:
                                                        5
                                                            for (i = 0; i < 10; i += 1) {
                                                        6
                                                                if (i === 5) {
                                                        7
                                                                    break example;
                                                        8
                                                                }
                                                        9
                                                            }
                                                        10
                                                        }
                                                        11
                                                        JSLint found 1 errorVersion 2015-09-23
                                                        Line 4:Unexpected 'for'.

                                                        In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W090. This means you can tell JSHint to not issue this warning with the /*jshint -W090 */ directive.

                                                        + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W093.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W093.html index f93865f..2af8e0a 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W093.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W093.html @@ -1,10 +1,11 @@ -

                                                        When do I get this error?

                                                        + +

                                                        When do I get this error?

                                                        The "Did you mean to return a conditional instead of an assignment?" error, and the alternative "Return statement should not contain assignment", is thrown when JSHint or ESLint encounters a return statement containing an assignment expression. In the following example we attempt to assign the result of an operation to result and also return the result of that assignment:

                                                        -
                                                        x
                                                         
                                                        1
                                                        var result;
                                                        2
                                                        function multiply(a, b) {
                                                        3
                                                            "use strict";
                                                        4
                                                            return result = a * b;
                                                        5
                                                        }
                                                        6
                                                        JSHint found 1 errorVersion 2.5.0
                                                        Line 4:Did you mean to return a conditional instead of an assignment?
                                                        +
                                                        x
                                                         
                                                        1
                                                        var result;
                                                        2
                                                        function multiply(a, b) {
                                                        3
                                                            "use strict";
                                                        4
                                                            return result = a * b;
                                                        5
                                                        }
                                                        6
                                                        JSHint found 1 errorVersion 2.9.0
                                                        Line 4:Did you mean to return a conditional instead of an assignment?

                                                        Since May 2013 JSLint has used the more generic "Unexpected assignment expression" warning in the same situation.

                                                        Why do I get this error?

                                                        @@ -16,15 +17,17 @@

                                                        Why do I get this error?

                                                        expression is evaluated and its result is returned from the function we end up with the value we expect. You can resolve this error by splitting the logic out into two distinct steps which makes the code much more readable:

                                                        -
                                                        7
                                                         
                                                        1
                                                        var result;
                                                        2
                                                        function multiply(a, b) {
                                                        3
                                                            "use strict";
                                                        4
                                                            result = a * b;
                                                        5
                                                            return result;
                                                        6
                                                        }
                                                        7
                                                        JSHint found no errorsVersion 2.5.0
                                                        +
                                                        7
                                                         
                                                        1
                                                        var result;
                                                        2
                                                        function multiply(a, b) {
                                                        3
                                                            "use strict";
                                                        4
                                                            result = a * b;
                                                        5
                                                            return result;
                                                        6
                                                        }
                                                        7
                                                        JSHint found no errorsVersion 2.9.0

                                                        If you didn't mean to return the result of an assignment and are receiving this error then the chances are you actually wanted to return a boolean value. This is why JSHint asks if you meant to return a conditional. If that's the case, make sure the expression is conditional by using === instead of =:

                                                        -
                                                        6
                                                         
                                                        1
                                                        var result;
                                                        2
                                                        function multiply(a, b) {
                                                        3
                                                            "use strict";
                                                        4
                                                            return result === a * b;
                                                        5
                                                        }
                                                        6
                                                        JSHint found no errorsVersion 2.5.0
                                                        +
                                                        6
                                                         
                                                        1
                                                        var result;
                                                        2
                                                        function multiply(a, b) {
                                                        3
                                                            "use strict";
                                                        4
                                                            return result === a * b;
                                                        5
                                                        }
                                                        6
                                                        JSHint found no errorsVersion 2.9.0

                                                        In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W093. This means you can tell JSHint to not issue this warning with the /*jshint -W093 */ directive.

                                                        In ESLint the rule that generates this warning is named no-return-assign. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                        + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W097.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W097.html index b45864b..ad7be08 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W097.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W097.html @@ -1,9 +1,10 @@ -

                                                        When do I get this error?

                                                        + +

                                                        When do I get this error?

                                                        The "Use the function form of 'use strict'" error is thrown when JSLint, JSHint or ESLint encounters a strict mode directive in the outermost scope of the code. In the following example we use a strict mode directive in the global scope to ensure the entire program runs in strict mode:

                                                        -
                                                        x
                                                         
                                                        1
                                                        "use strict";
                                                        2
                                                        function example() {
                                                        3
                                                            return true;
                                                        4
                                                        }
                                                        5
                                                        JSLint found 1 errorVersion 2014-02-06
                                                        Line 1:Use the function form of 'use strict'.
                                                        +
                                                        x
                                                         
                                                        1
                                                        "use strict";
                                                        2
                                                        function example() {
                                                        3
                                                            return true;
                                                        4
                                                        }
                                                        5
                                                        JSLint found no errorsVersion 2015-09-23

                                                        Why do I get this error?

                                                        This error is raised to highlight a potentially dangerous piece of code. It's common and good practice to concatenate multiple JavaScript files into one @@ -13,13 +14,13 @@

                                                        Why do I get this error?

                                                        features that are disallowed in strict mode you may run into errors. Consider the following example which shows the previous script concatentated with another that relies upon features that are illegal in strict mode:

                                                        -
                                                        8
                                                         
                                                        1
                                                        "use strict";
                                                        2
                                                        function example() {
                                                        3
                                                            return true;
                                                        4
                                                        }
                                                        5
                                                        function another(a) {
                                                        6
                                                            return 010; // Octal literal, illegal in strict mode
                                                        7
                                                        }
                                                        8
                                                        JSLint found 3 errorsVersion 2014-02-06
                                                        Line 1:Use the function form of 'use strict'.
                                                        Line 6:Unexpected '010'.
                                                        Line 5:Unused 'a'.
                                                        +
                                                        8
                                                         
                                                        1
                                                        "use strict";
                                                        2
                                                        function example() {
                                                        3
                                                            return true;
                                                        4
                                                        }
                                                        5
                                                        function another(a) {
                                                        6
                                                            return 010; // Octal literal, illegal in strict mode
                                                        7
                                                        }
                                                        8
                                                        JSLint found 1 errorVersion 2015-09-23
                                                        Line 5:Unexpected '1' after '0'.

                                                        This example will cause a syntax error since octal literals are not allowed in strict mode. If we want to use strict mode in our script and still be able to concatenate it with others we need to ensure our strict mode directive is not in the global scope. Since JavaScript only has function scope this means we need to place the directive within a function:

                                                        -
                                                        5
                                                         
                                                        1
                                                        function example() {
                                                        2
                                                            "use strict";
                                                        3
                                                            return true;
                                                        4
                                                        }
                                                        5
                                                        JSLint found no errorsVersion 2014-02-06
                                                        +
                                                        5
                                                         
                                                        1
                                                        function example() {
                                                        2
                                                            "use strict";
                                                        3
                                                            return true;
                                                        4
                                                        }
                                                        5
                                                        JSLint found no errorsVersion 2015-09-23

                                                        This has the added benefit of allowing you to control exactly which parts of your own script run in strict mode. However, a common technique is to wrap your entire program in an immediately invoked function expression to constrain it to @@ -30,3 +31,5 @@

                                                        Why do I get this error?

                                                        -W097 */ directive. You can also set the sub option to true.

                                                        In ESLint the rule that generates this warning is named no-global-strict. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                        + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W098.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W098.html index 7abef66..1305d7d 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W098.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W098.html @@ -1,4 +1,5 @@ -

                                                        History

                                                        + +

                                                        History

                                                        This warning has existed in two forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three linters ever since.

                                                        @@ -15,7 +16,7 @@

                                                        When do I get this error?

                                                        binding with an identifier that is not referenced aside from its declaration
                                                        . In JSHint the warning is only raised if the unused option is set to true. In the following example there are various unused identifiers:

                                                        -
                                                        x
                                                         
                                                        1
                                                        /*jshint unused: true */
                                                        2
                                                        function demo(a, b) {
                                                        3
                                                            "use strict";
                                                        4
                                                            var c;
                                                        5
                                                        }
                                                        6
                                                        JSHint found 4 errorsVersion 2.5.0
                                                        Line 2:'demo' is defined but never used.
                                                        Line 4:'c' is defined but never used.
                                                        Line 2:'b' is defined but never used.
                                                        Line 2:'a' is defined but never used.
                                                        +
                                                        x
                                                         
                                                        1
                                                        /*jshint unused: true */
                                                        2
                                                        function demo(a, b) {
                                                        3
                                                            "use strict";
                                                        4
                                                            var c;
                                                        5
                                                        }
                                                        6
                                                        JSHint found 4 errorsVersion 2.9.0
                                                        Line 4:'c' is defined but never used.
                                                        Line 2:'b' is defined but never used.
                                                        Line 2:'a' is defined but never used.
                                                        Line 2:'demo' is defined but never used.

                                                        Why do I get this error?

                                                        This error is raised to highlight a potentially useless code. Your code will run without error if you just ignore this warning, but it could be doing @@ -28,19 +29,19 @@

                                                        Why do I get this error?

                                                        completely. However, sometimes you may declare variables in one file but use them in another. If that's the case and you're using JSHint you can use the exported directive to signify those variables:

                                                        -
                                                        7
                                                         
                                                        1
                                                        /*jshint unused: true */
                                                        2
                                                        /*exported demo */
                                                        3
                                                        function demo(a, b) {
                                                        4
                                                            "use strict";
                                                        5
                                                            var c;
                                                        6
                                                        }
                                                        7
                                                        JSHint found 3 errorsVersion 2.5.0
                                                        Line 5:'c' is defined but never used.
                                                        Line 3:'b' is defined but never used.
                                                        Line 3:'a' is defined but never used.
                                                        +
                                                        7
                                                         
                                                        1
                                                        /*jshint unused: true */
                                                        2
                                                        /*exported demo */
                                                        3
                                                        function demo(a, b) {
                                                        4
                                                            "use strict";
                                                        5
                                                            var c;
                                                        6
                                                        }
                                                        7
                                                        JSHint found 3 errorsVersion 2.9.0
                                                        Line 5:'c' is defined but never used.
                                                        Line 3:'b' is defined but never used.
                                                        Line 3:'a' is defined but never used.

                                                        A note about function arguments

                                                        The behaviour described above is not ideal when it comes to function parameters. It's relatively common to have function arguments that are not referred to within the function but are necessary in the function signature because subsequent arguments are referred to. For example:

                                                        -
                                                        8
                                                         
                                                        1
                                                        /*jshint unused: true, node: true */
                                                        2
                                                        /*jslint node: true */
                                                        3
                                                        var fs = require("fs");
                                                        4
                                                        fs.readdir("dir", function (err, files) {
                                                        5
                                                            "use strict";
                                                        6
                                                            console.log(files); // Ignoring any error in 'err'
                                                        7
                                                        });
                                                        8
                                                        JSLint found 1 errorVersion 2014-02-06
                                                        Line 4:Unused 'err'.
                                                        +
                                                        8
                                                         
                                                        1
                                                        /*jshint unused: true, node: true */
                                                        2
                                                        /*jslint node: true */
                                                        3
                                                        var fs = require("fs");
                                                        4
                                                        fs.readdir("dir", function (err, files) {
                                                        5
                                                            "use strict";
                                                        6
                                                            console.log(files); // Ignoring any error in 'err'
                                                        7
                                                        });
                                                        8
                                                        JSLint found 1 errorVersion 2015-09-23
                                                        Line 3:Unused 'err'.

                                                        In this example we don't care about the err argument so we don't refer to it. JSLint still complains that the variable is unused. JSHint and ESLint are clever enough to know that since files is used there is no need to warn about err but in JSLint you'll have to set the unparam option to true to avoid a warning in this situation:

                                                        -
                                                        8
                                                         
                                                        1
                                                        /*jshint unused: true, node: true */
                                                        2
                                                        /*jslint unparam: true, node: true */
                                                        3
                                                        var fs = require("fs");
                                                        4
                                                        fs.readdir("dir", function (err, files) {
                                                        5
                                                            "use strict";
                                                        6
                                                            console.log(files); // Ignoring any error in 'err'
                                                        7
                                                        });
                                                        8
                                                        JSLint found no errorsVersion 2014-02-06
                                                        +
                                                        8
                                                         
                                                        1
                                                        /*jshint unused: true, node: true */
                                                        2
                                                        /*jslint unparam: true, node: true */
                                                        3
                                                        var fs = require("fs");
                                                        4
                                                        fs.readdir("dir", function (err, files) {
                                                        5
                                                            "use strict";
                                                        6
                                                            console.log(files); // Ignoring any error in 'err'
                                                        7
                                                        });
                                                        8
                                                        JSLint found 2 errorsVersion 2015-09-23
                                                        Line 1:Bad option 'unparam'.
                                                        Line 3:Unused 'err'.

                                                        In JSHint 1.1.0 and above you are able to configure the behaviour around function arguments. The unused option accepts a string rather than a boolean:

                                                          @@ -62,3 +63,5 @@

                                                          A note about function arguments

                                                          -W098 */ directive.

                                                          In ESLint the rule that generates this warning is named no-unused-vars. You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W105.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W105.html index 0d1bab3..aa83f35 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W105.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W105.html @@ -1,11 +1,12 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Unexpected dangling '_' in '{a}'" error is thrown when JSLint, JSHint or ESLint encounters an identifier that begins or ends with the underscore character. JSHint will only raise this warning when the nomen option is set to true. ESLint only raises this warning for variable and function identifiers and not for object property identifiers. In the following example we use several such identifiers:

                                                          -
                                                          x
                                                           
                                                          1
                                                          /*jshint nomen: true */
                                                          2
                                                          var _x = 10,
                                                          3
                                                              y = {
                                                          4
                                                                  z_: 20
                                                          5
                                                              };
                                                          6
                                                          7
                                                          function _test() {
                                                          8
                                                              "use strict";
                                                          9
                                                              return true;
                                                          10
                                                          }
                                                          11
                                                          JSLint found 3 errorsVersion 2014-02-06
                                                          Line 2:Unexpected dangling '_' in '_x'.
                                                          Line 4:Unexpected dangling '_' in 'z_'.
                                                          Line 7:Unexpected dangling '_' in '_test'.
                                                          +
                                                          x
                                                           
                                                          1
                                                          /*jshint nomen: true */
                                                          2
                                                          var _x = 10,
                                                          3
                                                              y = {
                                                          4
                                                                  z_: 20
                                                          5
                                                              };
                                                          6
                                                          7
                                                          function _test() {
                                                          8
                                                              "use strict";
                                                          9
                                                              return true;
                                                          10
                                                          }
                                                          11
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 3:Bad property name 'z_'.

                                                          Why do I get this error?

                                                          This error is raised to highlight a lack of convention. Your code will run without error if you do not change it, but could be confusing to other @@ -16,12 +17,14 @@

                                                          Why do I get this error?

                                                          If you're using JSLint, you can fix the error by setting the nomen (short for nomenclature) option to true. Conversely, if you're using JSHint, you can simply remove the same option:

                                                          -
                                                          11
                                                           
                                                          1
                                                          /*jslint nomen: true */
                                                          2
                                                          var _x = 10,
                                                          3
                                                              y = {
                                                          4
                                                                  z_: 20
                                                          5
                                                              };
                                                          6
                                                          7
                                                          function _test() {
                                                          8
                                                              "use strict";
                                                          9
                                                              return true;
                                                          10
                                                          }
                                                          11
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          11
                                                           
                                                          1
                                                          /*jslint nomen: true */
                                                          2
                                                          var _x = 10,
                                                          3
                                                              y = {
                                                          4
                                                                  z_: 20
                                                          5
                                                              };
                                                          6
                                                          7
                                                          function _test() {
                                                          8
                                                              "use strict";
                                                          9
                                                              return true;
                                                          10
                                                          }
                                                          11
                                                          JSLint found 2 errorsVersion 2015-09-23
                                                          Line 0:Bad option 'nomen'.
                                                          Line 3:Bad property name 'z_'.

                                                          Alternatively, you can simply remove the underscore character from the start or end of your identifiers (note that use of this character elsewhere in identifiers is accepted):

                                                          -
                                                          11
                                                           
                                                          1
                                                          /*jshint nomen: true */
                                                          2
                                                          var x = 10,
                                                          3
                                                              y = {
                                                          4
                                                                  z: 20
                                                          5
                                                              };
                                                          6
                                                          7
                                                          function test_with_underscores() {
                                                          8
                                                              "use strict";
                                                          9
                                                              return true;
                                                          10
                                                          }
                                                          11
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          11
                                                           
                                                          1
                                                          /*jshint nomen: true */
                                                          2
                                                          var x = 10,
                                                          3
                                                              y = {
                                                          4
                                                                  z: 20
                                                          5
                                                              };
                                                          6
                                                          7
                                                          function test_with_underscores() {
                                                          8
                                                              "use strict";
                                                          9
                                                              return true;
                                                          10
                                                          }
                                                          11
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W105. This means you can tell JSHint to not issue this warning with the /*jshint -W105 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W108.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W108.html index a3eca3f..d5b7d6b 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W108.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W108.html @@ -1,11 +1,12 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Strings must use singlequote" and "Strings must use doublequote" errors are thrown when JSHint or ESLint encounters string literal delimited by double quote characters when the quotmark option is set to single or a string literal delimited by single quote characters when the quotmark option is set to double. In the following example we attempt to assign a string literal to the variable x:

                                                          -
                                                          x
                                                           
                                                          1
                                                          /*jshint quotmark: double */
                                                          2
                                                          var x = 'My String';
                                                          3
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 2:Strings must use doublequote.
                                                          +
                                                          x
                                                           
                                                          1
                                                          /*jshint quotmark: double */
                                                          2
                                                          var x = 'My String';
                                                          3
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 2:Strings must use doublequote.

                                                          Why do I get this error?

                                                          This error is raised to highlight a deviation from a specific coding style. Your code will run fine if you do not fix this error, but it demonstrates a lack @@ -23,9 +24,11 @@

                                                          Why do I get this error?

                                                          double or single then it is likely your codebase requires you to conform to a specific style in which one type of quote is preferred. To fix the error, simply use the correct type of quote:

                                                          -
                                                          3
                                                           
                                                          1
                                                          /*jshint quotmark: double */
                                                          2
                                                          var x = "My String";
                                                          3
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          3
                                                           
                                                          1
                                                          /*jshint quotmark: double */
                                                          2
                                                          var x = "My String";
                                                          3
                                                          JSHint found no errorsVersion 2.9.0

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W108 (for double quotes) or W109 (for single quotes). This means you can tell JSHint to not issue this warning with the /*jshint -W108 */ or /*jshint -W109 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W110.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W110.html index 1b4ba8f..6839158 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W110.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W110.html @@ -1,10 +1,11 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Mixed double and single quotes" error is thrown when JSHint encounters string literal delimited by double or single quote characters when a string literal delimited by the other has already been found. It will only raise this warning if the quotmark option is set to true. In the following example we attempt to assign string literals to the variables x and y:

                                                          -
                                                          x
                                                           
                                                          1
                                                          /*jshint quotmark: true */
                                                          2
                                                          var x = "My String",
                                                          3
                                                              y = 'Another string';
                                                          4
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 3:Mixed double and single quotes.
                                                          +
                                                          x
                                                           
                                                          1
                                                          /*jshint quotmark: true */
                                                          2
                                                          var x = "My String",
                                                          3
                                                              y = 'Another string';
                                                          4
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 3:Mixed double and single quotes.

                                                          Why do I get this error?

                                                          This error is raised to highlight a lack of consistency. Your code will run fine if you do not fix this error, but it demonstrates a lack of care. There is @@ -22,8 +23,10 @@

                                                          Why do I get this error?

                                                          exceptions, such as nested quotes). You can easily resolve this issue by sticking to one type, and you should consider setting the quotmark option to either double or single to enforce your preference:

                                                          -
                                                          4
                                                           
                                                          1
                                                          /*jshint quotmark: double */
                                                          2
                                                          var x = "My String",
                                                          3
                                                              y = "Another string";
                                                          4
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          4
                                                           
                                                          1
                                                          /*jshint quotmark: double */
                                                          2
                                                          var x = "My String",
                                                          3
                                                              y = "Another string";
                                                          4
                                                          JSHint found no errorsVersion 2.9.0

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W110. This means you can tell JSHint to not issue this warning with the /*jshint -W110 */ directive. You can also set the quotmark option to false.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W112.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W112.html new file mode 100644 index 0000000..9c3a3ab --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W112.html @@ -0,0 +1,37 @@ + +

                                                          When do I get this error?

                                                          +

                                                          The "Unclosed string" error is thrown when JSLint or JSHint encounters a a +string that is not closed before the next line break or the end of the +program. There are numerous situations that could cause this. In this first +example, we accidentally forget to close our string:

                                                          +
                                                          x
                                                           
                                                          1
                                                          var myString = "my string,
                                                          2
                                                              myNumber = 10;
                                                          3
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Unclosed string.
                                                          +

                                                          In the next example, we want our string to include a backslash character. The +string appears to be closed but actually isn't, due to the backslash character +escaping the closing quote:

                                                          +
                                                          3
                                                           
                                                          1
                                                          var myString = "my string\",
                                                          2
                                                              myNumber = 10;
                                                          3
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Unclosed string.
                                                          +

                                                          And this final example, which makes use of the multiline strings allowed by +ECMAScript 5, features a string that has not closed by the end of the program +(the previous two examples failed at the first line break):

                                                          +
                                                          3
                                                           
                                                          1
                                                          var myString = "my multiline \
                                                          2
                                                                          string
                                                          3
                                                          JSLint found 1 errorVersion 2015-09-23
                                                          Line 0:Unclosed string.
                                                          +

                                                          Why do I get this error?

                                                          +

                                                          This error is raised to highlight a fatal JavaScript syntax error. Your code +will not run unless you fix this issue. The ECMAScript grammar states that any +string literal must be closed by the same character (either " or ') that +opened it (ES5 §7.8.4):

                                                          +
                                                          +

                                                          StringLiteral ::
                                                          +    " DoubleStringCharactersopt "
                                                          +    ' SingleStringCharactersopt '

                                                          +
                                                          +

                                                          To fix the error, simply close any unclosed strings:

                                                          +
                                                          3
                                                           
                                                          1
                                                          var myString = "my string",
                                                          2
                                                              myNumber = 10;
                                                          3
                                                          JSLint found no errorsVersion 2015-09-23
                                                          +

                                                          The second example above failed because the backslash character was escaping the +closing quote, turning it into a literal character rather than a syntactic +structure. To include a backslash in a string, you need to escape the backslash +itself:

                                                          +
                                                          3
                                                           
                                                          1
                                                          var myString = "my string\\",
                                                          2
                                                              myNumber = 10;
                                                          3
                                                          JSLint found no errorsVersion 2015-09-23
                                                          +

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a +special option syntax. Since this message relates to a fatal +syntax error you cannot disable it.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W115.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W115.html index 677e637..8c565a8 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W115.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W115.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in three forms across the three main linters. It was introduced in the original version of JSLint and has remained (in a way) in all three tools ever since.

                                                          @@ -19,7 +20,7 @@

                                                          When do I get this error?

                                                          raise this warning when the relevant code is running in strict mode. In the following example we attempt to assign a string containing an octal escape to a variable x:

                                                          -
                                                          x
                                                           
                                                          1
                                                          function demo() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "Copyright \251";
                                                          4
                                                          }
                                                          5
                                                          JSLint found 1 errorVersion 2014-02-06
                                                          Line 3:Don't use octal: '\2'. Use '\u....' instead.
                                                          +
                                                          x
                                                           
                                                          1
                                                          function demo() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "Copyright \251";
                                                          4
                                                          }
                                                          5
                                                          JSLint found no errorsVersion 2015-09-23

                                                          Why do I get this error?

                                                          This error is raised to highlight the use of a deprecated language feature. As of version 5 of the ECMAScript specification, octal escape sequences are @@ -40,11 +41,13 @@

                                                          Why do I get this error?

                                                          escapes. Note that although they have different names, both hexadecimal and unicode escape sequences use hexadecimal numbers. Here's the above example again, using a unicode escape instead:

                                                          -
                                                          5
                                                           
                                                          1
                                                          function demo() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "Copyright \u00A9";
                                                          4
                                                          }
                                                          5
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          5
                                                           
                                                          1
                                                          function demo() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "Copyright \u00A9";
                                                          4
                                                          }
                                                          5
                                                          JSLint found no errorsVersion 2015-09-23

                                                          However, if you would rather use the hexadecimal escape sequence, none of the three main linters will ask you to do otherwise:

                                                          -
                                                          5
                                                           
                                                          1
                                                          function demo() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "Copyright \xA9";
                                                          4
                                                          }
                                                          5
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          5
                                                           
                                                          1
                                                          function demo() {
                                                          2
                                                              "use strict";
                                                          3
                                                              return "Copyright \xA9";
                                                          4
                                                          }
                                                          5
                                                          JSLint found no errorsVersion 2015-09-23

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W115. This means you can tell JSHint to not issue this warning with the /*jshint -W115 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W117.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W117.html new file mode 100644 index 0000000..01fff7a --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W117.html @@ -0,0 +1,123 @@ + +

                                                          History

                                                          +

                                                          This warning has existed in two forms across the three main linters. It was +introduced in the original version of JSLint and has remained in all three tools +ever since.

                                                          +
                                                            +
                                                          • In JSLint the warning given is "'{a}' was used before it was defined"

                                                            +
                                                          • +
                                                          • In JSHint and ESLint the message has always been "'{a}' is not defined"

                                                            +
                                                          • +
                                                          • In JSHint and ESLint the message "'{a}' was used before it was defined" is +issued under closely related circumstances

                                                            +
                                                          • +
                                                          +

                                                          The situations that produce the warning have not changed despite changes to the +text of the warning itself.

                                                          +

                                                          When do I get this error?

                                                          +

                                                          The "'{a}' was used before it was defined" error (and the alternative "'{a}' is +not defined" error) is thrown when JSLint, JSHint and ESLint encounter an +identifier that has not been previously declared in a var statement or +function declaration. Some very common examples of this error are those that +refer to native environment objects:

                                                          +
                                                            +
                                                          • "'document' was used before it was defined"
                                                          • +
                                                          • "'window' was used before it was defined"
                                                          • +
                                                          • "'alert' was used before it was defined"
                                                          • +
                                                          • "'console' was used before it was defined"
                                                          • +
                                                          • "'require' was used before it was defined"
                                                          • +
                                                          +

                                                          In the following example we attempt to set the value of the undeclared variable +x and then attempt to use some native browser environment objects:

                                                          +
                                                          x
                                                           
                                                          1
                                                          x = 10;
                                                          2
                                                          alert("Errors...");
                                                          3
                                                          console.log("Errors everywhere");
                                                          4
                                                          JSLint found 3 errorsVersion 2015-09-23
                                                          Line 0:Undeclared 'x'.
                                                          Line 1:Undeclared 'alert'.
                                                          Line 2:Undeclared 'console'.
                                                          +

                                                          In JSHint and ESLint the "'{a}' was used before it was defined" error (as +opposed to the "'{a}' is not defined" error) is raised when a reference to an +identifier occurs before the declaration of that identifier. In the following +example we reference the variable a before we declare it:

                                                          +
                                                          8
                                                           
                                                          1
                                                          /*jshint latedef: true */
                                                          2
                                                          function test() {
                                                          3
                                                              "use strict";
                                                          4
                                                              a = 1;
                                                          5
                                                              var a;
                                                          6
                                                              return a;
                                                          7
                                                          }
                                                          8
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 5:'a' was used before it was defined.
                                                          +

                                                          Why do I get this error?

                                                          +

                                                          This error is raised to highlight potentially dangerous code. Your code may +run without error, depending on the identifier in question, but is likely to +cause confusion to other developers and could in some cases cause a fatal error +that will prevent the rest of your script from executing.

                                                          +

                                                          The example above is valid JavaScript when not running in strict mode. It will +create a property of the global object (in the browser, the global object is +window) with the given identifier. If you had accidentally omitted the var +keyword, you could have ended up overwriting a variable declared in a parent +scope, causing unexpected behaviour. If it does run in strict mode, it will +generate a reference error as it's illegal to assign a value to an undefined +variable under such conditions ([ES5 Annex C]es5-c]):

                                                          +
                                                          +

                                                          Assignment to an undeclared identifier or otherwise unresolvable reference +does not create a property in the global object. When a simple assignment +occurs within strict mode code, its LeftHandSide must not evaluate to an +unresolvable Reference. If it does a ReferenceError exception is thrown.

                                                          +
                                                          +

                                                          If you are referring to an identifier that has been declared elsewhere (in +another JavaScript file included in the page for example), you can tell JSLint, +JSHint and ESLint about it by using the global directive:

                                                          +
                                                          3
                                                           
                                                          1
                                                          /*global someFunction */
                                                          2
                                                          var x = someFunction();
                                                          3
                                                          JSLint found no errorsVersion 2015-09-23
                                                          +

                                                          If you have mistakenly omitted a var keyword, you can fix this error by simply +adding it in. If you omitted the keyword on purpose (to allow access to a +variable from other scope for example), declare the variable in the top-most +scope in which it should be available:

                                                          +
                                                          3
                                                           
                                                          1
                                                          /*global someFunction */
                                                          2
                                                          var x = 10;
                                                          3
                                                          JSLint found no errorsVersion 2015-09-23
                                                          +

                                                          If you understand the concept of hoisting and prefer to define functions after +they are used (perhaps at the end of a file) you can tell JSHint to allow that +specific use case by setting the latedef option to nofunc:

                                                          +
                                                          7
                                                           
                                                          1
                                                          /*jshint latedef: nofunc */
                                                          2
                                                          doStuff();
                                                          3
                                                          4
                                                          function doStuff() {
                                                          5
                                                            return 1;
                                                          6
                                                          }
                                                          7
                                                          JSHint found no errorsVersion 2.9.0
                                                          +

                                                          In the case of environment-specific global identifiers (like window or +document in the browser or module in Node.js) there are a few JSLint/JSHint +options that you can set to let the linter know what environment the code is +expected to run in:

                                                          +
                                                            +
                                                          • browser - JSLint, JSHint and ESLint. Defines global variables available in +the browser.

                                                            +
                                                          • +
                                                          • devel - JSLint and JSHint. Defines global variables that are only used in +a development environment (such as alert and console).

                                                            +
                                                          • +
                                                          • node - JSLint, JSHint and ESLint. Defines global variables available in +Node.js.

                                                            +
                                                          • +
                                                          • couch - JSLint and JSHint. Defines global variables available in CouchDB.

                                                            +
                                                          • +
                                                          • rhino - JSLint and JSHint. Defines global variables available in Rhino.

                                                            +
                                                          • +
                                                          • phantom - JSHint only. Defines global variables available in PhantomJS.

                                                            +
                                                          • +
                                                          • shelljs - JSHint only. Defines global variables available in ShellJS

                                                            +
                                                          • +
                                                          • typed - JSHint only. Defines global typed array variables (such as +Int32Array and ArrayBuffer)

                                                            +
                                                          • +
                                                          • wsh - JSHint only. Defines global variables available in Windows Script +Host

                                                            +
                                                          • +
                                                          • mocha - ESLint only. Defines global variables available in the Mocha test +framework

                                                            +
                                                          • +
                                                          +

                                                          JSHint also has a set options that tell it about libraries your script has +access to. They can be set in the same way as the environment options listed +above:

                                                          +
                                                            +
                                                          • dojo - Defines global variables provided by the Dojo Toolkit

                                                            +
                                                          • +
                                                          • jquery - Defines global variables provided by jQuery

                                                            +
                                                          • +
                                                          • mootools - Defines global variables provided by Mootools

                                                            +
                                                          • +
                                                          • prototypejs - Defines global variables provided by PrototypeJS

                                                            +
                                                          • +
                                                          • yui - Defines global variables provided by YUI

                                                            +
                                                          • +
                                                          +

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a +special option syntax. The identifier of this warning is W117. +This means you can tell JSHint to not issue this warning with the /*jshint +-W117 */ directive.

                                                          +

                                                          In ESLint the rule that generates this warning is named no-use-before-define. +You can disable it by setting it to 0, or enable it by setting it to 1.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W120.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W120.html index 66ef0b5..1b8fc84 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W120.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W120.html @@ -1,4 +1,5 @@ -

                                                          History

                                                          + +

                                                          History

                                                          This warning has existed in two forms across the three main linters. It was introduced in the original version of JSLint and has remained in all three tools ever since.

                                                          @@ -20,20 +21,22 @@

                                                          When do I get this error?

                                                          might be leaking a variable ({a}) here" error) is thrown when JSLint and JSHint encounter more than one inline assignment. In this example, we attempt to assign a string literal to the variables x, y and z:

                                                          -
                                                          x
                                                           
                                                          1
                                                          var x = y = z = "example";
                                                          2
                                                          JSLint found 3 errorsVersion 2014-02-06
                                                          Line 1:Variable y was not declared correctly.
                                                          Line 1:Stopping. (50% scanned).
                                                          +
                                                          x
                                                           
                                                          1
                                                          var x = y = z = "example";
                                                          2
                                                          JSLint found 4 errorsVersion 2015-09-23
                                                          Line 0:Undeclared 'y'.
                                                          Line 0:Unexpected statement '=' in expression position.
                                                          Line 0:Undeclared 'z'.
                                                          Line 0:Unexpected '='.

                                                          Why do I get this error?

                                                          This error is raised to highlight a potential misunderstanding of the language. A relatively common beginner mistake is to use the above code in an attempt to declare multiple variables and assign a single value to all of them at the same time. However, the above is actually equivalent to the following:

                                                          -
                                                          3
                                                           
                                                          1
                                                          var x;
                                                          2
                                                          x = y = z = "example";
                                                          3
                                                          JSLint found 2 errorsVersion 2014-02-06
                                                          Line 2:'y' was used before it was defined.
                                                          Line 2:'z' was used before it was defined.
                                                          +
                                                          3
                                                           
                                                          1
                                                          var x;
                                                          2
                                                          x = y = z = "example";
                                                          3
                                                          JSLint found 4 errorsVersion 2015-09-23
                                                          Line 1:Undeclared 'y'.
                                                          Line 1:Unexpected '='.
                                                          Line 1:Undeclared 'z'.
                                                          Line 1:Unexpected '='.

                                                          This makes the problem more obvious. Instead of declaring three variables, we have actually only declared one. y and z will refer to variables with those identifiers in ancestor scopes, or, assuming the code is not running in strict mode, will be created as properties of the global object. If you intended to declare multiple variables, you can use commas to separate them instead:

                                                          -
                                                          3
                                                           
                                                          1
                                                          var x, y, z;
                                                          2
                                                          x = y = z = "example";
                                                          3
                                                          JSLint found no errorsVersion 2014-02-06
                                                          +
                                                          3
                                                           
                                                          1
                                                          var x, y, z;
                                                          2
                                                          x = y = z = "example";
                                                          3
                                                          JSLint found 2 errorsVersion 2015-09-23
                                                          Line 1:Unexpected '='.
                                                          Line 1:Unexpected '='.

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W120. This means you can tell JSHint to not issue this warning with the /*jshint -W120 */ directive.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W121.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W121.html index cdc1252..c72c252 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W121.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W121.html @@ -1,14 +1,15 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Extending prototype of native object: '{a}'" error, and the alternative "{a} prototype is read only, properties should not be added" error, is thrown when JSHint (only versions 2.3.0 and above) or ESLint encounters *a assignment to a property of the prototype of a native object. JSHint will only raise this warning if the freeze option is set to true. The following example defines a reverse method on the native String prototype:

                                                          -
                                                          x
                                                           
                                                          1
                                                          /*jshint freeze: true */
                                                          2
                                                          String.prototype.reverse = function () {
                                                          3
                                                              "use strict";
                                                          4
                                                              return this.split("").reverse().join("");
                                                          5
                                                          };
                                                          6
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 2:Extending prototype of native object: 'String'.
                                                          +
                                                          x
                                                           
                                                          1
                                                          /*jshint freeze: true */
                                                          2
                                                          String.prototype.reverse = function () {
                                                          3
                                                              "use strict";
                                                          4
                                                              return this.split("").reverse().join("");
                                                          5
                                                          };
                                                          6
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 2:Extending prototype of native object: 'String'.

                                                          ESLint will also issue the warning when the Object.defineProperty method is used. JSHint does not warn in this situation:

                                                          -
                                                          8
                                                           
                                                          1
                                                          /*jshint freeze: true */
                                                          2
                                                          Object.defineProperty(String.prototype, "reverse", {
                                                          3
                                                              value: function () {
                                                          4
                                                                  "use strict";
                                                          5
                                                                  return this.split("").reverse().join("");
                                                          6
                                                              }
                                                          7
                                                          });
                                                          8
                                                          ESLint found 1 errorVersion 0.6.2
                                                          Line 2:String prototype is read only, properties should not be added.
                                                          +
                                                          8
                                                           
                                                          1
                                                          /*jshint freeze: true */
                                                          2
                                                          Object.defineProperty(String.prototype, "reverse", {
                                                          3
                                                              value: function () {
                                                          4
                                                                  "use strict";
                                                          5
                                                                  return this.split("").reverse().join("");
                                                          6
                                                              }
                                                          7
                                                          });
                                                          8
                                                          JSLint found no errorsVersion v0.16.1

                                                          Side note: the implementation of string reversal above is naive because it fails to take into account the way characters are encoded internally in JavaScript. See this Stack Overflow answer for a great explanation.

                                                          @@ -32,3 +33,5 @@

                                                          Why do I get this error?

                                                          special option syntax. The identifier of this warning is W121. This means you can tell JSHint to not issue this warning with the /*jshint -W121 */ directive. You can also set the freeze option to false.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/rules/jshint/W122.html b/sonar-web-frontend-js/src/main/resources/rules/jshint/W122.html index d93cb66..868c654 100644 --- a/sonar-web-frontend-js/src/main/resources/rules/jshint/W122.html +++ b/sonar-web-frontend-js/src/main/resources/rules/jshint/W122.html @@ -1,9 +1,10 @@ -

                                                          When do I get this error?

                                                          + +

                                                          When do I get this error?

                                                          The "Invalid typeof value '{a}'" error is thrown when JSHint encounters a comparison with a typeof expression on one side and an invalid string literal on the other. In the following example we have a function that will return true if the argument is of type "bool":

                                                          -
                                                          x
                                                           
                                                          1
                                                          function demo(a) {
                                                          2
                                                              return typeof a === "bool";
                                                          3
                                                          }
                                                          4
                                                          JSHint found 1 errorVersion 2.5.0
                                                          Line 2:Invalid typeof value 'bool'
                                                          +
                                                          x
                                                           
                                                          1
                                                          function demo(a) {
                                                          2
                                                              return typeof a === "bool";
                                                          3
                                                          }
                                                          4
                                                          JSHint found 1 errorVersion 2.9.0
                                                          Line 2:Invalid typeof value 'bool'

                                                          This functionality was introduced in JSHint 2.3.0. Prior versions do not raise any error in this situation. Neither JSLint nor ESLint raises any error in this situation.

                                                          @@ -35,8 +36,10 @@

                                                          Why do I get this error?

                                                          condition will always evaluate to false since it is not possible for the typeof operator to ever return the value you're using. To solve this issue simply use a valid value:

                                                          -
                                                          4
                                                           
                                                          1
                                                          function demo(a) {
                                                          2
                                                              return typeof a === "boolean";
                                                          3
                                                          }
                                                          4
                                                          JSHint found no errorsVersion 2.5.0
                                                          +
                                                          4
                                                           
                                                          1
                                                          function demo(a) {
                                                          2
                                                              return typeof a === "boolean";
                                                          3
                                                          }
                                                          4
                                                          JSHint found no errorsVersion 2.9.0

                                                          In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W122. This means you can tell JSHint to not issue this warning with the /*jshint -W122 */ directive. You can also set the sub option to true.

                                                          + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/static/fonts/glyphicons-halflings-regular.eot b/sonar-web-frontend-js/src/main/resources/static/fonts/glyphicons-halflings-regular.eot new file mode 100755 index 0000000..423bd5d Binary files /dev/null and b/sonar-web-frontend-js/src/main/resources/static/fonts/glyphicons-halflings-regular.eot differ diff --git a/sonar-web-frontend-js/src/main/resources/static/fonts/glyphicons-halflings-regular.svg b/sonar-web-frontend-js/src/main/resources/static/fonts/glyphicons-halflings-regular.svg new file mode 100755 index 0000000..4469488 --- /dev/null +++ b/sonar-web-frontend-js/src/main/resources/static/fonts/glyphicons-halflings-regular.svg @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sonar-web-frontend-js/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf b/sonar-web-frontend-js/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf new file mode 100755 index 0000000..a498ef4 Binary files /dev/null and b/sonar-web-frontend-js/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf differ diff --git a/sonar-web-frontend-js/src/main/resources/static/fonts/glyphicons-halflings-regular.woff b/sonar-web-frontend-js/src/main/resources/static/fonts/glyphicons-halflings-regular.woff new file mode 100755 index 0000000..d83c539 Binary files /dev/null and b/sonar-web-frontend-js/src/main/resources/static/fonts/glyphicons-halflings-regular.woff differ diff --git a/sonar-web-frontend-plugin/pom.xml b/sonar-web-frontend-plugin/pom.xml index cc9ef27..f36b949 100644 --- a/sonar-web-frontend-plugin/pom.xml +++ b/sonar-web-frontend-plugin/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 fr.sii.sonar sonar-sii-plugin-parent - 2.0-SNAPSHOT + 2.0.1-SNAPSHOT sonar-web-frontend-plugin @@ -46,6 +45,11 @@ sonar-web-frontend-angular-eslint ${project.version} + + fr.sii.sonar + sonar-web-frontend-typescript + ${project.version} + diff --git a/sonar-web-frontend-plugin/src/main/java/fr/sii/sonar/web/frontend/WebPlugin.java b/sonar-web-frontend-plugin/src/main/java/fr/sii/sonar/web/frontend/WebPlugin.java index 2bc0e1d..edd0361 100644 --- a/sonar-web-frontend-plugin/src/main/java/fr/sii/sonar/web/frontend/WebPlugin.java +++ b/sonar-web-frontend-plugin/src/main/java/fr/sii/sonar/web/frontend/WebPlugin.java @@ -21,6 +21,8 @@ import fr.sii.sonar.web.frontend.profile.AllJSLintersProfileDefinition; import fr.sii.sonar.web.frontend.scss.ScssLanguageConstants; import fr.sii.sonar.web.frontend.scss.ScssPlugin; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; +import fr.sii.sonar.web.frontend.typescript.TypeScriptPlugin; import fr.sii.sonar.web.frontend.widget.MultiLanguageDuplicationsWidget; import fr.sii.sonar.web.frontend.widget.MultiLanguageIssuesWidget; @@ -33,7 +35,8 @@ public final class WebPlugin extends SonarPlugin { public static final String LANGUAGES = JsLanguageConstants.LANGUAGE_KEY + "," + CssLanguageConstants.LANGUAGE_KEY + "," + HtmlLanguageConstants.LANGUAGE_KEY + "," + - ScssLanguageConstants.LANGUAGE_KEY; + ScssLanguageConstants.LANGUAGE_KEY + "," + + TypeScriptLanguageConstants.LANGUAGE_KEY; @SuppressWarnings({ "rawtypes", "unchecked" }) public List getExtensions() { @@ -44,6 +47,7 @@ public List getExtensions() { extensions.addAll(new ScssPlugin().getExtensions()); extensions.addAll(new AngularHintPlugin().getExtensions()); extensions.addAll(new EslintAngularPlugin().getExtensions()); + extensions.addAll(new TypeScriptPlugin().getExtensions()); // aggregated profile definitions extensions.add(AllJSLintersProfileDefinition.class); diff --git a/sonar-web-frontend-plugin/src/main/resources/profiles/js-all.json b/sonar-web-frontend-plugin/src/main/resources/profiles/js-all.json index bf37f2a..6614acd 100644 --- a/sonar-web-frontend-plugin/src/main/resources/profiles/js-all.json +++ b/sonar-web-frontend-plugin/src/main/resources/profiles/js-all.json @@ -4,6 +4,9 @@ "repositories": [{ "key": "jshint", "rules": "/rules/jshint.json" + }, { + "key": "eslint", + "rules": "/rules/eslint.json" }, { "key": "angular-hint", "rules": "/rules/angular-hint.json" diff --git a/sonar-web-frontend-plugin/src/main/resources/static/js/multiLangDuplications.js b/sonar-web-frontend-plugin/src/main/resources/static/js/multiLangDuplications.js index 40ed83b..80b04e8 100644 --- a/sonar-web-frontend-plugin/src/main/resources/static/js/multiLangDuplications.js +++ b/sonar-web-frontend-plugin/src/main/resources/static/js/multiLangDuplications.js @@ -46,7 +46,7 @@ MultiLanguageDuplications = (function() { } var setTotalCount = function(/*String*/lang, /*Object*/dups) { - var percent = (Math.round(dups["duplicated_lines"]/dups["lines"]*1000)/10)+"%"; + var percent = dups["lines"]>0 ? (Math.round(dups["duplicated_lines"]/dups["lines"]*1000)/10)+"%" : 0; jQuery("a[href='#"+lang+"-duplications'] .total-count").html(percent); jQuery("#"+lang+"-duplications .duplications-percent").html(percent); jQuery("#"+lang+"-duplications .duplications-blocks").html(dups["duplicated_blocks"]); diff --git a/sonar-web-frontend-scss/pom.xml b/sonar-web-frontend-scss/pom.xml index 6aec7ab..a58c179 100644 --- a/sonar-web-frontend-scss/pom.xml +++ b/sonar-web-frontend-scss/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 fr.sii.sonar sonar-sii-plugin-parent - 2.0-SNAPSHOT + 2.0.1-SNAPSHOT sonar-web-frontend-scss diff --git a/sonar-web-frontend-scss/src/main/java/fr/sii/sonar/web/frontend/scss/duplication/ScssDuplicationConstants.java b/sonar-web-frontend-scss/src/main/java/fr/sii/sonar/web/frontend/scss/duplication/ScssDuplicationConstants.java index 2aa4abe..cda94c2 100644 --- a/sonar-web-frontend-scss/src/main/java/fr/sii/sonar/web/frontend/scss/duplication/ScssDuplicationConstants.java +++ b/sonar-web-frontend-scss/src/main/java/fr/sii/sonar/web/frontend/scss/duplication/ScssDuplicationConstants.java @@ -8,7 +8,7 @@ public class ScssDuplicationConstants extends ScssLanguageConstants implements D public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.duplication.scss.file.missing.fail"; public static final String SKIP_DUPLICATION_KEY = "sonar.sii.duplication.scss.skip"; public static final String SKIP_DUPLICATION_DEFVAL = "false"; - public static final String REPORT_PATH_DEFVALUE = "/report/scss-duplication.xml"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/scss-duplication.xml"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String SUB_CATEGORY = "Duplication"; diff --git a/sonar-web-frontend-scss/src/main/java/fr/sii/sonar/web/frontend/scss/quality/ScssLintQualityConstants.java b/sonar-web-frontend-scss/src/main/java/fr/sii/sonar/web/frontend/scss/quality/ScssLintQualityConstants.java index 99fe120..934d528 100644 --- a/sonar-web-frontend-scss/src/main/java/fr/sii/sonar/web/frontend/scss/quality/ScssLintQualityConstants.java +++ b/sonar-web-frontend-scss/src/main/java/fr/sii/sonar/web/frontend/scss/quality/ScssLintQualityConstants.java @@ -10,7 +10,7 @@ public class ScssLintQualityConstants extends ScssLanguageConstants implements Q public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.quality.scss.file.missing.fail"; public static final String SKIP_FILE_METRICS_KEY = "sonar.sii.quality.scss.file.metrics.skip"; public static final String SKIP_FILE_METRICS_DEFVALUE = "false"; - public static final String REPORT_PATH_DEFVALUE = "/report/scsslint.json"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/scsslint.json"; public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; public static final String RULES_PATH = "/rules/scsslint.json"; public static final String REPOSITORY_NAME = "SCSSLint"; diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint.css b/sonar-web-frontend-scss/src/main/resources/rules/scsslint.css index 157c776..73c7fb8 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint.css +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint.css @@ -1,4 +1,7 @@ -.extended-html-description { +.ehd { margin-top: 20px; margin-bottom: 30px; -} \ No newline at end of file +} + +/* Github styles */ +.highlight{margin-bottom:16px}.highlight pre,pre{padding:16px;overflow:auto;font-size:85%;line-height:1.45;background-color:#f7f7f7;border-radius:3px}.highlight pre{margin-bottom:0;word-break:normal}pre{word-wrap:normal}pre code,pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}pre code:before,pre code:after,pre tt:before,pre tt:after{content:normal}kbd{display:inline-block;padding:3px 5px;font-size:11px;line-height:10px;color:#555;vertical-align:middle;background-color:#fcfcfc;border:solid 1px #ccc;border-bottom-color:#bbb;border-radius:3px;box-shadow:inset 0 -1px 0 #bbb}.pl-c{color:#969896}.pl-c1,.pl-s .pl-v{color:#0086b3}.pl-e,.pl-en{color:#795da3}.pl-s .pl-s1,.pl-smi{color:#333}.pl-ent{color:#63a35c}.pl-k{color:#a71d5d}.pl-pds,.pl-s,.pl-s .pl-pse .pl-s1,.pl-sr,.pl-sr .pl-cce,.pl-sr .pl-sra,.pl-sr .pl-sre{color:#183691}.pl-v{color:#ed6a43}.pl-id{color:#b52a1d}.pl-ii{background-color:#b52a1d;color:#f8f8f8}.pl-sr .pl-cce{color:#63a35c;font-weight:bold}.pl-ml{color:#693a17}.pl-mh,.pl-mh .pl-en,.pl-ms{color:#1d3e81;font-weight:bold}.pl-mq{color:#008080}.pl-mi{color:#333;font-style:italic}.pl-mb{color:#333;font-weight:bold}.pl-md{background-color:#ffecec;color:#bd2c00}.pl-mi1{background-color:#eaffea;color:#55a532}.pl-mdr{color:#795da3;font-weight:bold}.pl-mo{color:#1d3e81} diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint.json b/sonar-web-frontend-scss/src/main/resources/rules/scsslint.json index 6b23830..b5ff2c4 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint.json +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint.json @@ -1,226 +1,869 @@ -[{ - "key": "BangFormat", - "name": "Bang format", - "description": "Position of space with !important", - "severity": "INFO" -}, { - "key": "BorderZero", - "name": "border: none vs border: 0", - "description": "When using \"border: none\", the size of the border is still applied. If you want to remove completely the border, use \"border: 0\"", - "severity": "MINOR" -}, { - "key": "ColorKeyword", - "name": "Don't use color keywords", - "description": "Don't use color keywords (white, red, black...).", - "severity": "INFO" -}, { - "key": "Comment", - "name": "Use single line comment instead of multi-line comment", - "description": "Single line comment is removed from generated CSS while multi-line comment is still present in generated CSS", - "severity": "MINOR" -}, { - "key": "DebugStatement", - "name": "Remove @debug statement", - "description": "Remove @debug statement", - "severity": "MAJOR" -}, { - "key": "DeclarationOrder", - "name": "Declaration order of properties, nested rules, @extend, @include, pseudo-elements and chained selectors", - "description": "The properties should be before nested rules. \"@extend\" and \"@include\" should be before any other property. \"@include\" with \"@content\" should be after other properties but before nested rules. Pseudo-element and chained selector should appear after property and before nested rules", - "severity": "MAJOR" -}, { - "key": "DuplicateProperty", - "name": "Remove duplicate properties", - "description": "Remove duplicate properties", - "severity": "CRITICAL" -}, { - "key": "ElsePlacement", - "name": "\"@else\" should be on same line as previous curly brace", - "description": "\"@else\" should be on same line as previous curly brace", - "severity": "MINOR" -}, { - "key": "EmptyLineBetweenBlocks", - "name": "Use empty lines between blocks", - "description": "Use empty lines between blocks", - "severity": "MINOR" -}, { - "key": "EmptyRule", - "name": "Remove empty rules", - "description": "Remove empty rules", - "severity": "CRITICAL" -}, { - "key": "FinalNewline", - "name": "The file should end with a new line", - "description": "The file should end with a new line", - "severity": "INFO" -}, { - "key": "HexLength", - "name": "Use the short version of hexadecimal color", - "description": "Use the short version of hexadecimal color", - "severity": "INFO" -}, { - "key": "HexNotation", - "name": "Use lower case for hexadecimal colors", - "description": "Use lower case for hexadecimal colors", - "severity": "MINOR" -}, { - "key": "HexValidation", - "name": "Invalid hexadecimal color value", - "description": "Invalid hexadecimal color value", - "severity": "MAJOR" -}, { - "key": "IdSelector", - "name": "Avoid use of ID selector", - "description": "Avoid use of ID selector", - "severity": "MAJOR" -}, { - "key": "ImportPath", - "name": "\"@import\" should contain neither leading underscore nor extension", - "description": "\"@import\" should contain neither leading underscore nor extension", - "severity": "MAJOR" -}, { - "key": "Indentation", - "name": "Use correct indentation", - "description": "Use correct indentation", - "severity": "MINOR" -}, { - "key": "LeadingZero", - "name": "Remove unnecessary leading 0", - "description": "Remove unnecessary leading 0", - "severity": "MINOR" -}, { - "key": "MergeableSelector", - "name": "Merge selectors that are identical", - "description": "Merge selectors that are identical", - "severity": "MAJOR" -}, { - "key": "NameFormat", - "name": "Names should use \"-\"", - "description": "Names of variables, functions, mixins should use \"-\" instead of \"_\" or camel case", - "severity": "MAJOR" -}, { - "key": "NestingDepth", - "name": "Avoid too much nesting selectors", - "description": "If there are 5 nesting selectors, this will generate 5 selectors separated by spaces in the generated CSS. This will lead to performance issues", - "severity": "CRITICAL" -}, { - "key": "PlaceholderInExtend", - "name": "Should only extend rules with placeholder", - "description": "Should only extend rules with placeholder", - "severity": "MAJOR" -}, { - "key": "PropertySortOrder", - "name": "Properties declaration order is not conformed with selected profile", - "description": "Properties declaration order is not conformed with selected profile", - "severity": "INFO" -}, { - "key": "PropertySpelling", - "name": "Property is misspelled", - "description": "Property is misspelled", - "severity": "INFO" -}, { - "key": "QualifyingElement", - "name": "Avoid use of element and other selector", - "description": "Avoid use of element and other selector", - "severity": "MINOR" -}, { - "key": "SelectorDepth", - "name": "Avoid too much depth for selectors", - "description": "Avoid too much depth for selectors", - "severity": "CRITICAL" -}, { - "key": "SelectorFormat", - "name": "Selector name convention is not conform with selected profile", - "description": "Selector name convention is not conform with selected profile (hyphenated_lowercase, BEM, snake_case, camel_case, regex pattern)", - "severity": "MAJOR" -}, { - "key": "Shorthand", - "name": "Use shorthand value when possible", - "description": "Use shorthand value when possible", - "severity": "MAJOR" -}, { - "key": "SingleLinePerProperty", - "name": "Use one line per property", - "description": "Use one line per property", - "severity": "MAJOR" -}, { - "key": "SingleLinePerSelector", - "name": "Use one line per selector", - "description": "Use one line per selector", - "severity": "MAJOR" -}, { - "key": "SpaceAfterComma", - "name": "Use a space after comma", - "description": "Use a space after comma", - "severity": "MINOR" -}, { - "key": "SpaceAfterPropertyColon", - "name": "Use a space after property colon \":\"", - "description": "Use a space after property colon \":\"", - "severity": "MINOR" -}, { - "key": "SpaceAfterPropertyName", - "name": "Do not use space before property colon \":\"", - "description": "Do not use space before property colon \":\"", - "severity": "MINOR" -}, { - "key": "SpaceBeforeBrace", - "name": "Use one space before curly braces", - "description": "Use one space before curly braces", - "severity": "MINOR" -}, { - "key": "SpaceBetweenParens", - "name": "Do not use spaces between parenthesis", - "description": "Do not use spaces between parenthesis", - "severity": "MINOR" -}, { - "key": "StringQuotes", - "name": "Use the right quotes", - "description": "Use the right quotes", - "severity": "MINOR" -}, { - "key": "TrailingSemicolon", - "name": "Statement should end with one \";\"", - "description": "Property value, @import, @extend, @include statements should end with one semicolon", - "severity": "MAJOR" -}, { - "key": "TrailingZero", - "name": "Remove unnecessary trailing 0", - "description": "Remove unnecessary trailing 0", - "severity": "MAJOR" -}, { - "key": "UnnecessaryMantissa", - "name": "Remove unnecessary fraction", - "description": "Remove unnecessary fraction. For example \"top: 1.0em;\" should be \"top: 1em;\"", - "severity": "MINOR" -}, { - "key": "UnnecessaryParentReference", - "name": "Remove unnecessary parent reference", - "description": "Remove unnecessary parent reference (&)", - "severity": "MAJOR" -}, { - "key": "UrlFormat", - "name": "Wrong URL format", - "description": "An URL should be relative (not absolute and without protocol)", - "severity": "MAJOR" -}, { - "key": "UrlQuotes", - "name": "Use either single quotes or double quotes for URL", - "description": "Use either single quotes or double quotes for URL", - "severity": "MAJOR" -}, { - "key": "VendorPrefixes", - "name": "Vendor specific prefixes", - "description": "Don't use vendor specific when it is not needed on properties, property values, selectors or directives", - "severity": "MAJOR" -}, { - "key": "ZeroUnit", - "name": "Zero value should not have unit", - "description": "Zero value should not have unit", - "severity": "MAJOR" -}, { - "key": "Compass::PropertyWithMixin", - "name": "Use predefined mixins instead of properties when using Compass", - "description": "Use predefined mixins instead of properties when using Compass (\"@include inline-block\" instead of \"display: inline-block\", \"@include border-radius(5px)\" instead of \"border-radius: 5px\", ...)", - "severity": "MAJOR" -}] \ No newline at end of file +[ { + "key" : "BangFormat", + "name" : "Bang format", + "description" : "Position of space with !important", + "severity" : "INFO", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "BorderZero", + "name" : "border: none vs border: 0", + "description" : "When using \"border: none\", the size of the border is still applied. If you want to remove completely the border, use \"border: 0\"", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "ColorKeyword", + "name" : "Don't use color keywords", + "description" : "Don't use color keywords (white, red, black...).", + "severity" : "INFO", + "status" : null, + "tags" : [ "scsslint", "convention", "cross-browser" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "Comment", + "name" : "Use single line comment instead of multi-line comment", + "description" : "Single line comment is removed from generated CSS while multi-line comment is still present in generated CSS", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "NETWORK_USE" + } +}, { + "key" : "DebugStatement", + "name" : "Remove @debug statement", + "description" : "Remove @debug statement", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "DeclarationOrder", + "name" : "Declaration order of properties, nested rules, @extend, @include, pseudo-elements and chained selectors", + "description" : "The properties should be before nested rules. \"@extend\" and \"@include\" should be before any other property. \"@include\" with \"@content\" should be after other properties but before nested rules. Pseudo-element and chained selector should appear after property and before nested rules", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention", "pitfall", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "DuplicateProperty", + "name" : "Remove duplicate properties", + "description" : "Remove duplicate properties", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "scsslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ElsePlacement", + "name" : "\"@else\" should be on same line as previous curly brace", + "description" : "\"@else\" should be on same line as previous curly brace", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "EmptyLineBetweenBlocks", + "name" : "Use empty lines between blocks", + "description" : "Use empty lines between blocks", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "EmptyRule", + "name" : "Remove empty rules", + "description" : "Remove empty rules", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "scsslint", "convention", "dead-code" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "FinalNewline", + "name" : "The file should end with a new line", + "description" : "The file should end with a new line", + "severity" : "INFO", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "HexLength", + "name" : "Use the short version of hexadecimal color", + "description" : "Use the short version of hexadecimal color", + "severity" : "INFO", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "HexNotation", + "name" : "Use lower case for hexadecimal colors", + "description" : "Use lower case for hexadecimal colors", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "HexValidation", + "name" : "Invalid hexadecimal color value", + "description" : "Invalid hexadecimal color value", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "IdSelector", + "name" : "Avoid use of ID selector", + "description" : "Avoid use of ID selector", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_CHANGEABILITY" + } +}, { + "key" : "ImportPath", + "name" : "\"@import\" should contain neither leading underscore nor extension", + "description" : "\"@import\" should contain neither leading underscore nor extension", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "Indentation", + "name" : "Use correct indentation", + "description" : "Use correct indentation", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "LeadingZero", + "name" : "Remove unnecessary leading 0", + "description" : "Remove unnecessary leading 0", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "MergeableSelector", + "name" : "Merge selectors that are identical", + "description" : "Merge selectors that are identical", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "NameFormat", + "name" : "Names should use \"-\"", + "description" : "Names of variables, functions, mixins should use \"-\" instead of \"_\" or camel case", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "NestingDepth", + "name" : "Avoid too much nesting selectors", + "description" : "If there are 5 nesting selectors, this will generate 5 selectors separated by spaces in the generated CSS. This will lead to performance issues", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "scsslint", "bad-practice", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "CPU_EFFICIENCY" + } +}, { + "key" : "PlaceholderInExtend", + "name" : "Should only extend rules with placeholder", + "description" : "Should only extend rules with placeholder", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "PropertySortOrder", + "name" : "Properties declaration order is not conformed with selected profile", + "description" : "Properties declaration order is not conformed with selected profile", + "severity" : "INFO", + "status" : null, + "tags" : [ "scsslint", "convention", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "PropertySpelling", + "name" : "Property is misspelled", + "description" : "Property is misspelled", + "severity" : "INFO", + "status" : null, + "tags" : [ "scsslint", "pitfall", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "QualifyingElement", + "name" : "Avoid use of element and other selector", + "description" : "Avoid use of element and other selector", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_CHANGEABILITY" + } +}, { + "key" : "SelectorDepth", + "name" : "Avoid too much depth for selectors", + "description" : "Avoid too much depth for selectors", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "scsslint", "convention", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "CPU_EFFICIENCY" + } +}, { + "key" : "SelectorFormat", + "name" : "Selector name convention is not conform with selected profile", + "description" : "Selector name convention is not conform with selected profile (hyphenated_lowercase, BEM, snake_case, camel_case, regex pattern)", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention", "bem" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "Shorthand", + "name" : "Use shorthand value when possible", + "description" : "Use shorthand value when possible", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "SingleLinePerProperty", + "name" : "Use one line per property", + "description" : "Use one line per property", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "SingleLinePerSelector", + "name" : "Use one line per selector", + "description" : "Use one line per selector", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "SpaceAfterComma", + "name" : "Use a space after comma", + "description" : "Use a space after comma", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "SpaceAfterPropertyColon", + "name" : "Use a space after property colon \":\"", + "description" : "Use a space after property colon \":\"", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "SpaceAfterPropertyName", + "name" : "Do not use space before property colon \":\"", + "description" : "Do not use space before property colon \":\"", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "SpaceBeforeBrace", + "name" : "Use one space before curly braces", + "description" : "Use one space before curly braces", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "SpaceBetweenParens", + "name" : "Do not use spaces between parenthesis", + "description" : "Do not use spaces between parenthesis", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "StringQuotes", + "name" : "Use the right quotes", + "description" : "Use the right quotes", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "TrailingSemicolon", + "name" : "Statement should end with one \";\"", + "description" : "Property value, @import, @extend, @include statements should end with one semicolon", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "TrailingZero", + "name" : "Remove unnecessary trailing 0", + "description" : "Remove unnecessary trailing 0", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention", "useless" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "UnnecessaryMantissa", + "name" : "Remove unnecessary fraction", + "description" : "Remove unnecessary fraction. For example \"top: 1.0em;\" should be \"top: 1em;\"", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention", "useless" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "UnnecessaryParentReference", + "name" : "Remove unnecessary parent reference", + "description" : "Remove unnecessary parent reference (&)", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention", "useless" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "UrlFormat", + "name" : "Wrong URL format", + "description" : "An URL should be relative (not absolute and without protocol)", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "CHANGEABILITY_COMPLIANCE" + } +}, { + "key" : "UrlQuotes", + "name" : "Use either single quotes or double quotes for URL", + "description" : "Use either single quotes or double quotes for URL", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "VendorPrefixes", + "name" : "Vendor specific prefixes", + "description" : "Don't use vendor specific when it is not needed on properties, property values, selectors or directives", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ZeroUnit", + "name" : "Zero value should not have unit", + "description" : "Zero value should not have unit", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "PropertyWithMixin", + "name" : "Use predefined mixins instead of properties when using Compass", + "description" : "Use predefined mixins instead of properties when using Compass (\"@include inline-block\" instead of \"display: inline-block\", \"@include border-radius(5px)\" instead of \"border-radius: 5px\", ...)", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "convention", "compass", "cross-browser" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "BemDepth", + "name" : "Maximum number of elements allowed in a BEAM selector", + "description" : "Reports when a BEM selector contains more elements than a configurable maximum number", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "bem", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "LOGIC_CHANGEABILITY" + } +}, { + "key" : "ChainedClasses", + "name" : "Chained classes (adjoining classes)", + "description" : "Reports when you define a rule set using a selector with chained classes (a.k.a. adjoining classes)", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "bad-practice", "cross-browser", "ie6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "ColorVariable", + "name" : "Use variables for colors instead of color literals", + "description" : "Prefer color literals (keywords or hexadecimal codes) to be used only in variable declarations. They should be referred to via variables everywhere else.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "DATA_CHANGEABILITY" + } +}, { + "key" : "DisableLinterReason", + "name" : "Comment to explain why linter is disabled", + "description" : "scss-lint:disable control comments should be preceded by a comment explaining why these linters are being disabled for this file", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint-options" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "ExtendDirective", + "name" : "Reports when you have an @extend directive", + "description" : "Reports when you have an @extend directive", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "ImportantRule", + "name" : "Avoid using !important in properties", + "description" : "Avoid using !important in properties. It is usually indicative of a misunderstanding of CSS specificity and can lead to brittle code", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "LOGIC_CHANGEABILITY" + } +}, { + "key" : "PrivateNamingConvention", + "name" : "Prefix private functions, mixins and variables", + "description" : "Enforces that functions, mixins, and variables that follow the private naming convention (default to underscore-prefixed, e.g. $_foo) are defined and used within the same file", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "PropertyCount", + "name" : "Limit the number of properties in a rule set", + "description" : "Limit the number of properties in a rule set", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "scsslint", "bad-practice", "brain-overload" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "PropertyUnits", + "name" : "Configure which units are allowed for property values", + "description" : "By default a value may have any kind of unit. You can adjust which units are allowed globally by setting the global option", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint-options", "configuration" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "PseudoElement", + "name" : "Use :: for pseudo elements", + "description" : "Pseudo-elements, like ::before, and ::first-letter, should be declared with two colons", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "SpaceAfterVariableColon", + "name" : "Variables should be formatted with a single space separating the colon from the variable's value", + "description" : "Variables should be formatted with a single space separating the colon from the variable's value", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "SpaceAfterVariableName", + "name" : "Variables should be formatted with no space between the name and the colon", + "description" : "Variables should be formatted with no space between the name and the colon", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "SpaceAroundOperator", + "name" : "Operators should be formatted with a single space on both sides of an infix operator", + "description" : "Operators should be formatted with a single space on both sides of an infix operator", + "severity" : "MINOR", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "TrailingWhitespace", + "name" : "Reports lines containing trailing whitespace.", + "description" : "Reports lines containing trailing whitespace.", + "severity" : "INFO", + "status" : null, + "tags" : [ "scsslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "TransitionAll", + "name" : "Don't use the all keyword to specify transition properties", + "description" : "Don't use the all keyword to specify transition properties", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "scsslint", "bad-practice", "performance", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "CPU_EFFICIENCY" + } +}, { + "key" : "VariableForProperty", + "name" : "Properties, like color and font, are easier to read and maintain when defined using variables rather than literals", + "description" : "Properties, like color and font, are easier to read and maintain when defined using variables rather than literals", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "DATA_CHANGEABILITY" + } +}, { + "key" : "VendorPrefix", + "name" : "Vendor specific prefixes", + "description" : "Don't use vendor specific when it is not needed on properties, property values, selectors or directives", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "scsslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +} ] \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/BangFormat.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/BangFormat.html index e104842..fd82e5b 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/BangFormat.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/BangFormat.html @@ -1,12 +1,10 @@ -

                                                          Details

                                                          -

                                                          Reports when you use improper spacing around ! (the "bang") in !important and !default declarations.

                                                          You can prefer a single space or no space both before and after the !.

                                                          Bad

                                                          color: #000!important;

                                                          Good

                                                          color: #000 !important;
                                                          - +

                                                          Details

                                                          +

                                                          Reports when you use improper spacing around ! (the "bang") in !default, !global, !important, and !optional flags.

                                                          You can prefer a single space or no space both before and after the !.

                                                          Bad

                                                          color: #000!important;

                                                          Good

                                                          color: #000 !important;
                                                          - - + @@ -15,5 +13,4 @@

                                                          Details

                                                          - -
                                                          Configuration Option Description
                                                          space_before_bang Whether a space should be present before the !, as in color: #000 !important; (default true) space_after_bang Whether a space should be present after the !, as in color: #000 ! important; (default false)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/BemDepth.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/BemDepth.html new file mode 100644 index 0000000..e64f9a3 --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/BemDepth.html @@ -0,0 +1,13 @@ +

                                                          Details

                                                          +

                                                          Disabled by default

                                                          Reports when a BEM selector contains more elements than a configurable +maximum number.

                                                          Bad

                                                          .block__element__subelement  {
                                                          ...
                                                          }

                                                          Good

                                                          .block__element {
                                                          ...
                                                          }
                                                          + + + + + + + + + +
                                                          Configuration OptionDescription
                                                          max_elementsMaximum number of elements allowed in a BEM selector (default 1)
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/BorderZero.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/BorderZero.html index d0cf813..0c8696d 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/BorderZero.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/BorderZero.html @@ -1,2 +1,13 @@ -

                                                          Details

                                                          -

                                                          Prefer border: 0 over border: none.

                                                          \ No newline at end of file +

                                                          Details

                                                          +

                                                          Prefer the terser border: 0 over border: none.

                                                          You can specify preferring border: none over border: 0 by setting the +convention option.

                                                          + + + + + + + + + +
                                                          Configuration OptionDescription
                                                          conventionWhether to prefer 0 (zero) or none (none) (default zero)
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ChainedClasses.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ChainedClasses.html new file mode 100644 index 0000000..0d37192 --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ChainedClasses.html @@ -0,0 +1,3 @@ +

                                                          Details

                                                          +

                                                          Disabled by default

                                                          Reports when you define a rule set using a selector with chained classes +(a.k.a. adjoining classes).

                                                          Bad

                                                          .foo {
                                                          padding: 5px;
                                                          }

                                                          .bar {
                                                          margin: 5px;
                                                          }

                                                          .foo.bar {
                                                          display: block;
                                                          }

                                                          Good: write chained classes as new class

                                                          .foo {
                                                          padding: 5px;
                                                          }

                                                          .bar {
                                                          margin: 5px;
                                                          }

                                                          .new-class {
                                                          display: block;
                                                          }
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ColorKeyword.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ColorKeyword.html index 7687758..b3c4e0a 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ColorKeyword.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ColorKeyword.html @@ -1,11 +1,4 @@ -

                                                          Details

                                                          -

                                                          Prefer hexadecimal color codes over color keywords.

                                                          Bad: color keyword

                                                          color: green;

                                                          Good: hexadecimal color

                                                          color: #0f0;

                                                          Defining colors directly in properties is usually a smell. When you color your -body text in a number of places, if you ever want to change the color of the -text you'll have to update the explicitly defined color in a number of places, -and finding all those places can be difficult if you use the same color for -other elements (i.e. a simple find/replace may not always work).

                                                          A better approach is to use global variables like $color-text-body and refer -to this variable everywhere you want to use it. This makes it easy to update -the color, as you only need change it in one place. It is also more -intention-revealing, as seeing the name $color-text-body is more descriptive -than #333 or black. Using color keywords can obfuscate this, as they look -like variables.

                                                          \ No newline at end of file +

                                                          Details

                                                          +

                                                          Prefer hexadecimal color codes over color keywords.

                                                          Bad: color keyword

                                                          color: green;

                                                          Good: hexadecimal color

                                                          color: #0f0;

                                                          Color keywords look like variables but are not variables. See the +ColorVariable linter for more justification on why you should +always refer to colors via variables.

                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ColorVariable.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ColorVariable.html new file mode 100644 index 0000000..89156b8 --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ColorVariable.html @@ -0,0 +1,12 @@ +

                                                          Details

                                                          +

                                                          Prefer color literals (keywords or hexadecimal codes) to be used only in +variable declarations. They should be referred to via variables everywhere else.

                                                          Bad: literal color

                                                          p {
                                                          color: green;
                                                          }

                                                          Good: refer to color by variable name

                                                          $body-color: #0f0;

                                                          ...

                                                          p {
                                                          color: $body-color;
                                                          }

                                                          Defining colors directly in properties is usually a smell. When you color your +body text in a number of places, if you ever want to change the color of the +text you'll have to update the explicitly defined color in a number of places, +and finding all those places can be difficult if you use the same color for +other elements (i.e. a simple find/replace may not always work).

                                                          A better approach is to use global variables like $color-text-body and refer +to this variable everywhere you want to use it. This makes it easy to update +the color, as you only need change it in one place. It is also more +intention-revealing, as seeing the name $color-text-body is more descriptive +than #333 or black. Using color keywords can obfuscate this, as they look +like variables.

                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Comment.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Comment.html index ffe5e9d..b75b286 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Comment.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Comment.html @@ -1,4 +1,20 @@ -

                                                          Details

                                                          -

                                                          Prefer // comments over /* ... */.

                                                          Bad

                                                          /* This is a comment that gets rendered */

                                                          Good

                                                          // This comment never gets rendered

                                                          // comments should be preferred as they don't get rendered in the final +

                                                          Details

                                                          +

                                                          Prefer // comments over /* ... */.

                                                          Bad

                                                          /* This is a comment that gets rendered */

                                                          Good

                                                          // This comment never gets rendered

                                                          // comments should be preferred as they don't get rendered in the final generated CSS, whereas /* ... */ comments do.

                                                          Furthermore, comments should be concise, and using /* ... */ -encourages multi-line comments which tend to not be concise.

                                                          \ No newline at end of file +encourages multi-line comments which tend to not be concise.

                                                          If you want to allow multi-line comments containing certain text, such as +copyright notices, set the allowed option to a regular expression. This will +allow multi-line comments that match the regular expression.

                                                          + + + + + + + + + + + + + +
                                                          Configuration OptionDescription
                                                          allowedRegular expression for matching allowed comments, such as '^[/* ] Copyright'
                                                          styleStyle of comment to enforce (silent or loud) (default silent)
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Compass Linters.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Compass Linters.html index 198bb48..93fb276 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Compass Linters.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Compass Linters.html @@ -1,5 +1,3 @@ -

                                                          Details

                                                          +

                                                          Details

                                                          scss-lint includes a set of linters for codebases which use the -Compass framework.

                                                          -» Compass Linters Documentation -

                                                          \ No newline at end of file +Compass framework.

                                                          » Compass Linters Documentation

                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DebugStatement.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DebugStatement.html index 1c5aee1..ecbd18c 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DebugStatement.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DebugStatement.html @@ -1,2 +1,2 @@ -

                                                          Details

                                                          +

                                                          Details

                                                          Reports @debug statements (which you probably left behind accidentally).

                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DeclarationOrder.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DeclarationOrder.html index a74ff37..ea50c23 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DeclarationOrder.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DeclarationOrder.html @@ -1,23 +1,7 @@ -

                                                          Details

                                                          +

                                                          Details

                                                          Rule sets should be ordered as follows: @extend declarations, @include declarations without inner @content, properties, @include declarations -with inner @content, then nested rule sets.

                                                          Bad

                                                          .fatal-error {
                                                          -  p {
                                                          -    ...
                                                          -  }
                                                          -
                                                          -  color: #f00;
                                                          -  @extend %error;
                                                          -  @include message-box();
                                                          -}

                                                          Good

                                                          .fatal-error {
                                                          -  @extend %error;
                                                          -  @include message-box();
                                                          -  color: #f00;
                                                          -
                                                          -  p {
                                                          -    ...
                                                          -  }
                                                          -}

                                                          The @extend statement functionally acts like an inheritance mechanism, +with inner @content, then nested rule sets.

                                                          Bad

                                                          .fatal-error {
                                                          p {
                                                          ...
                                                          }

                                                          color: #f00;
                                                          @extend %error;
                                                          @include message-box();
                                                          }

                                                          Good

                                                          .fatal-error {
                                                          @extend %error;
                                                          @include message-box();
                                                          color: #f00;

                                                          p {
                                                          ...
                                                          }
                                                          }

                                                          The @extend statement functionally acts like an inheritance mechanism, which means the properties defined by the placeholder being extended are rendered before the rest of the properties in the rule set.

                                                          Thus, declaring the @extend at the top of the rule set reminds the developer of this behavior.

                                                          Placing @include declarations without inner @content before properties diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DisableLinterReason.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DisableLinterReason.html new file mode 100644 index 0000000..99ea717 --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DisableLinterReason.html @@ -0,0 +1,3 @@ +

                                                          Details

                                                          +

                                                          Disabled by default

                                                          scss-lint:disable control comments should be preceded by a comment explaining +why these linters are being disabled for this file.

                                                          Bad

                                                          // scss-lint:disable BorderZero
                                                          p {
                                                          border: none;
                                                          }

                                                          Good

                                                          // We really prefer `border: none` in this file, for reasons.
                                                          // scss-lint:disable BorderZero
                                                          p {
                                                          border: none;
                                                          }
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DuplicateProperty.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DuplicateProperty.html index f7e6e3f..9c4728e 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DuplicateProperty.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/DuplicateProperty.html @@ -1,16 +1,20 @@ -

                                                          Details

                                                          -

                                                          Reports when you define the same property twice in a single rule set.

                                                          Bad

                                                          h1 {
                                                          -  margin: 10px;
                                                          -  text-transform: uppercase;
                                                          -  margin: 0; // Second declaration
                                                          -}

                                                          Having duplicate properties is usually just an error. However, they can be used +

                                                          Details

                                                          +

                                                          Reports when you define the same property twice in a single rule set.

                                                          Bad

                                                          h1 {
                                                          margin: 10px;
                                                          text-transform: uppercase;
                                                          margin: 0; // Second declaration
                                                          }

                                                          Having duplicate properties is usually just an error. However, they can be used as a technique for dealing with varying levels of browser support for CSS properties. In the example below, some browsers might not support the rgba -function, so the intention is to fall back to the color #fff.

                                                          .box {
                                                          -  background: #fff;
                                                          -  background: rgba(255, 255, 255, .5);
                                                          -}

                                                          In this situation, using duplicate properties is acceptable, but the linter -won't be able to deduce your intention, and will still report an error.

                                                          If you've made the decision to not support older browsers, then this lint is -more helpful since you don't want to clutter your CSS with fallbacks. -Otherwise, you may want to consider disabling this check in your -.scss-lint.yml configuration.

                                                          \ No newline at end of file +function, so the intention is to fall back to the color #fff.

                                                          .box {
                                                          background: #fff;
                                                          background: rgba(255, 255, 255, .5);
                                                          }

                                                          In this situation, using duplicate properties is acceptable, but you will have +to configure DuplicateProperty with the ignore_consecutive option, so that it +won't consider such cases to be lint. ignore_consecutive can be set to true, +false (default), or a list of property names to be allowed. For example, to +ignore consecutive background and transition properties, as above, you can +configure DuplicateProperty with:

                                                          DuplicateProperty:
                                                          ignore_consecutive:
                                                          - background
                                                          - transition
                                                          + + + + + + + + + +
                                                          Configuration OptionDescription
                                                          ignore_consecutiveWhether to ignore consecutive duplicate properties (default false), or a whitelist.
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ElsePlacement.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ElsePlacement.html index 55ae56d..8852a3d 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ElsePlacement.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ElsePlacement.html @@ -1,26 +1,13 @@ -

                                                          Details

                                                          -

                                                          Place @else statements on the same line as the preceding curly brace.

                                                          Bad

                                                          @if {
                                                          -  ...
                                                          -}
                                                          -@else {
                                                          -  ...
                                                          -}

                                                          Good

                                                          @if {
                                                          -  ...
                                                          -} @else {
                                                          -  ...
                                                          -}

                                                          This will ignore single line @if/@else blocks, so you can write:

                                                          @if { ... } @else { ... }

                                                          You can prefer to enforce having @else on its own line by setting the style -configuration option to new_line.

                                                          - +

                                                          Details

                                                          +

                                                          Place @else statements on the same line as the preceding curly brace.

                                                          Bad

                                                          @if {
                                                          ...
                                                          }
                                                          @else {
                                                          ...
                                                          }

                                                          Good

                                                          @if {
                                                          ...
                                                          } @else {
                                                          ...
                                                          }

                                                          This will ignore single line @if/@else blocks, so you can write:

                                                          @if { ... } @else { ... }

                                                          You can prefer to enforce having @else on its own line by setting the style +configuration option to new_line.

                                                          - - + - + - -
                                                          Configuration Option Description
                                                          style -same_line or new_line (default same_line)same_line or new_line (default same_line)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/EmptyLineBetweenBlocks.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/EmptyLineBetweenBlocks.html index ae73a41..1933220 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/EmptyLineBetweenBlocks.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/EmptyLineBetweenBlocks.html @@ -1,36 +1,12 @@ -

                                                          Details

                                                          -

                                                          Separate rule, function, and mixin declarations with empty lines.

                                                          Bad: no lines separating blocks

                                                          p {
                                                          -  margin: 0;
                                                          -  em {
                                                          -    ...
                                                          -  }
                                                          -}
                                                          -a {
                                                          -  ...
                                                          -}

                                                          Good: lines separating blocks

                                                          p {
                                                          -  margin: 0;
                                                          -
                                                          -  em {
                                                          -    ...
                                                          -  }
                                                          -}
                                                          -
                                                          -a {
                                                          -  ...
                                                          -}

                                                          By default, this will ignore single line blocks, so you can write:

                                                          .icon-chevron-up    { &:before { content: "\e030"; } }
                                                          -.icon-chevron-down  { &:before { content: "\e031"; } }
                                                          -.icon-chevron-left  { &:before { content: "\e032"; } }
                                                          -.icon-chevron-right { &:before { content: "\e033"; } }
                                                          - +

                                                          Details

                                                          +

                                                          Separate rule, function, and mixin declarations with empty lines.

                                                          Bad: no lines separating blocks

                                                          p {
                                                          margin: 0;
                                                          em {
                                                          ...
                                                          }
                                                          }
                                                          a {
                                                          ...
                                                          }

                                                          Good: lines separating blocks

                                                          p {
                                                          margin: 0;

                                                          em {
                                                          ...
                                                          }
                                                          }

                                                          a {
                                                          ...
                                                          }

                                                          By default, this will ignore single line blocks, so you can write:

                                                          .icon-chevron-up    { &:before { content: "\e030"; } }
                                                          .icon-chevron-down { &:before { content: "\e031"; } }
                                                          .icon-chevron-left { &:before { content: "\e032"; } }
                                                          .icon-chevron-right { &:before { content: "\e033"; } }
                                                          - - + - -
                                                          Configuration Option Description
                                                          ignore_single_line_blocks Don't enforce for single-line blocks (default true)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/EmptyRule.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/EmptyRule.html index 8fd3703..5a041de 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/EmptyRule.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/EmptyRule.html @@ -1,3 +1,2 @@ -

                                                          Details

                                                          -

                                                          Reports when you have an empty rule set.

                                                          .cat {
                                                          -}
                                                          \ No newline at end of file +

                                                          Details

                                                          +

                                                          Reports when you have an empty rule set.

                                                          .cat {
                                                          }
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ExtendDirective.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ExtendDirective.html new file mode 100644 index 0000000..28675f7 --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ExtendDirective.html @@ -0,0 +1,3 @@ +

                                                          Details

                                                          +

                                                          Disabled by default

                                                          Reports when you have an @extend directive.

                                                          p {
                                                          @extend %placeholder;
                                                          }

                                                          If you want to restrict the @extend directive to only use placeholders, see +the PlaceholderInExtend linter instead.

                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/FinalNewline.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/FinalNewline.html index 0746fc0..3644c24 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/FinalNewline.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/FinalNewline.html @@ -1,18 +1,15 @@ -

                                                          Details

                                                          +

                                                          Details

                                                          Files should always have a final newline. This results in better diffs when adding lines to the file, since SCM systems such as git won't think that you touched the last line.

                                                          You can customize whether or not a final newline exists with the present -option.

                                                          - +option.

                                                          - - + - -
                                                          Configuration Option Description
                                                          present Whether a final newline should be present (default true)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/HexLength.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/HexLength.html index 5d92cc6..6a1a230 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/HexLength.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/HexLength.html @@ -1,16 +1,13 @@ -

                                                          Details

                                                          +

                                                          Details

                                                          You can specify whether you prefer shorthand or long-form hexadecimal -colors by setting the style option to short or long, respectively.

                                                          short

                                                          color: #f2e;

                                                          long

                                                          color: #ff22ee;
                                                          - +colors by setting the style option to short or long, respectively.

                                                          short

                                                          color: #f2e;

                                                          long

                                                          color: #ff22ee;
                                                          - - + - -
                                                          Configuration Option Description
                                                          style Prefer short or long (default short)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/HexNotation.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/HexNotation.html index 81e148a..744ea91 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/HexNotation.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/HexNotation.html @@ -1,16 +1,13 @@ -

                                                          Details

                                                          +

                                                          Details

                                                          Checks if hexadecimal colors are written in lowercase. You can specify which -case with the style option.

                                                          - +case with the style option.

                                                          - - + - -
                                                          Configuration Option Description
                                                          style Prefer lowercase or uppercase (default lowercase)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/HexValidation.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/HexValidation.html index 3313792..f7bdd76 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/HexValidation.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/HexValidation.html @@ -1,6 +1,2 @@ -

                                                          Details

                                                          -

                                                          Ensure hexadecimal colors are valid (either three or six digits).

                                                          Bad

                                                          p {
                                                          -  background: #ab; // Clearly a typo
                                                          -}

                                                          Good

                                                          p {
                                                          -  background: #abc;
                                                          -}
                                                          \ No newline at end of file +

                                                          Details

                                                          +

                                                          Ensure hexadecimal colors are valid (either three or six digits).

                                                          Bad

                                                          p {
                                                          background: #ab; // Clearly a typo
                                                          }

                                                          Good

                                                          p {
                                                          background: #abc;
                                                          }
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/IdSelector.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/IdSelector.html index a21ba0c..a98aee7 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/IdSelector.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/IdSelector.html @@ -1,9 +1,5 @@ -

                                                          Details

                                                          -

                                                          Avoid using ID selectors.

                                                          Bad: highly-specific styling for a single element via ID

                                                          #submit-button {
                                                          -  ...
                                                          -}

                                                          Good: reusable class

                                                          .submit-button {
                                                          -  ...
                                                          -}

                                                          While the CSS specification allows for multiple elements with the same ID to +

                                                          Details

                                                          +

                                                          Avoid using ID selectors.

                                                          Bad: highly-specific styling for a single element via ID

                                                          #submit-button {
                                                          ...
                                                          }

                                                          Good: reusable class

                                                          .submit-button {
                                                          ...
                                                          }

                                                          While the CSS specification allows for multiple elements with the same ID to appear in a single document, in practice this is a smell. ID selectors should never be used for the purposes of styling an element, as it leads to overly specific styles that diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ImportPath.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ImportPath.html index 1052d97..efccc50 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ImportPath.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ImportPath.html @@ -1,29 +1,20 @@ -

                                                          Details

                                                          +

                                                          Details

                                                          The basenames of @imported SCSS partials should not begin with an underscore -and should not include the filename extension.

                                                          Bad

                                                          @import "foo/_bar.scss";
                                                          -@import "_bar.scss";
                                                          -@import "_bar";
                                                          -@import "bar.scss";

                                                          Good

                                                          @import "foo/bar";
                                                          -@import "bar";

                                                          You can configure this linter to instead ensure that you do include the +and should not include the filename extension.

                                                          Bad

                                                          @import "foo/_bar.scss";
                                                          @import "_bar.scss";
                                                          @import "_bar";
                                                          @import "bar.scss";

                                                          Good

                                                          @import "foo/bar";
                                                          @import "bar";

                                                          You can configure this linter to instead ensure that you do include the leading underscore or the filename extension by setting either option to true. Being explicit might have its place, as long as you are consistent.

                                                          @import declarations that Sass compiles directly into CSS @import rules -will be ignored.

                                                          - +will be ignored.

                                                          - - + - + - + - -
                                                          Configuration Option Description
                                                          leading_underscore -false or true (default false)false or true (default false)
                                                          filename_extension -false or true (default false)false or true (default false)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ImportantRule.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ImportantRule.html new file mode 100644 index 0000000..a7c38e0 --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ImportantRule.html @@ -0,0 +1,5 @@ +

                                                          Details

                                                          +

                                                          Avoid using !important in properties. It is usually indicative of a +misunderstanding of CSS +specificity +and can lead to brittle code.

                                                          Bad

                                                          p {
                                                          color: #f00 !important;
                                                          }

                                                          Good

                                                          p {
                                                          color: #f00;
                                                          }
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Indentation.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Indentation.html index dbc30d7..04d92eb 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Indentation.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Indentation.html @@ -1,24 +1,23 @@ -

                                                          Details

                                                          -

                                                          Use two spaces per indentation level.

                                                          Bad: four spaces

                                                          p {
                                                          -    color: #f00;
                                                          -}

                                                          Good: two spaces

                                                          p {
                                                          -  color: #f00;
                                                          -}

                                                          You can configure this linter to prefer tabs if you like.

                                                          - +

                                                          Details

                                                          +

                                                          Use two spaces per indentation level.

                                                          Bad: four spaces

                                                          p {
                                                          color: #f00;
                                                          }

                                                          Good: two spaces

                                                          p {
                                                          color: #f00;
                                                          }

                                                          You can configure this linter to prefer tabs if you like.

                                                          For projects that follow BEM, you may prefer to allow arbitrary indentation for +rule sets that aren't nested in order to give the visual hints of hierarchy +without actually nesting selectors (which has a performance cost). For example:

                                                          .component {}
                                                          .component__image {}
                                                          .component__text {}
                                                          .component-subblock {}
                                                          .component-subblock__text {}
                                                          .component-category {}
                                                          .component-other {}

                                                          You can set allow_non_nested_indentation to true if this convention is +preferred.

                                                          - - + + + + + - + - -
                                                          Configuration Option Description
                                                          allow_non_nested_indentationWhether non-nested rule sets can be arbitrarily indented (default false)
                                                          character -tab or space (default space)tab or space (default space)
                                                          width Number of characters per indentation level (default 2)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/LeadingZero.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/LeadingZero.html index c80e4d0..d7a0031 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/LeadingZero.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/LeadingZero.html @@ -1,16 +1,12 @@ -

                                                          Details

                                                          -

                                                          Don't write leading zeros for numeric values with a decimal point.

                                                          Bad: unnecessary leading zero

                                                          margin: 0.5em;

                                                          Good: no leading zero

                                                          margin: .5em;

                                                          You can configure this to prefer including leading zeros.

                                                          - +

                                                          Details

                                                          +

                                                          Don't write leading zeros for numeric values with a decimal point.

                                                          Bad: unnecessary leading zero

                                                          margin: 0.5em;

                                                          Good: no leading zero

                                                          margin: .5em;

                                                          You can configure this to prefer including leading zeros.

                                                          - - + - + - -
                                                          Configuration Option Description
                                                          style -exclude_zero or include_zero (default exclude_zero)exclude_zero or include_zero (default exclude_zero)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/MergeableSelector.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/MergeableSelector.html index 22170e4..d203fe9 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/MergeableSelector.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/MergeableSelector.html @@ -1,50 +1,21 @@ -

                                                          Details

                                                          -

                                                          Reports when you define the same selector twice in a single sheet.

                                                          Bad

                                                          h1 {
                                                          -  margin: 10px;
                                                          -}
                                                          -
                                                          -.baz {
                                                          -  color: red;
                                                          -}
                                                          -
                                                          -// Second copy of h1 rule
                                                          -h1 {
                                                          -  text-transform: uppercase;
                                                          -}

                                                          Good

                                                          h1 {
                                                          -  margin: 10px;
                                                          -  text-transform: uppercase;
                                                          -}
                                                          -
                                                          -.baz {
                                                          -  color: red;
                                                          -}

                                                          Combining duplicate selectors can result in an easier to read sheet, but +

                                                          Details

                                                          +

                                                          Reports when you define the same selector twice in a single sheet.

                                                          Bad

                                                          h1 {
                                                          margin: 10px;
                                                          }

                                                          .baz {
                                                          color: red;
                                                          }

                                                          // Second copy of h1 rule
                                                          h1 {
                                                          text-transform: uppercase;
                                                          }

                                                          Good

                                                          h1 {
                                                          margin: 10px;
                                                          text-transform: uppercase;
                                                          }

                                                          .baz {
                                                          color: red;
                                                          }

                                                          Combining duplicate selectors can result in an easier to read sheet, but occasionally the rules may be purposely duplicated to set precedence after a rule with the same CSS specificity. However, coding your stylesheets in this way makes them more difficult to comprehend, and can usually be avoided.

                                                          You can specify that rule sets which can be nested within another rule -set must be nested via the force_nesting option, e.g.

                                                          Bad

                                                          h1 {
                                                          -  color: #fff;
                                                          -}
                                                          -
                                                          -h1.new {
                                                          -  color: #000;
                                                          -}

                                                          Good

                                                          h1 {
                                                          -  color: #fff;
                                                          -
                                                          -  &.new {
                                                          -    color: #000;
                                                          -  }
                                                          -}
                                                          - +set must be nested via the force_nesting option, e.g.

                                                          Bad

                                                          h1 {
                                                          color: #fff;
                                                          }

                                                          h1.new {
                                                          color: #000;
                                                          }

                                                          Good

                                                          h1 {
                                                          color: #fff;

                                                          &.new {
                                                          color: #000;
                                                          }
                                                          }
                                                          - - + - -
                                                          Configuration Option Description
                                                          force_nesting Ensure rule sets which can be nested are nested (default true)
                                                          \ No newline at end of file + +whitelist +A list of selectors that can MergeableSelector, list those used in CSS Shims + + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/NameFormat.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/NameFormat.html index 6ffe1ac..790bebe 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/NameFormat.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/NameFormat.html @@ -1,41 +1,36 @@ -

                                                          Details

                                                          -

                                                          Functions, mixins, and variables should be declared with all lowercase letters -and hyphens instead of underscores.

                                                          Bad: uppercase characters

                                                          $myVar: 10px;
                                                          -
                                                          -@mixin myMixin() {
                                                          -  ...
                                                          -}

                                                          Good: all lowercase with hyphens

                                                          $my-var: 10px;
                                                          -
                                                          -@mixin my-mixin() {
                                                          -  ...
                                                          -}

                                                          Using lowercase with hyphens in CSS has become the de facto standard, and -brings with it a couple of benefits. First of all, hyphens are easier to type -than underscores, due to the additional Shift key required for underscores on -most popular keyboard layouts. Furthermore, using hyphens in class names in -particular allows you to take advantage of the -|= attribute selector, -which allows you to write a selector like [class|="inactive"] to match both -inactive-user and inactive-button classes.

                                                          The Sass parser automatically treats underscores and hyphens the same, so even +

                                                          Details

                                                          +

                                                          Functions, mixins, variables, and placeholders should be declared with all +lowercase letters and hyphens instead of underscores.

                                                          Bad: uppercase characters

                                                          $myVar: 10px;

                                                          @mixin myMixin() {
                                                          ...
                                                          }

                                                          Good: all lowercase with hyphens

                                                          $my-var: 10px;

                                                          @mixin my-mixin() {
                                                          ...
                                                          }

                                                          The Sass parser automatically treats underscores and hyphens the same, so even if you're using a library that declares a function with an underscore, you can refer to it using the hyphenated form instead.

                                                          Depending on whether you use underscores to denote private functions within your code, you can set the allow_leading_underscore option (enabled by default) which will ignore leading underscores in names if they exist, allowing -declarations like @function _private-function() { ... }.

                                                          You can also prefer the BEM convention by setting the -convention option to BEM. Any other value will be treated as a regex.

                                                          - +declarations like @function _private-function() { ... }. If you want to +further enforce a private naming convention, use +PrivateNamingConvention.

                                                          - - + - + - -
                                                          Configuration Option Description
                                                          allow_leading_underscore Whether to allow names to start with a single underscore (default true)
                                                          conventionName of convention to use (hyphenated_lowercase (default) or BEM), or a regex the name must matchName of convention to use (hyphenated_lowercase (default), camel_case, snake_case), or a regex the name must match (eg: ^[a-zA-Z]+$)
                                                          \ No newline at end of file + +convention_explanation +Custom catch-all explanation if you do not want to use the built-in explanations + + +{type}_convention +Convention to use for {type}s, where {type} is on of function, mixin, variable, or placeholder + + +{type}_convention_explanation +Custom explanation for {type} convention, where {type} is one of function, mixin, variable, or placeholder + + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/NestingDepth.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/NestingDepth.html index f5e941b..1a42b28 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/NestingDepth.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/NestingDepth.html @@ -1,42 +1,20 @@ -

                                                          Details

                                                          -

                                                          Avoid nesting selectors too deeply.

                                                          Bad: deeply nested

                                                          .one {
                                                          -  .two {
                                                          -    .three {
                                                          -      .four {
                                                          -        ...
                                                          -      }
                                                          -    }
                                                          -  }
                                                          -}

                                                          Good

                                                          .three:hover {
                                                          -}
                                                          -
                                                          -.three {
                                                          -  &:hover {
                                                          -    ...
                                                          -  }
                                                          -}

                                                          Overly nested rules will result in over-qualified CSS that could prove hard to +

                                                          Details

                                                          +

                                                          Avoid nesting selectors too deeply.

                                                          Bad: deeply nested

                                                          .one {
                                                          .two {
                                                          .three {
                                                          .four {
                                                          ...
                                                          }
                                                          }
                                                          }
                                                          }

                                                          Good

                                                          .three:hover {
                                                          }

                                                          .three {
                                                          &:hover {
                                                          ...
                                                          }
                                                          }

                                                          Overly nested rules will result in over-qualified CSS that could prove hard to maintain, output unnecessary selectors and is generally considered bad practice.

                                                          This linter will not report an error if you have selectors with a large depth of applicability. Use -SelectorDepth for this purpose.

                                                          No error

                                                          .one .two .three {
                                                          -  ...
                                                          -}

                                                          Error

                                                          .one {
                                                          -  .two {
                                                          -    .three {
                                                          -      ...
                                                          -    }
                                                          -  }
                                                          -}
                                                          - +SelectorDepth for this purpose.

                                                          No error

                                                          .one .two .three {
                                                          ...
                                                          }

                                                          Error

                                                          .one {
                                                          .two {
                                                          .three {
                                                          ...
                                                          }
                                                          }
                                                          }
                                                          - - + - -
                                                          Configuration Option Description
                                                          max_depth Maximum depth before reporting errors (default 3)
                                                          \ No newline at end of file + +ignore_parent_selectors +Whether to report errors for parent selectors (default false) + + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PlaceholderInExtend.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PlaceholderInExtend.html index 1954e6c..21a8d9a 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PlaceholderInExtend.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PlaceholderInExtend.html @@ -1,9 +1,6 @@ -

                                                          Details

                                                          -

                                                          Always use placeholder selectors in @extend.

                                                          Bad: extending a class

                                                          .fatal {
                                                          -  @extend .error;
                                                          -}

                                                          Good: extending a placeholder

                                                          .fatal {
                                                          -  @extend %error;
                                                          -}

                                                          Using a class selector with the @extend statement statement usually results -in more generated CSS than when using a placeholder selector. Furthermore, -Sass specifically introduced placeholder selectors in order to be used with -@extend.

                                                          See Mastering Sass extends and placeholders.

                                                          \ No newline at end of file +

                                                          Details

                                                          +

                                                          Always use placeholder selectors in @extend.

                                                          Bad: extending a class

                                                          .fatal {
                                                          @extend .error;
                                                          }

                                                          Good: extending a placeholder

                                                          .fatal {
                                                          @extend %error;
                                                          }

                                                          Using a class selector with the @extend directive usually results in more +generated CSS than when using a placeholder selector. Furthermore, Sass +specifically introduced placeholder selectors in order to be used with +@extend.

                                                          See Mastering Sass extends and placeholders.

                                                          If you want to prevent the use of the @extend directive entirely, see the +ExtendDirective linter.

                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PrivateNamingConvention.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PrivateNamingConvention.html new file mode 100644 index 0000000..6e5637f --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PrivateNamingConvention.html @@ -0,0 +1,14 @@ +

                                                          Details

                                                          +

                                                          Disabled by default

                                                          Enforces that functions, mixins, and variables that follow the private naming +convention (default to underscore-prefixed, e.g. $_foo) are defined and used +within the same file.

                                                          Bad

                                                          $_foo: #f00;

                                                          p {
                                                          color: #00f;
                                                          }

                                                          Bad

                                                          p {
                                                          color: $_foo;
                                                          }

                                                          Bad

                                                          p {
                                                          color: $_foo;
                                                          }

                                                          $_foo: #f00;

                                                          Good

                                                          $_foo: #f00;

                                                          p {
                                                          color: $_foo;
                                                          }
                                                          + + + + + + + + + +
                                                          Configuration OptionDescription
                                                          prefixPrefix used to denote "private" (default _)
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertyCount.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertyCount.html new file mode 100644 index 0000000..ff31455 --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertyCount.html @@ -0,0 +1,22 @@ +

                                                          Details

                                                          +

                                                          Disabled by default

                                                          Limit the number of properties in a rule set.

                                                          Specifying a large number of properties in a rule set is usually an opportunity +to break down the rule set into smaller more reusable components. It is also +a sign that you might not be leveraging the true power of the "cascade", as you +are explicitly defining a large number of properties many times.

                                                          Bad: large number of properties

                                                          .class {
                                                          color: #f00;
                                                          font: 15px arial, sans-serif;
                                                          margin: 0;
                                                          padding: 0;
                                                          }

                                                          Good: small number of properties

                                                          .class {
                                                          margin: 0;
                                                          padding: 0;
                                                          }

                                                          You can specify that the count of properties include properties in nested rule +sets via the include_nested option. This is useful if you care about the +overall complexity of a generated rule set, rather than just each individual +set.

                                                          + + + + + + + + + + + + + +
                                                          Configuration OptionDescription
                                                          include_nestedWhether to include the properties in nested rule sets in the count
                                                          max_propertiesMaximum number of properties
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertySortOrder.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertySortOrder.html index 5dc5601..894e802 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertySortOrder.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertySortOrder.html @@ -1,46 +1,43 @@ -

                                                          Details

                                                          +

                                                          Details

                                                          Sort properties in a strict order. By default, will require properties be sorted in alphabetical order, as it's brain dead simple (highlight lines and execute :sort in vim), and it can benefit gzip compression.

                                                          You can also specify an explicit ordering via the order option, which allows you to specify an explicit array of properties representing the preferred order, or the name of a -preset order. +preset order. If a property is not in your explicit list, it will be placed at the bottom of -the list, disregarding its order relative to other unspecified properties.

                                                          For example, to define a custom sort order, you can write:

                                                          linters:
                                                          -  PropertySortOrder:
                                                          -    order:
                                                          -      - display
                                                          -      - margin
                                                          -      - etc...

                                                          Or you can use a preset order by writing:

                                                          linters:
                                                          -  PropertySortOrder:
                                                          -    order: concentric

                                                          If you need to write vendor-prefixed properties, the linter will allow you to +the list, disregarding its order relative to other unspecified properties.

                                                          For example, to define a custom sort order, you can write:

                                                          linters:
                                                          PropertySortOrder:
                                                          order:
                                                          - display
                                                          - margin
                                                          - etc...

                                                          Or you can use a preset order by writing:

                                                          linters:
                                                          PropertySortOrder:
                                                          order: concentric

                                                          You can enforce that "groups" of properties be visually separated by setting +the separate_groups option to true. When specifying a custom order, you +can indicate that you want two groups of properties to be visually separate +by inserting an empty item, e.g.

                                                          linters:
                                                          PropertySortOrder:
                                                          order:
                                                          - display
                                                          - position
                                                          - # This empty element signals a visual separation
                                                          - margin
                                                          - padding
                                                          separate_groups: true

                                                          This would result in the following separation being enforced:

                                                          p {
                                                          display: block;
                                                          position: absolute;

                                                          margin: 0;
                                                          padding: 0;
                                                          }

                                                          Note that separate_groups is only enforced if a custom order is specified via +the order option. Also note that if ignore_unspecified is true then +properties which are "ignored" are considered as visual separators.

                                                          If you need to write vendor-prefixed properties, the linter will allow you to order the vendor-prefixed properties before the standard CSS property they -apply to. For example:

                                                          border: 0;
                                                          --moz-border-radius: 3px;
                                                          --o-border-radius: 3px;
                                                          --webkit-border-radius: 3px;
                                                          -border-radius: 3px;
                                                          -color: #ccc;
                                                          -margin: 5px;

                                                          In this case, this is usually avoided by using mixins from a framework like +apply to. For example:

                                                          border: 0;
                                                          -moz-border-radius: 3px;
                                                          -o-border-radius: 3px;
                                                          -webkit-border-radius: 3px;
                                                          border-radius: 3px;
                                                          color: #ccc;
                                                          margin: 5px;

                                                          In this case, this is usually avoided by using mixins from a framework like Compass or Bourbon so vendor-specific properties rarely need to be explicitly written by hand.

                                                          If you are specifying an explicit order for properties, note that vendor-prefixed properties will still be ordered based on the example above -(i.e. you only need to specify normal properties in your list).

                                                          - +(i.e. you only need to specify normal properties in your list).

                                                          - - + + + + + + + + + - + - - + + - -
                                                          Configuration Option Description
                                                          ignore_unspecifiedWhether to ignore properties that are not explicitly specified in order (default false)
                                                          min_propertiesMinimum number of sortable properties (i.e. properties which are defined by the given order) present in the rule set before linting takes place (default 2)
                                                          orderArray of properties, or the name of a preset order (default is nil, resulting in alphabetical ordering)Array of properties, or the name of a preset order (default is nil, resulting in alphabetical ordering)
                                                          ignore_unspecifiedWhether to ignore properties that are not explicitly specified in order (default false)separate_groupsWhether gaps between groups of properties should be enforced.
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertySpelling.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertySpelling.html index ad6fdc2..c56cb2d 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertySpelling.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertySpelling.html @@ -1,27 +1,24 @@ -

                                                          Details

                                                          -

                                                          Reports when you use an unknown CSS property (ignoring vendor-prefixed -properties).

                                                          diplay: none; // "display" is spelled incorrectly

                                                          Since the list of available CSS properties is constantly changing, it's +

                                                          Details

                                                          +

                                                          Reports when you use an unknown or disabled CSS property (ignoring vendor-prefixed +properties).

                                                          diplay: none; // "display" is spelled incorrectly

                                                          Since the list of available CSS properties is constantly changing, it's possible that you might get some false positives here, especially if you're using experimental CSS features. If that's the case, you can add additional properties to the whitelist by adding the following to your .scss-lint.yml -configuration:

                                                          linters:
                                                          -  PropertySpelling:
                                                          -    extra_properties:
                                                          -      - some-experimental-property
                                                          -      - another-experimental-property

                                                          If you're sure the property in question is valid, -submit a request +configuration:

                                                          linters:
                                                          PropertySpelling:
                                                          extra_properties:
                                                          - some-experimental-property
                                                          - another-experimental-property
                                                          disabled_properties:
                                                          - some-existing-property
                                                          - another-existing-property

                                                          If you're sure the property in question is valid, +submit a request to add it to the -default whitelist.

                                                          - +default whitelist.

                                                          - - + - -
                                                          Configuration Option Description
                                                          extra_properties List of extra properties to allow
                                                          \ No newline at end of file + +disabled_properties +List of existing properties to deny + + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertyUnits.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertyUnits.html new file mode 100644 index 0000000..933551c --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PropertyUnits.html @@ -0,0 +1,19 @@ +

                                                          Details

                                                          +

                                                          Configure which units are allowed for property values.

                                                          By default a value may have any kind of unit. You can adjust which units are +allowed globally by setting the global option. Alternately, you can specify a +list of units for a single property by adding it to the properties option, +e.g.

                                                          PropertyUnits:
                                                          global: ['em', 'rem', '%'] # Allow relative units globally
                                                          properties:
                                                          border: ['px'] # Only pixels
                                                          line-height: [] # No units allowed
                                                          margin: ['em', 'rem']

                                                          With the above configuration, the following issues would be reported:

                                                          p {
                                                          border: 1rem solid blue; // rem not in `border` list
                                                          line-height: 55px; // px not in `line-height` list
                                                          padding: 10px; // px not in `global` list
                                                          margin: 10%; // % not in `margin` list
                                                          }
                                                          + + + + + + + + + + + + + +
                                                          Configuration OptionDescription
                                                          globalList of allowed units (by default any unit is allowed)
                                                          propertiesHash of property names and their list of allowed units. (empty by default)
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PseudoElement.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PseudoElement.html new file mode 100644 index 0000000..469b8dd --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/PseudoElement.html @@ -0,0 +1,7 @@ +

                                                          Details

                                                          +

                                                          Pseudo-elements, like ::before, and ::first-letter, should be declared with +two colons. Pseudo-classes, like :hover and :first-child, should be +declared with one colon.

                                                          If you're sure the pseudo-element in question is valid, +submit a request +to add it to the +default whitelist.

                                                          Bad: wrong colons

                                                          p:before {
                                                          content: '>'
                                                          }

                                                          p::hover {
                                                          color: red;
                                                          }

                                                          Good: correct colons

                                                          p::before {
                                                          content: '>'
                                                          }

                                                          p:hover {
                                                          color: red;
                                                          }
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/QualifyingElement.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/QualifyingElement.html index be4036a..23cbbff 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/QualifyingElement.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/QualifyingElement.html @@ -1,44 +1,14 @@ -

                                                          Details

                                                          -

                                                          Avoid qualifying elements in selectors (also known as "tag-qualifying").

                                                          Bad: qualifying elements

                                                          div#thing {
                                                          -  ...
                                                          -}
                                                          -
                                                          -ul.list {
                                                          -  ...
                                                          -}
                                                          -
                                                          -ul li.item {
                                                          -  ...
                                                          -}
                                                          -
                                                          -a[href="place"] {
                                                          -  ...
                                                          -}

                                                          Good

                                                          #thing {
                                                          -  ...
                                                          -}
                                                          -
                                                          -.list {
                                                          -  ...
                                                          -}
                                                          -
                                                          -ul .item {
                                                          -  ...
                                                          -}
                                                          -
                                                          -[href="place"] {
                                                          -  ...
                                                          -}

                                                          Since IDs are unique, they will not apply to multiple elements, so there is no +

                                                          Details

                                                          +

                                                          Avoid qualifying elements in selectors (also known as "tag-qualifying").

                                                          Bad: qualifying elements

                                                          div#thing {
                                                          ...
                                                          }

                                                          ul.list {
                                                          ...
                                                          }

                                                          ul li.item {
                                                          ...
                                                          }

                                                          a[href="place"] {
                                                          ...
                                                          }

                                                          Good

                                                          #thing {
                                                          ...
                                                          }

                                                          .list {
                                                          ...
                                                          }

                                                          ul .item {
                                                          ...
                                                          }

                                                          [href="place"] {
                                                          ...
                                                          }

                                                          Since IDs are unique, they will not apply to multiple elements, so there is no good reason to qualify an ID selector with an element.

                                                          In most cases, qualifying a class or attribute selector with an element adds unnecessary or undesirable specificity. Often the element qualifier is already superfluous; and if it is not, you will probably be better off -refactoring so that it can be removed.

                                                          Use the options to allow certain qualifying elements.

                                                          - +refactoring so that it can be removed.

                                                          Use the options to allow certain qualifying elements.

                                                          - - + @@ -51,5 +21,4 @@

                                                          Details

                                                          - -
                                                          Configuration Option Description
                                                          allow_element_with_attribute Allow elements to qualify attributes (default false) allow_element_with_id Allow elements to qualify ids (default false)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SelectorDepth.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SelectorDepth.html index 62dca2a..80b4015 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SelectorDepth.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SelectorDepth.html @@ -1,34 +1,15 @@ -

                                                          Details

                                                          -

                                                          Don't write selectors with a depth of applicability greater than 3.

                                                          Bad: selectors with depths of 4

                                                          .one .two .three > .four {
                                                          -  ...
                                                          -}
                                                          -
                                                          -.one .two {
                                                          -  .three > .four {
                                                          -    ...
                                                          -  }
                                                          -}

                                                          Good

                                                          .one .two .three {
                                                          -  ...
                                                          -}
                                                          -
                                                          -.one .two {
                                                          -  .three {
                                                          -    ...
                                                          -  }
                                                          -}

                                                          Selectors with a large depth of applicability +

                                                          Details

                                                          +

                                                          Don't write selectors with a depth of applicability greater than 3.

                                                          Bad: selectors with depths of 4

                                                          .one .two .three > .four {
                                                          ...
                                                          }

                                                          .one .two {
                                                          .three > .four {
                                                          ...
                                                          }
                                                          }

                                                          Good

                                                          .one .two .three {
                                                          ...
                                                          }

                                                          .one .two {
                                                          .three {
                                                          ...
                                                          }
                                                          }

                                                          Selectors with a large depth of applicability lead to CSS tightly-coupled to your HTML structure, making it brittle to change.

                                                          Deep selectors also come with a performance penalty, which can affect rendering times, especially on mobile devices. While the default limit is 3, ideally it -is better to use less than 3 whenever possible.

                                                          - +is better to use less than 3 whenever possible.

                                                          - - + - -
                                                          Configuration Option Description
                                                          max_depth Maximum depth before reporting errors (default 3)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SelectorFormat.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SelectorFormat.html index 703d02d..8629b8a 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SelectorFormat.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SelectorFormat.html @@ -1,26 +1,20 @@ -

                                                          Details

                                                          -

                                                          It is good practice to choose a convention for naming selectors.

                                                          Good

                                                          // convention: 'hyphenated_lowercase'
                                                          -.foo-bar-77, foo-bar, #foo-bar {}
                                                          -
                                                          -// convention: 'snake_case'
                                                          -.foo_bar77, foo_bar, #foo_bar {}
                                                          -
                                                          -// convention: 'camel_case'
                                                          -.fooBar77, fooBar, #fooBar {}
                                                          -}

                                                          You can specify different conventions for different types of selectors using the [type]_convention options.

                                                          Since you might need to overwrite selectors for third party stylesheets, you +

                                                          Details

                                                          +

                                                          It is good practice to choose a convention for naming selectors.

                                                          Good

                                                          // convention: 'hyphenated_lowercase'
                                                          .foo-bar-77, foo-bar, #foo-bar {}

                                                          // convention: 'snake_case'
                                                          .foo_bar77, foo_bar, #foo_bar {}

                                                          // convention: 'camel_case'
                                                          .fooBar77, fooBar, #fooBar {}
                                                          }

                                                          You can specify different conventions for different types of selectors using the [type]_convention options.

                                                          Since you might need to overwrite selectors for third party stylesheets, you can specify ignored_names as an array of individual selectors to ignore. Another option is to specify ignored_types to globally ignore a certain -type of selector.

                                                          - +type of selector.

                                                          - - + - + + + + + @@ -31,20 +25,15 @@

                                                          Details

                                                          - - - - - - - - - - + + - - + + - -
                                                          Configuration Option Description
                                                          conventionName of convention to use (hyphenated_lowercase (default) or snake_case, camel_case, or BEM, or hyphenated_BEM), or a regex the name must matchName of convention to use (hyphenated_lowercase (default) or snake_case, camel_case, or strict_BEM, or hyphenated_BEM), or a regex the name must match. Note: If your project uses BEM, pay attention to the dialect of BEM you use. It may be strict_BEM or hyphenated_BEM.
                                                          convention_explanationCustom catch-all explanation if you do not want to use the built-in explanations
                                                          ignored_names Array containing list of types of selectors to ignore (valid values are attribute, class, element, id, placeholder)
                                                          attribute_conventionConvention for attribute selectors only. See the convention option for possible values.
                                                          class_conventionConvention for class selectors only. See the convention option for possible values.
                                                          id_conventionConvention for id selectors only. See the convention option for possible values.{type}_conventionConvention for {type} selectors only, where {type} is one of attribute, class, id, or placeholder. See the convention option for possible values.
                                                          placeholder_conventionConvention for placeholder selectors only. See the convention option for possible values.{type}_convention_explanationCustom explanation for {type} selector convention, where {type} is one of attribute, class, id, or placeholder.
                                                          \ No newline at end of file +

                                                          Limitations

                                                          SelectorFormat will not resolve the parent selector reference (&), +and will ignore selectors containing any parent references. +This is because these references cannot be resolved without compiling +the Sass into actual CSS. If you would like to see such functionality, +we'd love to merge a pull request!

                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Shorthand.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Shorthand.html index f34efa5..ebabf29 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Shorthand.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/Shorthand.html @@ -1,2 +1,13 @@ -

                                                          Details

                                                          -

                                                          Prefer the shortest shorthand form possible for properties that support it.

                                                          Bad: all 4 sides specified with same value

                                                          margin: 1px 1px 1px 1px;

                                                          Good: equivalent to specifying 1px for all sides

                                                          margin: 1px;
                                                          \ No newline at end of file +

                                                          Details

                                                          +

                                                          Prefer the shortest shorthand form possible for properties that support it.

                                                          Bad: all 4 sides specified with same value

                                                          margin: 1px 1px 1px 1px;

                                                          Good: equivalent to specifying 1px for all sides

                                                          margin: 1px;

                                                          If you don't want to allow all possible shorthands, you can limit them by +setting the allowed_shorthands array option to a subset of [1, 2, 3].

                                                          + + + + + + + + + +
                                                          Configuration OptionDescription
                                                          allowed_shorthandsArray of allowed shorthand lengths (default [1, 2, 3])
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SingleLinePerProperty.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SingleLinePerProperty.html index 42f4f46..d9fdc3e 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SingleLinePerProperty.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SingleLinePerProperty.html @@ -1,23 +1,14 @@ -

                                                          Details

                                                          -

                                                          Properties within rule sets should each reside on their own line.

                                                          Bad

                                                          p {
                                                          -  margin: 0; padding: 0;
                                                          -}

                                                          Good

                                                          p {
                                                          -  margin: 0;
                                                          -  padding: 0;
                                                          -}

                                                          A special exception is made for single line rule sets. For example the -following is acceptable:

                                                          p { margin: 0; padding: 0; }

                                                          If you want to also report a lint for single line rule sets, set the -allow_single_line_rule_sets option to false.

                                                          - +

                                                          Details

                                                          +

                                                          Properties within rule sets should each reside on their own line.

                                                          Bad

                                                          p {
                                                          margin: 0; padding: 0;
                                                          }

                                                          Good

                                                          p {
                                                          margin: 0;
                                                          padding: 0;
                                                          }

                                                          A special exception is made for single line rule sets. For example the +following is acceptable:

                                                          p { margin: 0; padding: 0; }

                                                          If you want to also report a lint for single line rule sets, set the +allow_single_line_rule_sets option to false.

                                                          - - + - + - -
                                                          Configuration Option Description
                                                          allow_single_line_rule_sets -true or false (default true)true or false (default true)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SingleLinePerSelector.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SingleLinePerSelector.html index f622db0..4c764f3 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SingleLinePerSelector.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SingleLinePerSelector.html @@ -1,9 +1,5 @@ -

                                                          Details

                                                          -

                                                          Split selectors onto separate lines after each comma.

                                                          Bad: comma-separated selectors not on their own lines

                                                          .error p, p.explanation {
                                                          -  ...
                                                          -}

                                                          Good: each selector sequence is on its own line

                                                          .error p,
                                                          -p.explanation {
                                                          -  ...
                                                          -}

                                                          Note that selectors containing interpolation are ignored, since the Sass parser +

                                                          Details

                                                          +

                                                          Split selectors onto separate lines after each comma, and have each individual +selector occupy a single line.

                                                          Bad: comma-separated selectors not on their own lines

                                                          .error p, p.explanation {
                                                          ...
                                                          }

                                                          Bad: descendent selector spread over multiple lines

                                                          .error
                                                          p,
                                                          p.explanation {
                                                          ...
                                                          }

                                                          Good: each selector sequence is on its own individual line

                                                          .error p,
                                                          p.explanation {
                                                          ...
                                                          }

                                                          Note that selectors containing interpolation are ignored, since the Sass parser cannot construct the selector parse tree at parse time, only at run time (which is too late for scss-lint to do anything with).

                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterComma.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterComma.html index 1bc9152..f381794 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterComma.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterComma.html @@ -1,4 +1,12 @@ -

                                                          Details

                                                          -

                                                          Commas in lists should be followed by a space.

                                                          Bad: no space after commas

                                                          @include box-shadow(0 2px 2px rgba(0,0,0,.2));
                                                          -color: rgba(0,0,0,.1);

                                                          Good: commas followed by a space

                                                          @include box-shadow(0 2px 2px rgba(0, 0, 0, .2));
                                                          -color: rgba(0, 0, 0, .1);
                                                          \ No newline at end of file +

                                                          Details

                                                          +

                                                          Commas in lists should be followed by a space.

                                                          Bad: no space after commas

                                                          @include box-shadow(0 2px 2px rgba(0,0,0,.2));
                                                          color: rgba(0,0,0,.1);

                                                          Good: commas followed by a space

                                                          @include box-shadow(0 2px 2px rgba(0, 0, 0, .2));
                                                          color: rgba(0, 0, 0, .1);

                                                          The style option allows you to specify a different preferred style.

                                                          + + + + + + + + + +
                                                          Configuration OptionDescription
                                                          styleone_space, or no_space or at_least_one_space (default one_space)
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterPropertyColon.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterPropertyColon.html index 85f4c4e..c77292d 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterPropertyColon.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterPropertyColon.html @@ -1,17 +1,13 @@ -

                                                          Details

                                                          +

                                                          Details

                                                          Properties should be formatted with a single space separating the colon from -the property's value.

                                                          Bad: no space after colon

                                                          margin:0;

                                                          Bad: more than one space after colon

                                                          margin:  0;

                                                          Good

                                                          margin: 0;

                                                          The style option allows you to specify a different preferred style.

                                                          - +the property's value.

                                                          Bad: no space after colon

                                                          margin:0;

                                                          Bad: more than one space after colon

                                                          margin:  0;

                                                          Good

                                                          margin: 0;

                                                          The style option allows you to specify a different preferred style.

                                                          - - + - + - -
                                                          Configuration Option Description
                                                          style -one_space, no_space, at_least_one_space, or aligned (default one_space)one_space, no_space, at_least_one_space, one_space_or_newline, or aligned (default one_space)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterPropertyName.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterPropertyName.html index b4a3763..64c8369 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterPropertyName.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterPropertyName.html @@ -1,2 +1,2 @@ -

                                                          Details

                                                          -

                                                          Properties should be formatted with no space between the name and the colon.

                                                          Bad: space before colon

                                                          margin : 0;

                                                          Good

                                                          margin: 0;
                                                          \ No newline at end of file +

                                                          Details

                                                          +

                                                          Properties should be formatted with no space between the name and the colon.

                                                          Bad: space before colon

                                                          margin : 0;

                                                          Good

                                                          margin: 0;
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterVariableColon.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterVariableColon.html new file mode 100644 index 0000000..702c2ab --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterVariableColon.html @@ -0,0 +1,13 @@ +

                                                          Details

                                                          +

                                                          Variables should be formatted with a single space separating the colon from +the variable's value.

                                                          Bad: no space after colon

                                                          $my-color:#fff;

                                                          Bad: more than one space after colon

                                                          $my-color:  #fff;

                                                          Good

                                                          $my-color: #fff;

                                                          The style option allows you to specify a different preferred style.

                                                          + + + + + + + + + +
                                                          Configuration OptionDescription
                                                          styleone_space, no_space, at_least_one_space or one_space_or_newline (default one_space)
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterVariableName.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterVariableName.html new file mode 100644 index 0000000..b16bf6d --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAfterVariableName.html @@ -0,0 +1,2 @@ +

                                                          Details

                                                          +

                                                          Variables should be formatted with no space between the name and the colon.

                                                          Bad: space before colon

                                                          $my-var : 0;

                                                          Good

                                                          $my-var: 0;
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAroundOperator.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAroundOperator.html new file mode 100644 index 0000000..e94fe5a --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceAroundOperator.html @@ -0,0 +1,16 @@ +

                                                          Details

                                                          +

                                                          Operators should be formatted with a single space on both sides of an infix +operator. These include +, -, *, /, %, ==, !=, >, >=, <, +and <=.

                                                          Bad: no space around operator

                                                          margin: 5px+5px;

                                                          Bad: more than one space around operator

                                                          margin: 5px   +   5px;

                                                          Good

                                                          margin: 5px + 5px;

                                                          Note that this linter only applies to actual, evaluated operators. So values +like nth-child(2n+1), 10px/12px, and my-font will not be linted, as they +are valid CSS.

                                                          The style option allows you to specify a different preferred style.

                                                          + + + + + + + + + +
                                                          Configuration OptionDescription
                                                          styleone_space, at_least_one_space, no_space (default one_space)
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceBeforeBrace.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceBeforeBrace.html index 875b097..fa49941 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceBeforeBrace.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceBeforeBrace.html @@ -1,33 +1,17 @@ -

                                                          Details

                                                          -

                                                          Opening braces should be preceded by a single space.

                                                          Bad: no space before brace

                                                          p{
                                                          -  ...
                                                          -}

                                                          Bad: more than one space before brace

                                                          p  {
                                                          -  ...
                                                          -}

                                                          Good

                                                          p {
                                                          -  ...
                                                          -}

                                                          Setting allow_single_line_padding to true allows you to use extra spaces to -nicely align single line blocks, so you can write:

                                                          .icon-chevron-up    { &:before { content: "\e030"; } }
                                                          -.icon-chevron-down  { &:before { content: "\e031"; } }
                                                          -.icon-chevron-left  { &:before { content: "\e032"; } }
                                                          -.icon-chevron-right { &:before { content: "\e033"; } }

                                                          Set style to new_line if you prefer to use a new line before braces, rather than a single space.

                                                          p
                                                          -{
                                                          -  ...
                                                          -}
                                                          - +

                                                          Details

                                                          +

                                                          Opening braces should be preceded by a single space.

                                                          Bad: no space before brace

                                                          p{
                                                          ...
                                                          }

                                                          Bad: more than one space before brace

                                                          p  {
                                                          ...
                                                          }

                                                          Good

                                                          p {
                                                          ...
                                                          }

                                                          Setting allow_single_line_padding to true allows you to use extra spaces to +nicely align single line blocks, so you can write:

                                                          .icon-chevron-up    { &:before { content: "\e030"; } }
                                                          .icon-chevron-down { &:before { content: "\e031"; } }
                                                          .icon-chevron-left { &:before { content: "\e032"; } }
                                                          .icon-chevron-right { &:before { content: "\e033"; } }

                                                          Set style to new_line if you prefer to use a new line before braces, rather than a single space.

                                                          p
                                                          {
                                                          ...
                                                          }
                                                          - - + - + - -
                                                          Configuration Option Description
                                                          allow_single_line_padding Allow single line blocks to have extra spaces for nicer formatting (default false)
                                                          style -space or new_line (default space)space or new_line (default space)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceBetweenParens.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceBetweenParens.html index 354f194..09505b7 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceBetweenParens.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/SpaceBetweenParens.html @@ -1,17 +1,12 @@ -

                                                          Details

                                                          -

                                                          Parentheses should not be padded with spaces.

                                                          Bad

                                                          @include box-shadow( 0 2px 2px rgba( 0, 0, 0, .2 ) );
                                                          -color: rgba( 0, 0, 0, .1 );

                                                          Good

                                                          @include box-shadow(0 2px 2px rgba(0, 0, 0, .2));
                                                          -color: rgba(0, 0, 0, .1);
                                                          - +

                                                          Details

                                                          +

                                                          Parentheses should not be padded with spaces.

                                                          Bad

                                                          @include box-shadow( 0 2px 2px rgba( 0, 0, 0, .2 ) );
                                                          color: rgba( 0, 0, 0, .1 );

                                                          Good

                                                          @include box-shadow(0 2px 2px rgba(0, 0, 0, .2));
                                                          color: rgba(0, 0, 0, .1);
                                                          - - + - -
                                                          Configuration Option Description
                                                          spaces Spaces to require between parentheses (default 0)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/StringQuotes.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/StringQuotes.html index 136e859..f5768e5 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/StringQuotes.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/StringQuotes.html @@ -1,18 +1,14 @@ -

                                                          Details

                                                          +

                                                          Details

                                                          String literals should be written with single quotes unless using double quotes -would save on escape characters.

                                                          Bad: double quotes

                                                          content: "hello";

                                                          Good: single quotes

                                                          content: 'hello';

                                                          Good: double quotes prevent the need for escaping single quotes

                                                          content: "'hello'";

                                                          Single quotes are easier to type by virtue of not requiring the Shift key on -most popular keyboard layouts.

                                                          - +would save on escape characters.

                                                          Bad: double quotes

                                                          content: "hello";

                                                          Good: single quotes

                                                          content: 'hello';

                                                          Good: double quotes prevent the need for escaping single quotes

                                                          content: "'hello'";

                                                          Single quotes are easier to type by virtue of not requiring the Shift key on +most popular keyboard layouts.

                                                          - - + - + - -
                                                          Configuration Option Description
                                                          style -single_quotes or double_quotes (default single_quotes)single_quotes or double_quotes (default single_quotes)
                                                          \ No newline at end of file + \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TrailingSemicolon.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TrailingSemicolon.html index bec8c18..8fcb515 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TrailingSemicolon.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TrailingSemicolon.html @@ -1,11 +1,5 @@ -

                                                          Details

                                                          +

                                                          Details

                                                          Property values; @extend, @include, and @import directives; and variable -declarations should always end with a semicolon.

                                                          Bad: no semicolon

                                                          p {
                                                          -  color: #fff
                                                          -}

                                                          Bad: space between value and semicolon

                                                          p {
                                                          -  color: #fff ;
                                                          -}

                                                          Good

                                                          p {
                                                          -  color: #fff;
                                                          -}

                                                          CSS allows you to omit the semicolon if the statement is the last statement in +declarations should always end with a semicolon.

                                                          Bad: no semicolon

                                                          p {
                                                          color: #fff
                                                          }

                                                          Bad: space between value and semicolon

                                                          p {
                                                          color: #fff ;
                                                          }

                                                          Good

                                                          p {
                                                          color: #fff;
                                                          }

                                                          CSS allows you to omit the semicolon if the statement is the last statement in the rule set. However, this introduces inconsistency and requires anyone adding a property after that property to remember to append a semicolon.

                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TrailingWhitespace.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TrailingWhitespace.html new file mode 100644 index 0000000..4b134ae --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TrailingWhitespace.html @@ -0,0 +1,2 @@ +

                                                          Details

                                                          +

                                                          Reports lines containing trailing whitespace.

                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TrailingZero.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TrailingZero.html index 50e3116..b524920 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TrailingZero.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TrailingZero.html @@ -1,3 +1,3 @@ -

                                                          Details

                                                          -

                                                          Don't write trailing zeros for numeric values with a decimal point.

                                                          Bad: unnecessary trailing zero

                                                          margin: .500em;

                                                          Good: no trailing zero

                                                          margin: .5em;

                                                          The extra zeros are unnecessary and just add additional bytes to the resulting +

                                                          Details

                                                          +

                                                          Disabled by default

                                                          Don't write trailing zeros for numeric values with a decimal point.

                                                          Bad: unnecessary trailing zero

                                                          margin: .500em;

                                                          Good: no trailing zero

                                                          margin: .5em;

                                                          The extra zeros are unnecessary and just add additional bytes to the resulting generated CSS.

                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TransitionAll.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TransitionAll.html new file mode 100644 index 0000000..428a12f --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/TransitionAll.html @@ -0,0 +1,2 @@ +

                                                          Details

                                                          +

                                                          Disabled by default

                                                          Don't use the all keyword to specify transition properties.

                                                          Bad: use of transition all

                                                          transition: all .5s ease-in;

                                                          Good: explicitly specify properties to transition

                                                          transition: color .5s ease-in, margin-bottom .5s ease-in;
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UnnecessaryMantissa.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UnnecessaryMantissa.html index 3335793..4d187b1 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UnnecessaryMantissa.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UnnecessaryMantissa.html @@ -1,5 +1,4 @@ -

                                                          Details

                                                          -

                                                          Numeric values should not contain unnecessary fractional portions.

                                                          Bad

                                                          margin: 1.0em;

                                                          Good

                                                          margin: 1em;

                                                          Sass will automatically convert integers to floats when necessary, making the +

                                                          Details

                                                          +

                                                          Numeric values should not contain unnecessary fractional portions.

                                                          Bad

                                                          margin: 1.0em;

                                                          Good

                                                          margin: 1em;

                                                          Sass will automatically convert integers to floats when necessary, making the use of a fractional component in a value to "force" it to be a floating point -number unnecessary. For example, the following code:

                                                          $margin: 1;
                                                          -p { margin: $margin / 2; }

                                                          ...will compile to:

                                                          p { margin: 0.5; }
                                                          \ No newline at end of file +number unnecessary. For example, the following code:

                                                          $margin: 1;
                                                          p { margin: $margin / 2; }

                                                          ...will compile to:

                                                          p { margin: 0.5; }
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UnnecessaryParentReference.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UnnecessaryParentReference.html index 4a2fbb0..e630bef 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UnnecessaryParentReference.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UnnecessaryParentReference.html @@ -1,10 +1,3 @@ -

                                                          Details

                                                          +

                                                          Details

                                                          Do not use parent selector references (&) when they would otherwise be -unnecessary.

                                                          Bad

                                                          .foo {
                                                          -  & > .bar {
                                                          -    ...
                                                          -  }
                                                          -}

                                                          Good

                                                          .foo {
                                                          -  > .bar {
                                                          -  }
                                                          -}
                                                          \ No newline at end of file +unnecessary.

                                                          Bad

                                                          .foo {
                                                          & > .bar {
                                                          ...
                                                          }
                                                          }

                                                          Good

                                                          .foo {
                                                          > .bar {
                                                          }
                                                          }
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UrlFormat.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UrlFormat.html index 6f332a6..5d5ffa7 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UrlFormat.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UrlFormat.html @@ -1,3 +1,3 @@ -

                                                          Details

                                                          -

                                                          URLs should not contain protocols or domain names.

                                                          Including protocols or domains in URLs makes them brittle to change, and also -unnecessarily increases the size of your CSS documents, reducing performance.

                                                          Bad: protocol and domain present

                                                          background: url('https://example.com/assets/image.png');

                                                          Good

                                                          background: url('assets/image.png');
                                                          \ No newline at end of file +

                                                          Details

                                                          +

                                                          URLs should be valid and not contain protocols or domain names.

                                                          Including protocols or domains in URLs makes them brittle to change, and also +unnecessarily increases the size of your CSS documents, reducing performance.

                                                          Bad: protocol and domain present

                                                          background: url('https://example.com/assets/image.png');

                                                          Good

                                                          background: url('assets/image.png');
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UrlQuotes.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UrlQuotes.html index f8c2182..b2833c1 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UrlQuotes.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/UrlQuotes.html @@ -1,5 +1,5 @@ -

                                                          Details

                                                          -

                                                          URLs should always be enclosed within quotes.

                                                          Bad: no enclosing quotes

                                                          background: url(example.png);

                                                          Good

                                                          background: url('example.png');

                                                          Using quoted URLs is consistent with using other Sass asset helpers, which also +

                                                          Details

                                                          +

                                                          URLs should always be enclosed within quotes.

                                                          Bad: no enclosing quotes

                                                          background: url(example.png);

                                                          Good

                                                          background: url('example.png');

                                                          Using quoted URLs is consistent with using other Sass asset helpers, which also expect quoted strings. It also works better with most syntax highlighters, and makes it easier to escape characters, as the escape rules for strings apply, rather than the different set of rules for literal URLs.

                                                          See the URL type documentation diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/VariableForProperty.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/VariableForProperty.html new file mode 100644 index 0000000..42d376d --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/VariableForProperty.html @@ -0,0 +1,18 @@ +

                                                          Details

                                                          +

                                                          Disabled by default

                                                          Properties, like color and font, are easier to read and maintain when +defined using variables rather than literals.

                                                          Bad

                                                          p {
                                                          color: red;
                                                          }

                                                          .warning {
                                                          color: #ff0;
                                                          }

                                                          Good

                                                          p {
                                                          color: $body-text;
                                                          }

                                                          .warning {
                                                          color: $body-warning;
                                                          }

                                                          By using variables, you can describe the semantics of the property value rather +than just using the literal value (improving readability) and also make it +easier to perform side-wide changes as you only need to change the value in one +place, rather than several.

                                                          By default, this linter does not enforce the use of variables for any property. +To enable it, set the properties option in your configuration, e.g.

                                                          linters:
                                                          VariableForProperty:
                                                          enabled: true
                                                          properties:
                                                          - color
                                                          - font

                                                          Note that values like currentColor, inherit, and transparent will not be +reported, as they are special kinds of values that convey additional meaning.

                                                          + + + + + + + + + +
                                                          Configuration OptionDescription
                                                          propertiesArray of property names to check
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/VendorPrefix.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/VendorPrefix.html new file mode 100644 index 0000000..7064ac4 --- /dev/null +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/VendorPrefix.html @@ -0,0 +1,23 @@ +

                                                          Details

                                                          +

                                                          Avoid vendor prefixes. That is, don't write them yourself.

                                                          Instead, you can use Autoprefixer or mixins -- such as Compass or Bourbon -- to add vendor prefixes to your code. (If using your own mixins, make sure to exempt their source from this linter.)

                                                          At-rules, selectors, properties, and values are all checked. (See the examples below.)

                                                          The default identifier_list, base, should include everything that Autoprefixer addresses. You could also use a list covering Bourbon's CSS3 mixins: bourbon. If neither of those suit you, you can write your own identifier list.

                                                          Additionally, you can manually include or exclude identifiers from the identifier list -- if, for example, you want to use pretty much all of the base list but also want to allow yourself to use vendor prefixed transform properties, for one reason or another.

                                                          All identifiers used by the identifier_list, additional_identifiers, or +excluded_identifiers are stripped of vendor prefixes. See the predefined +lists +for examples.

                                                          Bad: vendor prefixes

                                                          @-webkit-keyframes anim {
                                                          0% { opacity: 0; }
                                                          }

                                                          ::-moz-placeholder {
                                                          color: red;
                                                          }

                                                          .foo {
                                                          -webkit-transition: none;
                                                          }

                                                          .bar {
                                                          position: -moz-sticky;
                                                          }

                                                          Good

                                                          // With Autoprefixer ...
                                                          @keyframes anim {
                                                          0% { opacity: 0; }
                                                          }

                                                          ::placeholder {
                                                          color: red;
                                                          }

                                                          .foo {
                                                          transition: none;
                                                          }

                                                          .bar {
                                                          position: sticky;
                                                          }

                                                          // With Bourbon mixin
                                                          @include placeholder {
                                                          color: red;
                                                          }
                                                          + + + + + + + + + + + + + + + + + +
                                                          Configuration OptionDescription
                                                          identifier_listName of predefined identifier list to use (base or bourbon) or an array of identifiers (default base)
                                                          additional_identifiersIdentifiers to lint, in addition to the identifier_list (default [])
                                                          excluded_identifiersIdentifers in the identifier_list and additional_identifiers to exclude from linting (default [])
                                                          \ No newline at end of file diff --git a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ZeroUnit.html b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ZeroUnit.html index f4ff13b..ed9c81b 100644 --- a/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ZeroUnit.html +++ b/sonar-web-frontend-scss/src/main/resources/rules/scsslint/ZeroUnit.html @@ -1,5 +1,5 @@ -

                                                          Details

                                                          -

                                                          Omit length units on zero values.

                                                          Bad: unnecessary units

                                                          margin: 0px;

                                                          Good

                                                          margin: 0;

                                                          Zero is zero regardless of the units of length.

                                                          Note that this only applies to +

                                                          Details

                                                          +

                                                          Omit length units on zero values.

                                                          Bad: unnecessary units

                                                          margin: 0px;

                                                          Good

                                                          margin: 0;

                                                          Zero is zero regardless of the units of length.

                                                          Note that this only applies to lengths, since it is invalid to omit units for other types such as angles or diff --git a/sonar-web-frontend-typescript/.gitignore b/sonar-web-frontend-typescript/.gitignore new file mode 100644 index 0000000..e1bb6cf --- /dev/null +++ b/sonar-web-frontend-typescript/.gitignore @@ -0,0 +1,2 @@ +/target +/target/* diff --git a/sonar-web-frontend-typescript/pom.xml b/sonar-web-frontend-typescript/pom.xml new file mode 100644 index 0000000..93c089d --- /dev/null +++ b/sonar-web-frontend-typescript/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + + fr.sii.sonar + sonar-sii-plugin-parent + 2.0.1-SNAPSHOT + + + sonar-web-frontend-typescript + sonar-plugin + + SII web frontend plugin :: TypeScript + Consume reports generated by tslint for code quality. Also consume reports for code duplication (either simian or cpd). Consumes the unit/integration tests reports (generated by Jasmin) coverage report (lcov generated by Istanbul). The information generated by reports are added in Sonar + + + + fr.sii.sonar + sonar-report-core + ${project.version} + + + fr.sii.sonar + sonar-coverage-lcov + ${project.version} + + + fr.sii.sonar + sonar-test-junit + ${project.version} + + + fr.sii.sonar + sonar-duplication-cpd + ${project.version} + + + fr.sii.sonar + sonar-duplication-simian + ${project.version} + + + + + + + org.codehaus.sonar + sonar-packaging-maven-plugin + ${sonar.plugin.version} + true + + fr.sii.sonar.web.frontend.typescript.TypeScriptPlugin + + + + + + diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScript.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScript.java new file mode 100644 index 0000000..d93be14 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScript.java @@ -0,0 +1,14 @@ +package fr.sii.sonar.web.frontend.typescript; + +import org.sonar.api.config.Settings; + +import fr.sii.sonar.report.core.common.language.ConfigurableLanguage; + +public class TypeScript extends ConfigurableLanguage { + + public TypeScript(Settings settings) { + super(settings, TypeScriptLanguageConstants.LANGUAGE_KEY, TypeScriptLanguageConstants.FILE_SUFFIXES_KEY, TypeScriptLanguageConstants.FILE_SUFFIXES_DEFVALUE, "TS"); + } + + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScriptLanguageConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScriptLanguageConstants.java new file mode 100644 index 0000000..cd06c43 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScriptLanguageConstants.java @@ -0,0 +1,16 @@ +package fr.sii.sonar.web.frontend.typescript; + +import fr.sii.sonar.report.core.common.ReportConstants; +import fr.sii.sonar.report.core.common.language.LanguageConstants; + +public abstract class TypeScriptLanguageConstants implements ReportConstants, LanguageConstants { + public static final String FILE_SUFFIXES_KEY = "sonar.sii.ts.suffixes"; + public static final String FILE_SUFFIXES_DEFVALUE = ".ts"; + public static final String LANGUAGE_KEY = "ts"; + public static final String CATEGORY = "TypeScript"; + public static final String SUB_CATEGORY = "General"; + + public String getLanguageKey() { + return LANGUAGE_KEY; + } +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScriptPlugin.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScriptPlugin.java new file mode 100644 index 0000000..31e577e --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScriptPlugin.java @@ -0,0 +1,219 @@ +package fr.sii.sonar.web.frontend.typescript; + +import java.util.Arrays; +import java.util.List; + +import org.sonar.api.SonarPlugin; +import org.sonar.api.config.PropertyDefinition; +import org.sonar.api.resources.Qualifiers; + +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.web.frontend.typescript.coverage.LcovIntegrationCoverageConstants; +import fr.sii.sonar.web.frontend.typescript.coverage.LcovIntegrationCoverageSensor; +import fr.sii.sonar.web.frontend.typescript.coverage.LcovOverallCoverageConstants; +import fr.sii.sonar.web.frontend.typescript.coverage.LcovOverallCoverageSensor; +import fr.sii.sonar.web.frontend.typescript.coverage.LcovUnitCoverageConstants; +import fr.sii.sonar.web.frontend.typescript.coverage.LcovUnitCoverageSensor; +import fr.sii.sonar.web.frontend.typescript.duplication.TypeScriptDuplicationConstants; +import fr.sii.sonar.web.frontend.typescript.duplication.TypeScriptDuplicationSensor; +import fr.sii.sonar.web.frontend.typescript.quality.TslintQualityConstants; +import fr.sii.sonar.web.frontend.typescript.quality.TslintQualitySensor; +import fr.sii.sonar.web.frontend.typescript.quality.TslintProfileDefinition; +import fr.sii.sonar.web.frontend.typescript.quality.TslintRulesDefinition; +import fr.sii.sonar.web.frontend.typescript.test.JUnitConstants; +import fr.sii.sonar.web.frontend.typescript.test.JUnitIntegrationConstants; +import fr.sii.sonar.web.frontend.typescript.test.JUnitIntegrationReportSensor; +import fr.sii.sonar.web.frontend.typescript.test.JUnitReportSensor; + +/** + * This class is the entry point for all extensions + */ +public final class TypeScriptPlugin extends SonarPlugin { + + + // This is where you're going to declare all your Sonar extensions + @SuppressWarnings({ "rawtypes" }) + public List getExtensions() { + return Arrays.asList( + // needed here for standalone version + PluginDependencies.class, + + // general configuration + PropertyDefinition.builder(TypeScriptLanguageConstants.FILE_SUFFIXES_KEY) + .defaultValue(TypeScriptLanguageConstants.FILE_SUFFIXES_DEFVALUE) + .category(TypeScriptLanguageConstants.CATEGORY) + .subCategory(TypeScriptLanguageConstants.SUB_CATEGORY) + .name("File suffixes for TypeScript files") + .description("Comma-separated list of suffixes for files to analyze.") + .onQualifiers(Qualifiers.PROJECT) + .build(), + + TypeScript.class, + + // Quality configuration + PropertyDefinition.builder(TslintQualityConstants.REPORT_PATH_KEY) + .defaultValue(TslintQualityConstants.REPORT_PATH_DEFVALUE) + .category(TslintQualityConstants.CATEGORY) + .subCategory(TslintQualityConstants.SUB_CATEGORY) + .name("TypeScript quality report path") + .description("The path to the TypeScript report file to load") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(TslintQualityConstants.FAIL_MISSING_FILE_KEY) + .defaultValue(TslintQualityConstants.FAIL_MISSING_FILE_DEFVALUE) + .category(TslintQualityConstants.CATEGORY) + .subCategory(TslintQualityConstants.SUB_CATEGORY) + .name("Fail on missing source file") + .description("True to stop analysis if a source file is not found") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(TslintQualityConstants.SKIP_FILE_METRICS_KEY) + .defaultValue(TslintQualityConstants.SKIP_FILE_METRICS_DEFVALUE) + .category(TslintQualityConstants.CATEGORY) + .subCategory(TslintQualityConstants.SUB_CATEGORY) + .name("Skip save of file metrics") + .description("If you have several plugins that are able to handle TypeScript, you may have an error (Can not add the same measure twice). Set it to true to let the other plugin save the metrics") + .onQualifiers(Qualifiers.PROJECT) + .build(), + + TslintQualityConstants.class, + TslintRulesDefinition.class, + TslintProfileDefinition.class, + TslintQualitySensor.class, + + // Unit coverage configuration + PropertyDefinition.builder(LcovUnitCoverageConstants.REPORT_PATH_KEY) + .defaultValue(LcovUnitCoverageConstants.REPORT_PATH_DEFVALUE) + .category(LcovUnitCoverageConstants.CATEGORY) + .subCategory(LcovUnitCoverageConstants.SUB_CATEGORY) + .name("TypeScript unit tests coverage report path") + .description("The path to the TypeScript report file to load for unit tests coverage") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(LcovUnitCoverageConstants.FAIL_MISSING_FILE_KEY) + .defaultValue(LcovUnitCoverageConstants.FAIL_MISSING_FILE_DEFVALUE) + .category(LcovUnitCoverageConstants.CATEGORY) + .subCategory(LcovUnitCoverageConstants.SUB_CATEGORY) + .name("Fail on missing source file") + .description("True to stop analysis if a source file is not found") + .onQualifiers(Qualifiers.PROJECT) + .build(), + + LcovUnitCoverageConstants.class, + LcovUnitCoverageSensor.class, + + // Integration coverage configuration + PropertyDefinition.builder(LcovIntegrationCoverageConstants.REPORT_PATH_KEY) + .defaultValue(LcovIntegrationCoverageConstants.REPORT_PATH_DEFVALUE) + .category(LcovIntegrationCoverageConstants.CATEGORY) + .subCategory(LcovIntegrationCoverageConstants.SUB_CATEGORY) + .name("TypeScript integration tests coverage report path") + .description("The path to the TypeScript report file to load for integration tests coverage") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(LcovIntegrationCoverageConstants.FAIL_MISSING_FILE_KEY) + .defaultValue(LcovIntegrationCoverageConstants.FAIL_MISSING_FILE_DEFVALUE) + .category(LcovIntegrationCoverageConstants.CATEGORY) + .subCategory(LcovIntegrationCoverageConstants.SUB_CATEGORY) + .name("Fail on missing source file") + .description("True to stop analysis if a source file is not found") + .onQualifiers(Qualifiers.PROJECT) + .build(), + + LcovIntegrationCoverageConstants.class, + LcovIntegrationCoverageSensor.class, + + // Overall coverage configuration + PropertyDefinition.builder(LcovOverallCoverageConstants.REPORT_PATH_KEY) + .defaultValue(LcovOverallCoverageConstants.REPORT_PATH_DEFVALUE) + .category(LcovOverallCoverageConstants.CATEGORY) + .subCategory(LcovOverallCoverageConstants.SUB_CATEGORY) + .name("TypeScript overall tests coverage report path") + .description("The path to the TypeScript report file to load for overall tests coverage") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(LcovOverallCoverageConstants.FAIL_MISSING_FILE_KEY) + .defaultValue(LcovOverallCoverageConstants.FAIL_MISSING_FILE_DEFVALUE) + .category(LcovOverallCoverageConstants.CATEGORY) + .subCategory(LcovOverallCoverageConstants.SUB_CATEGORY) + .name("Fail on missing source file") + .description("True to stop analysis if a source file is not found") + .onQualifiers(Qualifiers.PROJECT) + .build(), + + LcovOverallCoverageConstants.class, + LcovOverallCoverageSensor.class, + + // Unit testing configuration + PropertyDefinition.builder(JUnitConstants.REPORT_PATH_KEY) + .defaultValue(JUnitConstants.REPORT_PATH_DEFVALUE) + .category(JUnitConstants.CATEGORY) + .subCategory(JUnitConstants.SUB_CATEGORY) + .name("TypeScript junit unit test report path") + .description("The path to the TypeScript report file to load that contains unit test results") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(JUnitConstants.FAIL_MISSING_FILE_KEY) + .defaultValue(JUnitConstants.FAIL_MISSING_FILE_DEFVALUE) + .category(JUnitConstants.CATEGORY) + .subCategory(JUnitConstants.SUB_CATEGORY) + .name("Fail on missing test file") + .description("True to stop analysis if a test file is not found") + .onQualifiers(Qualifiers.PROJECT) + .build(), + + JUnitConstants.class, + JUnitReportSensor.class, + + // Integration testing configuration + PropertyDefinition.builder(JUnitIntegrationConstants.REPORT_PATH_KEY) + .defaultValue(JUnitIntegrationConstants.REPORT_PATH_DEFVALUE) + .category(JUnitIntegrationConstants.CATEGORY) + .subCategory(JUnitIntegrationConstants.SUB_CATEGORY) + .name("TypeScript junit integration test report path") + .description("The path to the TypeScript report file to load that contains integration test results") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(JUnitIntegrationConstants.FAIL_MISSING_FILE_KEY) + .defaultValue(JUnitIntegrationConstants.FAIL_MISSING_FILE_DEFVALUE) + .category(JUnitIntegrationConstants.CATEGORY) + .subCategory(JUnitIntegrationConstants.SUB_CATEGORY) + .name("Fail on missing test file") + .description("True to stop analysis if a test file is not found") + .onQualifiers(Qualifiers.PROJECT) + .build(), + + JUnitIntegrationConstants.class, + JUnitIntegrationReportSensor.class, + + // Duplication configuration + PropertyDefinition.builder(TypeScriptDuplicationConstants.REPORT_PATH_KEY) + .defaultValue(TypeScriptDuplicationConstants.REPORT_PATH_DEFVALUE) + .category(TypeScriptDuplicationConstants.CATEGORY) + .subCategory(TypeScriptDuplicationConstants.SUB_CATEGORY) + .name("TypeScript duplication report path") + .description("The path to the TypeScript report file to load") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(TypeScriptDuplicationConstants.FAIL_MISSING_FILE_KEY) + .defaultValue(TypeScriptDuplicationConstants.FAIL_MISSING_FILE_DEFVALUE) + .category(TypeScriptDuplicationConstants.CATEGORY) + .subCategory(TypeScriptDuplicationConstants.SUB_CATEGORY) + .name("Fail on missing source file") + .description("True to stop analysis if a source file is not found") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(TypeScriptDuplicationConstants.SKIP_DUPLICATION_KEY) + .defaultValue(TypeScriptDuplicationConstants.SKIP_DUPLICATION_DEFVAL) + .category(TypeScriptDuplicationConstants.CATEGORY) + .subCategory(TypeScriptDuplicationConstants.SUB_CATEGORY) + .name("Skip duplication analysis") + .description("True to skip code duplication analysis done by this plugin") + .onQualifiers(Qualifiers.PROJECT) + .build(), + + TypeScriptDuplicationConstants.class, + TypeScriptDuplicationSensor.class + ); + } +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovIntegrationCoverageConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovIntegrationCoverageConstants.java new file mode 100644 index 0000000..cb794f7 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovIntegrationCoverageConstants.java @@ -0,0 +1,22 @@ +package fr.sii.sonar.web.frontend.typescript.coverage; + +import fr.sii.sonar.report.core.common.ReportConstants; +import fr.sii.sonar.report.core.coverage.CoverageConstants; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class LcovIntegrationCoverageConstants extends TypeScriptLanguageConstants implements ReportConstants, CoverageConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.coverage.it.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.coverage.it.ts.file.missing.fail"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/ts-it.lcov"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String SUB_CATEGORY = "Coverage"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovIntegrationCoverageSensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovIntegrationCoverageSensor.java new file mode 100644 index 0000000..7856225 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovIntegrationCoverageSensor.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.web.frontend.typescript.coverage; + +import fr.sii.sonar.coverage.lcov.factory.LcovProviderFactory; +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.coverage.domain.CoverageReport; +import fr.sii.sonar.report.core.coverage.factory.IntegrationCoverageSaverFactory; + +/** + * Sensor specific to TypeScript code coverage for integration tests that loads LCOV report + * + * @author Aurélien Baudet + * + */ +public class LcovIntegrationCoverageSensor extends ReportSensor { + + public LcovIntegrationCoverageSensor(LcovIntegrationCoverageConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new LcovProviderFactory(), new IntegrationCoverageSaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovOverallCoverageConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovOverallCoverageConstants.java new file mode 100644 index 0000000..b4ff4db --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovOverallCoverageConstants.java @@ -0,0 +1,22 @@ +package fr.sii.sonar.web.frontend.typescript.coverage; + +import fr.sii.sonar.report.core.common.ReportConstants; +import fr.sii.sonar.report.core.coverage.CoverageConstants; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class LcovOverallCoverageConstants extends TypeScriptLanguageConstants implements ReportConstants, CoverageConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.coverage.overall.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.coverage.overall.ts.file.missing.fail"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/ts-overall.lcov"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String SUB_CATEGORY = "Coverage"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovOverallCoverageSensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovOverallCoverageSensor.java new file mode 100644 index 0000000..82c4579 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovOverallCoverageSensor.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.web.frontend.typescript.coverage; + +import fr.sii.sonar.coverage.lcov.factory.LcovProviderFactory; +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.coverage.domain.CoverageReport; +import fr.sii.sonar.report.core.coverage.factory.OverallCoverageSaverFactory; + +/** + * Sensor specific to TypeScript code coverage for overall tests that loads LCOV report + * + * @author Aurélien Baudet + * + */ +public class LcovOverallCoverageSensor extends ReportSensor { + + public LcovOverallCoverageSensor(LcovOverallCoverageConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new LcovProviderFactory(), new OverallCoverageSaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovUnitCoverageConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovUnitCoverageConstants.java new file mode 100644 index 0000000..8942b1d --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovUnitCoverageConstants.java @@ -0,0 +1,22 @@ +package fr.sii.sonar.web.frontend.typescript.coverage; + +import fr.sii.sonar.report.core.common.ReportConstants; +import fr.sii.sonar.report.core.coverage.CoverageConstants; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class LcovUnitCoverageConstants extends TypeScriptLanguageConstants implements ReportConstants, CoverageConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.coverage.ut.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.coverage.ut.ts.file.missing.fail"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/ts-ut.lcov"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String SUB_CATEGORY = "Coverage"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovUnitCoverageSensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovUnitCoverageSensor.java new file mode 100644 index 0000000..9e30994 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovUnitCoverageSensor.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.web.frontend.typescript.coverage; + +import fr.sii.sonar.coverage.lcov.factory.LcovProviderFactory; +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.coverage.domain.CoverageReport; +import fr.sii.sonar.report.core.coverage.factory.UnitCoverageSaverFactory; + +/** + * Sensor specific to TypeScript code coverage for unit tests that loads LCOV report + * + * @author Aurélien Baudet + * + */ +public class LcovUnitCoverageSensor extends ReportSensor { + + public LcovUnitCoverageSensor(LcovUnitCoverageConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new LcovProviderFactory(), new UnitCoverageSaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/duplication/TypeScriptDuplicationConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/duplication/TypeScriptDuplicationConstants.java new file mode 100644 index 0000000..8f779b2 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/duplication/TypeScriptDuplicationConstants.java @@ -0,0 +1,27 @@ +package fr.sii.sonar.web.frontend.typescript.duplication; + +import fr.sii.sonar.report.core.duplication.DuplicationConstants; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class TypeScriptDuplicationConstants extends TypeScriptLanguageConstants implements DuplicationConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.duplication.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.duplication.ts.file.missing.fail"; + public static final String SKIP_DUPLICATION_KEY = "sonar.sii.duplication.ts.skip"; + public static final String SKIP_DUPLICATION_DEFVAL = "false"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/ts-duplication.xml"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String SUB_CATEGORY = "Duplication"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + + public String getSkipDuplicationKey() { + return SKIP_DUPLICATION_KEY; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/duplication/TypeScriptDuplicationSensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/duplication/TypeScriptDuplicationSensor.java new file mode 100644 index 0000000..33adbfa --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/duplication/TypeScriptDuplicationSensor.java @@ -0,0 +1,24 @@ +package fr.sii.sonar.web.frontend.typescript.duplication; + +import fr.sii.sonar.duplication.cpd.provider.CpdProvider; +import fr.sii.sonar.duplication.simian.provider.SimianProvider; +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.common.factory.FallbackProviderFactory; +import fr.sii.sonar.report.core.duplication.domain.DuplicationReport; +import fr.sii.sonar.report.core.duplication.factory.DuplicationSaverFactory; + +/** + * Sensor specific to code duplication that loads duplication report (either CPD or Simian) + * + * @author Aurélien Baudet + * + */ +public class TypeScriptDuplicationSensor extends ReportSensor { + + @SuppressWarnings({ "unchecked" }) + public TypeScriptDuplicationSensor(TypeScriptDuplicationConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new FallbackProviderFactory(CpdProvider.class, SimianProvider.class), new DuplicationSaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintProfileDefinition.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintProfileDefinition.java new file mode 100644 index 0000000..ee36789 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintProfileDefinition.java @@ -0,0 +1,20 @@ +package fr.sii.sonar.web.frontend.typescript.quality; + +import org.sonar.api.rules.RuleFinder; + +import fr.sii.sonar.report.core.quality.profile.JsonProfileParser; +import fr.sii.sonar.report.core.quality.profile.ProfileFileDefinition; + +/** + * Just a specific implementation to help dependency injection + * + * @author Aurélien Baudet + * + */ +public class TslintProfileDefinition extends ProfileFileDefinition { + + public TslintProfileDefinition(RuleFinder ruleFinder, TslintQualityConstants constants) { + super(constants.getProfileJsonPath(), new JsonProfileParser(), ruleFinder); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintQualityConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintQualityConstants.java new file mode 100644 index 0000000..94d18c1 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintQualityConstants.java @@ -0,0 +1,49 @@ +package fr.sii.sonar.web.frontend.typescript.quality; + +import fr.sii.sonar.report.core.common.rules.RulesDefinitionConstants; +import fr.sii.sonar.report.core.quality.ProfileDefinitionConstants; +import fr.sii.sonar.report.core.quality.QualityConstants; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class TslintQualityConstants extends TypeScriptLanguageConstants implements QualityConstants, RulesDefinitionConstants, ProfileDefinitionConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.quality.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.quality.ts.file.missing.fail"; + public static final String SKIP_FILE_METRICS_KEY = "sonar.sii.quality.ts.file.metrics.skip"; + public static final String SKIP_FILE_METRICS_DEFVALUE = "false"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/tslint.json"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String RULES_PATH = "/rules/tslint.json"; + public static final String REPOSITORY_NAME = "TSLint"; + public static final String REPOSITORY_KEY = "tslint"; + public static final String SUB_CATEGORY = "Quality"; + public static final String PROFILE_PATH = "/profiles/tslint.json"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getRepositoryKey() { + return REPOSITORY_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + + public String getRepositoryName() { + return REPOSITORY_NAME; + } + + public String getRulesJsonPath() { + return RULES_PATH; + } + + public String getProfileJsonPath() { + return PROFILE_PATH; + } + + public String getSkipFileMetricsKey() { + return SKIP_FILE_METRICS_KEY; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintQualitySensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintQualitySensor.java new file mode 100644 index 0000000..43123fd --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintQualitySensor.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.web.frontend.typescript.quality; + +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.quality.domain.report.QualityReport; +import fr.sii.sonar.report.core.quality.factory.JsonQualityReportProviderFactory; +import fr.sii.sonar.report.core.quality.factory.QualitySaverFactory; + +/** + * Just a specific implementation to help dependency injection + * + * @author Aurélien Baudet + * + */ +public class TslintQualitySensor extends ReportSensor { + + public TslintQualitySensor(TslintQualityConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new JsonQualityReportProviderFactory(), new QualitySaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintRulesDefinition.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintRulesDefinition.java new file mode 100644 index 0000000..5c55c6c --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintRulesDefinition.java @@ -0,0 +1,17 @@ +package fr.sii.sonar.web.frontend.typescript.quality; + +import fr.sii.sonar.report.core.common.rules.ComposableRulesDefinition; + +/** + * Repository for tslint rules + * + * @author Aurélien Baudet + * + */ +public class TslintRulesDefinition extends ComposableRulesDefinition { + + public TslintRulesDefinition(TslintQualityConstants constants) { + super(constants); + } + +} \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitConstants.java new file mode 100644 index 0000000..745ebd0 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitConstants.java @@ -0,0 +1,26 @@ +package fr.sii.sonar.web.frontend.typescript.test; + +import fr.sii.sonar.report.core.test.TestConstants; +import fr.sii.sonar.report.core.test.domain.Type; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class JUnitConstants extends TypeScriptLanguageConstants implements TestConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.test.ut.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.test.ut.ts.file.missing.fail"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/ts-ut.xml"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String SUB_CATEGORY = "Unit testing"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + + public Type getType() { + return Type.UNIT; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitIntegrationConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitIntegrationConstants.java new file mode 100644 index 0000000..05ed208 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitIntegrationConstants.java @@ -0,0 +1,26 @@ +package fr.sii.sonar.web.frontend.typescript.test; + +import fr.sii.sonar.report.core.test.TestConstants; +import fr.sii.sonar.report.core.test.domain.Type; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class JUnitIntegrationConstants extends TypeScriptLanguageConstants implements TestConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.test.it.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.test.it.ts.file.missing.fail"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/ts-it.xml"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String SUB_CATEGORY = "Integration testing"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + + public Type getType() { + return Type.INTEGRATION; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitIntegrationReportSensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitIntegrationReportSensor.java new file mode 100644 index 0000000..221cb0e --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitIntegrationReportSensor.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.web.frontend.typescript.test; + +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.test.domain.TestReport; +import fr.sii.sonar.report.core.test.factory.TestSaverFactory; +import fr.sii.sonar.report.test.junit.factory.JUnitFallbackProviderFactory; + +/** + * Sensor specialized to load JUnit report file and save integration test measures + * + * @author Aurélien Baudet + * + */ +public class JUnitIntegrationReportSensor extends ReportSensor { + + public JUnitIntegrationReportSensor(JUnitIntegrationConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new JUnitFallbackProviderFactory(), new TestSaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitReportSensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitReportSensor.java new file mode 100644 index 0000000..0c307c2 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitReportSensor.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.web.frontend.typescript.test; + +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.test.domain.TestReport; +import fr.sii.sonar.report.core.test.factory.TestSaverFactory; +import fr.sii.sonar.report.test.junit.factory.JUnitFallbackProviderFactory; + +/** + * Sensor specialized to load JUnit report file and save unit test measures + * + * @author Aurélien Baudet + * + */ +public class JUnitReportSensor extends ReportSensor { + + public JUnitReportSensor(JUnitConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new JUnitFallbackProviderFactory(), new TestSaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/resources/profiles/tslint.json b/sonar-web-frontend-typescript/src/main/resources/profiles/tslint.json new file mode 100644 index 0000000..41f1eb5 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/profiles/tslint.json @@ -0,0 +1,12 @@ +{ + "name": "tslint", + "language": "ts", + "repositories": [{ + "key": "tslint", + "rules": "/rules/tslint.json" + }], + "rules": [{ + "repositoryKey": "tslint", + "key": "unknown-rule" + }] +} \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/jshint.css b/sonar-web-frontend-typescript/src/main/resources/rules/jshint.css new file mode 100644 index 0000000..e69de29 diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint.json b/sonar-web-frontend-typescript/src/main/resources/rules/tslint.json new file mode 100644 index 0000000..4d95136 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint.json @@ -0,0 +1,877 @@ +[ { + "key" : "member-access", + "name" : "Member access", + "description" : "Requires explicit visibility declarations for class members.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "member-ordering", + "name" : "Member ordering", + "description" : "Enforces member ordering.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-any", + "name" : "No any", + "description" : "Diallows usages of any as a type declaration.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-inferrable-types", + "name" : "No inferrable types", + "description" : "Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.", + "severity" : "INFO", + "status" : null, + "tags" : [ "tslint", "convention", "useless", "performance" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-internal-module", + "name" : "No internal module", + "description" : "Disallows internal module", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "convention", "confusing", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-namespace", + "name" : "No namespace", + "description" : "Disallows use of internal modules and namespaces.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "convention", "obsolete", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "no-reference", + "name" : "No reference", + "description" : "Disallows /// imports (use ES6-style imports instead).", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "obsolete", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "no-var-requires", + "name" : "No var requires", + "description" : "Disallows the use of require statements except in import statements.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "convention", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "MAINTAINABILITY_COMPLIANCE" + } +}, { + "key" : "typedef", + "name" : "Typedef", + "description" : "Requires type definitions to exist.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "typedef-whitespace", + "name" : "Typedef whitespace", + "description" : "Requires or disallows whitespace for type definitions.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ban", + "name" : "Ban", + "description" : "Bans the use of specific functions.", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "tslint", "convention", "forbidden" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "curly", + "name" : "Curly", + "description" : "Enforces braces for if/for/do/while statements.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "convention", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "forin", + "name" : "Forin", + "description" : "Requires a for ... in statement to be filtered with an if statement.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "suspicious", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "label-position", + "name" : "Label position", + "description" : "Only allows labels in sensible locations.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "label-undefined", + "name" : "Label undefined", + "description" : "Checks that labels are defined before usage.", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "tslint", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "no-arg", + "name" : "No arg", + "description" : "Disallows use of arguments.callee.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "performance", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "CPU_EFFICIENCY" + } +}, { + "key" : "no-bitwise", + "name" : "No bitwise", + "description" : "Disallows bitwise operators.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "suspicious", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-conditional-assignment", + "name" : "No conditional assignment", + "description" : "Disallows any type of assignment in conditionals.", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "tslint", "suspicious", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-console", + "name" : "No console", + "description" : "Bans the use of specified console methods.", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "tslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-construct", + "name" : "No construct", + "description" : "Disallows access to the constructors of String, Number, and Boolean.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-debugger", + "name" : "No debugger", + "description" : "Disallows debugger statements.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-duplicate-key", + "name" : "No duplicate key", + "description" : "Disallows duplicate keys in object literals.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "bad-practice", "suspicious", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-duplicate-variable", + "name" : "No duplicate variable", + "description" : "Disallows duplicate variable declarations in the same block scope.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-empty", + "name" : "No empty", + "description" : "Disallows empty blocks.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-eval", + "name" : "No eval", + "description" : "Disallows eval function invocations.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "bad-practice", "security" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "API_ABUSE" + } +}, { + "key" : "no-invalid-this", + "name" : "No invalid this", + "description" : "Disallows using the this keyword outside of classes.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-null-keyword", + "name" : "No null keyword", + "description" : "Disallows use of the null keyword literal.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-shadowed-variable", + "name" : "No shadowed variable", + "description" : "Disallows shadowing variable declarations.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-string-literal", + "name" : "No string literal", + "description" : "Disallows object access via string literals.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "convention", "pitfall", "type-safe" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_CHANGEABILITY" + } +}, { + "key" : "no-switch-case-fall-through", + "name" : "No switch case fall through", + "description" : "Disallows falling through case statements.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "pitfall", "bad-practice" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-unreachable", + "name" : "No unreachable", + "description" : "Disallows unreachable code after break, catch, throw, and return statements.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "suspicious", "bad-practice", "dead-code" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-unused-expression", + "name" : "No unused expression", + "description" : "Disallows unused expression statements.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "suspicious", "bad-practice", "unused" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-unused-variable", + "name" : "No unused variable", + "description" : "Disallows unused imports, variables, functions and private class members.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "bad-practice", "unused" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-use-before-declare", + "name" : "No use before declare", + "description" : "Disallows usage of variables before their declaration.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-var-keyword", + "name" : "No var keyword", + "description" : "Disallows usage of the var keyword.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "radix", + "name" : "Radix", + "description" : "Requires the radix parameter to be specified when calling parseInt.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "bad-practice", "pitfall" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "switch-default", + "name" : "Switch default", + "description" : "Require a default case in all switch statements.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "convention", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "DATA_CHANGEABILITY" + } +}, { + "key" : "triple-equals", + "name" : "Triple equals", + "description" : "Requires === and !== in place of == and !=.", + "severity" : "CRITICAL", + "status" : null, + "tags" : [ "tslint", "bad-practice", "pitfall", "suspicious" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "use-isnan", + "name" : "Use isnan", + "description" : "Enforces use of the isNaN() function to check for NaN references instead of a comparison to the NaN constant.", + "severity" : "BLOCKER", + "status" : null, + "tags" : [ "tslint", "bad-practice", "bug" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "use-strict", + "name" : "Use strict", + "description" : "Requires using ECMAScript 5’s strict mode.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "eofline", + "name" : "Eofline", + "description" : "Ensures the file ends with a newline.", + "severity" : "INFO", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "indent", + "name" : "Indent", + "description" : "Enforces indentation with tabs or spaces.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "max-line-length", + "name" : "Max line length", + "description" : "Requires lines to be under a certain max length.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-default-export", + "name" : "No default export", + "description" : "Disallows default exports in ES6-style modules.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "tools" ], + "debt" : null +}, { + "key" : "no-require-imports", + "name" : "No require imports", + "description" : "Disallows invocation of require().", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "convention", "es6" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "no-trailing-whitespace", + "name" : "No trailing whitespace", + "description" : "Disallows trailing whitespace at the end of a line.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "object-literal-sort-keys", + "name" : "Object literal sort keys", + "description" : "Requires keys in object literals to be sorted alphabetically", + "severity" : "INFO", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "trailing-comma", + "name" : "Trailing comma", + "description" : "Requires or disallows trailing commas in array and object literals, destructuring assignments and named imports.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "align", + "name" : "Align", + "description" : "Enforces vertical alignment.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "class-name", + "name" : "Class name", + "description" : "Enforces PascalCased class and interface names.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "comment-format", + "name" : "Comment format", + "description" : "Enforces formatting rules for single-line comments.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "interface-name", + "name" : "Interface name", + "description" : "Requires interface names to begin with a capital ‘I’", + "severity" : "INFO", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "jsdoc-format", + "name" : "Jsdoc format", + "description" : "Enforces basic format rules for JSDoc comments.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "new-parens", + "name" : "New parens", + "description" : "Requires parentheses when invoking a constructor via the new keyword.", + "severity" : "MAJOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-angle-bracket-type-assertion", + "name" : "No angle bracket type assertion", + "description" : "Requires the use of as Type for type assertions instead of .", + "severity" : "INFO", + "status" : null, + "tags" : [ "tslint", "convention", "react" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "no-consecutive-blank-lines", + "name" : "No consecutive blank lines", + "description" : "Disallows more than one blank line in a row.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-constructor-vars", + "name" : "No constructor vars", + "description" : "Disallows parameter properties.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "one-line", + "name" : "One line", + "description" : "Requires the specified tokens to be on the same line as the expression preceding them.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "one-variable-per-declaration", + "name" : "One variable per declaration", + "description" : "Disallows multiple variable definitions in the same declaration statement.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "quotemark", + "name" : "Quotemark", + "description" : "Requires single or double quotes for string literals.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention", "consistency" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "semicolon", + "name" : "Semicolon", + "description" : "Enforces consistent semicolon usage at the end of every statement.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "variable-name", + "name" : "Variable name", + "description" : "Checks variable names for various errors.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "whitespace", + "name" : "Whitespace", + "description" : "Enforces whitespace style conventions.", + "severity" : "MINOR", + "status" : null, + "tags" : [ "tslint", "convention" ], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +} ] \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/align.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/align.html new file mode 100644 index 0000000..a482512 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/align.html @@ -0,0 +1,38 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: align

                                                          +

                                                          +
                                                          + + +

                                                          Enforces vertical alignment.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Helps maintain a readable, consistent style in your codebase.

                                                          + + + + +

                                                          Config

                                                          + +

                                                          Three arguments may be optionally provided:

                                                          + +
                                                            +
                                                          • "parameters" checks alignment of function parameters.
                                                          • +
                                                          • "arguments" checks alignment of function call arguments.
                                                          • +
                                                          • "statements" checks alignment of statements.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "align": [true, "parameters", "statements"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "arguments",
                                                          "parameters",
                                                          "statements"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/ban.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/ban.html new file mode 100644 index 0000000..06a3383 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/ban.html @@ -0,0 +1,30 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: ban

                                                          +

                                                          +
                                                          + + +

                                                          Bans the use of specific functions.

                                                          + + +

                                                          At this time, there is no way to disable global methods with this rule.

                                                          + + + + + +

                                                          Config

                                                          +

                                                          A list of ['object', 'method'] pairs which ban object.method().

                                                          + + +
                                                          Examples
                                                          + +
                                                          "ban": [true, ["console", "log"], ["someObject", "someFunction"]]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "array",
                                                          "arrayMembers": [
                                                          {
                                                          "type": "string"
                                                          },
                                                          {
                                                          "type": "string"
                                                          }
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/class-name.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/class-name.html new file mode 100644 index 0000000..4ac5148 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/class-name.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: class-name

                                                          +

                                                          +
                                                          + + +

                                                          Enforces PascalCased class and interface names.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Makes it easy to differentitate classes from regular variables at a glance.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "class-name": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/comment-format.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/comment-format.html new file mode 100644 index 0000000..e89d167 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/comment-format.html @@ -0,0 +1,42 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: comment-format

                                                          +

                                                          +
                                                          + + +

                                                          Enforces formatting rules for single-line comments.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Helps maintain a consistent, readable style in your codebase.

                                                          + + + + +

                                                          Config

                                                          + +

                                                          Three arguments may be optionally provided:

                                                          + +
                                                            +
                                                          • "check-space" requires that all single-line comments must begin with a space, as in // comment +
                                                              +
                                                            • note that comments starting with /// are also allowed, for things such as ///<reference>
                                                            • +
                                                            +
                                                          • +
                                                          • "check-lowercase" requires that the first non-whitespace character of a comment must be lowercase, if applicable.
                                                          • +
                                                          • "check-uppercase" requires that the first non-whitespace character of a comment must be uppercase, if applicable.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "comment-format": [true, "check-space", "check-lowercase"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "check-space",
                                                          "check-lowercase",
                                                          "check-uppercase"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/curly.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/curly.html new file mode 100644 index 0000000..85f0c29 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/curly.html @@ -0,0 +1,36 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: curly

                                                          +

                                                          +
                                                          + + +

                                                          Enforces braces for if/for/do/while statements.

                                                          + + + +
                                                          Rationale
                                                          + +
                                                          if (foo === bar)
                                                          foo++;
                                                          bar++;
                                                          + +

                                                          In the code above, the author almost certainly meant for both foo++ and bar++ +to be executed only if foo === bar. However, he forgot braces and bar++ will be executed +no matter what. This rule could prevent such a mistake.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "curly": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/eofline.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/eofline.html new file mode 100644 index 0000000..e77e912 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/eofline.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: eofline

                                                          +

                                                          +
                                                          + + +

                                                          Ensures the file ends with a newline.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          It is a standard convention to end files with a newline.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "eofline": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/forin.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/forin.html new file mode 100644 index 0000000..3dca177 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/forin.html @@ -0,0 +1,35 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: forin

                                                          +

                                                          +
                                                          + + +

                                                          Requires a for ... in statement to be filtered with an if statement.

                                                          + + + +
                                                          Rationale
                                                          + +
                                                          for (let key in someObject) {
                                                          if (someObject.hasOwnProperty(key)) {
                                                          // code here
                                                          }
                                                          }
                                                          +

                                                          Prevents accidental interation over properties inherited from an object’s prototype. +See MDN’s for...in +documentation for more information about for...in loops.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "forin": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/indent.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/indent.html new file mode 100644 index 0000000..b432c9f --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/indent.html @@ -0,0 +1,39 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: indent

                                                          +

                                                          +
                                                          + + +

                                                          Enforces indentation with tabs or spaces.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          Using only one of tabs or spaces for indentation leads to more consistent editor behavior, +cleaner diffs in version control, and easier programatic manipulation.

                                                          + + + + +

                                                          Config

                                                          + +

                                                          One of the following arguments must be provided:

                                                          + +
                                                            +
                                                          • "spaces" enforces consistent spaces.
                                                          • +
                                                          • "tabs" enforces consistent tabs.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "indent": [true, "spaces"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "tabs",
                                                          "spaces"
                                                          ]
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/interface-name.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/interface-name.html new file mode 100644 index 0000000..ba0a4a1 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/interface-name.html @@ -0,0 +1,39 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: interface-name

                                                          +

                                                          +
                                                          + + +

                                                          Requires interface names to begin with a capital ‘I’

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Makes it easy to differentitate interfaces from regular classes at a glance.

                                                          + + + + +

                                                          Config

                                                          + +

                                                          One of the following two options must be provided:

                                                          + +
                                                            +
                                                          • "always-prefix" requires interface names to start with an “I”
                                                          • +
                                                          • "never-prefix" requires interface names to not have an “I” prefix
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "interface-name": [true, "always-prefix"]
                                                          + +
                                                          "interface-name": [true, "never-prefix"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "always-prefix",
                                                          "never-prefix"
                                                          ]
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/jsdoc-format.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/jsdoc-format.html new file mode 100644 index 0000000..9967284 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/jsdoc-format.html @@ -0,0 +1,42 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: jsdoc-format

                                                          +

                                                          +
                                                          + + +

                                                          Enforces basic format rules for JSDoc comments.

                                                          + + + +

                                                          The following rules are enforced for JSDoc comments (comments starting with /**):

                                                          + +
                                                            +
                                                          • each line contains an asterisk and asterisks must be aligned
                                                          • +
                                                          • each asterisk must be followed by either a space or a newline (except for the first and the last)
                                                          • +
                                                          • the only characters before the asterisk on each line must be whitespace characters
                                                          • +
                                                          • one line comments must start with /** and end with */
                                                          • +
                                                          + + + +
                                                          Rationale
                                                          +

                                                          Helps maintain a consistent, readable style for JSDoc comments.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "jsdoc-format": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/label-position.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/label-position.html new file mode 100644 index 0000000..813f060 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/label-position.html @@ -0,0 +1,37 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: label-position

                                                          +

                                                          +
                                                          + + +

                                                          Only allows labels in sensible locations.

                                                          + + +

                                                          This rule only allows labels to be on do/for/while/switch statements.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          Labels in JavaScript only can be used in conjunction with break or continue, +constructs meant to be used for loop flow control. While you can theoretically use +labels on any block statement in JS, it is considered poor code structure to do so.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "label-position": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/label-undefined.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/label-undefined.html new file mode 100644 index 0000000..5fa9d1a --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/label-undefined.html @@ -0,0 +1,34 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: label-undefined

                                                          +

                                                          +
                                                          + + +

                                                          Checks that labels are defined before usage.

                                                          + + +

                                                          This rule is now implemented in the TypeScript compiler and does not need to be used.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Using break or continue to go to an out-of-scope label is an error in JS.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "label-undefined": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/max-line-length.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/max-line-length.html new file mode 100644 index 0000000..676917f --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/max-line-length.html @@ -0,0 +1,34 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: max-line-length

                                                          +

                                                          +
                                                          + + +

                                                          Requires lines to be under a certain max length.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          Limiting the length of a line of code improves code readability. +It also makes comparing code side-by-side easier and improves compatibility with +various editors, IDEs, and diff viewers.

                                                          + + + + +

                                                          Config

                                                          +

                                                          An integer indicating the max length of lines.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "max-line-length": [true, 120]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "number"
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/member-access.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/member-access.html new file mode 100644 index 0000000..12e1e63 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/member-access.html @@ -0,0 +1,39 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: member-access

                                                          +

                                                          +
                                                          + + +

                                                          Requires explicit visibility declarations for class members.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Explicit visibility declarations can make code more readable and accessible for those new to TS.

                                                          + + + + +

                                                          Config

                                                          + +

                                                          Two arguments may be optionally provided:

                                                          + +
                                                            +
                                                          • "check-accessor" enforces explicit visibility on get/set accessors (can only be public)
                                                          • +
                                                          • "check-constructor" enforces explicit visibility on constructors (can only be public)
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "member-access": true
                                                          + +
                                                          "member-access": [true, "check-accessor"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "check-accessor",
                                                          "check-constructor"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/member-ordering.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/member-ordering.html new file mode 100644 index 0000000..9fa58ac --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/member-ordering.html @@ -0,0 +1,59 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: member-ordering

                                                          +

                                                          +
                                                          + + +

                                                          Enforces member ordering.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          A consistent ordering for class members can make classes easier to read, navigate, and edit.

                                                          + + + + +

                                                          Config

                                                          + +

                                                          One argument, which is an object, must be provided. It should contain an order property. +The order property should have a value of one of the following strings:

                                                          + +
                                                            +
                                                          • fields-first
                                                          • +
                                                          • statics-first
                                                          • +
                                                          • instance-sandwich
                                                          • +
                                                          + +

                                                          Alternatively, the value for order maybe be an array consisting of the following strings:

                                                          + +
                                                            +
                                                          • public-static-field
                                                          • +
                                                          • protected-static-field
                                                          • +
                                                          • private-static-field
                                                          • +
                                                          • public-instance-field
                                                          • +
                                                          • protected-instance-field
                                                          • +
                                                          • private-instance-field
                                                          • +
                                                          • constructor
                                                          • +
                                                          • public-static-method
                                                          • +
                                                          • protected-static-method
                                                          • +
                                                          • private-static-method
                                                          • +
                                                          • public-instance-method
                                                          • +
                                                          • protected-instance-method
                                                          • +
                                                          • private-instance-method
                                                          • +
                                                          + +

                                                          This is useful if one of the preset orders does not meet your needs.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "member-ordering": [true, { "order": "fields-first" }]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "object",
                                                          "properties": {
                                                          "order": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "fields-first",
                                                          "statics-first",
                                                          "instance-sandwich"
                                                          ]
                                                          }
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/new-parens.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/new-parens.html new file mode 100644 index 0000000..085e9ff --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/new-parens.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: new-parens

                                                          +

                                                          +
                                                          + + +

                                                          Requires parentheses when invoking a constructor via the new keyword.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Maintains stylistic consistency with other function calls.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "new-parens": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-angle-bracket-type-assertion.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-angle-bracket-type-assertion.html new file mode 100644 index 0000000..4b5a7e4 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-angle-bracket-type-assertion.html @@ -0,0 +1,34 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-angle-bracket-type-assertion

                                                          +

                                                          +
                                                          + + +

                                                          Requires the use of as Type for type assertions instead of <Type>.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          Both formats of type assertions have the same effect, but only as type assertions +work in .tsx files. This rule ensures that you have a consistent type assertion style +across your codebase.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-angle-bracket-type-assertion": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-any.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-any.html new file mode 100644 index 0000000..4cdb8c1 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-any.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-any

                                                          +

                                                          +
                                                          + + +

                                                          Diallows usages of any as a type declaration.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Using any as a type declaration nullifies the compile-time benefits of the type system.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-any": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-arg.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-arg.html new file mode 100644 index 0000000..30e73f1 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-arg.html @@ -0,0 +1,34 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-arg

                                                          +

                                                          +
                                                          + + +

                                                          Disallows use of arguments.callee.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          Using arguments.callee makes various performance optimizations impossible. +See MDN +for more details on why to avoid arguments.callee.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-arg": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-bitwise.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-bitwise.html new file mode 100644 index 0000000..0382bb6 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-bitwise.html @@ -0,0 +1,41 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-bitwise

                                                          +

                                                          +
                                                          + + +

                                                          Disallows bitwise operators.

                                                          + + + +

                                                          Specifically, the following bitwise operators are banned: +&, &=, |, |=, +^, ^=, <<, <<=, +>>, >>=, >>>, >>>=, and ~. +This rule does not ban the use of & and | for intersection and union types.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          Bitwise operators are often typos - for example bool1 & bool2 instead of bool1 && bool2. +They also can be an indicator of overly clever code which decreases maintainability.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-bitwise": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-conditional-assignment.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-conditional-assignment.html new file mode 100644 index 0000000..3ecde97 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-conditional-assignment.html @@ -0,0 +1,37 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-conditional-assignment

                                                          +

                                                          +
                                                          + + +

                                                          Disallows any type of assignment in conditionals.

                                                          + + +

                                                          This applies to do-while, for, if, and while statements.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          Assignments in conditionals are often typos: +for example if (var1 = var2) instead of if (var1 == var2). +They also can be an indicator of overly clever code which decreases maintainability.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-conditional-assignment": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-consecutive-blank-lines.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-consecutive-blank-lines.html new file mode 100644 index 0000000..e9e014d --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-consecutive-blank-lines.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-consecutive-blank-lines

                                                          +

                                                          +
                                                          + + +

                                                          Disallows more than one blank line in a row.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Helps maintain a readable style in your codebase.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-consecutive-blank-lines": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-console.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-console.html new file mode 100644 index 0000000..479c9c4 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-console.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-console

                                                          +

                                                          +
                                                          + + +

                                                          Bans the use of specified console methods.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          In general, console methods aren’t appropriate for production code.

                                                          + + + + +

                                                          Config

                                                          +

                                                          A list of method names to ban.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-console": [true, ["log", "error"]]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "string"
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-construct.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-construct.html new file mode 100644 index 0000000..d433bb1 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-construct.html @@ -0,0 +1,37 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-construct

                                                          +

                                                          +
                                                          + + +

                                                          Disallows access to the constructors of String, Number, and Boolean.

                                                          + + +

                                                          Disallows constructor use such as new Number(foo) but does not disallow Number(foo).

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          There is little reason to use String, Number, or Boolean as constructors. +In almost all cases, the regular function-call version is more appropriate. +More details are available on StackOverflow.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-construct": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-constructor-vars.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-constructor-vars.html new file mode 100644 index 0000000..025d752 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-constructor-vars.html @@ -0,0 +1,33 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-constructor-vars

                                                          +

                                                          +
                                                          + + +

                                                          Disallows parameter properties.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          Parameter properties can be confusing to those new to TS as they are less explicit +than other ways of declaring and initializing class members.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-constructor-vars": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-debugger.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-debugger.html new file mode 100644 index 0000000..339dbbe --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-debugger.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-debugger

                                                          +

                                                          +
                                                          + + +

                                                          Disallows debugger statements.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          In general, debugger statements aren’t appropriate for production code.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-debugger": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-default-export.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-default-export.html new file mode 100644 index 0000000..c76ee80 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-default-export.html @@ -0,0 +1,37 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-default-export

                                                          +

                                                          +
                                                          + + +

                                                          Disallows default exports in ES6-style modules.

                                                          + + +

                                                          Use named exports instead.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          Named imports/exports promote clarity. +In addition, current tooling differs on the correct way to handle default imports/exports. +Avoiding them all together can help avoid tooling bugs and conflicts.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-default-export": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-duplicate-key.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-duplicate-key.html new file mode 100644 index 0000000..59e7aaf --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-duplicate-key.html @@ -0,0 +1,33 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-duplicate-key

                                                          +

                                                          +
                                                          + + +

                                                          Disallows duplicate keys in object literals.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          There is no good reason to define an object literal with the same key twice. +This rule is now implemented in the TypeScript compiler and does not need to be used.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-duplicate-key": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-duplicate-variable.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-duplicate-variable.html new file mode 100644 index 0000000..91091e6 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-duplicate-variable.html @@ -0,0 +1,38 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-duplicate-variable

                                                          +

                                                          +
                                                          + + +

                                                          Disallows duplicate variable declarations in the same block scope.

                                                          + + + +

                                                          This rule is only useful when using the var keyword - +the compiler will detect redeclarations of let and const variables.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          A variable can be reassigned if necessary - +there’s no good reason to have a duplicate variable declaration.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-duplicate-variable": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-empty.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-empty.html new file mode 100644 index 0000000..2de7aa4 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-empty.html @@ -0,0 +1,34 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-empty

                                                          +

                                                          +
                                                          + + +

                                                          Disallows empty blocks.

                                                          + + +

                                                          Blocks with a comment inside are not considered empty.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Empty blocks are often indicators of missing code.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-empty": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-eval.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-eval.html new file mode 100644 index 0000000..28e76d3 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-eval.html @@ -0,0 +1,34 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-eval

                                                          +

                                                          +
                                                          + + +

                                                          Disallows eval function invocations.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          eval() is dangerous as it allows arbitrary code execution with full privileges. There are +alternatives +for most of the use cases for eval().

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-eval": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-inferrable-types.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-inferrable-types.html new file mode 100644 index 0000000..2456a7f --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-inferrable-types.html @@ -0,0 +1,39 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-inferrable-types

                                                          +

                                                          +
                                                          + + +

                                                          Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Explicit types where they can be easily infered by the compiler make code more verbose.

                                                          + + + + +

                                                          Config

                                                          + +

                                                          One argument may be optionally provided:

                                                          + +
                                                            +
                                                          • ignore-params allows specifying an inferrable type annotation for function params. +This can be useful when combining with the typedef rule.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-inferrable-types": true
                                                          + +
                                                          "no-inferrable-types": [true, "ignore-params"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "ignore-params"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-internal-module.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-internal-module.html new file mode 100644 index 0000000..1ce01b3 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-internal-module.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-internal-module

                                                          +

                                                          +
                                                          + + +

                                                          Disallows internal module

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Using module leads to a confusion of concepts with external modules. Use the newer namespace keyword instead.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-internal-module": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-invalid-this.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-invalid-this.html new file mode 100644 index 0000000..ebe6191 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-invalid-this.html @@ -0,0 +1,38 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-invalid-this

                                                          +

                                                          +
                                                          + + +

                                                          Disallows using the this keyword outside of classes.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          See the rule’s author’s rationale here.

                                                          + + + + +

                                                          Config

                                                          + +

                                                          One argument may be optionally provided:

                                                          + +
                                                            +
                                                          • check-function-in-method disallows using the this keyword in functions within class methods.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-invalid-this": true
                                                          + +
                                                          "no-invalid-this": [true, "check-function-in-method"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "check-function-in-method"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-namespace.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-namespace.html new file mode 100644 index 0000000..850069b --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-namespace.html @@ -0,0 +1,43 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-namespace

                                                          +

                                                          +
                                                          + + +

                                                          Disallows use of internal modules and namespaces.

                                                          + + +

                                                          This rule still allows the use of declare module ... {}

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          ES6-style external modules are the standard way to modularize code. +Using module {} and namespace {} are outdated ways to organize TypeScript code.

                                                          + + + + +

                                                          Config

                                                          + +

                                                          One argument may be optionally provided:

                                                          + +
                                                            +
                                                          • allow-declarations allows declare namespace ... {} to describe external APIs.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-namespace": true
                                                          + +
                                                          "no-namespace": [true, "allow-declarations"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "allow-declarations"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-null-keyword.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-null-keyword.html new file mode 100644 index 0000000..2e87659 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-null-keyword.html @@ -0,0 +1,33 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-null-keyword

                                                          +

                                                          +
                                                          + + +

                                                          Disallows use of the null keyword literal.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          Instead of having the dual concepts of null andundefined in a codebase, +this rule ensures that only undefined is used.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-null-keyword": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-reference.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-reference.html new file mode 100644 index 0000000..0ab2baf --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-reference.html @@ -0,0 +1,33 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-reference

                                                          +

                                                          +
                                                          + + +

                                                          Disallows /// <reference path=> imports (use ES6-style imports instead).

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          Using /// <reference path=> comments to load other files is outdated. +Use ES6-style imports to reference other files.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-reference": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-require-imports.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-require-imports.html new file mode 100644 index 0000000..3c6d2a7 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-require-imports.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-require-imports

                                                          +

                                                          +
                                                          + + +

                                                          Disallows invocation of require().

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Prefer the newer ES6-style imports over require().

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-require-imports": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-shadowed-variable.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-shadowed-variable.html new file mode 100644 index 0000000..f1fef2a --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-shadowed-variable.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-shadowed-variable

                                                          +

                                                          +
                                                          + + +

                                                          Disallows shadowing variable declarations.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Shadowing a variable masks access to it and obscures to what value an identifier actually refers.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-shadowed-variable": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-string-literal.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-string-literal.html new file mode 100644 index 0000000..deea3c8 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-string-literal.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-string-literal

                                                          +

                                                          +
                                                          + + +

                                                          Disallows object access via string literals.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Encourages using strongly-typed property access.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-string-literal": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-switch-case-fall-through.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-switch-case-fall-through.html new file mode 100644 index 0000000..3056e29 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-switch-case-fall-through.html @@ -0,0 +1,42 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-switch-case-fall-through

                                                          +

                                                          +
                                                          + + +

                                                          Disallows falling through case statements.

                                                          + + + +

                                                          For example, the following is not allowed:

                                                          + +
                                                          switch(foo) {
                                                          case 1:
                                                          someFunc(foo);
                                                          case 2:
                                                          someOtherFunc(foo);
                                                          }
                                                          + +

                                                          However, fall through is allowed when case statements are consecutive or +a magic /* falls through */ comment is present. The following is valid:

                                                          + +
                                                          switch(foo) {
                                                          case 1:
                                                          someFunc(foo);
                                                          /* falls through */
                                                          case 2:
                                                          case 3:
                                                          someOtherFunc(foo);
                                                          }
                                                          + + + +
                                                          Rationale
                                                          +

                                                          Fall though in switch statements is often unintentional and a bug.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-switch-case-fall-through": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-trailing-whitespace.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-trailing-whitespace.html new file mode 100644 index 0000000..aee4742 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-trailing-whitespace.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-trailing-whitespace

                                                          +

                                                          +
                                                          + + +

                                                          Disallows trailing whitespace at the end of a line.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Keeps version control diffs clean as it prevents accidental whitespace from being committed.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-trailing-whitespace": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unreachable.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unreachable.html new file mode 100644 index 0000000..4d9b8b7 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unreachable.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-unreachable

                                                          +

                                                          +
                                                          + + +

                                                          Disallows unreachable code after break, catch, throw, and return statements.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Unreachable code is often indication of a logic error.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-unreachable": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unused-expression.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unused-expression.html new file mode 100644 index 0000000..d44a6f6 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unused-expression.html @@ -0,0 +1,38 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-unused-expression

                                                          +

                                                          +
                                                          + + +

                                                          Disallows unused expression statements.

                                                          + + + +

                                                          Unused expressions are expression statements which are not assignments or function calls +(and thus usually no-ops).

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          Detects potential errors where an assignment or function call was intended. Also detects constructs such as +new SomeClass(), where a constructor is used solely for its side effects, which is considered poor style.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-unused-expression": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unused-variable.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unused-variable.html new file mode 100644 index 0000000..b6cb98f --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unused-variable.html @@ -0,0 +1,45 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-unused-variable

                                                          +

                                                          +
                                                          + + +

                                                          Disallows unused imports, variables, functions and private class members.

                                                          + + + + + +

                                                          Config

                                                          + +

                                                          Three optional arguments may be optionally provided:

                                                          + +
                                                            +
                                                          • "check-parameters" disallows unused function and constructor parameters. +
                                                              +
                                                            • NOTE: this option is experimental and does not work with classes + that use abstract method declarations, among other things.
                                                            • +
                                                            +
                                                          • +
                                                          • "react" relaxes the rule for a namespace import named React +(from either the module "react" or "react/addons"). +Any JSX expression in the file will be treated as a usage of React +(because it expands to React.createElement ).
                                                          • +
                                                          • {"ignore-pattern": "pattern"} where pattern is a case-sensitive regexp. +Variable names that match the pattern will be ignored.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-unused-variable": [true, "react"]
                                                          + +
                                                          "no-unused-variable": [true, {"ignore-pattern": "^_"}]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "array",
                                                          "arrayMembers": [
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "check-parameters",
                                                          "react"
                                                          ]
                                                          }
                                                          },
                                                          {
                                                          "type": "object",
                                                          "properties": {
                                                          "ignore-pattern": {
                                                          "type": "string"
                                                          }
                                                          }
                                                          }
                                                          ]
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-use-before-declare.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-use-before-declare.html new file mode 100644 index 0000000..089f66c --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-use-before-declare.html @@ -0,0 +1,32 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-use-before-declare

                                                          +

                                                          +
                                                          + + +

                                                          Disallows usage of variables before their declaration.

                                                          + + + +

                                                          This rule is primarily useful when using the var keyword - +the compiler will detect if a let and const variable is used before it is declared.

                                                          + + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-use-before-declare": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-var-keyword.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-var-keyword.html new file mode 100644 index 0000000..bbf9480 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-var-keyword.html @@ -0,0 +1,30 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-var-keyword

                                                          +

                                                          +
                                                          + + +

                                                          Disallows usage of the var keyword.

                                                          + + +

                                                          Use let or const instead.

                                                          + + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-var-keyword": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-var-requires.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-var-requires.html new file mode 100644 index 0000000..4b4670d --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-var-requires.html @@ -0,0 +1,32 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: no-var-requires

                                                          +

                                                          +
                                                          + + +

                                                          Disallows the use of require statements except in import statements.

                                                          + + + +

                                                          In other words, the use of forms such as var module = require("module") are banned. +Instead use ES6 style imports or import foo = require('foo') imports.

                                                          + + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "no-var-requires": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/object-literal-sort-keys.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/object-literal-sort-keys.html new file mode 100644 index 0000000..097844c --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/object-literal-sort-keys.html @@ -0,0 +1,31 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: object-literal-sort-keys

                                                          +

                                                          +
                                                          + + +

                                                          Requires keys in object literals to be sorted alphabetically

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Useful in preventing merge conflicts

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "object-literal-sort-keys": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/one-line.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/one-line.html new file mode 100644 index 0000000..245aeaa --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/one-line.html @@ -0,0 +1,36 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: one-line

                                                          +

                                                          +
                                                          + + +

                                                          Requires the specified tokens to be on the same line as the expression preceding them.

                                                          + + + + + +

                                                          Config

                                                          + +

                                                          Five arguments may be optionally provided:

                                                          + +
                                                            +
                                                          • "check-catch" checks that catch is on the same line as the closing brace for try.
                                                          • +
                                                          • "check-finally" checks that finally is on the same line as the closing brace for catch.
                                                          • +
                                                          • "check-else" checks that else is on the same line as the closing brace for if.
                                                          • +
                                                          • "check-open-brace" checks that an open brace falls on the same line as its preceding expression.
                                                          • +
                                                          • "check-whitespace" checks preceding whitespace for the specified tokens.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "one-line": [true, "check-catch", "check-finally", "check-else"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "check-catch",
                                                          "check-finally",
                                                          "check-else",
                                                          "check-open-brace",
                                                          "check-whitespace"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/one-variable-per-declaration.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/one-variable-per-declaration.html new file mode 100644 index 0000000..1a5a5e2 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/one-variable-per-declaration.html @@ -0,0 +1,34 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: one-variable-per-declaration

                                                          +

                                                          +
                                                          + + +

                                                          Disallows multiple variable definitions in the same declaration statement.

                                                          + + + + + +

                                                          Config

                                                          + +

                                                          One argument may be optionally provided:

                                                          + +
                                                            +
                                                          • ignore-for-loop allows multiple variable definitions in a for loop declaration.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "one-variable-per-declaration": true
                                                          + +
                                                          "one-variable-per-declaration": [true, "ignore-for-loop"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "ignore-for-loop"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/quotemark.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/quotemark.html new file mode 100644 index 0000000..090cfb6 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/quotemark.html @@ -0,0 +1,39 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: quotemark

                                                          +

                                                          +
                                                          + + +

                                                          Requires single or double quotes for string literals.

                                                          + + + + + +

                                                          Config

                                                          + +

                                                          Five arguments may be optionally provided:

                                                          + +
                                                            +
                                                          • "single" enforces single quotes.
                                                          • +
                                                          • "double" enforces double quotes.
                                                          • +
                                                          • "jsx-single" enforces single quotes for JSX attributes.
                                                          • +
                                                          • "jsx-double" enforces double quotes for JSX attributes.
                                                          • +
                                                          • "avoid-escape" allows you to use the “other” quotemark in cases where escaping would normally be required. +For example, [true, "double", "avoid-escape"] would not report a failure on the string literal 'Hello "World"'.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "quotemark": [true, "single", "avoid-escape"]
                                                          + +
                                                          "quotemark": [true, "single", "jsx-double"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "single",
                                                          "double",
                                                          "jsx-single",
                                                          "jsx-double",
                                                          "avoid-escape"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/radix.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/radix.html new file mode 100644 index 0000000..49a7a78 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/radix.html @@ -0,0 +1,34 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: radix

                                                          +

                                                          +
                                                          + + +

                                                          Requires the radix parameter to be specified when calling parseInt.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          From MDN: +> Always specify this parameter to eliminate reader confusion and to guarantee predictable behavior. +> Different implementations produce different results when a radix is not specified, usually defaulting the value to 10.

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "radix": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/semicolon.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/semicolon.html new file mode 100644 index 0000000..d9dbd5b --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/semicolon.html @@ -0,0 +1,35 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: semicolon

                                                          +

                                                          +
                                                          + + +

                                                          Enforces consistent semicolon usage at the end of every statement.

                                                          + + + + + +

                                                          Config

                                                          + +

                                                          One of the following arguments must be provided:

                                                          + +
                                                            +
                                                          • "always" enforces semicolons at the end of every statement.
                                                          • +
                                                          • "never" disallows semicolons at the end of every statement except for when they are necessary.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "semicolon": [true, "always"]
                                                          + +
                                                          "semicolon": [true, "never"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "always",
                                                          "never"
                                                          ]
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/switch-default.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/switch-default.html new file mode 100644 index 0000000..e186954 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/switch-default.html @@ -0,0 +1,27 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: switch-default

                                                          +

                                                          +
                                                          + + +

                                                          Require a default case in all switch statements.

                                                          + + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "switch-default": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/trailing-comma.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/trailing-comma.html new file mode 100644 index 0000000..fbfec2c --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/trailing-comma.html @@ -0,0 +1,38 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: trailing-comma

                                                          +

                                                          +
                                                          + + +

                                                          Requires or disallows trailing commas in array and object literals, destructuring assignments and named imports.

                                                          + + + + + +

                                                          Config

                                                          + +

                                                          One argument which is an object with the keys multiline and singleline. +Both should be set to either "always" or "never".

                                                          + +
                                                            +
                                                          • "multiline" checks multi-line object literals.
                                                          • +
                                                          • "singleline" checks single-line object literals.
                                                          • +
                                                          + +

                                                          A array is considered “multiline” if its closing bracket is on a line +after the last array element. The same general logic is followed for +object literals and named import statements.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "trailing-comma": [true, {"multiline": "always", "singleline": "never"}]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "object",
                                                          "properties": {
                                                          "multiline": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "always",
                                                          "never"
                                                          ]
                                                          },
                                                          "singleline": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "always",
                                                          "never"
                                                          ]
                                                          }
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/triple-equals.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/triple-equals.html new file mode 100644 index 0000000..970f923 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/triple-equals.html @@ -0,0 +1,37 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: triple-equals

                                                          +

                                                          +
                                                          + + +

                                                          Requires === and !== in place of == and !=.

                                                          + + + + + +

                                                          Config

                                                          + +

                                                          Two arguments may be optionally provided:

                                                          + +
                                                            +
                                                          • "allow-null-check" allows == and != when comparing to null.
                                                          • +
                                                          • "allow-undefined-check" allows == and != when comparing to undefined.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "triple-equals": true
                                                          + +
                                                          "triple-equals": [true, "allow-null-check"]
                                                          + +
                                                          "triple-equals": [true, "allow-undefined-check"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "allow-null-check",
                                                          "allow-undefined-check"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/typedef-whitespace.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/typedef-whitespace.html new file mode 100644 index 0000000..9f81c0a --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/typedef-whitespace.html @@ -0,0 +1,43 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: typedef-whitespace

                                                          +

                                                          +
                                                          + + +

                                                          Requires or disallows whitespace for type definitions.

                                                          + + +

                                                          Determines if a space is required or not before the colon in a type specifier.

                                                          + + + + + +

                                                          Config

                                                          + +

                                                          Two arguments which are both objects. +The first argument specifies how much space should be to the left of a typedef colon. +The second argument specifies how much space should be to the right of a typedef colon. +Each key should have a value of "space" or "nospace". +Possible keys are:

                                                          + +
                                                            +
                                                          • "call-signature" checks return type of functions.
                                                          • +
                                                          • "index-signature" checks index type specifier of indexers.
                                                          • +
                                                          • "parameter" checks function parameters.
                                                          • +
                                                          • "property-declaration" checks object property declarations.
                                                          • +
                                                          • "variable-declaration" checks variable declaration.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "typedef-whitespace": 
                                                          [
                                                          true,
                                                          {
                                                          "call-signature": "nospace",
                                                          "index-signature": "nospace",
                                                          "parameter": "nospace",
                                                          "property-declaration": "nospace",
                                                          "variable-declaration": "nospace"
                                                          },
                                                          {
                                                          "call-signature": "onespace",
                                                          "index-signature": "onespace",
                                                          "parameter": "onespace",
                                                          "property-declaration": "onespace",
                                                          "variable-declaration": "onespace"
                                                          }
                                                          ]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "array",
                                                          "arrayMembers": [
                                                          {
                                                          "type": "object",
                                                          "properties": {
                                                          "call-signature": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "nospace",
                                                          "onespace",
                                                          "space"
                                                          ]
                                                          },
                                                          "index-signature": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "nospace",
                                                          "onespace",
                                                          "space"
                                                          ]
                                                          },
                                                          "parameter": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "nospace",
                                                          "onespace",
                                                          "space"
                                                          ]
                                                          },
                                                          "property-declaration": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "nospace",
                                                          "onespace",
                                                          "space"
                                                          ]
                                                          },
                                                          "variable-declaration": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "nospace",
                                                          "onespace",
                                                          "space"
                                                          ]
                                                          }
                                                          }
                                                          },
                                                          {
                                                          "type": "object",
                                                          "properties": {
                                                          "call-signature": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "nospace",
                                                          "onespace",
                                                          "space"
                                                          ]
                                                          },
                                                          "index-signature": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "nospace",
                                                          "onespace",
                                                          "space"
                                                          ]
                                                          },
                                                          "parameter": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "nospace",
                                                          "onespace",
                                                          "space"
                                                          ]
                                                          },
                                                          "property-declaration": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "nospace",
                                                          "onespace",
                                                          "space"
                                                          ]
                                                          },
                                                          "variable-declaration": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "nospace",
                                                          "onespace",
                                                          "space"
                                                          ]
                                                          }
                                                          }
                                                          }
                                                          ]
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/typedef.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/typedef.html new file mode 100644 index 0000000..5b81a22 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/typedef.html @@ -0,0 +1,37 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: typedef

                                                          +

                                                          +
                                                          + + +

                                                          Requires type definitions to exist.

                                                          + + + + + +

                                                          Config

                                                          + +

                                                          Six arguments may be optionally provided:

                                                          + +
                                                            +
                                                          • "call-signature" checks return type of functions.
                                                          • +
                                                          • "parameter" checks type specifier of function parameters for non-arrow functions.
                                                          • +
                                                          • "arrow-parameter" checks type specifier of function parameters for arrow functions.
                                                          • +
                                                          • "property-declaration" checks return types of interface properties.
                                                          • +
                                                          • "variable-declaration" checks variable declarations.
                                                          • +
                                                          • "member-variable-declaration" checks member variable declarations.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "typedef": [true, "call-signature", "parameter", "member-variable-declaration"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "call-signature",
                                                          "parameter",
                                                          "arrow-parameter",
                                                          "property-declaration",
                                                          "variable-declaration",
                                                          "member-variable-declaration"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/use-isnan.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/use-isnan.html new file mode 100644 index 0000000..2b8be45 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/use-isnan.html @@ -0,0 +1,33 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: use-isnan

                                                          +

                                                          +
                                                          + + +

                                                          Enforces use of the isNaN() function to check for NaN references instead of a comparison to the NaN constant.

                                                          + + + +
                                                          Rationale
                                                          + +

                                                          Since NaN !== NaN, comparisons with regular operators will produce unexpected results. +So, instead of if (myVar === NaN), do if (isNaN(myVar)).

                                                          + + + + +

                                                          Config

                                                          +

                                                          Not configurable.

                                                          + + +
                                                          Examples
                                                          + +
                                                          "use-isnan": true
                                                          + + +
                                                          Schema
                                                          +
                                                          {}
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/use-strict.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/use-strict.html new file mode 100644 index 0000000..67e26e5 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/use-strict.html @@ -0,0 +1,33 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: use-strict

                                                          +

                                                          +
                                                          + + +

                                                          Requires using ECMAScript 5’s strict mode.

                                                          + + + + + +

                                                          Config

                                                          + +

                                                          Two arguments may be optionally provided:

                                                          + +
                                                            +
                                                          • check-module checks that all top-level modules are using strict mode.
                                                          • +
                                                          • check-function checks that all top-level functions are using strict mode.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "use-strict": [true, "check-module"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "check-module",
                                                          "check-function"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/variable-name.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/variable-name.html new file mode 100644 index 0000000..c5a843f --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/variable-name.html @@ -0,0 +1,40 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: variable-name

                                                          +

                                                          +
                                                          + + +

                                                          Checks variable names for various errors.

                                                          + + + + + +

                                                          Config

                                                          + +

                                                          Five arguments may be optionally provided:

                                                          + +
                                                            +
                                                          • "check-format": allows only camelCased or UPPER_CASED variable names +
                                                              +
                                                            • "allow-leading-underscore" allows underscores at the beginning (only has an effect if “check-format” specified)
                                                            • +
                                                            • "allow-trailing-underscore" allows underscores at the end. (only has an effect if “check-format” specified)
                                                            • +
                                                            • "allow-pascal-case allows PascalCase in addtion to camelCase.
                                                            • +
                                                            +
                                                          • +
                                                          • "ban-keywords": disallows the use of certain TypeScript keywords (any, Number, number, String, +string, Boolean, boolean, undefined) as variable or parameter names.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "check-format",
                                                          "allow-leading-underscore",
                                                          "allow-trailing-underscore",
                                                          "allow-pascal-case",
                                                          "ban-keywords"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/whitespace.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/whitespace.html new file mode 100644 index 0000000..a133bd0 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/whitespace.html @@ -0,0 +1,42 @@ +

                                                          Details

                                                          + + +
                                                          +

                                                          Rule: whitespace

                                                          +

                                                          +
                                                          + + +

                                                          Enforces whitespace style conventions.

                                                          + + + +
                                                          Rationale
                                                          +

                                                          Helps maintain a readable, consistent style in your codebase.

                                                          + + + + +

                                                          Config

                                                          + +

                                                          Seven arguments may be optionally provided:

                                                          + +
                                                            +
                                                          • "check-branch" checks branching statements (if/else/for/while) are followed by whitespace.
                                                          • +
                                                          • "check-decl"checks that variable declarations have whitespace around the equals token.
                                                          • +
                                                          • "check-operator" checks for whitespace around operator tokens.
                                                          • +
                                                          • "check-module" checks for whitespace in import & export statements.
                                                          • +
                                                          • "check-separator" checks for whitespace after separator tokens (,/;).
                                                          • +
                                                          • "check-type" checks for whitespace before a variable type specification.
                                                          • +
                                                          • "check-typecast" checks for whitespace between a typecast and its target.
                                                          • +
                                                          + + +
                                                          Examples
                                                          + +
                                                          "whitespace": [true, "check-branch", "check-operator", "check-typecast"]
                                                          + + +
                                                          Schema
                                                          +
                                                          {
                                                          "type": "list",
                                                          "listType": {
                                                          "type": "enum",
                                                          "enumValues": [
                                                          "check-branch",
                                                          "check-decl",
                                                          "check-operator",
                                                          "check-module",
                                                          "check-seperator",
                                                          "check-type",
                                                          "check-typecast"
                                                          ]
                                                          }
                                                          }
                                                          + \ No newline at end of file