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=
- * Soanr 5.3 removes utility libraries
+ * Sonar 5.3 removes utility libraries
*
* @author Aurélien Baudet
*/
public class StringEscapeUtils {
- /**
- * Escapes the characters in a 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.
+ * Escapes the characters in a
+ * For example:
+ * 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.
+ * Escapes the characters in a 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.
+ * Escapes the characters in a
+ * For example:
+ * 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.
+ * No delimiter is added before or after the list.
* A See the examples here: {@link #join(Object[],String)}. No delimiter is added before or after the list.
* A See the examples here: {@link #join(Object[],String)}. 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. The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 The number of AngularJS components in one file should be limited.
+The default limit is one. Styleguide Reference The following patterns are considered problems with default config; The following patterns are not considered problems with default config; The following patterns are considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.11.0 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 The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 You should use Angular's controllerAs syntax when defining routes or states. Styleguide Reference The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 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) Styleguide Reference The following patterns are considered problems with default config; The following patterns are not considered problems with default config; The following patterns are considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.1.0 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 The following patterns are considered problems with default config; The following patterns are not considered problems with default config; The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.1.0 When you want to create a new promise, you should not use the $q.deferred anymore.
+Prefer the new syntax : $q(function(resolve, reject){}) The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 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) The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 All your DI should use the same syntax : the Array, function, or $inject syntaxes ("di": [2, "array, function, or $inject"]) The following patterns are considered problems with default config; The following patterns are not considered problems with default config; The following patterns are not considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.1.0 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 The following patterns are considered problems with default config; The following patterns are not considered problems with default config; The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.6.0 Unused dependencies should not be injected. The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.8.0 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 The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured This rule was introduced in eslint-plugin-angular 0.1.0 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 Styleguide Reference The following patterns are not considered problems with default config; The following patterns are considered problems when configured The following patterns are considered problems when configured The following patterns are considered problems when configured This rule was introduced in eslint-plugin-angular 0.12.0 Instead of the default document object, you should prefer the AngularJS wrapper service $document. Styleguide Reference The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.15.0 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 The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 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 The following patterns are considered problems with default config; The following patterns are not considered problems with default config; The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are not considered problems when configured The following patterns are not considered problems when configured The following patterns are not considered problems when configured The following patterns are not considered problems when configured The following patterns are not considered problems when configured The following patterns are not considered problems when configured The following patterns are not considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.7.0 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"]) The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured This rule was introduced in eslint-plugin-angular 0.1.0 You should use the angular.forEach method instead of the default JavaScript implementation [].forEach. The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 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 The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.1.0 Instead of the default setInterval function, you should use the AngularJS wrapper service $interval Styleguide Reference The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 You should use angular.fromJson or angular.toJson instead of JSON.parse and JSON.stringify The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 You should use $log service instead of console for the methods 'log', 'debug', 'error', 'info', 'warn' The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 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 The following patterns are considered problems with default config; The following patterns are not considered problems with default config; The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.12.0 When using a module, avoid using a variable and instead use chaining with the getter syntax Styleguide Reference The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 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 The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured This rule was introduced in eslint-plugin-angular 0.1.0 Declare modules without a variable using the setter syntax. Styleguide Reference The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 All methods defined in the angular.mock object are also available in the object window.
+So you can remove angular.mock from your code The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.2.0 According to the Component-First pattern, we should avoid the use of AngularJS controller. The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.9.0 In Angular 1.4, the $cookieStore service is now deprected.
+Please use the $cookies service instead The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.3.0 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 The following patterns are considered problems with default config; The following patterns are not considered problems with default config; The following patterns are not considered problems when configured The following patterns are considered problems when configured This rule was introduced in eslint-plugin-angular 0.15.0 Disallow the $http success and error function.
+Instead the standard promise API should be used. The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.12.0 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}]) The following patterns are considered problems with default config; The following patterns are not considered problems with default config; The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.12.0 You should not wrap angular.element object into jQuery(), because angular.element already return jQLite element The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 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']} The following patterns are considered problems with default config; The following patterns are not considered problems with default config; The following patterns are considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.1.0 Initialization logic should be moved into a factory or service. This improves testability. Styleguide Reference The following patterns are considered problems with default config; The following patterns are not considered problems with default config; The following patterns are considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.15.0 You should prefer the factory() method instead of service() Styleguide Reference The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 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']}) The following patterns are considered problems with default config; The following patterns are not considered problems with default config; The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.1.0 Watch and On methods on the scope object should be assigned to a variable, in order to be deleted in a $destroy event handler The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 Injected dependencies should be written one per line. The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.14.0 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']). The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.5.0 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 The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured This rule was introduced in eslint-plugin-angular 0.1.0 Instead of the default setTimeout function, you should use the AngularJS wrapper service $timeout
+* Styleguide Reference The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 You should use the angular.isArray method instead of the default JavaScript implementation (typeof [] === "[object Array]"). The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 You should use the angular.isDate method instead of the default JavaScript implementation (typeof new Date() === "[object Date]"). The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 You should use the angular.isFunction method instead of the default JavaScript implementation (typeof function(){} ==="[object Function]"). The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 You should use the angular.isNumber method instead of the default JavaScript implementation (typeof 3 === "[object Number]"). The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 You should use the angular.isObject method instead of the default JavaScript implementation (typeof {} === "[object Object]"). The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 You should use the angular.isString method instead of the default JavaScript implementation (typeof "" === "[object String]"). The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 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 The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured This rule was introduced in eslint-plugin-angular 0.4.0 Instead of the default window object, you should prefer the AngularJS wrapper service $window. Styleguide Reference The following patterns are considered problems; The following patterns are not considered problems; This rule was introduced in eslint-plugin-angular 0.1.0 Adjoining classes, sometimes also called class chaining, look like Generally, it's better to define styles based on single classes instead of based on multiple classes being present. Consider the following: Adjoining classes, sometimes also called class chaining, look like Generally, it's better to define styles based on single classes instead of based on multiple classes being present. Consider the following: The rule for selector That new class, Rule ID: The following patterns are considered warnings: The following patterns are considered okay and do not cause a warning: 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: 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: A new developer might assume that the width of an element with the You can force most browsers to obey Now an element with a class of Rule ID: This rule is aimed at eliminating unwanted box model sizing issues. As such, the rule warns when it finds: The following patterns are considered warnings: The following patterns are considered okay and do not cause warnings: The CSS The CSS The actual width of this box is 112 pixels. That's because the 100 pixels specified by When you change 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 There is only a problem using Rule ID: The following patterns are considered warnings: When using When using 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: Rule ID: The following patterns are considered warnings: The following patterns are considered okay and do not cause warnings: 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. 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 ( 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 ( The following properties have multiple vendor-prefixed versions: 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 ID: The following patterns are considered warnings: Even though you can define any group of properties together in a CSS rule, some of them will be ignored due to the Even though you can define any group of properties together in a CSS rule, some of them will be ignored due to the For Other general rules based on Removing the ignored or problematic properties decreases file size thereby improving performance. Rule ID: This rule is aimed at flagging properties that don't work based with the The following patterns are considered warnings: The following patterns are considered okay and do not cause warnings: 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: 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: 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: Here, the Rule ID: The following patterns are considered warnings: The following patterns are considered okay and do not cause warnings: Early on in web development, including the same CSS property twice was certainly an error, especially if there were two different values. For example: Early on in web development, including the same CSS property twice was certainly an error, especially if there were two different values. For example: 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: 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 ID: This rule is intended to find errors of duplication in CSS code. It warns when: The following patterns are considered warnings: The following patterns are considered okay and do not cause a warning: An empty rule is one that doesn't contain any properties, such as: An empty rule is one that doesn't contain any properties, such as: 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 ID: This rule warns when an empty rule is found in the CSS. The following patterns are considered warnings: In the beginning, there were three ways to specify colors: in hexadecimal format, using either three or six characters, named colors such as In the beginning, there were three ways to specify colors: in hexadecimal format, using either three or six characters, named colors such as 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 Supporting browsers will treat this CSS code as described. Non-supporting browsers will completely drop the 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 ID: This rule is aimed at ensuring a proper color is displayed for all browsers. As such, the rule warns when it finds: The following patterns are considered warnings: The following patterns are considered okay and do not cause warnings: The The Frequently, using too many Using one of these grid systems can greatly reduce the amount of CSS code you need to write by hand. Rule ID: This rule is aimed at reducing complexity by watching how many times Web fonts are growing in popularity and use of Web fonts are growing in popularity and use of Rule ID: 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 You can create some standard font size class such as: 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 You can create some standard font size class such as: Using classes such as these in your project allows consistent use of font sizes throughout, and also limits the number of times Rule ID: This rule is aimed at pointing out opportunities for abstracting font sizes. The rule warns when 10 or more 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: 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: Meaning a simple two-color gradient that works across all browsers must look like this: It's easy to forget one or more gradient definitions with all of the various vendor prefix gradients available. Rule ID: The following patterns are considered warnings: The following patterns are considered okay and do not cause a warning: 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. 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: This style is only useful within the element with the ID of Once you've gotten to this point, you might as well just use the class and not mention the ID: 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 ID: The following patterns are considered warnings: The The This code includes two more style sheets at the beginning of a style sheet. When the browser parses this code, it stops at each There are two alternatives to using Rule ID: The following pattern is considered a warning: The The Rule ID: The following patterns are considered warnings: 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. 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 ID: The following patterns are considered warnings: The following pattern is considered okay and does not cause a warning: The CSS The CSS 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 : Or: 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 Rule ID: This rule is aimed at ensuring keyboard-only users have a visual indicator of focus. As such, the rule warns when it finds: The following patterns are considered warnings: The following pattern is considered okay and does not cause a warning: Writing selectors such as Writing selectors such as 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 ID: The following patterns are considered warnings: The following patterns are considered okay and do not cause warnings: Heading elements ( Heading elements ( Rule ID: The following patterns are considered warnings: The following patterns are considered okay and do not cause warnings: 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. 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 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 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. The first of the problematic selectors is the contains selector. This selector uses This selector matches any Note that it doesn't matter whether or not the string has white space on either side, it's just a substring match. The next selector to avoid is the starts with match. This uses the This rule will match any of the following: All the selector cares is that the string "ext" appears at the beginning of the attribute value of The next selector to avoid is the ends with match. This uses the This rule matches all Getting even more complex is the selector that checks for a value separated by white space. The This rule matches any of the following: The last problematic selector checks to see if the attribute value contains a string separated by dashes. The This matches all of the following: 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 ID: The following patterns are considered warnings: The following patterns are considered okay and do not cause warnings: Sometimes when editing a rule you may end up defining multiple properties that can better be represented using shorthand. For example: Sometimes when editing a rule you may end up defining multiple properties that can better be represented using shorthand. For example: These four properties can actually be combined into a single Using shorthand properties where possible helps to decrease the overall size of the CSS. Rule ID: 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: The following patterns are considered warnings: The following patterns are considered okay and do not cause warnings: 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: 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: In this example, the Star hack relies on an old CSS parser bug in Internet Explorer, and as such, some prefer not to use it. Rule ID: The following patterns are considered warnings: 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 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 The technique usually involves a very large negative number such as 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 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 ID: The following patterns are considered warnings: The following patterns are considered okay and do not cause a warning: 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: 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: In this example, the The underscore hack relies on an old CSS parser bug in Internet Explorer, and as such, some prefer not to use it. Rule ID: The following patterns are considered warnings: 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 ( 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 ( Rule ID: The following patterns are considered warnings: The following patterns are considered okay and do not cause warnings: The universal selector ( The universal selector ( 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 Rule ID: The following patterns are considered warnings: The following patterns are considered okay and do not cause warnings: Unqualified attribute selectors, such as Unqualified attribute selectors, such as 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 Rule ID: The following patterns are considered warnings: The following patterns are considered okay and do not cause warnings: 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. 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 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 ID: This rule is aimed at ensuring standard properties are included whenever vendor-prefixed properties are used. As such, the rule warns when it finds: The following patterns are considered warnings: The following patterns are considered okay and do not cause warnings: The value of 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 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 ID: This rule is aimed at flagging zero values that still have units. As such, it warns when This rule is aimed at flagging zero length values that still have units. As such, it warns when The following patterns are considered warnings: The following patterns are okay and do not cause warnings: Alt of img must be present and alt of area[href] and input[type=image] must be set value. good: bad: config value: Attribute name must be lowercase. good: bad: Attribute name must be lowercase. good: bad: config value: Attribute name can not been duplicated. good: bad: The same attribute can't be specified twice. good: bad: config value: Attribute value cant not use unsafe chars. good: bad: Tip: The unsafe chars is in the tail of the href attribute. Attribute value cant not use unsafe chars. regexp: good: bad: Tip: The unsafe chars is in the tail of the href attribute. config value: Attribute value must closed by double quotes. good: bad: Attribute value must closed by double quotes. good: bad: config value: Attribute must set value. good: bad: Attribute must set value. good: bad: config value: All csslint rules: https://github.com/stubbornella/csslint/wiki/Rules Scan css with csslint. All csslint rules: https://github.com/stubbornella/csslint/wiki/Rules Doctype must be first. good: bad: Doctype must be first. good: bad: config value: Doctype must be html5. good: Doctype must be html5. good: config value: The script tag can not be used in head. good: bad: The script tag can not be used in head. good: bad: config value: Href must be absolute or relative. good: Href must be absolute or relative. good: config value: Id and class can not use ad keyword, it will blocked by adblock software. good: bad: Id and class can not use ad keyword, it will blocked by adblock software. good: bad: config value: Id and class value must meet some rules: underline, dash, hump. good: Id and class value must meet some rules: underline, dash, hump. good: config value: Id must be unique. good: bad: ID attributes must be unique in the document. good: bad: config value: Inline script cannot be use. bad: config value: Inline style cannot be use. bad: config value: Scan script with jshint. All jshint rules: http://jshint.com/docs/#options Scan script with jshint. All jshint rules: http://jshint.com/docs/options/ Spaces and tabs can not mixed in front of line. good: bad: Tip: github will replace tab to space, read md file to read raw code. Spaces and tabs can not mixed in front of line. good: bad: Note: in the examples above, spaces and tabs are represented by config value: Special characters must be escaped. good: bad: Special characters must be escaped. good: bad: config value: Src of img(script,link) must set value. Emtpy of src will visit current page twice. good: bad: Src of img(script,link) must set value. Emtpy of src will visit current page twice. good: bad: config value: Style tag can not be use. bad: Style tag can not be use. bad: config value: Tag must be paired. good: bad: Tag must be paired. good: bad: config value: The empty tag must closed by self. good: bad: The empty tag must closed by self. good: bad: config value: Tagname must be lowercase. good: bad: Tagname must be lowercase. good: bad: config value: good: bad: config value: 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: This rule warns if setters are defined without getters. Using an option This rule enforces a style where it requires to have a getter for every property which has a setter defined. By activating the option Examples of incorrect code for the default Examples of correct code for the default Examples of incorrect code for the Examples of correct code for the You can turn this rule off if you are not concerned with the simultaneous presence of setters and getters on objects. This rule was introduced in ESLint 0.22.0. The 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). This rule enforces consistent spacing inside array brackets. This rule has a string option: This rule has an object option for exceptions to the This rule has an object option for exceptions to the This rule has built-in exceptions: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of incorrect this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the You can turn this rule off if you are not concerned with the consistency of spacing between array brackets. This rule was introduced in ESLint 0.24.0. This rule enforces usage of This rule finds callback functions of the following methods, then checks usage of Examples of incorrect code for this rule: Examples of correct code for this rule: This rule checks callback functions of methods with the given names, even if the object which has the method is not an array. If you don’t want to warn about usage of This rule was introduced in ESLint 2.0.0-alpha-1. 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. This rule can enforce the use of braces around arrow function body. The rule takes one option, a string, which can be: When the rule is set to The following patterns are not considered problems: When the rule is set to The following patterns are not considered problems: This rule was introduced in ESLint 1.8.0. 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. This rule enforces parentheses around arrow function parameters regardless of arity. For example: Following this style will help you find arrow functions ( The rule can also be configured to discourage the use of parens when they are not required: The rule takes one option, a string, which could be either You can set the option in configuration like this: When the rule is set to The following patterns are not considered problems: One benefits of this option is that it prevents the incorrect use of arrow functions in conditionals: The contents of the The following is another example of this behavior: This should be rewritten like so: When the rule is set to The following patterns are not considered problems: This rule was introduced in ESLint 1.0.0-rc-1. The This rule normalize style of spacing before/after an arrow function’s arrow( This rule takes an object argument with The default configuration is The following patterns are considered problems if The following patterns are not considered problems if The following patterns are not considered problems if The following patterns are not considered problems if The following patterns are not considered problems if This rule was introduced in ESLint 1.0.0-rc-1. The 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: Examples of correct code for this rule: This rule was introduced in ESLint 0.1.0. The This rule enforces consistent spacing inside single-line blocks. This rule has a string option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the If you don’t want to be notified about spacing style inside of blocks, you can safely disable this rule. This rule was introduced in ESLint 1.2.0. 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: One common variant of one true brace style is called Stroustrup, in which the Another style is called Allman, in which all the braces are expected to be on their own lines without any extra indentation. For example: 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. This rule enforces consistent brace style for blocks. This rule has a string option: This rule has an object option for an exception: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of correct code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the If your project will not be using the one true brace style, turn this rule off. This rule was introduced in ESLint 0.0.7. The callback pattern is at the heart of most I/O and event-driven programming
+ in JavaScript. To prevent calling the callback multiple times it is important to This rule is aimed at ensuring that callbacks used outside of the main function block are always part-of or immediately
+preceding a The rule takes a single option, which is an array of possible callback names. The default callback names are Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Because it is difficult to understand the meaning of a program through static analysis, this rule has limitations: 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, Example of a false negative when this rule reports correct code: 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: The static analysis of this rule does not detect that the program calls the callback only one time in each branch of an Example of a false positive when this rule reports incorrect code: 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. This rule was introduced in ESLint 1.0.0-rc-1. When it comes to naming variables, style guides generally fall into one of two camps: camelcase ( This rule looks for any underscores ( This rule has an object option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of correct code for this rule with the If you have established coding standards using a different naming convention (separating words with underscores), turn this rule off. This rule was introduced in ESLint 0.0.2. The 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. 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: More clear: This rule enforces consistent use of trailing commas in object and array literals. This rule has a string option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the You can turn this rule off if you are not concerned with dangling commas. This rule was introduced in ESLint 0.16.0. The 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. 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 This rule has an object option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Example of correct code for this rule with initial null element for the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with initial null element for the If your project will not be following a consistent comma-spacing pattern, turn this rule off. This rule was introduced in ESLint 0.9.0. The Comma Style rule enforces styles for comma-separated lists. There are two comma styles primarily used in JavaScript: 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. 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: This rule has a string option: This rule also accepts an additional A way to determine the node types as defined by ESTree is to use the online demo. Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the An example use case is to enforce comma style only in var statements. Examples of incorrect code for this rule with sample Examples of correct code for this rule with sample This rule can safely be turned off if your project does not care about enforcing a consistent comma style. For more information on the Comma First style: This rule was introduced in ESLint 0.9.0. Cyclomatic complexity measures the number of linearly independent paths through a program’s source code. This rule allows setting a cyclomatic complexity threshold. 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 Examples of incorrect code for a maximum of 2: Examples of correct code for a maximum of 2: Optionally, you may specify a is equivalent to Deprecated: the object property If you can’t determine an appropriate complexity limit for your code, then it’s best to disable this rule. This rule was introduced in ESLint 0.0.9. The While formatting preferences are very personal, a number of style guides require
+or disallow spaces between computed properties in the following situations: 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. This rule has a string option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the You can turn this rule off if you are not concerned with the consistency of computed properties. This rule was introduced in ESLint 0.23.0. 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 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: Here, one branch of the function returns This rule is aimed at ensuring all It excludes constructors which, when invoked with the Examples of incorrect code for this rule: Examples of correct code for this rule: If you want to allow functions to have different This rule was introduced in ESLint 0.4.0. 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: There are many commonly used aliases for This rule enforces two things about variables with the designated alias names for This rule has one or more string options: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default If you need to capture nested context, This rule was introduced in ESLint 0.0.9. Constructors of derived classes must call This rule checks whether or not there is a valid This rule is aimed to flag invalid/missing The following patterns are considered problems: The following patterns are not considered problems: If you don’t want to be notified about invalid/missing This rule was introduced in ESLint 0.24.0. 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: Can be rewritten as: There are, however, some who prefer to only use braces when there is more than one statement to be executed. 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. Examples of incorrect code for the default Examples of correct code for the default By default, this rule warns whenever Examples of incorrect code for the Examples of correct code for the Alternatively, you can relax the rule to allow brace-less single-line Examples of incorrect code for the Examples of correct code for the You can use another configuration that forces brace-less Examples of incorrect code for the Examples of correct code for the When using any of the Examples of incorrect code for the Examples of correct code for the If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. This rule was introduced in ESLint 0.0.2. Some code conventions require that all 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 Once again, the intent here is to show that the developer intended for there to be no default behavior. This rule aims to require Examples of incorrect code for this rule: Examples of correct code for this rule: This rule accepts a single options argument: Examples of correct code for the If you don’t want to enforce a This rule was introduced in ESLint 0.6.0. 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. 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. The rule takes one option, a string: The default Examples of incorrect code for the default Examples of correct code for the default The Examples of incorrect code for the Examples of correct code for the You can turn this rule off if you are not concerned with the consistency of newlines before or after dots in member expressions. This rule was introduced in ESLint 0.21.0. In JavaScript, one can access properties using the dot notation ( 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: Examples of correct code for this rule: This rule accepts a single options argument: Examples of correct code for the 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 Examples of correct code for the sample This rule was introduced in ESLint 0.0.7. The 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. 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 Examples of incorrect code for this rule: Examples of correct code for this rule: This rule has a string option: This rule was introduced in ESLint 0.7.1. It is considered good practice to use the type-safe equality operators The reason for this is that If one of those occurs in an innocent-looking statement such as This rule is aimed at eliminating the type-unsafe equality operators. Examples of incorrect code for this rule: The Examples of incorrect code for the Examples of correct code for the The Examples of incorrect code for the Examples of correct code for the If you don’t want to enforce a style for using equality operators, then it’s safe to disable this rule. This rule was introduced in ESLint 0.0.2. A pattern that’s becoming more common is to give function expressions names to aid in debugging. For example: Adding the second Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.4.0. There are two ways of defining functions in JavaScript: Equivalent function expressions begin with the The primary difference between Although this code might seem like an error, it actually works fine because JavaScript engines hoist the For In this case, 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. This rule enforces a particular type of This rule has a string option: This rule has an object option for an exception: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of additional correct code for this rule with the If you want to allow developers to each decide how they want to write functions on their own, then you can disable this rule. This rule was introduced in ESLint 0.2.0. The 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 Here is an example of a generator function: This is also valid: This is valid as well: To keep a sense of consistency when using generators this rule enforces a single position for the This rule aims to enforce spacing around the The rule takes one option, an object, which has two keys In object literal shorthand methods, spacing before the The default is And the option has shorthand as a string keyword: When using When using When using When using If your project will not be using generators or you are not concerned with spacing consistency, you do not need this rule. This rule was introduced in ESLint 0.17.0. In Node.js, module dependencies are included using the While Since Further, ES6 modules mandate that This rule requires all calls to Examples of incorrect code for this rule: Examples of correct code for this rule: 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 This rule was introduced in ESLint 1.4.0. Looping over objects with a This rule is aimed at preventing unexpected behavior that could arise from using a Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.6. In Node.js, a common pattern for dealing with asynchronous behavior is called the callback pattern.
+This pattern expects an This rule expects that when you’re using the callback pattern in Node.js you’ll handle the error. The rule takes a single string option: the name of the error parameter. The default is Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of correct code for this rule with a sample 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 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. This rule was introduced in ESLint 0.4.5. “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 This rule disallows specified identifiers in assignments and This rule will catch blacklisted identifiers that are: It will not catch blacklisted identifiers that are: The rule takes one or more strings as options: the names of restricted identifiers. For example, to restrict the use of common generic identifiers: Examples of incorrect code for this rule with sample Examples of correct code for this rule with sample You can turn this rule off if you are happy for identifiers to be named freely. This rule was introduced in ESLint 2.0.0-beta.2. Very short identifier names like This rule enforces a minimum and/or maximum identifier length convention. Examples of incorrect code for this rule with the default options: Examples of correct code for this rule with the default options: This rule has an shorthand integer option for the Examples of incorrect code for this rule with a minimum of 4: Examples of correct code for this rule with a minimum of 4: This rule has an object option: Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of additional correct code for this rule with the This rule was introduced in ESLint 1.0.0. “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! This rule requires identifiers in assignments and This rule has a string option for the specified regular expression. For example, to enforce a camelcase naming convention: Examples of correct code for this rule with the Examples of incorrect code for this rule with the This rule has an object option: Examples of incorrect code for this rule with the Examples of correct code for this rule with the If your rules are too complex, it is possible that you encounter performance issues due to the nature of the job. This rule was introduced in ESLint 1.0.0. The There are several common guidelines which require specific indentation of nested blocks and statements, like: These are the most common scenarios recommended in different style guides: This rule enforces a consistent indentation style. The default style is This rule has a mixed option: For example, for 2-space indentation: Or for tabbed indentation: Examples of incorrect code for this rule with the default options: Examples of correct code for this rule with the default options: This rule has an object option: Level of indentation denotes the multiple of the indent specified. Example: Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the This rule was introduced in ESLint 0.14.0. In JavaScript, variables can be assigned during declaration, or at any point afterwards using an assignment statement. For example, in the following code, This rule is aimed at enforcing or eliminating variable initializations during declaration. For example, in the following code, This rule aims to bring consistency to variable initializations and declarations. The rule takes two options: You can configure the rule as follows: Variables must be initialized at declaration (default) Variables must not be initialized at declaration Variables must not be initialized at declaration, except in for loops, where it is allowed Examples of incorrect code for the default Examples of correct code for the default Examples of incorrect code for the Examples of correct code for the The Examples of correct code for the When you are indifferent as to how your variables are initialized. This rule was introduced in ESLint 1.0.0-rc-1. The JSX attribute values can contain string literals, which are delimited with single or double quotes. 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. This rule enforces the consistent use of either double or single quotes in JSX attributes. This rule has a string option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the 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. This rule was introduced in ESLint 1.4.0. 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. 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. This rule has an object option: Please note that you can either use the top-level options or the grouped options ( Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of correct code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with sample 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. This rule was introduced in ESLint 0.9.0. The Keywords are syntax elements of JavaScript, such as Of course, you could also have a style guide that disallows spaces around keywords. This rule enforces consistent spacing around keywords and keyword-like tokens: This rule has an object option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the If you don’t want to enforce consistency on keyword spacing, then it’s safe to disable this rule. This rule was introduced in ESLint 2.0.0-beta.1. The 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 Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule. This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase. This rule has a string option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the If you aren’t concerned about having different line endings within you code, then you can safely turn this rule off. This rule was introduced in ESLint 0.21.0. 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. This rule requires empty lines before and/or after comments. It can be enabled separately for both block ( This rule has an object option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the 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. This rule was introduced in ESLint 0.22.0. Many developers consider code difficult to read if blocks are nested beyond a certain depth. This rule enforces a maximum depth that blocks can be nested to reduce code complexity. This rule has a number or object option: Deprecated: The object property Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default This rule was introduced in ESLint 0.0.9. 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). 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. This rule has a number or object option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct code for this rule with the This rule was introduced in ESLint 0.0.9. 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. This rule enforces a maximum depth that callbacks can be nested to increase code clarity. This rule has a number or object option: Deprecated: The object property Examples of incorrect code for this rule with the Examples of correct code for this rule with the This rule was introduced in ESLint 0.2.0. 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. This rule enforces a maximum number of parameters allowed in function definitions. This rule has a number or object option: Deprecated: The object property Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default This rule was introduced in ESLint 0.0.9. 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. This rule enforces a maximum number of statements allowed per line. The “max” object property is optional (default: 1). Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the You can turn this rule off if you are not concerned with the number of statements on each line. This rule was introduced in ESLint 2.5.0. The This rule enforces a maximum number of statements allowed in function blocks. This rule has a number or object option: Deprecated: The object property This rule has an object option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of additional correct code for this rule with the This rule was introduced in ESLint 0.0.9. The This rule requires constructor names to begin with a capital letter. Certain built-in identifiers are exempt from this rule. These identifiers are: Examples of correct code for this rule: This rule has an object option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of correct code for this rule with the Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of correct code for this rule with the Examples of additional correct code for this rule with the Examples of additional correct code for this rule with the Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of correct code for this rule with the 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. This rule was introduced in ESLint 0.0.3-0. JavaScript allows the omission of parentheses when invoking a function via the This rule requires parentheses when invoking a constructor with no arguments using the Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.6. 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: Whereas others don’t leave any empty newlines at all. 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 This rule enforces a coding style where empty lines are required or disallowed after This rule has a string option: Comments on a line directly after var statements are treated like additional var statements. Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the default Examples of correct code for this rule with the This rule was introduced in ESLint 0.18.0. There is no hardfast rule about whether empty lines should precede Adding newlines visibly separates the return statements from the previous lines, making it clear where the function exits and what value it returns: This rule requires an empty line before Examples of incorrect code for this rule: Examples of correct code for this rule: You can safely disable this rule if you do not have any strict conventions about whitespace before This rule was introduced in ESLint 2.3.0. 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. 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. 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: More clear: This rule requires a newline after each call in a method chain or deep member access. Computed property accesses such as This rule has an object option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default If you have conflicting rules or when you are fine with chained calls on one line, you can safely turn this rule off. This rule was introduced in ESLint 2.0.0-rc.0. 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. 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 Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.5. Use of the This rule disallows Examples of incorrect code for this rule: Examples of correct code for this rule: This rule enforces a nearly universal stylistic concern. That being said, this
+rule may be disabled if the constructor style is preferred. This rule was introduced in ESLint 0.4.0. The use of bitwise operators in JavaScript is very rare and often This rule disallows bitwise operators. Examples of incorrect code for this rule: Examples of correct code for this rule: This rule has an object option: Examples of correct code for this rule with the Examples of correct code for this rule with the This rule was introduced in ESLint 0.0.2. The use of This rule is aimed at discouraging the use of deprecated and sub-optimal code, but disallowing the use of Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.6. This rule disallows lexical declarations ( To ensure that the lexical declaration only applies to the current case clause
+wrap your clauses in blocks. 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: Examples of correct code for this rule: If you depend on fall through behavior and want access to bindings introduced in the case block. This rule was introduced in ESLint 1.9.0. 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. 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: Examples of correct code for this rule: If you do not need to support IE 8 and earlier, you should turn this rule off. This rule was introduced in ESLint 0.0.9. But the modification is a mistake in most cases. This rule is aimed to flag modifying variables of class declarations. The following patterns are considered problems: The following patterns are not considered problems: If you don’t want to be notified about modifying variables of class declarations, you can safely disable this rule. This rule was introduced in ESLint 1.0.0-rc-1. In conditional statements, it is very easy to mistype a comparison operator (such as There are valid reasons to use assignment operators in conditional statements. However, it can be difficult to tell whether a specific assignment was intentional. This rule disallows ambiguous assignment operators in test conditions of This rule has a string option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the This rule was introduced in ESLint 0.0.9. Arrow functions ( Here’s an example where the usage of The following patterns are considered warnings: The following patterns are not considered warnings: This rule accepts a single options argument with the following defaults: When This rule was introduced in ESLint 2.0.0-alpha-2. In JavaScript that is designed to be executed in the browser, it’s considered a best practice to avoid using methods on This rule disallows calls to methods of the Examples of incorrect code for this rule: Examples of correct code for this rule: This rule has an object option for exceptions: Examples of additional correct code for this rule with a sample If you’re using Node.js, however, This rule was introduced in ESLint 0.0.2. We cannot modify variables that are declared using Under non ES2015 environment, it might be ignored merely. This rule is aimed to flag modifying variables that are declared using The following patterns are considered problems: The following patterns are not considered problems: If you don’t want to be notified about modifying variables that are declared using This rule was introduced in ESLint 1.0.0-rc-1. 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. This rule disallows constant expressions in the test condition of: Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.4.1. The This rule disallows Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.19.0. 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. This rule disallows control characters in regular expressions. Examples of incorrect code for this rule: Examples of correct code for this rule: If you need to use control character pattern matching, then you should turn this rule off. This rule was introduced in ESLint 0.1.0. The This rule disallows Example of incorrect code for this rule: Example of correct code for this rule: If your code is still very much in development and don’t want to worry about stripping about This rule was introduced in ESLint 0.0.2. The purpose of the This rule disallows the use of the If ESLint parses code in strict mode, the parser (instead of this rule) reports the error. Examples of incorrect code for this rule: This rule was introduced in ESLint 0.0.9. Require regex literals to escape division operators. This is used to disambiguate the division operator to not confuse users. Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.1.0. 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. 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: Examples of correct code for this rule: This rule was introduced in ESLint 0.16.0. If there are declarations of the same name in class members, the last declaration overwrites other declarations silently.
+It can cause unexpected behaviors. This rule is aimed to flag the use of duplicate names in class members. The following patterns are considered problems: The following patterns are not considered problems: 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. This rule was introduced in ESLint 1.2.0. Multiple properties with the same key in object literals can cause unexpected behavior in your application. This rule disallows duplicate keys in object literals. Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.9. If a This rule disallows duplicate test expressions in Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.17.0. 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 This inspection reports any duplicated module in an import statement. The following patterns are considered problems: The following patterns are not considered problems: This rule takes one optional argument, an object with a single key, With this option set to The following patterns are not considered problems: This rule was introduced in ESLint 2.5.0. If an This rule is aimed at highlighting an unnecessary block of code following an Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.9. Because empty character classes in regular expressions do not match anything, they might be typing mistakes. This rule disallows empty character classes in regular expressions. Examples of incorrect code for this rule: Examples of correct code for this rule: This rule does not report empty character classes in the string argument of calls to the Example of a false negative when this rule reports correct code: This rule was introduced in ESLint 0.22.0. 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. Especially, the empty block of arrow functions might be confusing developers.
+It’s very similar to an empty object literal. 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: Examples of correct code for this rule: This rule has an option to allow specific kinds of functions to be empty. Examples of correct code for the Examples of correct code for the Examples of correct code for the Examples of correct code for the Examples of correct code for the Examples of correct code for the Examples of correct code for the Examples of correct code for the If you don’t want to be notified about empty functions, then it’s safe to disable this rule. This rule was introduced in ESLint 2.0.0. 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: In this code, no new variables are created because In many cases, the empty object pattern is a mistake where the author intended to use a default value instead, such as: The difference between these two patterns is subtle, especially because the problematic empty pattern looks just like an object literal. 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: Examples of correct code for this rule: This rule was introduced in ESLint 1.7.0. Empty block statements, while not technically errors, usually occur due to refactoring that wasn’t completed. They can cause confusion when reading code. This rule disallows empty block statements. This rule ignores block statements which contain a comment (for example, in an empty Examples of incorrect code for this rule: Examples of correct code for this rule: This rule has an object option for exceptions: Examples of additional correct code for this rule with the If you intentionally use empty block statements then you can disable this rule. This rule was introduced in ESLint 0.0.2. Comparing to The Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.9. JavaScript’s This rule is aimed at preventing potentially dangerous, unnecessary, and slow code by disallowing the use of the Examples of incorrect code for this rule: Examples of incorrect code for this rule with browser environment: Examples of incorrect code for this rule with node environment: Examples of correct code for this rule: This rule has an option to allow indirect calls to With this option the following patterns are considered problems: With this option the following patterns are not considered problems: This rule is warning every This rule cannot catch renaming the global object. Such as: This rule was introduced in ESLint 0.0.2. If a This rule disallows reassigning exceptions in Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.9. 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. A common suggestion to avoid this problem would be to wrap the inside of the Disallows directly modifying the prototype of builtin objects. Examples of incorrect code for this rule: This rule accepts an Examples of correct code for the sample This rule does not report any of the following less obvious approaches to modify the prototype of builtin objects: 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 This rule was introduced in ESLint 0.1.4. The This code is an example of a good use of Sometimes during the course of code maintenance, the In this code, the reference to This rule is aimed at avoiding the unnecessary use of Note: Arrow functions can never have their Examples of incorrect code for this rule: Examples of correct code for this rule: If you are not concerned about unnecessary calls to This rule was introduced in ESLint 0.8.0. In contexts such as an This rule disallows unnecessary boolean casts. Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.4.0. If a loop contains no nested loops or switches, labeling the loop is unnecessary. You can achieve the same result by removing the label and using This rule is aimed at eliminating unnecessary labels. Examples of incorrect code for this rule: Examples of correct code for this rule: If you don’t want to be notified about usage of labels, then it’s safe to disable this rule. This rule was introduced in ESLint 2.0.0-rc.0. This rule restricts the use of parentheses to only where they are necessary. This rule always ignores extra parentheses around the following: This rule has a string option: This rule has an object option for exceptions to the Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of correct code for this rule with the Examples of correct code for this rule with the Examples of correct for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the This rule was introduced in ESLint 0.1.4. The 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. This rule disallows unnecessary semicolons. Examples of incorrect code for this rule: Examples of correct code for this rule: If you intentionally use extra semicolons then you can disable this rule. This rule was introduced in ESLint 0.0.9. The In this example, if 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 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. 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: Examples of correct code for this rule: Note that the last This rule accepts a single options argument: Examples of correct code for the If you don’t want to enforce that each This rule was introduced in ESLint 0.0.7. 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: 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. 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: Examples of correct code for this rule: If you aren’t concerned about misinterpreting floating decimal point values, then you can safely turn this rule off. This rule was introduced in ESLint 0.0.6. JavaScript functions can be written as a FunctionDeclaration This rule disallows reassigning Examples of incorrect code for this rule: Examples of incorrect code for this rule, unlike the corresponding rule in JSHint: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.9. 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: Those can be replaced with the following code: This rule is aimed to flag shorter notations for the type conversion, then suggest a more self-explanatory notation. This rule has three main options and one override option to allow some coercions as required. Note that operator Examples of incorrect code for the default Examples of correct code for the default Examples of incorrect code for the default Examples of correct code for the default Examples of incorrect code for the default Examples of correct code for the default Using Examples of correct code for the sample If you don’t want to be notified about shorter notations for the type conversion, you can safely disable this rule. This rule was introduced in ESLint 1.0.0-rc-2. When working with browser scripts, developers often forget that variable and function declarations at the top-level scope become global variables on the This rule disallows Examples of incorrect code for this rule: Examples of correct code for this rule: Examples of correct code for this rule with 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. This rule was introduced in ESLint 2.0.0-alpha-1. It’s considered a good practice to avoid using The first is using This is considered an implied The best practice is to always use a function for the first argument of This rule aims to eliminate implied Examples of incorrect code for this rule: Examples of correct code for this rule: If you want to allow This rule was introduced in ESLint 0.0.7. 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. This rule disallows comments on the same line as code. Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.10.0. 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. 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 ( This rule requires that function declarations and, optionally, variable declarations be in the root of a program or the body of a function. This rule has a string option: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of correct code for this rule with the 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. This rule was introduced in ESLint 0.6.0. An invalid pattern in a regular expression literal is a This rule disallows invalid regular expression strings in Examples of incorrect code for this rule: Examples of correct code for this rule: ECMAScript 6 adds the following flag arguments to the 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 This rule has an object option for exceptions: Examples of correct code for this rule with the This rule was introduced in ESLint 0.1.4. Under the strict mode, This rule aims to flag usage of Basically this rule checks whether or not a function which are containing This rule judges from following conditions whether or not the function is a constructor: This rule judges from following conditions whether or not the function is a method: And this rule allows Otherwise are considered problems. This rule applies only in strict mode.
+With Examples of incorrect code for this rule in strict mode: Examples of correct code for this rule in strict mode: If you don’t want to be notified about usage of This rule was introduced in ESLint 1.0.0-rc-2. 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: 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: This rule has an object option for exceptions: Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of additional correct code for this rule with the Examples of additional correct code for this rule with the Examples of additional correct code for this rule with the If you decide that you wish to use whitespace other than tabs and spaces outside of strings in your application. This rule was introduced in ESLint 0.9.0. The You should use ECMAScript 6 iterators and generators instead. This rule is aimed at preventing errors that may arise from using the Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.9. 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: Examples of correct code for this rule: If you don’t want to be notified about usage of labels, then it’s safe to disable this rule. This rule was introduced in ESLint 0.0.9. Labeled statements in JavaScript are used in conjunction with The 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. This rule aims to eliminate the use of labeled statements in JavaScript. It will warn whenever a labeled statement is encountered and whenever Examples of incorrect code for this rule: Examples of correct code for this rule: The options allow labels with loop or 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. Examples of correct code for the { “allowLoop”: true } option: Examples of correct code for the { “allowSwitch”: true } option: If you need to use labeled statements everywhere, then you can safely disable this rule. This rule was introduced in ESLint 0.4.0. 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 In ES6, code blocks may create a new scope if a block-level binding ( 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: Examples of correct code for this rule with es6 environment: Examples of correct code for this rule with es6 environment and strict mode via This rule was introduced in ESLint 0.4.0. If an should be rewritten as This rule warns when an The following patterns are considered problems: The following patterns are not considered problems: Disable this rule if the code is clearer without requiring the This rule was introduced in ESLint 0.6.0. Writing functions within loops tends to result in errors due to the way the function creates a closure around the loop. For example: 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 In this case, each function created within the loop returns a different number as expected. 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: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.9. ‘Magic numbers’ are numbers that occur multiple time in code without an explicit meaning.
+They should preferably be replaced by named constants. The Examples of incorrect code for this rule: Examples of correct code for this rule: An array of numbers to ignore. It’s set to Examples of correct code for the sample { “ignore”: [1] } option: A boolean to specify if numbers used as array indexes are considered okay. Examples of correct code for the { “ignoreArrayIndexes”: true } option: A boolean to specify if we should check for the const keyword in variable declaration of numbers. Examples of incorrect code for the { “enforceConst”: true } option: A boolean to specify if we should detect numbers when setting object properties for example. Examples of incorrect code for the { “detectObjects”: true } option: Examples of correct code for the { “detectObjects”: true } option: This rule was introduced in ESLint 1.7.0. In the Node.js community it is often customary to separate initializations with calls to When this rule is enabled, each This rule distinguishes between six kinds of variable declaration types: In this document, the first four types are summed up under the term require declaration. This rule can have an object literal option whose two properties have Configuring this rule with one boolean option Examples of incorrect code for this rule with the default Examples of correct code for this rule with the default Examples of incorrect code for this rule with the Examples of incorrect code for this rule with the Examples of correct code for this rule with the The implementation is not aware of any local functions with the name Internally, the list of core modules is retrieved via If you use a pattern such as UMD where the This rule was introduced in ESLint 0.0.9. 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. The 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: The following patterns are considered problems: The following patterns are not considered problems: When the SmartTabs option is enabled the following does not produce a warning: This rule was introduced in ESLint 0.7.1. The Multiple spaces in a row that are not used for indentation are typically mistakes. For example: It’s hard to tell, but there are two spaces between 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: Examples of correct code for this rule: 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. The Only the Examples of correct code for the default Examples of incorrect code for the Examples of correct code for the Examples of correct code for the Examples of correct code for the If you don’t want to check and disallow multiple spaces, then you should turn this rule off. This rule was introduced in ESLint 0.9.0. It’s possible to create multiline strings in JavaScript by using a slash before a newline, such as: Some consider this to be a bad practice as it was an undocumented feature of JavaScript that was only formalized later. This rule is aimed at preventing the use of multiline strings. Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.9. 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. 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. The second argument can be used to configure this rule: In the following example, the The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: If you do not care about extra blank lines, turn this off. This rule was introduced in ESLint 0.9.0. Reports an error when they encounter an attempt to assign a value to built-in native object. The native objects reported by this rule are the Examples of incorrect code for this rule: This rule accepts an If you are trying to override one of the native objects. This rule was introduced in ESLint 0.0.9. 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: should instead be written as: The rule is aimed at preventing the use of a negated expression in a condition. The following patterns are considered warnings: The following patterns are not warnings: This rule was introduced in ESLint 1.6.0. Just as developers might type This rule disallows negating the left operand in Examples of incorrect code for this rule: Examples of correct code for this rule: Never. This rule was introduced in ESLint 0.1.2. Nesting ternary expressions makes code unclear. The The The following patterns are considered problems: The following patterns are considered okay and could be used alternatively: This rule was introduced in ESLint 0.2.0. It’s possible to create functions in JavaScript using the This is considered by many to be a bad practice due to the difficulty in debugging and reading these types of functions. 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 Examples of incorrect code for this rule: Examples of correct code for this rule: In more advanced cases where you really need to use the This rule was introduced in ESLint 0.0.7. The However, this is no different from using the more concise object literal syntax: For this reason, many prefer to always use the object literal syntax and never use the 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. This rule aims to eliminate use of the The following patterns are considered problems: The following patterns are not considered problems: If you wish to allow the use of the This rule was introduced in ESLint 0.0.9. The Some modules return a constructor which can potentially lead to code such as: Unfortunately, this introduces a high potential for confusion since the code author likely meant to write: For this reason, it is usually best to disallow this particular expression. This rule aims to eliminate use of the Examples of incorrect code for this rule: Examples of correct code for this rule: If you are using a custom implementation of This rule was introduced in ESLint 0.6.0. The This throws a This rule is aimed at preventing the accidental calling of The following patterns are considered problems: The following patterns are not considered problems: This rule should not be used in ES3/5 environments. This rule was introduced in ESLint 2.0.0-beta.1. There are three primitive types in JavaScript that have wrapper objects: string, number, and boolean. These are represented by the constructors Behind the scenes in this example, a It’s also possible to manually create a new wrapper instance: 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: The first problem is that primitive wrapper objects are, in fact, objects. That means For these reasons, it’s considered a best practice to avoid using primitive wrapper types with This rule aims to eliminate the use of Examples of incorrect code for this rule: Examples of correct code for this rule: If you want to allow the use of primitive wrapper objects, then you can safely disable this rule. This rule was introduced in ESLint 0.0.6. The goal of using It’s less common to use 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 This rule is aimed at maintaining consistency and convention by disallowing constructor calls using the Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.7. 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 The ECMAScript 5 specification makes it clear that both The Math object does not have a This rule disallows calling the Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.9. 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. 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: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.9. Octal literals are numerals that begin with a leading zero, such as: 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. 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: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.6. Assignment to variables declared as function parameters can be misleading and lead to confusing behavior, as modifying function parameters will also mutate the 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. This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters. Examples of incorrect code for this rule: Examples of correct code for this rule: This rule takes one option, an object, with a boolean property Examples of correct code for the default Examples of incorrect code for the If you want to allow assignment to function parameters, then you can safely disable this rule. This rule was introduced in ESLint 0.18.0. In Node.js, the 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 This example doesn’t need to include separators as Both This rule aims to prevent string concatenation of directory paths in Node.js Examples of incorrect code for this rule: Examples of correct code for this rule: If you want to allow string concatenation of path names. This rule was introduced in ESLint 0.4.0. The The This rule is aimed at flagging the use of 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: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are not considered problems if This rule was introduced in ESLint 0.0.9. The This rule is aimed at discouraging use of Examples of incorrect code for this rule: Examples of correct code for this rule: If prefer to use This rule was introduced in ESLint 0.9.0. The This code could appear in any module and will stop the entire application when 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. This rule aims to prevent the use of Examples of incorrect code for this rule: Examples of correct code for this rule: 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. This rule was introduced in ESLint 0.4.0. When an object is created Examples of incorrect code for this rule: Examples of correct code for this rule: If you need to support legacy browsers, you might want to turn this rule off, since support for This rule was introduced in ESLint 0.0.9. In JavaScript, it’s possible to redeclare the same variable name using This rule is aimed at eliminating variables that have multiple declarations in the same scope. Examples of incorrect code for this rule: Examples of correct code for this rule: This rule takes one optional argument, an object with a boolean property Examples of incorrect code for the Examples of incorrect code for the The This rule was introduced in ESLint 0.0.9. 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: 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: Now it is very clear that three spaces are expected to be matched. This rule disallows multiple spaces in regular expression literals. Examples of incorrect code for this rule: Examples of correct code for this rule: This rule does not report multiple spaces in the string argument of calls to the Example of a false negative when this rule reports correct code: If you want to allow multiple spaces in a regular expression, then you can safely turn this rule off. This rule was introduced in ESLint 0.4.0. 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
+ This rule allows you to specify global variable names that you don’t want to use in your application. This rule takes a list of strings which are the global variable names. Examples of incorrect code for sample Examples of correct code for a sample This rule was introduced in ESLint 2.3.0. 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 Why would you want to restrict imports? Some imports might not make sense in a particular environment. For example, Node.js’ Some modules provide similar or identical functionality, think This rule allows you to specify imports that you don’t want to use in your application. The syntax to specify restricted modules looks like this: To restrict the use of all Node.js core imports (via https://github.com/nodejs/node/tree/master/lib): The following patterns are considered problems: The following patterns are not considered problems: 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. This rule was introduced in ESLint 2.0.0-alpha-1. 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 This rule allows you to specify modules that you don’t want to use in your application. 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): Examples of incorrect code for this rule with sample Examples of correct code for this rule with sample This rule was introduced in ESLint 0.6.0. 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 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 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. This rule takes a list of strings where strings denote the node types: The following patterns are considered problems: The following patterns are not considered problems: If you don’t want to restrict your code from using any JavaScript features or syntax, you should not use this rule. This rule was introduced in ESLint 1.4.0. 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 It is difficult to tell the intent of the Because of this ambiguity, it’s considered a best practice to not use assignment in This rule aims to eliminate assignments from The rule takes one option, a string, which must contain one of the following values: This is the default option.
+It disallows assignments unless they are enclosed in parentheses. Examples of incorrect code for the default Examples of correct code for the default This option disallows all assignments in Examples of incorrect code for the Examples of correct code for the If you want to allow the use of assignment operators in a This rule was introduced in ESLint 0.0.9. Using Examples of incorrect code for this rule: This rule was introduced in ESLint 0.0.9. 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. This rule is aimed at eliminating self assignments. Examples of incorrect code for this rule: Examples of correct code for this rule: If you don’t want to notify about self assignments, then it’s safe to disable this rule. This rule was introduced in ESLint 2.0.0-rc.0. 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 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: This rule was introduced in ESLint 0.0.9. 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: This rule forbids the use of the comma operator, with the following exceptions: Examples of incorrect code for this rule: Examples of correct code for this rule: Disable this rule if sequence expressions with the comma operator are acceptable. This rule was introduced in ESLint 0.5.1. ES5 §15.1.1 Value Properties of the Global Object ( Then any code used within the same scope would not get the global Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.1.4. Shadowing is the process by which a local variable shares the same name as a variable in its containing scope. For example: In this case, the variable This rule aims to eliminate shadowed variable declarations. Examples of incorrect code for this rule: This rule takes one option, an object, with properties The Examples of incorrect code for the The Examples of incorrect code for the default Although Examples of correct code for the default Because Examples of incorrect code for the Examples of correct code for the Because The Examples of correct code for the This rule was introduced in ESLint 0.0.9. The 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. This rule does not allow gaps between the function identifier and application. The following patterns are considered problems: The following patterns are not considered problems: This rule was introduced in ESLint 0.1.2. Sparse arrays contain empty slots, most frequently due to multiple commas being used in an array literal, such as: While the In this example, the 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. 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: Examples of correct code for this rule: If you want to use sparse arrays, then it is safe to disable this rule. This rule was introduced in ESLint 0.4.0. In Node.js, most I/O is done through asynchronous methods. However, there are often synchronous versions of the asynchronous methods. For example, This rule is aimed at preventing synchronous methods from being called in Node.js. It looks specifically for the method suffix “ Examples of incorrect code for this rule: Examples of correct code for this rule: If you want to allow synchronous operations in your script. This rule was introduced in ESLint 0.0.9. 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. The The following patterns are considered problems: The following patterns are considered okay and could be used alternatively: This rule was introduced in ESLint 0.0.9. In the constructor of derived classes, if This rule checks This rule is aimed to flag The following patterns are considered problems: The following patterns are not considered problems: If you don’t want to be notified about using This rule was introduced in ESLint 0.24.0. It is considered good practice to only 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 This rule is aimed at maintaining consistency when throwing exception by disallowing to throw literals and other expressions which cannot possibly be an Examples of incorrect code for this rule: Examples of correct code for this rule: Due to the limits of static analysis, this rule cannot guarantee that you will only throw Examples of correct code for this rule, but which do not throw an This rule was introduced in ESLint 0.15.0. The 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. The following patterns are considered problems: The following patterns are not considered problems: There is one option for this rule, You can enable this option in your config like this: With this option enabled, The following patterns are not considered problems: This rule was introduced in ESLint 0.7.1. In JavaScript, a variable that is declared and not initialized to any value automatically gets the value of It’s therefore unnecessary to initialize a variable to It’s considered a best practice to avoid initializing variables to This rule aims to eliminate variable declarations that initialize to Examples of incorrect code for this rule: Examples of correct code for this rule: There is one situation where initializing to Example of incorrect code for this rule: In this case, the If you were to remove the initialization, then the behavior of the loop changes: This code is equivalent to: This produces a different outcome than defining 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: This rule was introduced in ESLint 0.0.6. 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 Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a Examples of incorrect code for this rule: Examples of correct code for this rule with The Examples of incorrect code for this rule with By default, variables declared in Examples of correct code for the default You can use this option if you want to prevent Examples of incorrect code for the Examples of correct code for the 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. Examples of correct code for this rule with Examples of correct code for this rule with If explicit declaration of global variables is not to your taste. This rule provides compatibility with treatment of global variables in JSHint and JSLint. This rule was introduced in ESLint 0.0.9. The This represents a problem for All uninitialized variables automatically get the value of For this reason, it’s not necessary to explicitly initialize a variable to Taking all of this into account, some style guides forbid the use of This rule aims to eliminate the use of Examples of incorrect code for this rule: Examples of correct code for this rule: If you want to allow the use of This rule was introduced in ESLint 0.7.1. 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: 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 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. This rule aims to eliminate the use of dangling underscores in identifiers. Array of variable names that are permitted to be used with underscore. If provided, it must be an This option allows usage of dangled variables as members of The following patterns are considered problems: The following patterns are not considered problems: If you want to allow dangling underscores in identifiers, then you can safely turn this rule off. This rule was introduced in ESLint 0.0.9. 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: 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. 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: Examples of correct code for this rule: 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. This rule was introduced in ESLint 0.24.0. Variables in a loop condition often are modified in the loop.
+If not, it’s possibly a mistake. 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. Examples of incorrect code for this rule: Examples of correct code for this rule: If you don’t want to notified about references inside of loop conditions, then it’s safe to disable this rule. This rule was introduced in ESLint 2.0.0-alpha-2. 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: 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 This rule disallows the conditional expression as a default assignment pattern when the 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 The following patterns are considered problems: The following pattern is considered a warning when The following patterns are not considered problems: The following pattern is not considered a warning when You can turn this rule off if you are not concerned with unnecessary complexity in conditional expressions. This rule was introduced in ESLint 0.21.0. Because the This rule disallows unreachable code after Examples of incorrect code for this rule: Examples of correct code for this rule, because of JavaScript function and variable hoisting: This rule was introduced in ESLint 0.0.6. JavaScript suspends the control flow statements of This rule disallows Examples of incorrect code for this rule: Examples of correct code for this rule: If you want to allow control flow operations in This rule was introduced in ESLint 2.9.0. An unused expression which has no effect on the state of the program indicates a logic error. For example, 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 This rule does not apply to directives (which are in the form of literal string expressions such as Sequence expressions (those using a comma, such as 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: 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 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. Examples of correct code for the default Examples of incorrect code for the Examples of correct code for the Examples of incorrect code for the Examples of correct code for the Examples of correct code for the This rule was introduced in ESLint 0.1.0. Labels that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. In this case, probably removing This rule is aimed at eliminating unused labels. Examples of incorrect code for this rule: Examples of correct code for this rule: If you don’t want to be notified about unused labels, then it’s safe to disable this rule. This rule was introduced in ESLint 2.0.0-rc.0. 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. 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: A variable is not considered to be used if it is only ever assigned to ( Examples of incorrect code for this rule: Examples of correct code for this rule: In environments outside of CommonJS or ECMAScript modules, you may use Note that This rule takes one argument which can be a string or an object. The string settings are the same as those of the By default this rule is enabled with The Examples of correct code for the The Examples of correct code for the The Examples of incorrect code for the default Examples of correct code for the default Examples of incorrect code for the Examples of correct code for the The Examples of correct code for the The It has two settings: Not specifying this rule is equivalent of assigning it to Examples of correct code for the Examples of incorrect code for the The Examples of correct code for the If you don’t want to be notified about unused variables or function arguments, you can safely turn this rule off. This rule was introduced in ESLint 0.0.9. 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 ( 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: Examples of correct code for this rule: This rule accepts Examples of correct code for the Examples of incorrect code for the Examples of correct code for the This rule was introduced in ESLint 0.0.9. The function invocation can be written by This rule is aimed to flag usage of Examples of incorrect code for this rule: Examples of correct code for this rule: This rule compares code statically to check whether or not Examples of incorrect code for this rule: Examples of correct code for this rule: If you don’t want to be notified about unnecessary This rule was introduced in ESLint 1.0.0-rc-1. It’s unnecessary to use computed properties with literals such as: The code can be rewritten as: This rule disallows unnecessary usage of computed property keys. Examples of incorrect code for this rule: Examples of correct code for this rule: If you don’t want to be notified about unnecessary computed property keys, you can safely disable this rule. This rule was introduced in ESLint 2.9.0. It’s unnecessary to concatenate two strings together, such as: This code is likely the result of refactoring where a variable was removed from the concatenation (such as 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: Examples of correct code for this rule: If you don’t want to be notified about unnecessary string concatenation, you can safely disable this rule. This rule was introduced in ESLint 1.3.0. 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: This rule flags class constructors that can be safely removed without changing how the class works. The following patterns are considered problems: The following patterns are not considered problems: If you don’t want to be notified about unnecessary constructors, you can safely disable this rule. This rule was introduced in ESLint 2.0.0-beta.1. Escaping non-special characters in strings and regular expressions doesn’t have any effects on results, as in the following example: This rule flags escapes that can be safely removed without changing behavior. The following patterns are considered problems: The following patterns are not considered problems: If you don’t want to be notified about unnecessary escapes, you can safely disable this rule. This rule was introduced in ESLint 2.5.0. ECMAScript 6 allows programmers to create variables with block scope instead of function scope using the This rule is aimed at discouraging the use of The following patterns are considered problems: The following patterns are not considered problems: 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 This rule was introduced in ESLint 0.12.0. The The common case of using Another common case is to minify code as When used with IIFE (immediately-invoked function expression) Some code styles prohibit This rule aims to eliminate use of void operator. Examples of incorrect code for this rule: If you intentionally use the This rule was introduced in ESLint 0.8.0. 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. This rule reports comments that include any of the predefined terms specified in its configuration. This rule has an options object literal: Example of incorrect code for the default Example of correct code for the default Examples of incorrect code for the Examples of correct code for the This rule was introduced in ESLint 0.4.4. The JavaScript allows whitespace between objects and their properties. However, inconsistent spacing can make code harder to read and can lead to errors. 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: The following patterns are considered problems when this rule is turned on: And the following patterns are not considered problems: 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. This rule was introduced in ESLint 2.0.0-beta.1. The This rule disallows If ESLint parses code in strict mode, the parser (instead of this rule) reports the error. Examples of incorrect code for this rule: Examples of correct code for this rule: If you intentionally use This rule was introduced in ESLint 0.0.2. The While formatting preferences are very personal, a number of style guides require
+or disallow spaces between curly braces in the following situations: 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. There are two main options for the rule: Depending on your coding conventions, you can choose either option by specifying it in your configuration: When The following patterns are not considered problems: When The following patterns are not considered problems: Note that There are two exceptions you can apply to this rule: These exceptions work in the context of the first option.
+That is, if You can add exceptions like so: In the case of the In the case of the In the case of the In the case of the You can turn this rule off if you are not concerned with the consistency of spacing between curly braces. This rule was introduced in ESLint 0.22.0. 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: This rule aims to maintain consistency of newlines between object properties. Examples of incorrect code for this rule: Examples of correct code for this rule: This rule has an object option: Examples of additional correct code for this rule with the You can turn this rule off if you are not concerned with the consistency of newlines between object properties. This rule was introduced in ESLint 2.10.0. 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: Now here are ES6 equivalents: 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: In that case the expected syntax would have been: This rule does not flag arrow functions inside of object literals.
+The following will not warn: 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”. You can set the option in configuration like this: While set to Examples of incorrect code for this rule with the Examples of correct code for this rule with the While set to The following will not warn when 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. This rule was introduced in ESLint 0.20.0. Some developers declare multiple var statements on the same line: Others prefer to declare one var per line. This rule enforces a consistent style across the entire project. 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. This rule takes one option, a string, which can be: The following patterns are considered problems when set to The following patterns are not considered problems when set to The following patterns are considered problems when set to The following patterns are not considered problems when set to This rule was introduced in ESLint 2.0.0-beta.3. Variables can be declared at any point in JavaScript code using There are two schools of thought in this regard: For instance: 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 This rule is aimed at enforcing the use of either one variable declaration or multiple declarations per function (for There are two ways to configure this rule. The first is by using one string specified as The second way to configure this rule is with an object. The keys are any of: or: and the values are either You can configure the rule as follows: (default) Exactly one variable declaration per type per function (var) or block (let or const) Exactly one declarator per declaration per function (var) or block (let or const) Configure each declaration type individually. Defaults to Configure uninitialized and initialized seperately. Defaults to When configured with The following patterns are not considered problems: When configured with The following patterns are not considered problems: When configured with an object as the first option, you can individually control how The following patterns are not considered problems: The following patterns are not considered problems: 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: JSLint Errors - Combine this with the previous ‘var’ statement This rule was introduced in ESLint 0.0.9. JavaScript provides shorthand operators that combine variable assignment and some simple mathematical operations. For example, This rule enforces use of the shorthand assignment operators by requiring them where possible or prohibiting them entirely. This rule has two options: This mode enforces use of operator assignment shorthand where possible. The following are examples of valid patterns: The following patterns are considered problems and should be replaced by their shorthand equivalents: This mode warns on any use of operator assignment shorthand. The following are examples of valid patterns: The following patterns are considered problems and should be written out fully without the shorthand assignments: 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. This rule was introduced in ESLint 0.10.0. 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. Some developers find that placing operators at the beginning of the line makes the code more readable. The The rule takes two options, a string, which can be You can set the style in configuration like this: The default configuration is to enforce line breaks after the operator except for the ternary operator 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: The following patterns are not considered problems: This option requires the line break to be placed before the operator. While using this setting, the following patterns are considered problems: The following patterns are not considered problems: This option disallows line breaks on either side of the operator. While using this setting, the following patterns are considered problems: The following patterns are not considered problems: The rule allows you to have even finer-grained control over individual operators by specifying an This would override the global setting for that specific operator. 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: If your project will not be using a common operator line break style, turn this rule off. This rule was introduced in ESLint 0.19.0. 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. Since it’s good to have a consistent code style, you should either always write
+padded blocks or never do it. This rule enforces consistent padding within blocks. This rule takes one argument, which can be an string or an object. If it is 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. The following patterns are considered problems when set to The following patterns are not considered problems when set to The following patterns are considered problems when set to The following patterns are not considered problems when set to The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured You can turn this rule off if you are not concerned with the consistency of padding within blocks. This rule was introduced in ESLint 0.9.0. Arrow functions are suited to callbacks, because: This rule is aimed to flag usage of function expressions in an argument list. The following patterns are considered problems: The following patterns are not considered problems: This rule takes one optional argument, an object which is an options object. This is a Examples of correct code for the This is a Examples of incorrect code for the 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. This rule was introduced in ESLint 1.2.0. If a variable is never reassigned, using the This rule is aimed at flagging variables that are declared using Examples of incorrect code for this rule: Examples of correct code for this rule: The kind of the way to address variables in destructuring.
+There are 2 values: Examples of incorrect code for the default Examples of correct code for the default Examples of incorrect code for the Examples of correct code for the This is an option to avoid conflicting with Examples of correct code for the Examples of correct code for the defaut If you don’t want to be notified about variables that are never reassigned after initial assignment, you can safely disable this rule. This rule was introduced in ESLint 0.23.0. 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. The For example if you wish to use all Reflect methods, except for If you want to use Reflect methods, but keep using the These can be combined as much as you like. To make all methods exceptions (thereby rendering this rule useless), use The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: config: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: config: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: (Note: For a rule preventing deletion of variables, see no-delete-var instead) 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. This rule was introduced in ESLint 1.0.0-rc-2. There are rest parameters in ES2015.
+We can use that feature for variadic functions instead of the This rule is aimed to flag usage of The following patterns are considered problems: The following patterns are not considered problems: This rule should not be used in ES3/5 environments. In ES2015 (ES6) or later, if you don’t want to be notified about This rule was introduced in ESLint 2.0.0-alpha-1. Before ES2015, one must use In ES2015, one can use the spread operator to call variadic functions. This rule is aimed to flag usage of The following patterns are considered problems: The following patterns are not considered problems: Known limitations: This rule analyzes code statically to check whether or not the This rule should not be used in ES3/5 environments. In ES2015 (ES6) or later, if you don’t want to be notified about This rule was introduced in ESLint 1.0.0-rc-1. In ES2015 (ES6), we can use template literals instead of string concatenation. This rule is aimed to flag usage of The following patterns are considered problems: The following patterns are not considered problems: 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. This rule was introduced in ESLint 1.2.0. Object literal property names can be defined in two ways: using literals or using strings. For example, these two objects are equivalent: 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: Another example where quotes do matter is when using numeric literals as property keys: This may look alright at first sight, but this code in fact throws a syntax error in ECMAScript 5 strict mode. This happens because 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). There are four behaviors for this rule: When configured with Here, the properties or, if you prefer single quotes: When configured with The following patterns are not considered problems: When configured with The following patterns are not considered problems: When the When Another modifier for this rule is the When A When and the following patterns stop being problems: When configured with The following patterns are not considered problems: When configured with The following patterns are not considered problems: When the When 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. This rule was introduced in ESLint 0.0.6. The JavaScript allows you to define strings in one of three ways: double quotes, single quotes, and backticks (as of ECMAScript 6). For example: 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. 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: When using Configuration looks like this: Deprecation notice: The The following patterns are considered problems: The following patterns are not considered problems: If you do not need consistency in your string styles, you can safely disable this rule. This rule was introduced in ESLint 0.0.7. When using the This confusion led to the suggestion that you always use the radix parameter to Do this: ECMAScript 5 changed the behavior of On the other hand, if the code is targeting only ES5-compliant environments passing the radix 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 There are two options for this rule: Examples of incorrect code for the default Examples of correct code for the default Examples of incorrect code for the Examples of correct code for the If you don’t want to enforce either presence or omission of the This rule was introduced in ESLint 0.0.7. 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: Some style guides require JSDoc comments for all functions as a way of explaining function behavior. This rule generates warnings for nodes that do not have JSDoc comments when they should. Supported nodes: This rule accepts a Default option settings are The following patterns are considered problems: The following patterns are not considered problems: If you do not require JSDoc for your functions, then you can leave this rule off. This rule was introduced in ESLint 1.4.0. This rule generates warnings for generator functions that do not have the The following patterns are considered problems: The following patterns are not considered problems: This rule was introduced in ESLint 1.0.0-rc-1. The 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. 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 ( The spacing around the semicolon in a for loop with an empty condition ( The rule takes one option, an object, which has two keys The default is This is the default option. It enforces spacing after semicolons and disallows spacing before semicolons. The following patterns are considered problems: The following patterns are not considered problems: This option enforces spacing before semicolons and disallows spacing after semicolons. The following patterns are considered problems: The following patterns are not considered problems: You can turn this rule off if you are not concerned with the consistency of spacing before or after semicolons. This rule was introduced in ESLint 0.16.0. The 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: 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: This may look like a Effectively, a semicolon is inserted after the 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: 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 This rule is aimed at ensuring consistent use of semicolons. You can decide whether or not to require semicolons at the end of statements. The rule takes one or two options. The first one is a string, which could be You can set the option in configuration like this: By using the default option, semicolons must be used any place where they are valid. The following patterns are considered problems: The following patterns are not considered problems: 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: The following patterns are considered problems: The following patterns are not considered problems: If you want to enforce that semicolons are never used, switch the configuration to: Then, the following patterns are considered problems: And the following patterns are not considered problems: Even in If you do not want to enforce semicolon usage (or omission) in any particular way, then you can turn this rule off. This rule was introduced in ESLint 0.0.6. 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: 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. 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. 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 The following example shows correct sorted import declarations: The following patterns are considered problems: The following patterns are not considered problems: This rule accepts an object with its properties as Default option settings are When The following patterns are considered problems: The following patterns are not considered problems: Default is Ignores the member sorting within a The following patterns are considered problems: The following patterns are not considered problems: Default is The member syntax sort order can be configured with this option. There are four different styles and the default member syntax sort order is: 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: The following patterns are not considered problems: Default is 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. This rule was introduced in ESLint 2.0.0-beta.1. 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. 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: The following patterns are not considered problems: Alphabetical list is maintained starting from the first variable and excluding any that are considered problems. So the following code will produce two problems: But this one, will only produce one: When The following patterns are not considered problems: 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. This rule was introduced in ESLint 0.2.0. The 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. 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 takes one argument. If it is ( e.g. The default is The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured You can turn this rule off if you are not concerned with the consistency of spacing before blocks or if you are using the This rule was introduced in ESLint 0.9.0. The When formatting a function, whitespace is allowed between the function name or Style guides may require a space after the This rule aims to enforce consistent spacing before function parentheses and as such, will warn whenever whitespace doesn’t match the preferences specified. This rule takes one argument. If it is The default configuration is The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: You can turn this rule off if you are not concerned with the consistency of spacing before function parenthesis. This rule was introduced in ESLint 0.18.0. The Some style guides require or disallow spaces inside of parentheses: This rule will enforce consistency of spacing directly inside of parentheses, by disallowing or requiring one or more spaces to the right of There are two options for this rule: Depending on your coding conventions, you can choose either option by specifying it in your configuration: When The following patterns are not considered problems: When The following patterns are not considered problems: An object literal may be used as a third array item to specify exceptions, with the key The following exceptions are available: For example, given The following patterns are not considered problems: Or, given The following patterns are not considered problems: Given The following patterns are not considered problems: Or, given The following patterns are not considered problems: Given The following patterns are not considered problems: Or, given The following patterns are not considered problems: The For example, given The following patterns are not considered problems: Or, given The following patterns are not considered problems: You can include multiple entries in the The following patterns are not considered problems: You can turn this rule off if you are not concerned with the consistency of spacing between parentheses. This rule was introduced in ESLint 0.8.0. The While formatting preferences are very personal, a number of style guides require spaces around operators, such as: The proponents of these extra spaces believe it make the code easier to read and can more easily highlight potential errors, such as: While this is valid JavaScript syntax, it is hard to determine what the author intended. This rule is aimed at ensuring there are spaces around infix operators. This rule accepts a single options argument with the following defaults: Set the The following patterns are considered problems: The following patterns are not considered problems: This rule was introduced in ESLint 0.2.0. The 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. This rule enforces consistency regarding the spaces after Examples of unary Examples of unary This rule has three options: In this case, spacing will be disallowed after a Given the default values Given the default values This rule was introduced in ESLint 0.10.0. The Some style guides require or disallow a whitespace immediately after the initial This rule will enforce consistency of spacing after the start of a comment The rule takes two options. The first is a string which be either If If This rule can also take a 2nd option, an object with either of the following keys: 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: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: The following patterns are considered problems: The following patterns are not considered problems: This rule was introduced in ESLint 0.23.0. 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: It is also possible to specify function-level strict mode, such that strict mode applies only to the function in which the directive occurs: Unlike scripts, ECMAScript modules are always in strict mode. Strict mode directives in ECMAScript modules have no effect. This rule is aimed at using strict mode directives effectively, and as such, will flag any unexpected uses or omissions of strict mode directives. There are four options for this rule: 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. 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 This mode forbids any occurrence of a strict mode directive. Examples of incorrect code for the Examples of correct code for the 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 Examples of correct code for the 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 Examples of correct code for the Replacement notice: This mode, previously enabled by turning on the rule without specifying a mode, has been removed in ESLint v1.0. 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: Examples of correct code for an earlier default option which has been removed: 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 This rule was introduced in ESLint 0.1.0. The We can embed expressions in template strings with using a pair of This rule aims to maintain consistency around the spacing inside of template literals. This rule has one option which has either The following patterns are considered problems when configured The following patterns are considered problems when configured The following patterns are not considered problems when configured The following patterns are not considered problems when configured If you don’t want to be notified about usage of spacing inside of template strings, then it’s safe to disable this rule. This rule was introduced in ESLint 2.0.0-rc.0. In JavaScript, Because Therefore, use This rule disallows comparisons to ‘NaN’. Examples of incorrect code for this rule: Examples of correct code for this rule: This rule was introduced in ESLint 0.0.6. 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: 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. This rule aims to prevent invalid and incomplete JSDoc comments. It will warn when any of the following is true: Examples of incorrect code for this rule: Examples of correct code for this rule: JSDoc offers a lot of tags with overlapping meaning. For example, both With this configuration, ESLint will warn when it finds By default ESLint requires you to document every function with a By default ESLint requires you to specify a description for each By default ESLint requires you to specify a description for each Specify a regular expression to validate jsdoc comment block description against. By default ESLint requires you to specify 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. Examples of incorrect code for a sample of Examples of correct code for a sample of If you aren’t using JSDoc, then you can safely turn this rule off. This rule was introduced in ESLint 0.4.0. For a vast majority of use cases, the result of the This rule enforces comparing Examples of incorrect code for this rule: Examples of correct code for this rule: You may want to turn this rule off if you will be using the This rule was introduced in ESLint 0.5.0. The 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: Examples of correct code for this rule: This rule was introduced in ESLint 0.8.0. 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. This rule requires all immediately-invoked function expressions to be wrapped in parentheses. The rule takes one option which can enforce a consistent wrapping style: Examples of incorrect code for the default Examples of correct code for the default Examples of incorrect code for the Examples of correct code for the Examples of incorrect code for the Examples of correct code for the This rule was introduced in ESLint 0.0.9. When a regular expression is used in certain situations, it can end up looking like a division operator. For example: This is used to disambiguate the slash operator and facilitates more readable code. The following patterns are considered problems: The following patterns are not considered problems: This rule was introduced in ESLint 0.1.0. The This rule enforces spacing around the The rule takes one option, an object, which has two keys The default is The option also has a string shorthand: When using When using When using When using To use this rule you either need to use the If your project will not be using generators or you are not concerned with spacing consistency, you do not need this rule. This rule was introduced in ESLint 2.0.0-alpha-1. 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: 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: 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 Opponents of Yoda conditions point out that tooling has made us better programmers because tools will catch the mistaken use of This rule aims to enforce consistent style of conditions which compare a variable to a literal value. This rule can take a string option: The default The Examples of incorrect code for the default Examples of correct code for the default Examples of correct code for the Examples of correct code for the Examples of incorrect code for the Examples of correct code for the This rule was introduced in ESLint 0.7.1. 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 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 @@ > 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
String using XML entities.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);
- }
+ /**
+ * String using XML entities.
+ * "bread" & "butter" {@literal =>}
+ * "bread" & "butter".
+ * 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);
+ }
- /**
- * String using XML entities.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);
- }
+ /**
+ * String using XML entities.
+ * "bread" & "butter" {@literal =>}
+ * "bread" & "butter".
+ * 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() {
* null separator is the same as an empty String ("").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) {
* null separator is the same as an empty String ("").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("Details
+
+
+angularelement - use
+
+angular.element instead of $ or jQueryExamples
+
+
+
+/*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
+
+/*eslint angular/angularelement: 2*/
// valid
angular.element('.some-class');Version
+
+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
+
+
+
+
+Examples
+
+
+
+/*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
+
+/*eslint angular/component-limit: 2*/
// valid
angular.module('myModule').controller('SomeController', function() {
// ...
});
// valid
angular.module('myModule').directive('myDirective', function() {
// ...
});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 43:
+
+/*eslint angular/component-limit: [2,3]*/
// valid
angular.module('myModule').controller('ControllerOne', function() {
// ...
}).directive('directiveTwo', function() {
// ...
}).factory('serviceThree', function() {
// ...
});Version
+
+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 controllersExamples
+
+
+
+/*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"
+
+/*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
+
+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
+
+Examples
+
+
+
+/*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"
+
+/*eslint angular/controller-as-route: 2*/
// valid
$routeProvider.when('/myroute', {
controller: 'MyController',
controllerAs: 'vm'
});
// valid
$routeProvider.when('/myroute', {
controller: 'MyController as vm'
});Version
+
+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
+
+
+Examples
+
+
+
+/*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"
+
+/*eslint angular/controller-as-vm: 2*/
// valid
angular.module('test').controller('TestController', function() {
var vm = this;
vm.test = 'test';
});"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"viewModel":
+
+/*eslint angular/controller-as-vm: [2,"viewModel"]*/
// valid
angular.module('test').controller('TestController', function() {
var viewModel = this;
viewModel.test = 'test';
});Version
+
+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
+
+Examples
+
+
+
+/*eslint angular/controller-name: 2*/
// invalid
angular.module('myModule').controller('MyCtrl', function () {
// ...
}); // error: The MyCtrl controller should follow this pattern: /[A-Z].*Controller$/
+
+/*eslint angular/controller-name: 2*/
// valid
angular.module('myModule').controller('MyController', function () {
// ...
});"ui":
+
+/*eslint angular/controller-name: [2,"ui"]*/
// invalid
angular.module('myModule').controller('TabsController', function () {
// ...
}); // error: The TabsController controller should be prefixed by ui"ui":
+
+/*eslint angular/controller-name: [2,"ui"]*/
// valid
angular.module('myModule').controller('uiTabsController', function () {
// ...
});"/[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/"/[A-Z].*Ctrl/":
+
+/*eslint angular/controller-name: [2,"/[A-Z].*Ctrl/"]*/
// valid
angular.module('myModule').controller('MyCtrl', function () {
// ...
});Version
+
+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.deferredExamples
+
+
+
+/*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.
+
+/*eslint angular/deferred: 2*/
// valid
$q(function() {
// ...
});Version
+
+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 checksExamples
+
+
+
+/*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
+
+/*eslint angular/definedundefined: 2*/
// valid
angular.isUndefined(value)
// valid
angular.isDefined(value)Version
+
+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
+
+Examples
+
+
+
+/*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
+
+/*eslint angular/di: 2*/
// valid
angular.module('myModule').factory('myService', function ($http, $log, anotherService) {
// ...
});"array":
+
+/*eslint angular/di: [2,"array"]*/
// valid
angular.module('myModule').factory('myService', ['$http', '$log', 'anotherService', function ($http, $log, anotherService) {
// ...
}]);"$inject":
+
+/*eslint angular/di: [2,"$inject"]*/
// valid
angular.module('myModule').factory('myService', myServiceFn);
myServiceFn.$inject=['$http', '$log', 'anotherService'];
function myServiceFn($http, $log, anotherService) {
// ...
}Version
+
+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
+
+_$httpBackend_ goes before _$http_.Examples
+
+
+
+/*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
+
+/*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) {
// ...
});true:
+
+/*eslint angular/di-order: [2,true]*/
// invalid
beforeEach(inject(function ($httpBackend, _$compile_, _$log_, _$rootScope_) {
// ...
})); // error: Injected values should be sorted alphabeticallytrue:
+
+/*eslint angular/di-order: [2,true]*/
// valid
beforeEach(inject(function (_$compile_, $httpBackend, _$log_, _$rootScope_) {
// ...
}));false:
+
+/*eslint angular/di-order: [2,false]*/
// invalid
beforeEach(inject(function (_$compile_, $httpBackend, _$log_, _$rootScope_) {
// ...
})); // error: Injected values should be sorted alphabeticallyfalse:
+
+/*eslint angular/di-order: [2,false]*/
// valid
beforeEach(inject(function ($httpBackend, _$compile_, _$log_, _$rootScope_) {
// ...
}));Version
+
+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
+
+Examples
+
+
+
+/*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
+
+/*eslint angular/di-unused: 2*/
// valid
angular.module('myModule').factory('myService', function ($log, anotherService) {
$log.log(anotherService.getSomeData());
});Version
+
+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
+
+
+
+
+Examples
+
+"prefix":
+
+/*eslint angular/directive-name: [2,"prefix"]*/
// valid
angular.module('myModule').directive('prefixTabs', function () {
// ...
});"/^ui/":
+
+/*eslint angular/directive-name: [2,"/^ui/"]*/
// invalid
angular.module('myModule').directive('navigation', function () {
// ...
}); // error: The navigation directive should follow this pattern: /^ui/"/^ui/":
+
+/*eslint angular/directive-name: [2,"/^ui/"]*/
// valid
angular.module('myModule').directive('uiNavigation', function () {
// ...
});"ui":
+
+/*eslint angular/directive-name: [2,"ui"]*/
// invalid
angular.module('myModule').directive('tabs', function () {
// ...
}); // error: The tabs directive should be prefixed by uiVersion
+
+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'
+
+AE and disallows explicitly specifying a default.
+("directive-restrict": [0, {"restrict": "AE", "explicit": "never"}])Examples
+
+
+
+/*eslint angular/directive-restrict: 2*/
// valid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '<h2>Hello World!</h2>',
restrict: 'A' // also allowed: A, E, AE, EA
};
});
// valid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '<h2>Hello World!</h2>'
// no explicit restrict is allowed by default
};
});{"explicit":"always"}:
+
+/*eslint angular/directive-restrict: [2,{"explicit":"always"}]*/
// invalid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '<h2>Hello World!</h2>'
};
}); // error: Missing directive restriction{"explicit":"never"}:
+
+/*eslint angular/directive-restrict: [2,{"explicit":"never"}]*/
// invalid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '<h2>Hello World!</h2>',
restrict: 'AE'
};
}); // error: No need to explicitly specify a default directive restriction{"restrict":"A"}:
+
+/*eslint angular/directive-restrict: [2,{"restrict":"A"}]*/
// invalid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '<h2>Hello World!</h2>',
restrict: 'E'
};
}); // error: Disallowed directive restriction. It must be one of A in that orderVersion
+
+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 documentExamples
+
+
+
+/*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
+
+/*eslint angular/document-service: 2*/
// valid
$document[0].title = ""Version
+
+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 variablesinject 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
+
+
+
+/*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'
+
+/*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
+
+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
+
+Examples
+
+
+
+/*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
+
+/*eslint angular/empty-controller: 2*/
// valid
angular.module('myModule').controller('MyController', function ($log) {
$log.log('Hello World!');
});Version
+
+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
+
+Examples
+
+
+
+/*eslint angular/file-name: 2*/
// invalid with filename: src/app/filters.js
app.filter('usefulFilter', function() {}); // error: Filename must be "usefulFilter.js"
+
+/*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() {});{"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"{"typeSeparator":"dot"}:
+
+/*eslint angular/file-name: [2,{"typeSeparator":"dot"}]*/
// valid with filename: src/app/usefulFilter.filter.js
app.filter('usefulFilter', function() {});{"typeSeparator":"dash"}:
+
+/*eslint angular/file-name: [2,{"typeSeparator":"dash"}]*/
// valid with filename: app/utils/myUtils-service.js
app.factory('myUtils', function() {});{"typeSeparator":"underscore"}:
+
+/*eslint angular/file-name: [2,{"typeSeparator":"underscore"}]*/
// valid with filename: src/app/awesomeModule/beautifulDirective_directive.js
app.directive('beautifulDirective', function() {});{"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() {});{"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() {});{"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() {});{"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() {});{"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() {});{"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
+
+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
+
+Examples
+
+"prefix":
+
+/*eslint angular/filter-name: [2,"prefix"]*/
// valid
angular.module('myModule').filter('prefixFilter', function () {
// ...
});"/^xyz/":
+
+/*eslint angular/filter-name: [2,"/^xyz/"]*/
// invalid
angular.module('myModule').filter('otherFilter', function () {
// ...
}); // error: The otherFilter filter should follow this pattern: /^xyz/"/^xyz/":
+
+/*eslint angular/filter-name: [2,"/^xyz/"]*/
// valid
angular.module('myModule').filter('xyzFilter', function () {
// ...
});"xyz":
+
+/*eslint angular/filter-name: [2,"xyz"]*/
// invalid
angular.module('myModule').filter('someFilter', function () {
// ...
}); // error: The someFilter filter should be prefixed by xyzVersion
+
+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.forEachExamples
+
+
+
+/*eslint angular/foreach: 2*/
// invalid
someArray.forEach(function (element) {
// ...
}); // error: You should use the angular.forEach method
+
+/*eslint angular/foreach: 2*/
// valid
angular.forEach(someArray, function (element) {
// ...
});Version
+
+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
+
+Examples
+
+"anonymous":
+
+/*eslint angular/function-type: [2,"anonymous"]*/
// invalid
angular.module('myModule').factory('myService', myServiceFn);
function myServiceFn() {
// ...
} // error: Use anonymous functions instead of named function"anonymous":
+
+/*eslint angular/function-type: [2,"anonymous"]*/
// valid
angular.module('myModule').factory('myService', function () {
// ...
});"named":
+
+/*eslint angular/function-type: [2,"named"]*/
// invalid
angular.module('myModule').factory('myService', function () {
// ...
}); // error: Use named functions instead of anonymous function"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
+
+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 setIntervalExamples
+
+
+
+/*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
+
+/*eslint angular/interval-service: 2*/
// valid
$interval(function() {
// ...
}, 1000)Version
+
+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 of
+
+angular.fromJson and 'angular.toJson'Examples
+
+
+
+/*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
+
+/*eslint angular/json-functions: 2*/
// valid
angular.toJson({
// ...
});
// valid
var data = angular.fromJson('{"message": "Hello World!"}');Version
+
+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 methodsExamples
+
+
+
+/*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
+
+/*eslint angular/log: 2*/
// valid
$log.log('Hello world!');
// valid
$log.error('Some error!');Version
+
+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
+
+false all dependencies combined should be sorted alphabetically.
+('module-dependency-order', [2, {grouped: true, prefix: "app"}])Examples
+
+
+
+/*eslint angular/module-dependency-order: 2*/
// invalid
angular.module('myModule', ['ngRoute', 'ngAnimate']); // error: ngAnimate should be sorted before ngRoute
+
+/*eslint angular/module-dependency-order: 2*/
// valid
angular.module('myModule', ['ngAnimate', 'ngRoute', 'app', 'appFilters', 'ui.router']);{"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{"grouped":true}:
+
+/*eslint angular/module-dependency-order: [2,{"grouped":true}]*/
// valid
angular.module('myModule', ['ngAnimate', 'ngRoute', 'app', 'appFilters', 'ui.router']);{"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{"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
+
+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
+
+Examples
+
+
+
+/*eslint angular/module-getter: 2*/
// invalid
app.controller('MyController', function () {
// ...
}); // error: Avoid using a variable and instead use chaining with the getter syntax.
+
+/*eslint angular/module-getter: 2*/
// valid
angular.module('myModule').controller('MyController', function () {
// ...
});Version
+
+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
+
+Examples
+
+"prefix":
+
+/*eslint angular/module-name: [2,"prefix"]*/
// valid
angular.module('prefixModule', []);"/^xyz/":
+
+/*eslint angular/module-name: [2,"/^xyz/"]*/
// invalid
angular.module('otherModule', []); // error: The otherModule module should follow this pattern: /^xyz/"/^xyz/":
+
+/*eslint angular/module-name: [2,"/^xyz/"]*/
// valid
angular.module('xyzModule', []);"xyz":
+
+/*eslint angular/module-name: [2,"xyz"]*/
// invalid
angular.module('myModule', []); // error: The myModule module should be prefixed by xyzVersion
+
+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
+
+Examples
+
+
+
+/*eslint angular/module-setter: 2*/
// invalid
var app = angular.module('myModule', []); // error: Declare modules without a variable using the setter syntax.
+
+/*eslint angular/module-setter: 2*/
// valid
angular.module('myModule', [])Version
+
+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 directlyExamples
+
+
+
+/*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.
+
+/*eslint angular/no-angular-mock: 2*/
// valid
dump($scope);
// valid
inject(function (someService) {
// ...
});
// valid
module('myModule');Version
+
+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)
+
+Examples
+
+
+
+/*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
+
+/*eslint angular/no-controller: 2*/
// valid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '<div>{{ text }}',
controller: function ($scope) {
$scope.text = 'Hello World';
}
};
});Version
+
+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 $cookieStoreExamples
+
+
+
+/*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.
+
+/*eslint angular/no-cookiestore: 2*/
// valid
$cookies.put('favoriteMeal', 'pizza');
// valid
$cookies.get('favoriteMeal');Version
+
+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
+
+ignoreReplaceFalse let you ignore directive definitions with replace set to false.Examples
+
+
+
+/*eslint angular/no-directive-replace: 2*/
// invalid
angular.module('myModule').directive('helloWorld', function() {
return {
template: '<h2>Hello World!</h2>',
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.
+
+/*eslint angular/no-directive-replace: 2*/
// valid
angular.module('myModule').directive('helloWorld', function() {
return {
template: '<h2>Hello World!</h2>'
};
});{"ignoreReplaceFalse":true}:
+
+/*eslint angular/no-directive-replace: [2,{"ignoreReplaceFalse":true}]*/
// valid
angular.module('myModule').directive('helloWorld', function() {
return {
template: '<h2>Hello World!</h2>',
replace: false
};
});{"ignoreReplaceFalse":false}:
+
+/*eslint angular/no-directive-replace: [2,{"ignoreReplaceFalse":false}]*/
// invalid
angular.module('myModule').directive('helloWorld', function() {
return {
template: '<h2>Hello World!</h2>',
replace: true
};
}); // error: Directive definition property replace is deprecated.Version
+
+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()Examples
+
+
+
+/*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
+
+/*eslint angular/no-http-callback: 2*/
// valid
$http.get('api/data').then(function onSuccess() {
// ...
}, function onReject() {
// ...
});Version
+
+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
+
+Examples
+
+
+
+/*eslint angular/no-inline-template: 2*/
// invalid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '<div>Hello World! <button>Say hello!</button></div>'
};
}); // error: Inline template is too complex. Use an external template instead
+
+/*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: '<div>Hello World</div>' // simple templates are allowed by default
};
});
// valid
angular.module('myModule').config(function ($routeProvider) {
$routeProvider.when('/hello', {
template: '<hello-world></hello-world>' // directives for routing
});
});{"allowSimple":true}:
+
+/*eslint angular/no-inline-template: [2,{"allowSimple":true}]*/
// invalid
angular.module('myModule').config(function ($routeProvider) {
$routeProvider.when('/dashboard', {
template: '<div><h1>Dashboard</h1><dashboard></dashboard></div>'
});
}); // error: Inline template is too complex. Use an external template instead{"allowSimple":true}:
+
+/*eslint angular/no-inline-template: [2,{"allowSimple":true}]*/
// valid
angular.module('myModule').config(function ($routeProvider) {
$routeProvider.when('/dashboard', {
template: '<dashboard></dashboard>' // directives for routing
});
});{"allowSimple":false}:
+
+/*eslint angular/no-inline-template: [2,{"allowSimple":false}]*/
// invalid
angular.module('myModule').config(function ($routeProvider) {
$routeProvider.when('/dashboard', {
template: '<dashboard></dashboard>'
});
}); // error: Inline templates are not allowed. Use an external template instead{"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
+
+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 $Examples
+
+
+
+/*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
+
+/*eslint angular/no-jquery-angularelement: 2*/
// valid
angular.element("#id")Version
+
+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 $$
+
+Examples
+
+
+
+/*eslint angular/no-private-call: 2*/
// invalid
$scope.$$watchers.forEach(function (watcher) {
// ...
}); // error: Using $$-prefixed Angular objects/methods are not recommended
+
+/*eslint angular/no-private-call: 2*/
// valid
$scope.$apply();{"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{"allow":["$$watchers"]}:
+
+/*eslint angular/no-private-call: [2,{"allow":["$$watchers"]}]*/
// valid
$scope.$$watchers.forEach(function (watcher) {
// ...
});Version
+
+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
+
+Examples
+
+
+
+/*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
+
+/*eslint angular/no-run-logic: 2*/
// valid
angular.module('app').run(function(KITTENS, kittenService, startup) {
kittenService.prefetchData(KITTENS);
startup('foo', true, 1);
});{"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{"allowParams":false}:
+
+/*eslint angular/no-run-logic: [2,{"allowParams":false}]*/
// valid
angular.module('app').run(function(kittenService, startup) {
kittenService.prefetchData();
startup();
});Version
+
+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()Examples
+
+
+
+/*eslint angular/no-service-method: 2*/
// invalid
angular.module('myModule').service('myService', function() {
// ...
}); // error: You should prefer the factory() method instead of service()
+
+/*eslint angular/no-service-method: 2*/
// valid
angular.module('myModule').factory('myService', function () {
// ...
});
// valid
angular.module('myModule').value('someValue', {
// ...
});Version
+
+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
+
+Examples
+
+
+
+/*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)
+
+/*eslint angular/no-services: 2*/
// valid
app.controller('MyController', function(myService) {
// ...
});["$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)["$http","$q"]:
+
+/*eslint angular/no-services: [2,["$http","$q"]]*/
// valid
app.directive('helloWorld', function($resource) {
// ...
});["$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)["$http","$q"] and ["directive"]:
+
+/*eslint angular/no-services: [2,["$http","$q"],["directive"]]*/
// valid
app.controller('MyController', function($http) {
// ...
});{"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){"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
+
+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 variableExamples
+
+
+
+/*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
+
+/*eslint angular/on-watch: 2*/
// valid
$scope.$on('event', function () {
// ...
});
// valid
var unregister = $rootScope.$on('event', function () {
// ...
});Version
+
+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
+
+Examples
+
+
+
+/*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
+
+/*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
+
+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'
+
+Examples
+
+"$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"$http":
+
+/*eslint angular/rest-service: [2,"$http"]*/
// valid
angular.module('myModule').service('myService', function($http) {
// ...
});"$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"$resource":
+
+/*eslint angular/rest-service: [2,"$resource"]*/
// valid
angular.module('myModule').service('myService', function($resource) {
// ...
});"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"Restangular":
+
+/*eslint angular/rest-service: [2,"Restangular"]*/
// valid
angular.module('myModule').service('myService', function(Restangular) {
// ...
});Version
+
+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
+
+Examples
+
+"prefix":
+
+/*eslint angular/service-name: [2,"prefix"]*/
// valid
angular.module('myModule').factory('prefixService', function () {
// ...
});"/^xyz/":
+
+/*eslint angular/service-name: [2,"/^xyz/"]*/
// invalid
angular.module('myModule').factory('otherService', function () {
// ...
}); // error: The otherService service should follow this pattern: /^xyz/"/^xyz/":
+
+/*eslint angular/service-name: [2,"/^xyz/"]*/
// valid
angular.module('myModule').factory('xyzService', function () {
// ...
});"xyz":
+
+/*eslint angular/service-name: [2,"xyz"]*/
// invalid
angular.module('myModule').factory('myService', function () {
// ...
}); // error: The myService service should be prefixed by xyzVersion
+
+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 setTimeoutExamples
+
+
+
+/*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
+
+/*eslint angular/timeout-service: 2*/
// valid
$timeout(function() {
// ...
}, 1000)Version
+
+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 comparisonsExamples
+
+
+
+/*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
+
+/*eslint angular/typecheck-array: 2*/
// valid
angular.isArray(someArray);Version
+
+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 comparisonsExamples
+
+
+
+/*eslint angular/typecheck-date: 2*/
// invalid
Object.prototype.toString.call(someDate) === '[object Date]'; // error: You should use the angular.isDate method
+
+/*eslint angular/typecheck-date: 2*/
// valid
angular.isDate(someDate);Version
+
+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 comparisonsExamples
+
+
+
+/*eslint angular/typecheck-function: 2*/
// invalid
typeof someFunction === 'function' // error: You should use the angular.isFunction method
+
+/*eslint angular/typecheck-function: 2*/
// valid
angular.isFunction(someFunction);Version
+
+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 comparisonsExamples
+
+
+
+/*eslint angular/typecheck-number: 2*/
// invalid
typeof someNumber === 'number' // error: You should use the angular.isNumber method
+
+/*eslint angular/typecheck-number: 2*/
// valid
angular.isNumber(someNumber);Version
+
+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 comparisonsExamples
+
+
+
+/*eslint angular/typecheck-object: 2*/
// invalid
typeof someObject === 'object' // error: You should use the angular.isObject method
+
+/*eslint angular/typecheck-object: 2*/
// valid
angular.isObject(someObject);Version
+
+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 comparisonsExamples
+
+
+
+/*eslint angular/typecheck-string: 2*/
// invalid
typeof someString === 'string' // error: You should use the angular.isString method
+
+/*eslint angular/typecheck-string: 2*/
// valid
angular.isString(someString);Version
+
+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()Examples
+
+"$apply":
+
+/*eslint angular/watchers-execution: [2,"$apply"]*/
// invalid
$scope.$digest(); // error: Instead of using the $digest() method, you should prefer $apply()"$apply":
+
+/*eslint angular/watchers-execution: [2,"$apply"]*/
// valid
$scope.$apply(function() {
// ...
});"$digest":
+
+/*eslint angular/watchers-execution: [2,"$digest"]*/
// invalid
$scope.$apply(function() {
// ...
}); // error: Instead of using the $apply() method, you should prefer $digest()"$digest":
+
+/*eslint angular/watchers-execution: [2,"$digest"]*/
// valid
$scope.$digest();Version
+
+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 windowExamples
+
+
+
+/*eslint angular/window-service: 2*/
// invalid
window.alert('Hello world!'); // error: You should use the $window service instead of the default window object
+
+/*eslint angular/window-service: 2*/
// valid
$window.alert('Hello world!');Version
+
+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 @@
-Details
- .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
-.foo {
- font-weight: bold;
-}
+
.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..foo {
font-weight: bold;
}
.bar {
padding: 10px;
}
.foo.bar {
color: red;
}.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;
}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
adjoining-classes
.foo.bar {
- border: 1px solid black;
-}
-
-.first .abc.def {
- color: red;
-}
.foo.bar {
border: 1px solid black;
}
.first .abc.def {
color: red;
}/* 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
-Details
-.mybox {
- border: 1px solid black;
- padding: 5px;
- width: 100px;
-}
.mybox {
border: 1px solid black;
padding: 5px;
width: 100px;
}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.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;
}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
box-model
+
width being used with border, border-left, border-right, padding, padding-left, or padding-right
-/* 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;
}/* 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
+
+
+
\ 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
- 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;
-}
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;
}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.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;
}border-box setting to be more logical and more like how these properties should work.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
box-sizing
.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
- @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');
-}
@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');
}@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
bulletproof-font-face
@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');
}@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');
}
-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
- -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
+
+ -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.
+
animationanimation-delayanimation-directionDetails
-Rule Details
+Rule Details
compatible-vendor-prefixes
/* 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;
}Details
- display of the element. This leads to extra cruft in your CSS and misunderstandings around how a rule should work.Details
+
+ display of the element. This leads to extra cruft in your CSS and misunderstandings around how a rule should work.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.display are:
+
display: inline-block should not use float.Details
-Rule Details
+Rule Details
display-property-groupingdisplay 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.
/* 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;
}/* 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
- Details
-.heart-icon {
- background: url(sprite.png) -16px 0 no-repeat;
-}
+
.heart-icon {
background: url(sprite.png) -16px 0 no-repeat;
}
.task-icon {
background: url(sprite.png) -32px 0 no-repeat;
}.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;
}icons class contains the background image while the other classes just change the background position.
-Rule Details
+Rule Details
duplicate-background-images
/* 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;
}/* 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;
}Details
- Details
-.mybox {
- width: 100px;
- width: 120px;
-}
.mybox {
width: 100px;
width: 120px;
}.mybox {
- background: #fff;
- background: rgba(255, 255, 255, 0.5);
-}
.mybox {
background: #fff;
background: rgba(255, 255, 255, 0.5);
}
-Rule Details
+Rule Details
duplicate-properties
+
-/* 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;
}
-/* 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;
}Details
- Details
-.foo {
-}.foo {
}
-Rule Details
+Rule Details
empty-rules.mybox { }
-
-.mybox {
-
-}
+
.mybox { }
.mybox {
}
.mybox {
/* a comment */
}Details
- 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
+
+ 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.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);
}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);
}
-Rule Details
+Rule Details
fallback-colors
+
color property with a rgba(), hsl(), or hsla() color without a preceding color property that has an older color format.background property with a rgba(), hsl(), or hsla() color without a preceding background property that has an older color format.background-color property with a rgba(), hsl(), or hsla() color without a preceding background-color property that has an older color format.
-/* 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;
}/* 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);
}Details
- 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
+
+ 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.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:
+
-Rule Details
+Rule Details
floatsfloat 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
- @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
+
+ @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.font-facesDetails
- 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
-.small {
- font-size: 8px;
-}
+
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..small {
font-size: 8px;
}
.medium {
font-size: 11px;
}
.large {
font-size: 14px;
}font-size appears in your CSS. Now there is one place to go to change font sizes instead of multiple.
-Rule Details
+Rule Details
font-sizesfont-size declarations are found.Details
- Details
-
+
-ms-linear-gradient and -ms-radial-gradient for Internet Explorer 10+Details
+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+ */
-Rule Details
+Rule Details
gradients
/* 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%);
}.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%);
}Details
- Details
+
+ #header a {
- color: black;
-}
#header a {
color: black;
}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;
}.callout a {
- color: black;
-}
.callout a {
color: black;
}
-Rule Details
+Rule Details
ids
#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
- @import command is used to include CSS files within other CSS files, for example:Details
-@import url(more.css);
-@import url(andmore.css);
+
@import command is used to include CSS files within other CSS files, for example:@import url(more.css);
@import url(andmore.css);
a {
color: black;
}@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.@import:
+
<link> tags to include the style sheets you want. These will still be downloaded in parallel.
-Rule Details
+Rule Details
import
@import url(foo.css);
@import url(foo.css);
-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/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
- !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
+
+ !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
important
.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
- Details
+
+
-Rule Details
+Rule Details
known-properties
-/* 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;
}/* -moz- is a vendor prefix, so ignore */
-a {
- -moz-foo: bar;
-}
/* -moz- is a vendor prefix, so ignore */
a {
-moz-foo: bar;
}Details
- 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
+
+ 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. a {
- outline: none;
-}
a {
outline: none;
}a {
- outline: 0;
-}
a {
outline: 0;
}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
outline-none
+
outline: none or outline: 0 in any rule whose selectors doesn't contain :focus
-/* 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;
}/* :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
- 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
+
+ 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).
-Rule Details
+Rule Details
overqualified-elements
div.mybox {
- color: red;
-}
-
-.mybox li.active {
- background: red;
-}
div.mybox {
color: red;
}
.mybox li.active {
background: red;
}
-/* 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;
}Details
- 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%;
-}
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
qualified-headings
/* 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;
}/* Not qualified */
-h3 {
- font-weight: normal;
-}
/* Not qualified */
h3 {
font-weight: normal;
}
-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/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
- Details
+
+ href property is specified on an <a> element://OK
-a[href] {
- color: red;
-}
//OK
a[href] {
color: red;
}rel attribute of an <a> element is "external"://OK
-a[rel=external] {
- color: blue;
-}
//OK
a[rel=external] {
color: blue;
}
-Contains
+Contains
*= 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;
}<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>
-Starts With
+Starts With
^= 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;
}<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>rel.
-Ends With
+Ends With
$= 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;
}<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
~= 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;
}<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
|= 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;
}<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
-Rule Details
+Rule Details
regex-selectors
.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;
}.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
- .mybox {
- margin-left: 10px;
- margin-right: 10px;
- margin-top: 20px;
- margin-bottom: 30px;
-}
Details
+
+ .mybox {
margin-left: 10px;
margin-right: 10px;
margin-top: 20px;
margin-bottom: 30px;
}margin property, such as:.mybox {
- margin: 20px 10px 30px;
-}
.mybox {
margin: 20px 10px 30px;
}
-Rule Details
+Rule Details
shorthand
+
margin-left, margin-right, margin-top, and margin-bottom are used together in a single rule.padding-left, padding-right, padding-top, and padding-bottom are used together in a single rule..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;
}
-/* 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;
}Details
- Details
-.mybox {
- border: 1px solid black;
- padding: 5px;
- width: 100px;
- *width: 200px;
-}
.mybox {
border: 1px solid black;
padding: 5px;
width: 100px;
*width: 200px;
}*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.
-Rule Details
+Rule Details
star-property-hack
-.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
- 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
+
+ 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.-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;
}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;
}
-Rule Details
+Rule Details
text-indent
-/* 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;
}/* 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
- Details
-.mybox {
- border: 1px solid black;
- padding: 5px;
- width: 100px;
- _width: 200px;
-}
.mybox {
border: 1px solid black;
padding: 5px;
width: 100px;
_width: 200px;
}_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.
-Rule Details
+Rule Details
underscore-property-hack
-.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
- 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
+
+ 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
unique-headings
/* 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;
}/* :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
- *) 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);
-}
*) 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);
}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
universal-selector
* {
- color: red;
-}
-
-.selected * {
- color: red;
-}
* {
color: red;
}
.selected * {
color: red;
}/* universal selector is not key */
-.selected * a {
- color: red;
-}
/* universal selector is not key */
.selected * a {
color: red;
}Details
- [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);
-}
[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);
}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
unqualified-attributes
[type=text] {
- color: red;
-}
-
-.selected [type=text] {
- color: red;
-}[type=text] {
color: red;
}
.selected [type=text] {
color: red;
}/* unqualified attribute selector is not key */
-.selected [type=text] a {
- color: red;
-}
/* unqualified attribute selector is not key */
.selected [type=text] a {
color: red;
}Details
- Details
+
+ -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;
}
-Rule Details
+Rule Details
vendor-prefix
+
-/* 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;
}/* 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
- 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
-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.
-Rule Details
+Rule Details
zero-units0 is found followed by a unit or a percentage sign.0 is found followed by a unit or a percentage sign..mybox {
- margin: 0px;
-}
-
-.mybox {
- width: 0%;
-}
-
-.mybox {
- padding: 10px 0px;
-}
.mybox {
margin: 0px;
}
.mybox {
width: 0%;
}
.mybox {
padding: 10px 0px;
}.mybox {
- margin: 0;
-}
+
.mybox {
margin: 0;
}
.mybox {
padding: 10px 0;
}Details
+
+<img src="test.png" alt="test">
<input type="image" alt="test">
<area shape="circle" coords="180,139,14" href ="test.html" alt="test" />
+<img src="test.png">
<input type="image">
<area shape="circle" coords="180,139,14" href ="test.html" />
+
\ 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
-
-
-<img src="test.png" alt="test">
-
\ No newline at end of file
+<img SRC="test.png" ALT="test">
-Details
+
+<img src="test.png" alt="test">
+<img SRC="test.png" ALT="test">
+
\ 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
-
-
-<img src="a.png" />
-
+<img src="a.png" src="b.png" />
-Details
+
+<img src="a.png" />
+<img src="a.png" src="b.png" />
+
\ 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
-
-
-<li><a href="https://vimeo.com/album/1951235/video/56931059">Sud Web 2012</a></li>
-
-
-<li><a href="https://vimeo.com/album/1951235/video/56931059">Sud Web 2012</a></li>
-Details
+/[\u0000-\u0009\u000b\u000c\u000e-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/
+<li><a href="https://vimeo.com/album/1951235/video/56931059">Sud Web 2012</a></li>
+<li><a href="https://vimeo.com/album/1951235/video/56931059">Sud Web 2012</a></li>
+
\ 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
-
-
-<a href="" title="abc">
-
\ No newline at end of file
+<a href='' title=abc>
-Details
+
+<a href="" title="abc">
+<a href='' title=abc>
+
\ 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
-
-
-<input type="button" disabled="disabled">
-
\ No newline at end of file
+<input type="button" disabled>
-Details
+
+<input type="button" disabled="disabled">
+<input type="button" disabled>
+
\ 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
-Details
+Details
-
-
-<!DOCTYPE HTML><html>
-
+<!--comment--><!DOCTYPE HTML><html>
-Details
+
+<!DOCTYPE HTML><html>
+<!--comment--><!DOCTYPE HTML><html>
+
\ 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 HTML><html>
-Details
+
+<!DOCTYPE HTML><html>
+
\ 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
-
-
-<body><script type="text/javascript" src="test.js"></script></body>
-
+<head><script type="text/javascript" src="test.js"></script></head>
-Details
+
+<body><script type="text/javascript" src="test.js"></script></body>
+<head><script type="text/javascript" src="test.js"></script></head>
+
\ 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
-
+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
+
+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>
+
\ 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
-
-
-<div id="adcontainer"></div>
-
\ No newline at end of file
+<div id="ad-container"></div>
-<div id="ad_container"></div>
-Details
+
+<div id="adcontainer"></div>
+<div id="ad-container"></div>
<div id="ad_container"></div>
+
\ 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
-
+underline: <div id="aaa_bbb">
-dash: <div id="aaa-bbb">
-hump: <div id="aaaBbb">
-Details
+
+underline: <div id="aaa_bbb">
dash: <div id="aaa-bbb">
hump: <div id="aaaBbb">
+
\ 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
-
-
-<div id="id1"></div><div id="id2"></div>
-
+<div id="id1"></div><div id="id1"></div>
-Details
+
+<div id="id1"></div><div id="id2"></div>
+<div id="id1"></div><div id="id1"></div>
+
\ 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
+
+<img src="test.gif" onclick="alert(1);">
<img src="javascript:alert(1)">
<a href="javascript:alert(1)">test1</a>
+
\ 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
+
+<div style="color:red"></div>
+
\ 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
-Details
+Details
-
-
- <img src="tab.png" />
- <img src="space.png" />
-
-
- <img src="tab_before_space.png" />
- <img src="space_before_tab.png" />
-Details
+
+ → →<img src="tab.png" />
········<img src="space.png" />
+ →····<img src="tab_before_space.png" />
···· →<img src="space_before_tab.png" />· and →, respectively, to make the difference visible.
+
\ 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
-
-
-<span>aaa>bbb<ccc</span>
-
+<span>aaa>bbb<ccc</span>
-Details
+
+<span>aaa>bbb<ccc</span>
+<span>aaa>bbb<ccc</span>
+
\ 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
-
-
-<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">
-
-
+<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
+
+<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">
+<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>
+
\ 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
-
+<head><style type="text/css"></style></head>
-<body><style type="text/css"></style></body>
-Details
+
+<head><style type="text/css"></style></head>
<body><style type="text/css"></style></body>
+
\ 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
-
-
-<ul><li></li></ul>
-
+<ul><li></ul>
-<ul></li></ul>
-Details
+
+<ul><li></li></ul>
+<ul><li></ul>
<ul></li></ul>
+
\ 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
-
-
-<br />
-
+<br>
-Details
+
+<br />
+<br>
+
\ 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
-
-
-<span><div>
-
+<SPAN><BR>
-Details
+
+<span><div>
+<SPAN><BR>
+
\ 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.
+<html><head><title>test</title></head></html>
+<html><head></head></html>
<html><head><title></title></head></html>
<html><title></title><head></head></html>
+
\ 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 @@
-Enforces getter/setter pairs in objects (accessor-pairs)
+
+
+// Bad
var o = {
set a(value) {
this.val = value;
}
};
// Good
var o = {
set a(value) {
this.val = value;
},
get a() {
return this.val;
}
};getWithoutSet, it will warn if you have a getter without a setter also.Rule Details
+
+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
+
+{ "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;
}
});{ "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
+
+{ "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;
}
});{ "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
+
+Further Reading
+
+
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+/*eslint-env es6*/
var arr = [ 'foo', 'bar' ];
var [ x, y ] = z;
var arr = ['foo', 'bar'];
var [x,y] = z;Rule Details
+
+Options
+
+
+
+
+"never" (default) disallows spaces inside array brackets"always" requires one or more spaces or newlines inside array brackets"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 ] ]"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 ]]
+
+
+"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
+
+"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;"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
+
+"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;"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
+
+"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' } ];"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
+
+"always", { "objectsInArrays": false } options:
+/*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
var arr = [ { 'foo': 'bar' } ];
var arr = [ {
'foo': 'bar'
} ]"always", { "objectsInArrays": false } options:
+/*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
var arr = [{ 'foo': 'bar' }];
var arr = [{
'foo': 'bar'
}];arraysInArrays
+
+"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 ] ];"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
+
+Related Rules
+
+
+
+Version
+
+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 undefinedreturn statement in callbacks of array’s methods.Rule Details
+
+return statement.
+
+
+Array.fromArray.prototype.everyArray.prototype.filterArray.prototype.findArray.prototype.findIndexArray.prototype.mapArray.prototype.reduceArray.prototype.reduceRightArray.prototype.someArray.prototype.sort
+/*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;
}
});
+/*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
+
+When Not To Use It
+
+return statement in callbacks of array’s methods, then it’s safe to disable this rule.Version
+
+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)
+
+Rule Details
+
+Options
+
+
+
+
+"always" enforces braces around the function body"as-needed" enforces no braces where they can be omitted (default)“always”
+
+
+"arrow-body-style": ["error", "always"]"always" the following patterns are considered problems:
+/*eslint arrow-body-style: ["error", "always"]*/
/*eslint-env es6*/
let foo = () => 0;
+let foo = () => {
return 0;
};
let foo = (retv, name) => {
retv[name] = true;
return retv;
};“as-needed”
+
+"as-needed" the following patterns are considered problems:
+/*eslint arrow-body-style: ["error", "as-needed"]*/
/*eslint-env es6*/
let foo = () => {
return 0;
};
+/*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
+
+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)
+
+Rule Details
+
+
+/*eslint-env es6*/
// Bad
a => {}
// Good
(a) => {}=>) 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) {
}
+/*eslint-env es6*/
// Bad
(a) => {}
// Good
a => {}Options
+
+"always" or "as-needed". The default is "always".
+"arrow-parens": ["error", "always"]“always”
+
+"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) {}; });
+/*eslint arrow-parens: ["error", "always"]*/
/*eslint-env es6*/
() => {};
(a) => {};
(a) => a;
(a) => {'\n'}
a.then((foo) => {});
a.then((foo) => { if (true) {}; });If Statements
+
+
+/*eslint-env es6*/
var a = 1;
var b = 2;
// ...
if (a => b) {
console.log('bigger');
} else {
console.log('smaller');
};
// outputs 'bigger', not smaller as expectedif 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'
+/*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.
+/*eslint-env es6*/
var a = 1, b = 2, c = 3, d = 4;
var f = (a) => b ? c: d;“as-needed”
+
+"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) {}; });
+/*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
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.=>).
+/*eslint-env es6*/
// { "before": true, "after": true }
(a) => {}
// { "before": false, "after": false }
(a)=>{}Rule Details
+
+before and after properties, each with a Boolean value.{ "before": true, "after": true }.true means there should be one or more spaces and false means no spaces.{ "before": true, "after": true }.
+/*eslint arrow-spacing: "error"*/
/*eslint-env es6*/
()=> {};
() =>{};
(a)=> {};
(a) =>{};
a =>a;
a=> a;
()=> {'\n'};
() =>{'\n'};{ "before": true, "after": true }.
+/*eslint arrow-spacing: "error"*/
/*eslint-env es6*/
() => {};
(a) => {};
a => a;
() => {'\n'};{ "before": false, "after": false }.
+/*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
/*eslint-env es6*/
()=>{};
(a)=>{};
a=>a;
()=>{'\n'};{ "before": true, "after": false }.
+/*eslint arrow-spacing: ["error", { "before": true, "after": false }]*/
/*eslint-env es6*/
() =>{};
(a) =>{};
a =>a;
() =>{'\n'};{ "before": false, "after": true }.
+/*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
/*eslint-env es6*/
()=> {};
(a)=> {};
a=> a;
()=> {'\n'};Version
+
+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)
+
+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
+
+
+/*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;
}
}
+/*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
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.Rule Details
+
+Options
+
+
+
+
+"always" (default) requires one or more spaces"never" disallows spacesalways
+
+"always" option:
+/*eslint block-spacing: "error"*/
function foo() {return true;}
if (foo) { bar = 0;}"always" option:
+/*eslint block-spacing: "error"*/
function foo() { return true; }
if (foo) { bar = 0; }never
+
+"never" option:
+/*eslint block-spacing: ["error", "never"]*/
function foo() { return true; }
if (foo) { bar = 0;}"never" option:
+/*eslint block-spacing: ["error", "never"]*/
function foo() {return true;}
if (foo) {bar = 0;}When Not To Use It
+
+Version
+
+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)
+
+
+if (foo) {
bar();
} else {
baz();
}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();
}
+if (foo)
{
bar();
}
else
{
baz();
}Rule Details
+
+Options
+
+
+
+
+"1tbs" (default) enforces one true brace style"stroustrup" enforces Stroustrup style"allman" enforces Allman style
+
+
+"allowSingleLine": true (default false) allows the opening and closing braces for a block to be on the same line1tbs
+
+"1tbs" option:
+/*eslint brace-style: "error"*/
function foo()
{
return true;
}
if (foo)
{
bar();
}
try
{
somethingRisky();
} catch(e)
{
handleError();
}
if (foo) {
bar();
}
else {
baz();
}"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();"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
+
+"stroustrup" option:
+/*eslint brace-style: ["error", "stroustrup"]*/
function foo()
{
return true;
}
if (foo)
{
bar();
}
try
{
somethingRisky();
} catch(e)
{
handleError();
}
if (foo) {
bar();
} else {
baz();
}"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();"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
+
+"allman" option:
+/*eslint brace-style: ["error", "allman"]*/
function foo() {
return true;
}
if (foo)
{
bar(); }
try
{
somethingRisky();
} catch(e)
{
handleError();
}
if (foo) {
bar();
} else {
baz();
}"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();"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
+
+Further Reading
+
+
+
+
+Version
+
+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)
+
+
+function doSomething(err, callback) {
if (err) {
return callback(err);
}
callback();
}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
+
+return statement. This rule decides what is a callback based on the name of the function being called.Options
+
+callback, cb, next.["callback", "cb", "next"] option:
+/*eslint callback-return: "error"*/
function foo() {
if (err) {
callback(err);
}
callback();
}["callback", "cb", "next"] option:
+/*eslint callback-return: "error"*/
function foo() {
if (err) {
return callback(err);
}
callback();
}Known Limitations
+
+
+
+
+Passing the callback by reference
+
+setTimeout).
+/*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
+
+
+/*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
+
+if statement.
+/*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
+
+Further Reading
+
+
+
+Related Rules
+
+
+
+Version
+
+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)
+
+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
+
+_) 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
+
+
+
+
+"properties": "always" (default) enforces camelcase style for property names"properties": "never" does not check property namesalways
+
+{ "properties": "always" } option:
+/*eslint camelcase: "error"*/
var my_favorite_color = "#112C85";
function do_something() {
// ...
}
obj.do_something = function() {
// ...
};
var obj = {
my_pref: 1
};{ "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
+
+{ "properties": "never" } option:
+/*eslint camelcase: ["error", {properties: "never"}]*/
var obj = {
my_pref: 1
};When Not To Use It
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+var foo = {
bar: "baz",
qux: "quux",
};
+ var foo = {
- bar: "baz",
- qux: "quux"
+ bar: "baz"
};
+ var foo = {
bar: "baz",
- qux: "quux",
};Rule Details
+
+Options
+
+
+
+
+"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
+
+"never" option:
+/*eslint comma-dangle: ["error", "never"]*/
var foo = {
bar: "baz",
qux: "quux",
};
var arr = [1,2,];
foo({
bar: "baz",
qux: "quux",
});"never" option:
+/*eslint comma-dangle: ["error", "never"]*/
var foo = {
bar: "baz",
qux: "quux"
};
var arr = [1,2];
foo({
bar: "baz",
qux: "quux"
});always
+
+"always" option:
+/*eslint comma-dangle: ["error", "always"]*/
var foo = {
bar: "baz",
qux: "quux"
};
var arr = [1,2];
foo({
bar: "baz",
qux: "quux"
});"always" option:
+/*eslint comma-dangle: ["error", "always"]*/
var foo = {
bar: "baz",
qux: "quux",
};
var arr = [1,2,];
foo({
bar: "baz",
qux: "quux",
});always-multiline
+
+"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"
});"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
+
+"only-multiline" option:
+/*eslint comma-dangle: ["error", "only-multiline"]*/
var foo = { bar: "baz", qux: "quux", };
var arr = [1,2,];
var arr = [1,
2,];"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
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+var foo = 1, bar = 2;
var foo = 1 ,bar = 2;Rule Details
+
+ArrayExpression or ArrayPattern in either of the following cases:
+
+
+array-bracket-spacing ruleOptions
+
+
+
+
+"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 commasafter
+
+{ "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{ "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{ "before": false, "after": true } options:
+/*eslint comma-spacing: ["error", { "before": false, "after": true }]*/
/*eslint array-bracket-spacing: ["error", "always"]*/
var arr = [ , 2, 3 ]before
+
+{ "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{ "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{ "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
+
+Further Reading
+
+
+
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+
+
+
+Rule Details
+
+
+
+
+Options
+
+
+
+
+"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 declarationexceptions 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 declarationslast
+
+"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
};
}"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
+
+"first" option:
+/*eslint comma-style: ["error", "first"]*/
var foo = 1,
bar = 2;
var foo = ["apples",
"oranges"];
function bar() {
return {
"a": 1,
"b:": 2
};
}"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
+
+"first", { "exceptions": { … } } options:
+/*eslint comma-style: ["error", "first", { "exceptions": { "ArrayExpression": true, "ObjectExpression": true } }]*/
var o = {},
a = [];"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
+
+Further Reading
+
+
+
+
+Related Rules
+
+
+
+Version
+
+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)
+
+
+function a(x) {
if (true) {
return x; // 1st path
} else if (false) {
return x+1; // 2nd path
} else {
return 4; // 3rd path
}
}Rule Details
+
+20).
+/*eslint complexity: ["error", 2]*/
function a(x) {
if (true) {
return x;
} else if (false) {
return x+1;
} else {
return 4; // 3rd path
}
}
+/*eslint complexity: ["error", 2]*/
function a(x) {
if (true) {
return x;
} else {
return 4;
}
}Options
+
+max object property:
+"complexity": ["error", 2]
+"complexity": ["error", { "max": 2 }]maximum is deprecated. Please use the property max instead.When Not To Use It
+
+Further Reading
+
+
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+/*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
+
+Options
+
+
+
+
+"never" (default) disallows spaces inside computed property brackets"always" requires one or more spaces inside computed property bracketsnever
+
+"never" option:
+/*eslint computed-property-spacing: ["error", "never"]*/
/*eslint-env es6*/
obj[foo ]
obj[ 'foo']
var x = {[ b ]: a}
obj[foo[ bar ]]"never" option:
+/*eslint computed-property-spacing: ["error", "never"]*/
/*eslint-env es6*/
obj[foo]
obj['foo']
var x = {[b]: a}
obj[foo[bar]]always
+
+"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}"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
+
+Related Rules
+
+
+
+Version
+
+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)
+
+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.
+function doSomething(condition) {
if (condition) {
return true;
} else {
return;
}
}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
+
+return statements either specify a value or don’t specify a value.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.
+/*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;
}
}
+/*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
+
+return behavior depending on code branching, then it is safe to disable this rule.Version
+
+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)
+
+
+var that = this;
jQuery('li').click(function (event) {
// here, "this" is the HTMLElement where the click event occurred
that.setFoo(42);
});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:
+
+
+this.this, the name of the variable must be a designated alias.Options
+
+
+
+
+this (default "that")"that" option:
+/*eslint consistent-this: ["error", "that"]*/
var that = 42;
var self = this;
that = 42;
self = this;"that" option:
+/*eslint consistent-this: ["error", "that"]*/
var that = this;
var self = 42;
var self;
that = this;
foo.bar = this;"that" option, if the variable is not initialized:
+/*eslint consistent-this: ["error", "that"]*/
var that;
function f() {
that = this;
}"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
+
+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
+
+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)super().
+Constructors of non derived classes must not call super().
+If this is not observed, the javascript engine will raise a runtime error.super() call.Rule Details
+
+super() calls.
+/*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.
}
+/*eslint constructor-super: "error"*/
/*eslint-env es6*/
class A {
constructor() { }
}
class A extends B {
constructor() {
super();
}
}When Not To Use It
+
+super() callings in constructors, you can safely disable this rule.Version
+
+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)
+
+
+if (foo) foo++;
+if (foo) {
foo++;
}Rule Details
+
+Options
+
+all
+
+"all" option:
+/*eslint curly: "error"*/
if (foo) foo++;
while (bar)
baz();
if (foo) {
baz();
} else qux();"all" option:
+/*eslint curly: "error"*/
if (foo) {
foo++;
}
while (bar) {
baz();
}
if (foo) {
baz();
} else {
qux();
}multi
+
+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."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();
}"multi" option:
+/*eslint curly: ["error", "multi"]*/
if (foo) foo++;
else foo();
while (true) {
doSomething();
doSomethingElse();
}multi-line
+
+if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances."multi-line" option:
+/*eslint curly: ["error", "multi-line"]*/
if (foo)
doSomething();
else
doSomethingElse();
if (foo) foo(
bar,
baz);"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
+
+if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases."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();
}"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
+
+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."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++;
}"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
+
+Version
+
+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)
+
+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
}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
}Rule Details
+
+default case in switch statements. You may optionally include a // no default after the last case if there is no default case.
+/*eslint default-case: "error"*/
switch (a) {
case 1:
/* code */
break;
}
+/*eslint default-case: "error"*/
switch (a) {
case 1:
/* code */
break;
default:
/* code */
break;
}
switch (a) {
case 1:
/* code */
break;
// no default
}Options
+
+
+
+
+commentPattern option to a regular expression string to change the default ^no default$ comment test patterncommentPattern
+
+{ "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
+
+default case for switch statements, you can safely disable this rule.Related Rules
+
+
+
+
+Version
+
+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)
+
+
+var a = universe.
galaxy;
var b = universe
.galaxy;Rule Details
+
+Options
+
+
+
+
+"object", the dot in a member expression should be on the same line as the object portion. The default is "object"."property", the dot in a member expression should be on the same line as the property portion.object
+
+"object" option requires the dot to be on the same line as the object."object" option:
+/*eslint dot-location: ["error", "object"]*/
var foo = object
.property;"object" option:
+/*eslint dot-location: ["error", "object"]*/
var foo = object.
property;
var bar = object.property;property
+
+"property" option requires the dot to be on the same line as the property."property" option:
+/*eslint dot-location: ["error", "property"]*/
var foo = object.
property;"property" option:
+/*eslint dot-location: ["error", "property"]*/
var foo = object
.property;
var bar = object.property;When Not To Use It
+
+Related Rules
+
+
+
+Version
+
+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)
+
+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
+
+
+/*eslint dot-notation: "error"*/
var x = foo["bar"];
+/*eslint dot-notation: "error"*/
var x = foo.bar;
var x = foo[bar]; // Property name is a variable, square-bracket notation requiredOptions
+
+
+
+
+allowKeywords option to false (default is true) to follow ECMAScript version 3 compatible style, avoiding dot notation for reserved word properties.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
+
+{ "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 requiredallowPattern
+
+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.{ "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 warningVersion
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.Rule Details
+
+maxEOF and/or
+no-trailing-spaces.
+/*eslint eol-last: "error"*/
function doSmth() {
var foo = 2;
}
+/*eslint eol-last: "error"*/
function doSmth() {
var foo = 2;
}Options
+
+
+
+
+"unix" (default) enforces line feed (LF) as newline"windows" enforces carriage return line feed (CRLF) as newlineVersion
+
+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)
+
+=== and !== instead of their regular counterparts == and !=.== 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"a == b the actual problem is very difficult to spot.Rule Details
+
+
+/*eslint eqeqeq: "error"*/
if (x == 42) { }
if ("" == text) { }
if (obj.getStuff() != undefined) { }Options
+
+smart
+
+"smart" option enforces the use of === and !== except for these cases:
+
+
+typeofnull"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"smart" option:
+/*eslint eqeqeq: ["error", "smart"]*/
typeof foo == 'undefined'
'hello' != 'world'
0 == 0
true == true
foo == nullallow-null
+
+"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."allow-null" option:
+/*eslint eqeqeq: ["error", "allow-null"]*/
bananas != 1
typeof foo == 'undefined'
'hello' != 'world'
0 == 0
foo == undefined"allow-null" option:
+/*eslint eqeqeq: ["error", "allow-null"]*/
foo == nullWhen Not To Use It
+
+Version
+
+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)
+
+
+Foo.prototype.bar = function bar() {};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
+
+
+/*eslint func-names: "error"*/
Foo.prototype.bar = function() {};
(function() {
// ...
}())
+/*eslint func-names: "error"*/
Foo.prototype.bar = function bar() {};
(function bar() {
// ...
}())Further Reading
+
+
+
+Version
+
+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)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() {
// ...
}var keyword, followed by a name and then the function itself, such as:
+var doSomething = function() {
// ...
};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() {
// ...
}function declarations to the top of the scope. That means this code is treated as if the declaration came before the invocation.function expressions, you must define the function before it is used, otherwise it causes an error. Example:
+doSomething(); // error!
var doSomething = function() {
// ...
};doSomething() is undefined at the time of invocation and so causes a runtime error.Rule Details
+
+function style throughout a JavaScript file, either declarations or expressions. You can specify which you prefer in the configuration.Options
+
+
+
+
+"expression" (default) requires the use of function expressions instead of function declarations"declaration" requires the use of function declarations instead of function expressions
+
+
+"allowArrowFunctions": true (default false) allows the use of arrow functionsexpression
+
+"expression" option:
+/*eslint func-style: ["error", "expression"]*/
function foo() {
// ...
}"expression" option:
+/*eslint func-style: ["error", "expression"]*/
var foo = function() {
// ...
};declaration
+
+"declaration" option:
+/*eslint func-style: ["error", "declaration"]*/
var foo = function() {
// ...
};
var foo = () => {};"declaration" option:
+/*eslint func-style: ["error", "declaration"]*/
function foo() {
// ...
}
// Methods (functions assigned to objects) are not checked by this rule
SomeObject.foo = function() {
// ...
};allowArrowFunctions
+
+"declaration", { "allowArrowFunctions": true } options:
+/*eslint func-style: ["error", "declaration", { "allowArrowFunctions": true }]*/
var foo = () => {};When Not To Use It
+
+Further Reading
+
+
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.* after the function keyword.
+/*eslint-env es6*/
function* generator() {
yield "44";
yield "55";
}
+/*eslint-env es6*/
function *generator() {
yield "44";
yield "55";
}
+/*eslint-env es6*/
function * generator() {
yield "44";
yield "55";
}*.Rule Details
+
+* of generator functions.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.* 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.{"before": true, "after": false}.
+"generator-star-spacing": ["error", {"before": false, "after": true}]
+
+
+{"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"]{"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() {} };{"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() {} };{"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() {} };{"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
+
+Further Reading
+
+
+
+Version
+
+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)
+
+require() function, such as:
+var fs = require("fs");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");
}
}require() does a synchronous load, it can cause performance problems when used in other locations.import and export statements can only occur in the top level of the module’s body.Rule Details
+
+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.
+/*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);
}
+/*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
+
+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
+
+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)
+
+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
+
+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.
+/*eslint guard-for-in: "error"*/
for (key in foo) {
doSomething(key);
}
+/*eslint guard-for-in: "error"*/
for (key in foo) {
if ({}.hasOwnProperty.call(foo, key)) {
doSomething(key);
}
}Further Reading
+
+
+
+Version
+
+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)
+
+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
+
+Options
+
+"err"."err" parameter name:
+/*eslint handle-callback-err: "error"*/
function loadData (err, data) {
doSomething();
}"err" parameter name:
+/*eslint handle-callback-err: "error"*/
function loadData (err, data) {
if (err) {
console.log(err.stack);
}
doSomething();
}
function generateError (err) {
if (err) {}
}"error" parameter name:
+/*eslint handle-callback-err: ["error", "error"]*/
function loadData (error, data) {
if (error) {
console.log(error.stack);
}
doSomething();
}regular expression
+
+^ it is considered to be a regexp pattern.
+
+
+"^(err|error|anySpecificError)$", the rule reports unhandled errors where the parameter name can be err, error or anySpecificError."^.+Error$", the rule reports unhandled errors where the parameter name ends with Error (for example, connectionError or validationError will match)."^.*(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
+
+Further Reading
+
+
+
+Version
+
+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)
+
+
+
+
+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
+
+function definitions.
+
+
+
+
+
+Options
+
+
+{
"id-blacklist": ["error", "data", "err", "e", "cb", "callback"]
}"data", "callback" restricted identifiers:
+/*eslint id-blacklist: ["error", "data", "callback"] */
var data = {...};
function callback() {
// ...
}
element.callback = function() {
// ...
};
var itemSet = {
data: [...]
};"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 ignoredWhen Not To Use It
+
+Version
+
+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)
+
+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 contextRule Details
+
+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 }) = {};
+/*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"min" object property.
+/*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 }) = {};
+/*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
+
+
+"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 namesmin
+
+{ "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 }) = {};{ "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 accessmax
+
+{ "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; };{ "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
+
+{ "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
+
+{ "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; };Related Rules
+
+
+
+
+Version
+
+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)
+
+
+
+
+Rule Details
+
+function definitions to match a specified regular expression.Options
+
+
+{
"id-match": ["error", "^[a-z]+([A-Z][a-z]+)*$"]
}"^[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
};"^[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() {
// ...
};
+
+
+"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 expressionproperties
+
+"^[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
+
+"^[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
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+function hello(indentSize, type) {
if (indentSize === 4 && type !== 'tab') {
console.log('Each next indentation will increase on 4 spaces');
}
}
+
+
+Rule Details
+
+4 spaces.Options
+
+
+{
"indent": ["error", 2]
}
+{
"indent": ["error", "tab"]
}
+/*eslint indent: "error"*/
if (a) {
b=c;
function foo(d) {
e=f;
}
}
+/*eslint indent: "error"*/
if (a) {
b=c;
function foo(d) {
e=f;
}
}
+
+
+"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.
+
+
+VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.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.VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.SwitchCase set to 0 will not indent case clauses with respect to switch statements.SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.tab
+
+"tab" option:
+/*eslint indent: ["error", "tab"]*/
if (a) {
b=c;
function foo(d) {
e=f;
}
}"tab" option:
+/*eslint indent: ["error", "tab"]*/
if (a) {
/*tab*/b=c;
/*tab*/function foo(d) {
/*tab*//*tab*/e=f;
/*tab*/}
}SwitchCase
+
+2, { "SwitchCase": 1 } options:
+/*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
switch(a){
case "a":
break;
case "b":
break;
}2, { "SwitchCase": 1 } option:
+/*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
switch(a){
case "a":
break;
case "b":
break;
}VariableDeclarator
+
+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;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;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;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
+
+
+
+
+indentvalidateIndentationVersion
+
+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)
+
+foo is initialized during declaration, while bar is initialized later.
+var foo = 1;
var bar;
if (foo) {
bar = 1;
} else {
bar = 2;
}Rule Details
+
+foo is initialized during declaration, while bar is not.
+var foo = 1;
var bar;
bar = 2;Options
+
+
+
+
+"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.ignoreForLoopInit, which indicates if initialization at declaration is allowed in for loops when "never" is set, since it is a very typical use case.
+{
"init-declarations": ["error", "always"],
}
+{
"init-declarations": ["error", "never"]
}
+{
"init-declarations": ["error", "never", { "ignoreForLoopInit": true }]
}always
+
+"always" option:
+/*eslint init-declarations: ["error", "always"]*/
/*eslint-env es6*/
function foo() {
var bar;
let baz;
}"always" option:
+/*eslint init-declarations: ["error", "always"]*/
/*eslint-env es6*/
function foo() {
var bar = 1;
let baz = 2;
const qux = 3;
}never
+
+"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++) {}
}"never" option:
+/*eslint init-declarations: ["error", "never"]*/
/*eslint-env es6*/
function foo() {
var bar;
let baz;
const buzz = 1;
}"never" option ignores const variable initializations.ignoreForLoopInit
+
+"never", { "ignoreForLoopInit": true } options:
+/*eslint init-declarations: ["error", "never", { "ignoreForLoopInit": true }]*/
for (var i = 0; i < 1; i++) {}When Not To Use It
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+<a b='c' />
<a b="c" />
+<a b="'" />
<a b='"' />Rule Details
+
+Options
+
+
+
+
+"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
+
+"prefer-double" option:
+/*eslint jsx-quotes: ["error", "prefer-double"]*/
<a b='c' />"prefer-double" option:
+/*eslint jsx-quotes: ["error", "prefer-double"]*/
<a b="c" />
<a b='"' />prefer-single
+
+"prefer-single" option:
+/*eslint jsx-quotes: ["error", "prefer-single"]*/
<a b="c" />"prefer-single" option:
+/*eslint jsx-quotes: ["error", "prefer-single"]*/
<a b='c' />
<a b="'" />When Not To Use It
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+Rule Details
+
+Options
+
+
+
+
+"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 literalssingleLine and multiLine) but not both.beforeColon
+
+{ "beforeColon": false } option:
+/*eslint key-spacing: ["error", { "beforeColon": false }]*/
var obj = { "foo" : 42 };{ "beforeColon": false } option:
+/*eslint key-spacing: ["error", { "beforeColon": false }]*/
var obj = { "foo": 42 };{ "beforeColon": true } option:
+/*eslint key-spacing: ["error", { "beforeColon": true }]*/
var obj = { "foo": 42 };{ "beforeColon": true } option:
+/*eslint key-spacing: ["error", { "beforeColon": true }]*/
var obj = { "foo" : 42 };afterColon
+
+{ "afterColon": true } option:
+/*eslint key-spacing: ["error", { "afterColon": true }]*/
var obj = { "foo":42 };{ "afterColon": true } option:
+/*eslint key-spacing: ["error", { "afterColon": true }]*/
var obj = { "foo": 42 };{ "afterColon": false } option:
+/*eslint key-spacing: ["error", { "afterColon": false }]*/
var obj = { "foo": 42 };{ "afterColon": false } option:
+/*eslint key-spacing: ["error", { "afterColon": false }]*/
var obj = { "foo":42 };mode
+
+{ "mode": "strict" } option:
+/*eslint key-spacing: ["error", { "mode": "strict" }]*/
call({
foobar: 42,
bat: 2 * 2
});{ "mode": "strict" } option:
+/*eslint key-spacing: ["error", { "mode": "strict" }]*/
call({
foobar: 42,
bat: 2 * 2
});{ "mode": "minimum" } option:
+/*eslint key-spacing: ["error", { "mode": "minimum" }]*/
call({
foobar: 42,
bat: 2 * 2
});align
+
+{ "align": "value" } option:
+/*eslint key-spacing: ["error", { "align": "value" }]*/
var obj = {
a: value,
bcde: 42,
fg : foo()
};{ "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" };{ "align": "colon" } option:
+/*eslint key-spacing: ["error", { "align": "colon" }]*/
call({
foobar: 42,
bat: 2 * 2
});{ "align": "colon" } option:
+/*eslint key-spacing: ["error", { "align": "colon" }]*/
call({
foobar: 42,
bat : 2 * 2
});singleLine and multiLine
+
+{ "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
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.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 {
// ...
}Rule Details
+
+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
+
+
+
+
+"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 keywordsbefore
+
+{ "before": true } option:
+/*eslint keyword-spacing: ["error", { "before": true }]*/
if (foo) {
//...
}else if (bar) {
//...
}else {
//...
}{ "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(){}} />{ "before": false } option:
+/*eslint keyword-spacing: ["error", { "before": false }]*/
if (foo) {
//...
} else if (bar) {
//...
} else {
//...
}{ "before": false } option:
+/*eslint keyword-spacing: ["error", { "before": false }]*/
if (foo) {
//...
}else if (bar) {
//...
}else {
//...
}after
+
+{ "after": true } option:
+/*eslint keyword-spacing: ["error", { "after": true }]*/
if(foo) {
//...
} else if(bar) {
//...
} else{
//...
}{ "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(){}} />{ "after": false } option:
+/*eslint keyword-spacing: ["error", { "after": false }]*/
if (foo) {
//...
} else if (bar) {
//...
} else {
//...
}{ "after": false } option:
+/*eslint keyword-spacing: ["error", { "after": false }]*/
if(foo) {
//...
} else if(bar) {
//...
} else{
//...
}overrides
+
+{ "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
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule."\n" (for LF) and "\r\n" for (CRLF).Rule Details
+
+Options
+
+
+
+
+"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
+
+"unix" option:
+/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n"unix" option:
+/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \nwindows
+
+"windows" option:
+/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n"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\nWhen Not To Use It
+
+Compatibility
+
+
+
+
+validateLineBreaksVersion
+
+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)
+
+Rule Details
+
+/*) 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
+
+
+
+
+"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 literalsbeforeBlockComment
+
+{ "beforeBlockComment": true } option:
+/*eslint lines-around-comment: ["error", { "beforeBlockComment": true }]*/
var night = "long";
/* what a great and wonderful day */
var day = "great"{ "beforeBlockComment": true } option:
+/*eslint lines-around-comment: ["error", { "beforeBlockComment": true }]*/
var night = "long";
/* what a great and wonderful day */
var day = "great"afterBlockComment
+
+{ "afterBlockComment": true } option:
+/*eslint lines-around-comment: ["error", { "afterBlockComment": true }]*/
var night = "long";
/* what a great and wonderful day */
var day = "great"{ "afterBlockComment": true } option:
+/*eslint lines-around-comment: ["error", { "afterBlockComment": true }]*/
var night = "long";
/* what a great and wonderful day */
var day = "great"beforeLineComment
+
+{ "beforeLineComment": true } option:
+/*eslint lines-around-comment: ["error", { "beforeLineComment": true }]*/
var night = "long";
// what a great and wonderful day
var day = "great"{ "beforeLineComment": true } option:
+/*eslint lines-around-comment: ["error", { "beforeLineComment": true }]*/
var night = "long";
// what a great and wonderful day
var day = "great"afterLineComment
+
+{ "afterLineComment": true } option:
+/*eslint lines-around-comment: ["error", { "afterLineComment": true }]*/
var night = "long";
// what a great and wonderful day
var day = "great"{ "afterLineComment": true } option:
+/*eslint lines-around-comment: ["error", { "afterLineComment": true }]*/
var night = "long";
// what a great and wonderful day
var day = "great"allowBlockStart
+
+{ "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;
}{ "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
+
+{ "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
}{ "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
+
+{ "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"};{ "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
+
+{ "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"};{ "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
+
+{ "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"];{ "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
+
+{ "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"];{ "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
+
+Related Rules
+
+
+
+Version
+
+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)
+
+Rule Details
+
+Options
+
+
+
+
+"max" (default 4) enforces a maximum depth that blocks can be nestedmaximum is deprecated; please use the object property max instead.max
+
+{ "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
}
}
}
};
}
}{ "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
}
}
};
}
}Related Rules
+
+
+
+
+Version
+
+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)
+
+
+var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" }; // very longRule Details
+
+Options
+
+
+
+
+"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 URLcode
+
+{ "code": 80 } option:
+/*eslint max-len: ["error", 80]*/
var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" };{ "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
+
+{ "tabWidth": 4 } option:
+/*eslint max-len: ["error", 80, 4]*/
\t \t var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" } };{ "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
+
+{ "comments": 65 } option:
+/*eslint max-len: ["error", { "comments": 65 }]*/
/**
* This is a comment that violates the maximum line length we have specified
**/ignoreComments
+
+{ "ignoreComments": true } option:
+/*eslint max-len: ["error", { "ignoreComments": true }]*/
/**
* This is a really really really really really really really really really long comment
**/ignoreTrailingComments
+
+{ "ignoreTrailingComments": true } option:
+/*eslint max-len: ["error", { "ignoreTrailingComments": true }]*/
var foo = 'bar'; // This is a really really really really really really really long commentignoreUrls
+
+{ "ignoreUrls": true } option:
+/*eslint max-len: ["error", { "ignoreUrls": true }]*/
var url = 'https://www.example.com/really/really/really/really/really/really/really/long';ignorePattern
+
+{ "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');Related Rules
+
+
+
+
+Version
+
+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)
+
+
+foo(function () {
bar(function () {
baz(function() {
qux(function () {
});
});
});
});Rule Details
+
+Options
+
+
+
+
+"max" (default 10) enforces a maximum depth that callbacks can be nestedmaximum is deprecated; please use the object property max instead.max
+
+{ "max": 3 } option:
+/*eslint max-nested-callbacks: ["error", 3]*/
foo1(function() {
foo2(function() {
foo3(function() {
foo4(function() {
// Do something
});
});
});
});{ "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
+
+
+
+Related Rules
+
+
+
+
+Version
+
+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)
+function foo (bar, baz, qux, qxx) { // four parameters, may be too many
doSomething();
}Rule Details
+
+Options
+
+
+
+
+"max" (default 3) enforces a maximum number of parameters in function definitionsmaximum is deprecated; please use the object property max instead.max
+
+{ "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();
};{ "max": 4 } option:
+/*eslint max-params: ["error", 3]*/
/*eslint-env es6*/
function foo (bar, baz, qux) {
doSomething();
}
let foo = (bar, baz, qux) => {
doSomething();
};Related Rules
+
+
+
+
+Version
+
+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)
+
+
+function () { var bar; if (condition) { bar = 1; } else { bar = 2; } return true; } // too many statementsRule Details
+
+Options
+
+max
+
+{ "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; })();{ "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() { })();{ "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; })();{ "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
+
+Related Rules
+
+
+
+
+Version
+
+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)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
+
+Options
+
+
+
+
+"max" (default 10) enforces a maximum number of statements allows in function blocksmaximum is deprecated; please use the object property max instead.
+
+
+"ignoreTopLevelFunctions": true ignores top-level functionsmax
+
+{ "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.
};{ "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
+
+{ "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;
}Related Rules
+
+
+
+
+Version
+
+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)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
+
+
+
+
+ArrayBooleanDateErrorFunctionNumberObjectRegExpStringSymbol
+/*eslint new-cap: "error"*/
function foo(arg) {
return Boolean(arg);
}Options
+
+
+
+
+"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 propertiesnewIsCap
+
+{ "newIsCap": true } option:
+/*eslint new-cap: ["error", { "newIsCap": true }]*/
var friend = new person();{ "newIsCap": true } option:
+/*eslint new-cap: ["error", { "newIsCap": true }]*/
var friend = new Person();{ "newIsCap": false } option:
+/*eslint new-cap: ["error", { "newIsCap": false }]*/
var friend = new person();capIsNew
+
+{ "capIsNew": true } option:
+/*eslint new-cap: ["error", { "capIsNew": true }]*/
var colleague = Person();{ "capIsNew": true } option:
+/*eslint new-cap: ["error", { "capIsNew": true }]*/
var colleague = new Person();{ "capIsNew": false } option:
+/*eslint new-cap: ["error", { "capIsNew": false }]*/
var colleague = Person();newIsCapExceptions
+
+{ "newIsCapExceptions": ["events"] } option:
+/*eslint new-cap: ["error", { "newIsCapExceptions": ["events"] }]*/
var events = require('events');
var emitter = new events();capIsNewExceptions
+
+{ "capIsNewExceptions": ["Person"] } option:
+/*eslint new-cap: ["error", { "capIsNewExceptions": ["Person"] }]*/
function foo(arg) {
return Person(arg);
}properties
+
+{ "properties": true } option:
+/*eslint new-cap: ["error", { "properties": true }]*/
var friend = new person.acquaintance();{ "properties": true } option:
+/*eslint new-cap: ["error", { "properties": true }]*/
var friend = new person.Acquaintance();{ "properties": false } option:
+/*eslint new-cap: ["error", { "properties": false }]*/
var friend = new person.acquaintance();When Not To Use It
+
+Version
+
+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)
+
+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
+
+new keyword in order to increase code clarity.
+/*eslint new-parens: "error"*/
var person = new Person;
+/*eslint new-parens: "error"*/
var person = new Person();Version
+
+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)
+var foo;
// do something with foo
+var foo;
// do something with foovar, let, or const statements. It helps the code to look consistent across the entire project.Rule Details
+
+var, let, or const statements to achieve a consistent coding style across the project.Options
+
+
+
+
+"always" (default) requires an empty line after var, let, or const"never" disallows empty lines after var, let, or constalways
+
+"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);"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
+
+"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);"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
+
+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)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;
}
+function foo(bar) {
var baz = 'baz';
if (!bar) {
bar = baz;
return bar;
}
return bar;
}Rule Details
+
+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.
+/*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;
}
+/*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
+
+return statements.Related Rules
+
+
+
+Version
+
+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)
+
+
+d3.select("body").selectAll("p").data([4, 8, 15, 16, 23, 42 ]).enter().append("p").text(function(d) { return "I'm number " + d + "!"; });
+d3
.select("body")
.selectAll("p")
.data([
4,
8,
15,
16,
23,
42
])
.enter()
.append("p")
.text(function (d) {
return "I'm number " + d + "!";
});
+-d3.select("body").selectAll("p").style("color", "white");
+d3.select("body").selectAll("p").style("color", "blue");
+d3
.select("body")
.selectAll("p")
- .style("color", "white");
+ .style("color", "blue");Rule Details
+
+instance[something] are excluded.Options
+
+
+
+
+"ignoreChainWithDepth" (default: 2) allows chains up to a specified depth.ignoreChainWithDepth
+
+{ "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();{ "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
+
+Version
+
+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)
+
+
+alert("here!");Rule Details
+
+alert, prompt, and confirm function calls which are not shadowed.
+/*eslint no-alert: "error"*/
alert("here!");
confirm("Are you sure?");
prompt("What's your name?", "John Doe");
+/*eslint no-alert: "error"*/
customAlert("Something happened!");
customConfirm("Are you sure?");
customPrompt("Who are you?");
function foo() {
var alert = myCustomLib.customAlert;
alert();
}Related Rules
+
+
+
+
+Version
+
+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)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
+
+Array constructors.
+/*eslint no-array-constructor: "error"*/
Array(0, 1, 2)
+/*eslint no-array-constructor: "error"*/
new Array(0, 1, 2)
+/*eslint no-array-constructor: "error"*/
Array(500)
+/*eslint no-array-constructor: "error"*/
new Array(someOtherArray.length)When Not To Use It
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+& or | is simply a mistyped && or ||, which will lead to unexpected behavior.
+var x = y | z;Rule Details
+
+
+/*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;
+/*eslint no-bitwise: "error"*/
var x = y || z;
var x = y && z;
var x = y > z;
var x = y < z;
x += y;Options
+
+
+
+
+"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
+
+{ "allow": ["~"] } option:
+/*eslint no-bitwise: ["error", { "allow": ["~"] }] */
~[1,2,3].indexOf(1) === -1;int32Hint
+
+{ "int32Hint": true } option:
+/*eslint no-bitwise: ["error", { "int32Hint": true }] */
var b = a|0;Version
+
+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)
+
+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
+
+arguments.caller and arguments.callee. As such, it will warn when arguments.caller and arguments.callee are used.
+/*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;
});
+/*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
+
+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)
+
+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.Rule Details
+
+
+/*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 {}
}
+/*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
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+
+var err = "x";
try {
throw "problem";
} catch (err) {
}
console.log(err) // err is 'problem', not 'x'Rule Details
+
+
+/*eslint no-catch-shadow: "error"*/
var err = "x";
try {
throw "problem";
} catch (err) {
}
function err() {
// ...
};
try {
throw "problem";
} catch (err) {
}
+/*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
+
+Version
+
+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;Rule Details
+
+
+/*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.
}
}
+/*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
+
+Version
+
+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)
+
+==) as an assignment operator (such as =). For example:
+// Check the user's job title
if (user.jobTitle = "manager") {
// user.jobTitle is now incorrect
}Rule Details
+
+if, for, while, and do...while statements.Options
+
+
+
+
+"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 conditionsexcept-parens
+
+"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);
}"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
+
+"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);
}"always" option:
+/*eslint no-cond-assign: ["error", "always"]*/
// Assignment replaced by comparison
var x;
if (x === 0) {
var b = 1;
}Further Reading
+
+
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+=>) 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.=> 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
+
+
+/*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);
+/*eslint no-confusing-arrow: "error"*/
/*eslint-env es6*/
var x = a => { return 1 ? 2 : 3; };
var x = (a) => { return 1 ? 2 : 3; };Options
+
+
+{
"rules": {
"no-confusing-arrow": ["error", {"allowParens": false}]
}
}allowParens is a boolean setting that can be true or false:
+
+
+true relaxes the rule and accepts parenthesis as a valid “confusion-preventing” syntax.false warns even if the expression is wrapped in parenthesisallowParens 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);Related Rules
+
+
+
+Version
+
+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)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
+
+console object.
+/*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.");
+/*eslint no-console: "error"*/
// custom console
Console.log("Hello world!");Options
+
+
+
+
+"allow" has an array of strings which are allowed methods of the console object{ "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
+
+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.Related Rules
+
+
+
+
+Version
+
+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)const keyword.
+It will raise a runtime error.Rule Details
+
+const keyword.
+/*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;
+/*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
+
+const keyword, you can safely disable this rule.Version
+
+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)
+
+
+if (false) {
doSomethingUnfinished();
}Rule Details
+
+
+
+
+if, for, while, or do...while statement?: ternary expression
+/*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;
+/*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
+
+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)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
+
+continue statements.
+/*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;
}
+/*eslint no-continue: "error"*/
var sum = 0,
i;
for(i = 0; i < 10; i++) {
if(i < 5) {
a += i;
}
}Compatibility
+
+
+
+
+continueVersion
+
+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)
+
+Rule Details
+
+
+/*eslint no-control-regex: "error"*/
var pattern1 = /\x1f/;
var pattern2 = new RegExp("\x1f");
+/*eslint no-control-regex: "error"*/
var pattern1 = /\x20/;
var pattern2 = new RegExp("\x20");When Not To Use It
+
+Related Rules
+
+
+
+
+Version
+
+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)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
+
+debugger statements.
+/*eslint no-debugger: "error"*/
function isTruthy(x) {
debugger;
return Boolean(x);
}
+/*eslint no-debugger: "error"*/
function isTruthy(x) {
return Boolean(x); // set a breakpoint at this line
}When Not To Use It
+
+debugger statements, then turn this rule off. You’ll generally want to turn it back on when testing code prior to deployment.Further Reading
+
+
+
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+delete operator is to remove a property from an object. Using the delete operator on a variable might lead to unexpected behavior.Rule Details
+
+delete operator on variables.
+/*eslint no-delete-var: "error"*/
var x;
delete x;Further Reading
+
+
+
+Version
+
+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)
+
+
+function bar() { return /=foo/; }Rule Details
+
+
+/*eslint no-div-regex: "error"*/
function bar() { return /=foo/; }
+/*eslint no-div-regex: "error"*/
function bar() { return /\=foo/; }Related Rules
+
+
+
+Version
+
+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)Rule Details
+
+
+/*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);
};
+/*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
+
+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)
+
+
+/*eslint-env es6*/
class Foo {
bar() { console.log("hello"); }
bar() { console.log("goodbye"); }
}
var foo = new Foo();
foo.bar(); // goodbyeRule Details
+
+
+/*eslint no-dupe-class-members: "error"*/
/*eslint-env es6*/
class Foo {
bar() { }
bar() { }
}
class Foo {
bar() { }
get bar() { }
}
class Foo {
static bar() { }
static bar() { }
}
+/*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
+
+Version
+
+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)
+
+
+var foo = {
bar: "baz",
bar: "qux"
};Rule Details
+
+
+/*eslint no-dupe-keys: "error"*/
var foo = {
bar: "baz",
bar: "qux"
};
var foo = {
"bar": "baz",
bar: "qux"
};
var foo = {
0x1: "baz",
1: "qux"
};
+/*eslint no-dupe-keys: "error"*/
var foo = {
bar: "baz",
quxx: "qux"
};Version
+
+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)
+
+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
+
+case clauses of switch statements.
+/*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;
}
+/*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
+
+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)
+
+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
+
+
+/*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';
+/*eslint no-duplicate-imports: "error"*/
import { merge, find } from 'module';
import path from 'another-module';Options
+
+includeExports which is a boolean. It defaults to false.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';
+/*eslint no-duplicate-imports: ["error", { includeExports: true }]*/
import { merge, find } from 'module';
export { merge };
export { find as lodashFind };Version
+
+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 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
+
+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.
+/*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;
}
}
+/*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
+
+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)
+
+
+var foo = /^abc[]/;Rule Details
+
+
+/*eslint no-empty-character-class: "error"*/
/^abc[]/.test("abcdefg"); // false
"abcdefg".match(/^abc[]/); // null
+/*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
+
+RegExp constructor.
+/*eslint no-empty-character-class: "error"*/
var abcNeverMatches = new RegExp("^abc[]");Version
+
+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)
+
+
+function foo() {
// do nothing.
}
+list.map(() => {}); // This is a block, would return undefined.
list.map(() => ({})); // This is an empty object.Rule Details
+
+
+/*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) {}
}
+/*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
+
+
+
+
+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
+
+{ "allow": ["functions"] } option:
+/*eslint no-empty-function: ["error", { "allow": ["functions"] }]*/
function foo() {}
var foo = function() {};
var obj = {
foo: function() {}
};allow: arrowFunctions
+
+{ "allow": ["arrowFunctions"] } option:
+/*eslint no-empty-function: ["error", { "allow": ["arrowFunctions"] }]*/
/*eslint-env es6*/
var foo = () => {};allow: generatorFunctions
+
+{ "allow": ["generatorFunctions"] } option:
+/*eslint no-empty-function: ["error", { "allow": ["generatorFunctions"] }]*/
/*eslint-env es6*/
function* foo() {}
var foo = function*() {};
var obj = {
foo: function*() {}
};allow: methods
+
+{ "allow": ["methods"] } option:
+/*eslint no-empty-function: ["error", { "allow": ["methods"] }]*/
/*eslint-env es6*/
var obj = {
foo() {}
};
class A {
foo() {}
static foo() {}
}allow: generatorMethods
+
+{ "allow": ["generatorMethods"] } option:
+/*eslint no-empty-function: ["error", { "allow": ["generatorMethods"] }]*/
/*eslint-env es6*/
var obj = {
*foo() {}
};
class A {
*foo() {}
static *foo() {}
}allow: getters
+
+{ "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
+
+{ "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
+
+{ "allow": ["constructors"] } option:
+/*eslint no-empty-function: ["error", { "allow": ["constructors"] }]*/
/*eslint-env es6*/
class A {
constructor() {}
}When Not To Use It
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+
+// doesn't create any variables
var {a: {}} = foo;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;
+// creates variable a
var {a = {}} = foo;Rule Details
+
+
+/*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: []}) {}
+/*eslint no-empty-pattern: "error"*/
var {a = {}} = foo;
var {a = []} = foo;
function foo({a = {}}) {}
function foo({a = []}) {}Version
+
+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)
+
+Rule Details
+
+catch or finally block of a try statement to indicate that execution should continue regardless of errors).
+/*eslint no-empty: "error"*/
if (foo) {
}
while (foo) {
}
switch(foo) {
}
try {
doSomething();
} catch(ex) {
} finally {
}
+/*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
+
+
+
+
+"allowEmptyCatch": true allows empty catch clauses (that is, which do not contain a comment)allowEmptyCatch
+
+{ "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
+
+Related Rules
+
+
+
+Version
+
+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)
+
+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
+
+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 !=.
+/*eslint no-eq-null: "error"*/
if (foo == null) {
bar();
}
while (qux != null) {
baz();
}
+/*eslint no-eq-null: "error"*/
if (foo === null) {
bar();
}
while (qux !== null) {
baz();
}Version
+
+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)
+
+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
+
+eval() function. As such, it will warn whenever the eval() function is used.
+/*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");
+/*eslint no-eval: "error"*/
/*eslint-env browser*/
window.eval("var a = 0");
+/*eslint no-eval: "error"*/
/*eslint-env node*/
global.eval("var a = 0");
+/*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
+
+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
}
+/*eslint no-eval: "error"*/
var obj = { x: "foo" },
key = "x",
value = eval("obj." + key);
+/*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
+
+
+
+
+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");
};
+ var foo = window;
foo.eval("var a = 0");Further Reading
+
+
+
+Related Rules
+
+
+
+
+Version
+
+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)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
+
+catch clauses.
+/*eslint no-ex-assign: "error"*/
try {
// code
} catch (e) {
e = 10;
}
+/*eslint no-ex-assign: "error"*/
try {
// code
} catch (e) {
var foo = 10;
}Further Reading
+
+
+
+
+Version
+
+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)
+
+
+// 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"
}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
+
+
+/*eslint no-extend-native: "error"*/
Object.prototype.a = "a";
Object.defineProperty(Array.prototype, "times", { value: 999 });Options
+
+exceptions option, which can be used to specify a list of builtins for which extensions will be allowed.exceptions
+
+{ "exceptions": ["Object"] } option:
+/*eslint no-extend-native: ["error", { "exceptions": ["Object"] }]*/
Object.prototype.a = "a";Known Limitations
+
+
+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
+
+Function.prototype.bind or Array.prototype.forEach in a future-friendly way.Related Rules
+
+
+
+Version
+
+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)
+
+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"bind() for setting the value of this.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"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
+
+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.this value set using bind(). This rule flags all uses of bind() with arrow functions as a problem
+/*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);
+/*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
+
+bind(), you can safely disable this rule.Further Reading
+
+
+
+Version
+
+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)
+
+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
+
+
+/*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; ) {
// ...
}
+/*eslint no-extra-boolean-cast: "error"*/
var foo = !!bar;
var foo = Boolean(bar);
function foo() {
return !!bar;
}
var foo = bar ? !!baz : !!bat;Version
+
+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)
+
+
+A: while (a) {
break A;
}break or continue without a label.
+Probably those labels would confuse developers because they expect labels to jump to further.Rule Details
+
+
+/*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;
}
+/*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
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+Rule Details
+
+
+
+
+(/abc/).test(var) to avoid conflicts with the wrap-regex rulevar x = (function () {})(); and ((function foo() {return 1;})()) to avoid conflicts with the wrap-iife ruleOptions
+
+
+
+
+"all" (default) disallows unnecessary parentheses around any expression"functions" disallows unnecessary parentheses only around function expressions"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 expressionsall
+
+"all" option:
+/* eslint no-extra-parens: "error" */
a = (b * c);
(a * b) + c;
typeof (a);
(function(){} ? a() : b());"all" option:
+/* eslint no-extra-parens: "error" */
(0).toString();
({}.toString.call());
(function(){}) ? a() : b();
(/^a$/).test(x);conditionalAssign
+
+"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
+
+"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
+
+"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
+
+"functions" option:
+/* eslint no-extra-parens: ["error", "functions"] */
((function foo() {}))();
var y = (function () {return 1;});"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
+
+
+
+Related Rules
+
+
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.Rule Details
+
+
+/*eslint no-extra-semi: "error"*/
var x = 5;;
function foo() {
// code
};
+/*eslint no-extra-semi: "error"*/
var x = 5;
var foo = function() {
// code
};When Not To Use It
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+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();
}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();
}/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();
}Rule Details
+
+
+/*eslint no-fallthrough: "error"*/
switch(foo) {
case 1:
doSomething();
case 2:
doSomething();
}
+/*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();
}case statement in these examples does not cause a warning because there is nothing to fall through into.Options
+
+
+
+
+commentPattern option to a regular expression string to change the test for intentional fallthrough commentcommentPattern
+
+{ "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
+
+case statement should end with a throw, return, break, or comment, then you can safely turn this rule off.Related Rules
+
+
+
+
+Version
+
+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)
+
+
+var num = .5;
var num = 2.;
var num = -.7;Rule Details
+
+
+/*eslint no-floating-decimal: "error"*/
var num = .5;
var num = 2.;
var num = -.7;
+/*eslint no-floating-decimal: "error"*/
var num = 0.5;
var num = 2.0;
var num = -0.7;When Not To Use It
+
+Compatibility
+
+
+
+
+Further Reading
+
+
+
+Version
+
+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)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
+
+function declarations.
+/*eslint no-func-assign: "error"*/
function foo() {}
foo = bar;
function foo() {
foo = bar;
}
+/*eslint no-func-assign: "error"*/
foo = bar;
function foo() {}
+/*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
+
+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)
+
+
+var b = !!foo;
var b = ~foo.indexOf(".");
var n = +foo;
var n = 1 * foo;
var s = "" + foo;
foo += "";
+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
+
+Options
+
+
+
+
+"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.+ in allow list would allow +foo (number coercion) as well as "" + foo (string coercion).boolean
+
+{ "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.{ "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
+
+{ "number": true } option:
+/*eslint no-implicit-coercion: "error"*/
var n = +foo;
var n = 1 * foo;{ "number": true } option:
+/*eslint no-implicit-coercion: "error"*/
var n = Number(foo);
var n = parseFloat(foo);
var n = parseInt(foo, 10);string
+
+{ "string": true } option:
+/*eslint no-implicit-coercion: "error"*/
var s = "" + foo;
foo += "";{ "string": true } option:
+/*eslint no-implicit-coercion: "error"*/
var s = String(foo);allow
+
+allow list, we can override and allow specific operators.{ "allow": ["!!", "~"] } option:
+/*eslint no-implicit-coercion: [2, { "allow": ["!!", "~"] } ]*/
var b = !!foo;
var b = ~foo.indexOf(".");When Not To Use It
+
+Version
+
+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)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
+
+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.
+/*eslint no-implicit-globals: "error"*/
var foo = 1;
function bar() {}
+/*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() {}
})();"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
+
+Further Reading
+
+
+
+Version
+
+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)
+
+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.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);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);setTimeout() and setInterval() (and avoid execScript()).Rule Details
+
+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.
+/*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);
+/*eslint no-implied-eval: "error"*/
setTimeout(function() {
alert("Hi!");
}, 100);
setInterval(function() {
alert("Hi!");
}, 100);When Not To Use It
+
+setTimeout() and setInterval() with string arguments, then you can safely disable this rule.Further Reading
+
+
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+Rule Details
+
+
+/*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 */
+/*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 codeVersion
+
+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)
+// Good
function doSomething() { }
// Bad
if (test) {
function doSomethingElse () { }
}
function anotherThing() {
var fn;
if (test) {
// Good
fn = function expression() { };
// Bad
function declaration() { }
}
}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
+
+Options
+
+
+
+
+"functions" (default) disallows function declarations in nested blocks"both" disallows function and var declarations in nested blocksfunctions
+
+"functions" option:
+/*eslint no-inner-declarations: "error"*/
if (test) {
function doSomething() { }
}
function doSomethingElse() {
if (test) {
function doAnotherThing() { }
}
}"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
+
+"both" option:
+/*eslint no-inner-declarations: ["error", "both"]*/
if (test) {
var foo = 42;
}
function doAnotherThing() {
if (test) {
var bar = 81;
}
}"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
+
+Version
+
+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)SyntaxError when the code is parsed, but an invalid string in RegExp constructors throws a SyntaxError only when the code is executed.Rule Details
+
+RegExp constructors.
+/*eslint no-invalid-regexp: "error"*/
RegExp('[')
RegExp('.', 'z')
new RegExp('\\')
+/*eslint no-invalid-regexp: "error"*/
RegExp('.')
new RegExp
this.RegExp('[')Environments
+
+RegExp constructor:allowConstructorFlags option in .eslintrc. These flags will then be ignored by the rule regardless of the ecmaVersion setting.Options
+
+
+
+
+"allowConstructorFlags" is an array of flagsallowConstructorFlags
+
+{ "allowConstructorFlags": ["u", "y"] } option:
+/*eslint no-invalid-regexp: ["error", { "allowConstructorFlags": ["u", "y"] }]*/
new RegExp('.', 'y')
new RegExp('.', 'yu')Further Reading
+
+
+
+Version
+
+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)this keywords outside of classes or class-like objects might be undefined and raise a TypeError.Rule Details
+
+this keywords outside of classes or class-like objects.this keywords is a constructor or a method.
+
+
+
+
+
+this keywords in functions below:
+
+
+call/apply/bind method of the function is called directly..forEach()) if thisArg is given.@this tag in its JSDoc comment."parserOptions": { "sourceType": "module" } in the ESLint configuration, your code is in strict mode even without a "use strict" directive.
+/*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);
});
+/*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
+
+this keyword outside of classes or class-like objects, you can safely disable this rule.Version
+
+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)
+
+
+
+
+
+
+ Unexpected token ILLEGAL
+
+ Rule Details
+
+
+\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 SpaceOptions
+
+
+
+
+"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 literalsskipStrings
+
+{ "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`;
}{ "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
+
+{ "skipComments": true } option:
+/*eslint no-irregular-whitespace: ["error", { "skipComments": true }]*/
function thing() {
// Description <NBSP>: some descriptive text
}
/*
Description <NBSP>: some descriptive text
*/skipRegExps
+
+{ "skipRegExps": true } option:
+/*eslint no-irregular-whitespace: ["error", { "skipRegExps": true }]*/
function thing() {
return / <NBSP>regexp/;
}skipTemplates
+
+{ "skipTemplates": true } option:
+/*eslint no-irregular-whitespace: ["error", { "skipTemplates": true }]*/
/*eslint-env es6*/
function thing() {
return `template <NBSP>string`;
}When Not To Use It
+
+Further Reading
+
+
+
+Version
+
+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)
+
+__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);
}Rule Details
+
+__iterator__ property, which is not implemented in several browsers. As such, it will warn whenever it encounters the __iterator__ property.
+/*eslint no-iterator: "error"*/
Foo.prototype.__iterator__ = function() {
return new FooIterator(this);
};
foo.__iterator__ = function () {};
foo["__iterator__"] = function () {};
+/*eslint no-iterator: "error"*/
var __iterator__ = foo; // Not using the `__iterator__` property.Further Reading
+
+
+
+
+Version
+
+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
+
+
+/*eslint no-label-var: "error"*/
var x = foo;
function bar() {
x:
for (;;) {
break x;
}
}
+/*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
+
+Further Reading
+
+
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+break and continue to control flow around multiple loops. For example:
+outer:
while (true) {
while (true) {
break outer;
}
}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.Rule Details
+
+break or continue are used with a label.
+/*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;
}
+/*eslint no-labels: "error"*/
var f = {
label: "foo"
};
while (true) {
break;
}
while (true) {
continue;
}Options
+
+
+
+
+"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.allowLoop
+
+
+/*eslint no-labels: ["error", { "allowLoop": true }]*/
label:
while (true) {
break label;
}allowSwitch
+
+
+/*eslint no-labels: ["error", { "allowSwitch": true }]*/
label:
switch (a) {
case 0:
break label;
}When Not To Use It
+
+Related Rules
+
+
+
+Version
+
+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)
+
+foo:
+{
var foo = bar();
}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
+
+
+/*eslint no-lone-blocks: "error"*/
{}
if (foo) {
bar();
{
baz();
}
}
function bar() {
{
baz();
}
}
{
function foo() {}
}
{
aLabel: {
}
}
+/*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: {
}"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
+
+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 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) {
// ...
}
}
+if (foo) {
// ...
} else if (bar) {
// ...
}Rule Details
+
+if statement’s else block contains only another if statement.
+/*eslint no-lonely-if: "error"*/
if (condition) {
// ...
} else {
if (anotherCondition) {
// ...
}
}
if (condition) {
// ...
} else {
if (anotherCondition) {
// ...
} else {
// ...
}
}
+/*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
+
+else if form.Version
+
+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)
+
+
+for (var i = 0; i < 10; i++) {
funcs[i] = function() {
return i;
};
}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;
};
}Rule Details
+
+
+/*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();
}
+/*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
+
+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)
+
+
+var now = Date.now(),
inOneHour = now + (60 * 60 * 1000);Rule Details
+
+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.
+/*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];
+/*eslint no-magic-numbers: "error"*/
var TAX = 0.25;
var dutyFreePrice = 100,
finalPrice = dutyFreePrice + (dutyFreePrice * TAX);Options
+
+ignore
+
+[] by default.
+If provided, it must be an Array.
+/*eslint no-magic-numbers: ["error", { "ignore": [1] }]*/
var data = ['foo', 'bar', 'baz'];
var dataLast = data.length && data[data.length - 1];ignoreArrayIndexes
+
+false by default.
+/*eslint no-magic-numbers: ["error", { "ignoreArrayIndexes": true }]*/
var data = ['foo', 'bar', 'baz'];
var dataLast = data[2];enforceConst
+
+false by default.
+/*eslint no-magic-numbers: ["error", { "enforceConst": true }]*/
var TAX = 0.25;
var dutyFreePrice = 100,
finalPrice = dutyFreePrice + (dutyFreePrice * TAX);detectObjects
+
+false by default.
+/*eslint no-magic-numbers: ["error", { "detectObjects": true }]*/
var magic = {
tax: 0.25
};
var dutyFreePrice = 100,
finalPrice = dutyFreePrice + (dutyFreePrice * magic.tax);
+/*eslint no-magic-numbers: ["error", { "detectObjects": true }]*/
var TAX = 0.25;
var magic = {
tax: TAX
};
var dutyFreePrice = 100,
finalPrice = dutyFreePrice + (dutyFreePrice * magic.tax);Version
+
+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)
+
+require modules from other variable declarations, sometimes also grouping them by the type of module. This rule helps you enforce this convention.Rule Details
+
+var statement must satisfy the following conditions:
+
+
+
+
+
+core: declaration of a required core modulefile: declaration of a required file modulemodule: declaration of a required module from the node_modules foldercomputed: 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 initializedother: any other kind of 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
+
+false values by default.true is deprecated.{ "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');{ "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
+
+{ "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
+
+{ "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');{ "allowCall": true } option:
+/*eslint no-mixed-requires: ["error", { "allowCall": true }]*/
var async = require('async'),
debug = require('diagnostics')('my-module'),
eslint = require('eslint');Known Limitations
+
+
+
+
+require that may shadow Node.js’ global require.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
+
+required modules are not loaded in variable declarations, this rule will obviously do nothing for you.Version
+
+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)
+
+Rule Details
+
+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
+
+
+"no-mixed-spaces-and-tabs": ["error", "smart-tabs"]
+/*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;
}
+/*eslint no-mixed-spaces-and-tabs: "error"*/
function add(x, y) {
// --->return x + y;
return x + y;
}
+/*eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/
function main() {
// --->var x = 5,
// --->....y = 7;
var x = 5,
y = 7;
}Further Reading
+
+
+
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+
if(foo === "bar") {}foo and ===. Multiple spaces such as this are generally frowned upon in favor of single spaces:
+
if(foo === "bar") {}Rule Details
+
+
+/*eslint no-multi-spaces: "error"*/
var a = 1;
if(foo === "bar") {}
a << b
var arr = [1, 2];
a ? b: c
+/*eslint no-multi-spaces: "error"*/
var a = 1;
if(foo === "bar") {}
a << b
var arr = [1, 2];
a ? b: cOptions
+
+exceptions
+
+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.Property node type is ignored by default, because for the key-spacing rule some alignment options require multiple spaces in properties of object literals."exceptions": { "Property": true } option:
+/*eslint no-multi-spaces: "error"*/
/*eslint key-spacing: ["error", { align: "value" }]*/
var obj = {
first: "first",
second: "second"
};"exceptions": { "Property": false } option:
+/*eslint no-multi-spaces: ["error", { exceptions: { "Property": false } }]*/
/*eslint key-spacing: ["error", { align: "value" }]*/
var obj = {
first: "first",
second: "second"
};"exceptions": { "BinaryExpression": true } option:
+/*eslint no-multi-spaces: ["error", { exceptions: { "BinaryExpression": true } }]*/
var a = 1 * 2;"exceptions": { "VariableDeclarator": true } option:
+/*eslint no-multi-spaces: ["error", { exceptions: { "VariableDeclarator": true } }]*/
var someVar = 'foo';
var someOtherVar = 'barBaz';"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
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+
+var x = "Line 1 \
Line 2";Rule Details
+
+
+/*eslint no-multi-str: "error"*/
var x = "Line 1 \
Line 2";
+/*eslint no-multi-str: "error"*/
var x = "Line 1\n" +
"Line 2";Further Reading
+
+
+
+Version
+
+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)
+
+Rule Details
+
+Options
+
+
+
+
+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
+
+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}]
+/*eslint no-multiple-empty-lines: ["error", {max: 2}]*/
var foo = 5;
var bar = 3;
+/*eslint no-multiple-empty-lines: ["error", {max: 2}]*/
var foo = 5;
var bar = 3;maxEOF
+
+
+"no-multiple-empty-lines": ["error", {"max": 2, "maxEOF": 1}]
+/*eslint no-multiple-empty-lines: ["error", {max: 2, maxEOF: 1}]*/
var foo = 5;
var bar = 3;
+/*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}]
+/*eslint no-multiple-empty-lines: ["error", {max: 2, maxBOF: 0}]*/
var foo = 5;
var bar = 3;
+/*eslint no-multiple-empty-lines: ["error", {max: 2, maxBOF: 0}]*/
var foo = 5;
var bar = 3;When Not To Use It
+
+Version
+
+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)
+
+
+String = "hello world";Rule Details
+
+builtin variables from globals.
+/*eslint no-native-reassign: "error"*/
String = new Object();Options
+
+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
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+
+if (!a) {
doSomething();
}
else {
doSomethingElse();
}
+if (a) {
doSomethingElse();
}
else {
doSomething();
}Rule Details
+
+
+/*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
+/*eslint no-negated-condition: "error"*/
if (!a) {
doSomething();
}
if (!a) {
doSomething();
} else if (b) {
doSomething();
}
if (a != b) {
doSomething();
}
a ? b : cVersion
+
+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
+
+-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
+
+in expressions.
+/*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
}
+/*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
+
+Version
+
+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)
+
+no-nested-ternary rule disallows the use of nested ternary expressions.
+var foo = bar ? baz : qux === quxx ? bing : bam;Rule Details
+
+no-nested-ternary rule aims to increase the clarity and readability of code by disallowing the use of nested ternary expressions.
+/*eslint no-nested-ternary: "error"*/
var thing = foo ? bar : baz === qux ? quxx : foobar;
foo ? baz === qux ? quxx() : foobar() : bar();
+/*eslint no-nested-ternary: "error"*/
var thing;
if (foo) {
thing = bar;
} else if (baz === qux) {
thing = quxx;
} else {
thing = foobar;
}Related Rules
+
+
+
+Version
+
+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)
+
+Function constructor, such as:
+var x = new Function("a", "b", "return a + b");Rule Details
+
+eval function.
+/*eslint no-new-func: "error"*/
var x = new Function("a", "b", "return a + b");
var x = Function("a", "b", "return a + b");
+/*eslint no-new-func: "error"*/
var x = function (a, b) {
return a + b;
};When Not To Use It
+
+Function constructor.Further Reading
+
+
+
+Version
+
+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)
+
+Object constructor is used to create new generic objects in JavaScript, such as:
+var myObject = new Object();
+var myObject = {};Object constructor.Rule Details
+
+Object constructor. As such, it warns whenever new Object is found in code.
+/*eslint no-new-object: "error"*/
var myObject = new Object();
var myObject = new Object;
+/*eslint no-new-object: "error"*/
var myObject = new CustomObject();
var myObject = {};When Not To Use It
+
+Object constructor, you can safely turn this rule off.Related Rules
+
+
+
+Version
+
+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)
+
+require function is used to include modules that exist in separate files, such as:
+var appHeader = require('app-header');
+var appHeader = new require('app-header');
+var appHeader = new (require('app-header'));Rule Details
+
+new require expression.
+/*eslint no-new-require: "error"*/
var appHeader = new require('app-header');
+/*eslint no-new-require: "error"*/
var AppHeader = require('app-header');
var appHeader = new AppHeader();When Not To Use It
+
+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
+
+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)
+
+Symbol constructor is not intended to be used with the new operator, but to be called as a function.
+var foo = new Symbol("foo");TypeError exception.Rule Details
+
+Symbol with the new operator.
+/*eslint no-new-symbol: "error"*/
/*eslint-env es6*/
var foo = new Symbol('foo');
+/*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
+
+Further Reading
+
+
+
+Version
+
+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)
+
+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);String object is constructed. The substring() method exists on String.prototype and so is accessible to the string instance.
+var stringObject = new String("Hello world");
var numberObject = new Number(33);
var booleanObject = new Boolean(false);
+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");
}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.new.Rule Details
+
+String, Number, and Boolean with the new operator. As such, it warns whenever it sees new String, new Number, or new Boolean.
+/*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;
+/*eslint no-new-wrappers: "error"*/
var text = String(someValue);
var num = Number(someValue);
var object = new MyString();When Not To Use It
+
+Further Reading
+
+
+
+
+Related Rules
+
+
+
+Version
+
+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)
+
+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();new and not store the result, such as:
+new Person();new to be used.Rule Details
+
+new keyword that do not assign the resulting object to a variable.
+/*eslint no-new: "error"*/
new Thing();
+/*eslint no-new: "error"*/
var thing = new Thing();
Thing();Version
+
+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)
+
+Math and JSON) but will throw an error if you try to execute them as functions.Math and JSON cannot be invoked:
+
+
+[[Call]] internal property; it is not possible to invoke the Math object as a function.Rule Details
+
+Math and JSON objects as functions.
+/*eslint no-obj-calls: "error"*/
var math = Math();
var json = JSON();
+/*eslint no-obj-calls: "error"*/
function area(r) {
return Math.PI * r * r;
}
var object = JSON.parse("{}");Further Reading
+
+
+
+Version
+
+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)
+
+
+var foo = "Copyright \251";Rule Details
+
+
+/*eslint no-octal-escape: "error"*/
var foo = "Copyright \251";
+/*eslint no-octal-escape: "error"*/
var foo = "Copyright \u00A9"; // unicode
var foo = "Copyright \xA9"; // hexadecimalVersion
+
+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)
+
+
+var num = 071; // 57Rule Details
+
+
+/*eslint no-octal: "error"*/
var num = 071;
var result = 5 + 07;
+/*eslint no-octal: "error"*/
var num = "071";Compatibility
+
+
+
+
+Further Reading
+
+
+
+Version
+
+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)
+
+arguments object. Often, assignment to function parameters is unintended and indicative of a mistake or programmer error.Rule Details
+
+
+/*eslint no-param-reassign: "error"*/
function foo(bar) {
bar = 13;
}
function foo(bar) {
bar++;
}
+/*eslint no-param-reassign: "error"*/
function foo(bar) {
var baz = bar;
}Options
+
+"props". It is false by default. If it is set to true, this rule warns against the modification of parameter properties.props
+
+{ "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++;
}{ "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
+
+Further Reading
+
+
+
+Version
+
+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)__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";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");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");path.join() and path.resolve() are suitable replacements for string concatenation wherever file or directory paths are being created.Rule Details
+
+
+/*eslint no-path-concat: "error"*/
var fullPath = __dirname + "/foo.js";
var fullPath = __filename + "/foo.js";
+/*eslint no-path-concat: "error"*/
var fullPath = dirname + "/foo.js";When Not To Use It
+
+Version
+
+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)
+
+no-plusplus rule flags the use of unary operators, ++ and --.
+var foo = 0;
foo++;++ 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 = 21Rule Details
+
+++ 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
+
+
+
+
+allowForLoopAfterthoughts set to true will allow you to use the unary operators ++ and -- in the afterthought (final expression) of a for loop.
+/*eslint no-plusplus: "error"*/
var foo = 0;
foo++;
var bar = 42;
bar--;
for (i = 0; i < l; i++) {
return;
}
+/*eslint no-plusplus: "error"*/
var foo = 0;
foo += 1;
var bar = 42;
bar -= 1;
for (i = 0; i < l; i += 1) {
return;
}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
+
+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)
+
+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
+
+process.env to avoid global dependencies. As such, it will warn whenever process.env is used.
+/*eslint no-process-env: "error"*/
if(process.env.NODE_ENV === "development") {
//...
}
+/*eslint no-process-env: "error"*/
var config = require("./config");
if(config.env === "development") {
//...
}When Not To Use It
+
+process.env throughout your project to retrieve values from environment variables, then you can safely disable this rule.Further Reading
+
+
+
+
+Version
+
+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)
+
+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);
}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!");
}Rule Details
+
+process.exit() in Node.js JavaScript. As such, it warns whenever process.exit() is found in code.
+/*eslint no-process-exit: "error"*/
process.exit(1);
process.exit(0);
+/*eslint no-process-exit: "error"*/
Process.exit();
var exit = process.exit;When Not To Use It
+
+Version
+
+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
+
+__proto__ is set to the original prototype property of the object’s constructor function. getPrototypeOf is the preferred method of getting “the prototype”.
+/*eslint no-proto: "error"*/
var a = obj.__proto__;
var a = obj["__proto__"];
+/*eslint no-proto: "error"*/
var a = Object.getPrototypeOf(obj);When Not To Use It
+
+getPrototypeOf is not yet universal.Further Reading
+
+
+
+Version
+
+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)
+
+var. This can lead to confusion as to where the variable is actually declared and initialized.Rule Details
+
+
+/*eslint no-redeclare: "error"*/
var a = 3;
var a = 10;
+/*eslint no-redeclare: "error"*/
var a = 3;
// ...
a = 10;Options
+
+"builtinGlobals". It defaults to false.
+If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number…builtinGlobals
+
+{ "builtinGlobals": true } option:
+/*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
var Object = 0;{ "builtinGlobals": true } option and the browser environment:
+/*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
/*eslint-env browser*/
var top = 0;browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared.Version
+
+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)
+
+
+var re = /foo bar/;
+var re = /foo {3}bar/;Rule Details
+
+
+/*eslint no-regex-spaces: "error"*/
var re = /foo bar/;
+/*eslint no-regex-spaces: "error"*/
var re = /foo {3}bar/;Known Limitations
+
+RegExp constructor.
+/*eslint no-regex-spaces: "error"*/
var re = new RegExp("foo bar");When Not To Use It
+
+Further Reading
+
+
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+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
+
+Options
+
+"event", "fdescribe" global variable names:
+/*global event, fdescribe*/
/*eslint no-restricted-globals: ["error", "event", "fdescribe"]*/
function onClick() {
console.log(event);
}
fdescribe("foo", function() {
});"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
+
+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)
+
+no-restricted-modules.
+
+
+fs module would not make sense in an environment that didn’t have a file system.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
+
+Options
+
+
+"no-restricted-imports": ["error", "import1", "import2"]
+ "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"
],
+/*eslint no-restricted-imports: ["error", "fs"]*/
import fs from 'fs';
+/*eslint no-restricted-imports: ["error", "cluster"]*/
import cluster from ' cluster ';
+/*eslint no-restricted-imports: ["error", "fs"]*/
import crypto from 'crypto';When Not To Use It
+
+Version
+
+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)
+
+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
+
+Options
+
+
+{
"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"
]
}"fs", "cluster" restricted modules:
+/*eslint no-restricted-modules: ["error", "fs", "cluster"]*/
var fs = require('fs');
var cluster = require(' cluster ');"fs", "cluster" restricted modules:
+/*eslint no-restricted-modules: ["error", "fs", "cluster"]*/
var crypto = require('crypto');Version
+
+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)
+
+try-catch or class.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
+
+Options
+
+
+{
"rules": {
"no-restricted-syntax": ["error", "FunctionExpression", "WithStatement"]
}
}
+/* eslint no-restricted-syntax: ["error", "FunctionExpression", "WithStatement"] */
with (me) {
dontMess();
}
var doSomething = function () {};
+/* eslint no-restricted-syntax: ["error", "FunctionExpression", "WithStatement"] */
me.dontMess();
function doSomething() {};When Not To Use It
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+return statement. For example:
+function doSomething() {
return foo = bar + 2;
}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.return statements.Rule Details
+
+return statements. As such, it will warn whenever an assignment is found as part of return.Options
+
+
+
+
+except-parens (default): Disallow assignments unless they are enclosed in parentheses.always: Disallow all assignments.except-parens
+
+"except-parens" option:
+/*eslint no-return-assign: "error"*/
function doSomething() {
return foo = bar + 2;
}
function doSomething() {
return foo += 2;
}"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
+
+return statements.
+All assignments are treated as problems."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);
}"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
+
+return statement, then you can safely disable this rule.Version
+
+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)
+
+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
+
+
+/*eslint no-script-url: "error"*/
location.href = "javascript:void(0)";Compatibility
+
+
+
+
+scripturl rule of JSHint.Further Reading
+
+
+
+Version
+
+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)
+
+
+foo = foo;
[bar, baz] = [bar, qiz];Rule Details
+
+
+/*eslint no-self-assign: "error"*/
foo = foo;
[a, b] = [a, b];
[a, ...b] = [x, ...b];
({a, b} = {a, x});
+/*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
+
+Version
+
+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)
+
+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
+
+
+/*eslint no-self-compare: "error"*/
var x = 10;
if (x === x) {
x = 20;
}Further Reading
+
+
+
+
+Version
+
+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)
+
+
+var a = (3, 5); // a = 5
a = b += 5, a + b;
while (a = next(), a && a.length);
(0, eval)("doSomething();");Rule Details
+
+
+
+
+for statement.
+/*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) {}
+/*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
+
+Version
+
+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)
+
+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";undefined, but rather the local version with a very different meaning.Rule Details
+
+
+/*eslint no-shadow-restricted-names: "error"*/
function NaN(){}
!function(Infinity){};
var undefined;
try {} catch(eval){}
+/*eslint no-shadow-restricted-names: "error"*/
var Object;
function f(a, b){}Further Reading
+
+
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+
+var a = 3;
function b() {
var a = 10;
}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
+
+
+/*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
+
+"builtinGlobals", "hoist" and "allow".
+{
"no-shadow": ["error", { "builtinGlobals": false, "hoist": "functions", "allow": [] }]
}builtinGlobals
+
+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.{ "builtinGlobals": true } option:
+/*eslint no-shadow: ["error", { "builtinGlobals": true }]*/
function foo() {
var Object = 0;
}hoist
+
+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
+
+{ "hoist": "functions" } option:
+/*eslint no-shadow: ["error", { "hoist": "functions" }]*/
/*eslint-env es6*/
if (true) {
let b = 6;
}
function b() {}let b in the if statement is before the function declaration in the outer scope, it is incorrect.{ "hoist": "functions" } option:
+/*eslint no-shadow: ["error", { "hoist": "functions" }]*/
/*eslint-env es6*/
if (true) {
let a = 3;
}
let a = 5;let a in the if statement is before the variable declaration in the outer scope, it is correct.hoist: all
+
+{ "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
+
+{ "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() {}let a and let b in the if statement are before the declarations in the outer scope, they are correct.allow
+
+allow option is an array of identifier names for which shadowing is allowed. For example, "resolve", "reject", "done", "cb".{ "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
+
+
+
+Related Rules
+
+
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.Rule Details
+
+
+fn ()
+/*eslint no-spaced-func: "error"*/
fn ()
fn
()
+/*eslint no-spaced-func: "error"*/
fn()Version
+
+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)
+
+
+var items = [,,];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" ];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?Rule Details
+
+
+/*eslint no-sparse-arrays: "error"*/
var items = [,];
var colors = [ "red",, "blue" ];
+/*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
+
+Further Reading
+
+
+
+Version
+
+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)
+
+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
+
+Sync” (as is the convention with Node.js operations).
+/*eslint no-sync: "error"*/
fs.existsSync(somePath);
var contents = fs.readFileSync(somePath).toString();
+/*eslint no-sync: "error"*/
obj.sync();
async(function() {
// ...
});When Not To Use It
+
+Version
+
+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)
+
+
+var foo = isBar ? baz : qux;Rule Details
+
+no-ternary rule aims to disallow the use of ternary operators.
+/*eslint no-ternary: "error"*/
var foo = isBar ? baz : qux;
foo ? bar() : baz();
function quux() {
return foo ? bar : baz;
}
+/*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;
}
}Related Rules
+
+
+
+Version
+
+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)this/super are used before super() calls, it raises a reference error.this/super keywords in constructors, then reports those that are before super().Rule Details
+
+this/super keywords before super() callings.
+/*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());
}
}
+/*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
+
+this/super before super() in constructors, you can safely disable this rule.Version
+
+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)
+
+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.Error object.Rule Details
+
+Error object.
+/*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}`
+/*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
+
+Error objects.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
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.Rule Details
+
+
+/*eslint no-trailing-spaces: "error"*/
// spaces, tabs and unicode whitespaces
// are not allowed at the end of lines
var foo = 0;//•••••
var baz = 5;//••
+/*eslint no-trailing-spaces: "error"*/
var foo = 0;
var baz = 5;Options
+
+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.
+{
"no-trailing-spaces": ["error", { "skipBlankLines": true }]
}
+/*eslint no-trailing-spaces: ["error", { "skipBlankLines": true }]*/
var foo = 0;
//••••
var baz = 5;Version
+
+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)
+
+undefined. For example:
+var foo;
console.log(foo === undefined); // trueundefined, such as:
+var foo = undefined;undefined.Rule Details
+
+undefined.
+/*eslint no-undef-init: "error"*/
/*eslint-env es6*/
var foo = undefined;
let bar = undefined;
+/*eslint no-undef-init: "error"*/
/*eslint-env es6*/
var foo;
let bar;
const baz = undefined;When Not To Use It
+
+undefined behaves differently than omitting the initialization, and that’s when a var declaration occurs inside of a loop. For example:
+for (i = 0; i < 10; i++) {
var x = undefined;
console.log(x);
x = i;
}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;
}
+for (i = 0; i < 10; i++) {
var x;
console.log(x);
x = i;
}
+var x;
for (i = 0; i < 10; i++) {
console.log(x);
x = i;
}var x = undefined in the loop, as x is no longer reset to undefined each time through the loop.
+/*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;
}Related Rules
+
+
+
+
+Version
+
+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)
+
+var keyword in a for loop initializer).Rule Details
+
+/*global ...*/ comment.
+/*eslint no-undef: "error"*/
var a = someFunction();
b = 10;global declaration:
+/*global someFunction b:true*/
/*eslint no-undef: "error"*/
var a = someFunction();
b = 10;b:true syntax in /*global */ indicates that assignment to b is correct.global declaration:
+/*global b*/
/*eslint no-undef: "error"*/
b = 10;/*global */ are read-only, therefore assignment is incorrect.Options
+
+
+
+
+typeof set to true will warn for variables used inside typeof check (Default false).typeof
+
+{ "typeof": false } option:
+/*eslint no-undef: "error"*/
if (typeof UndefinedIdentifier === "undefined") {
// do something ...
}typeof check on a variable which has not been declared.{ "typeof": true } option:
+/*eslint no-undef: ["error", { "typeof": true }] */
if(typeof a === "string"){}{ "typeof": true } option with global declaration:
+/*global a*/
/*eslint no-undef: ["error", { "typeof": true }] */
if(typeof a === "string"){}Environments
+
+browser
+
+browser environment:
+/*eslint no-undef: "error"*/
/*eslint-env browser*/
setTimeout(function() {
alert("Hello");
});node
+
+node environment:
+/*eslint no-undef: "error"*/
/*eslint-env node*/
var fs = require("fs");
module.exports = function() {
console.log(fs);
};When Not To Use It
+
+Compatibility
+
+Further Reading
+
+
+
+Version
+
+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)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) {
// ...
}
}undefined that doesn’t exist for null, which is a keyword and primitive value that can neither be overwritten nor shadowed.undefined:
+var foo;
console.log(foo === undefined); // true (assuming no shadowing)undefined.undefined, recommending instead:
+
+
+undefined are simply left uninitialized.undefined should be done with typeof.void operator to generate the value of undefined if necessary.Rule Details
+
+undefined, and as such, generates a warning whenever it is used.
+/*eslint no-undefined: "error"*/
var foo = undefined;
var undefined = "foo";
if (foo === undefined) {
// ...
}
function foo(undefined) {
// ...
}
+/*eslint no-undefined: "error"*/
var foo = void 0;
var Undefined = "foo";
if (typeof foo === "undefined") {
// ...
}
global.undefined = "foo";When Not To Use It
+
+undefined in your code, then you can safely turn this rule off.Further Reading
+
+
+
+
+
+
+
+
+
+
+ [undefined - JavaScript
+ MDN](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/)
+ Related Rules
+
+
+
+
+Version
+
+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)
+
+
+var _foo;__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.Rule Details
+
+Options
+
+
+
+allow
+"no-underscore-dangle": ["error", { "allow": [] }]Array.
+
+allowAfterThis
+"no-underscore-dangle": ["error", { "allowAfterThis": true }]this.
+/*eslint no-underscore-dangle: "error"*/
var foo_;
var __proto__ = {};
foo._bar();
+/*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
+
+Version
+
+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)
+
+
+
+
+. or ,.)-- or ++ (in which case it will decrement/increment the next token.)for(), while(), do, if(), or else, and there is no {[, (, +, *, /, -, ,, ., or some other binary operator that can only be found between two tokens in a single expression.Rule Details
+
+
+/*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`
+/*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
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+
+while (node) {
doSomething(node);
}
+while (node) {
doSomething(node);
node = node.parent;
}Rule Details
+
+CallExpression,
+YieldExpression, …), this rule ignores it.
+while (node) {
doSomething(node);
}
node = other;
for (var j = 0; j < items.length; ++i) {
doSomething(items[j]);
}
while (node !== root) {
doSomething(node);
}
+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
+
+Version
+
+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)
+
+
+// Bad
var isYes = answer === 1 ? true : false;
// Good
var isYes = answer === 1;
// Bad
var isNo = answer === 1 ? false : true;
// Good
var isNo = answer !== 1;OR can be used to provide the same functionality.
+Here is an example:
+// Bad
var foo = bar ? bar : 1;
// Good
var foo = bar || 1;defaultAssignment option is set to false.Rule Details
+
+{"defaultAssignment": true }.
+/*eslint no-unneeded-ternary: "error"*/
var a = x === 2 ? true : false;
var a = x ? true : false;defaultAssignment is false:
+var a = x ? x : 1;
+/*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;defaultAssignment is true:
+var a = x ? x : 1;When Not To Use It
+
+Related Rules
+
+
+
+
+Version
+
+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)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
+
+return, throw, continue, and break statements.
+/*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");
+/*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
+
+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)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;
})();
// > 1Rule Details
+
+return, throw, break, and continue statements inside finally blocks. It allows indirect usages, such as in function or class definitions.
+/*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;
}
};
+/*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
+
+finally blocks, you can turn this rule off.Version
+
+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)
+
+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
+
+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"use strict"; at the beginning of a script, module, or function).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
+
+
+
+
+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).{ "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 () {});
+"use strict";
"use asm"
"use stricter";
"use babel"
"any other strings like this in the prologue";{ "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 aallowShortCircuit
+
+{ "allowShortCircuit": true } option:
+/*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
a || b{ "allowShortCircuit": true } option:
+/*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
a && b()
a() || (b = c)allowTernary
+
+{ "allowTernary": true } option:
+/*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
a ? b : 0
a ? b : c(){ "allowTernary": true } option:
+/*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
a ? b() : c()
a ? (b = c) : d()allowShortCircuit and allowTernary
+
+{ "allowShortCircuit": true, "allowTernary": true } options:
+/*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/
a ? b() || (c = d) : e()Version
+
+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)
+
+
+OUTER_LOOP:
for (const student of students) {
if (checkScores(student.scores)) {
continue;
}
doSomething(student);
}OUTER_LOOP: had been forgotten.
+Such labels take up space in the code and can lead to confusion by readers.Rule Details
+
+
+/*eslint no-unused-labels: "error"*/
A: var foo = 0;
B: {
foo();
}
C:
for (let i = 0; i < 10; ++i) {
foo();
}
+/*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
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+Rule Details
+
+
+
+
+doSomething())var y = x)doSomething(x))var x = 5) or declared.
+/*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);
}
+/*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
+
+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./* exported */ has no effect for any of the following:
+
+
+node or commonjsparserOptions.sourceType is moduleecmaFeatures.globalReturn is trueOptions
+
+vars property (explained below).all option for variables and after-used for arguments.
+{
"rules": {
"no-unused-vars": ["error", { "vars": "all", "args": "after-used" }]
}
}vars
+
+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
+
+{ "vars": "local" } option:
+/*eslint no-unused-vars: ["error", { "vars": "local" }]*/
/*global some_unused_var */
some_unused_var = 42;varsIgnorePattern
+
+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.{ "varsIgnorePattern": "[iI]gnored" } option:
+/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "[iI]gnored" }]*/
var firstVarIgnored = 1;
var secondVar = 2;
console.log(secondVar);args
+
+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
+
+{ "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;
})();{ "args": "after-used" } option:
+/*eslint no-unused-vars: ["error", {"args": "after-used"}]*/
(function(foo, bar, baz) {
return baz;
})();args: all
+
+{ "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
+
+{ "args": "none" } option:
+/*eslint no-unused-vars: ["error", { "args": "none" }]*/
(function(foo, bar, baz) {
return bar;
})();argsIgnorePattern
+
+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.{ "argsIgnorePattern": "^_" } option:
+/*eslint no-unused-vars: ["error", { "argsIgnorePattern": "^_" }]*/
function foo(x, _y) {
return x + 1;
}
foo();caughtErrors
+
+caughtErrors option is used for catch block arguments validation.
+
+
+none - do not check error objects. This is the default setting.all - all named arguments must be used.caughtErrors: none
+
+none.{ "caughtErrors": "none" } option:
+/*eslint no-unused-vars: ["error", { "caughtErrors": "none" }]*/
try {
//...
} catch (err) {
console.error("errors");
}caughtErrors: all
+
+{ "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
+
+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’.{ "caughtErrorsIgnorePattern": "^ignore" } option:
+/*eslint no-unused-vars: ["error", { "caughtErrorsIgnorePattern": "^ignore" }]*/
try {
//...
} catch (ignoreErr) {
console.error("errors");
}When Not To Use It
+
+Version
+
+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)
+
+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
+
+
+/*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;
}
+/*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."nofunc" string as a option.
+"nofunc" is the same as { "functions": false, "classes": true }.functions
+
+{ "functions": false } option:
+/*eslint no-use-before-define: ["error", { "functions": false }]*/
f();
function f() {}classes
+
+{ "classes": false } option:
+/*eslint no-use-before-define: ["error", { "classes": false }]*/
/*eslint-env es6*/
new A();
class A {
}{ "classes": false } option:
+/*eslint no-use-before-define: ["error", { "classes": false }]*/
/*eslint-env es6*/
function foo() {
return new A();
}
class A {
}Version
+
+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)Function.prototype.call() and Function.prototype.apply().
+But Function.prototype.call() and Function.prototype.apply() are slower than the normal function invocation.Rule Details
+
+Function.prototype.call() and Function.prototype.apply() that can be replaced with the normal function invocation.
+/*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]);
+/*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
+
+thisArg is changed.
+So if the code about thisArg is a dynamic expression, this rule cannot judge correctly.
+/*eslint no-useless-call: "error"*/
a[i++].foo.call(a[i++], 1, 2, 3);
+/*eslint no-useless-call: "error"*/
a[++i].foo.call(a[i], 1, 2, 3);When Not To Use It
+
+.call() and .apply(), you can safely disable this rule.Version
+
+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)
+
+
+var foo = {["a"]: "b"};
+var foo = {"a": "b"};Rule Details
+
+
+/*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']() {} };
+/*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
+
+Version
+
+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)
+
+
+var foo = "a" + "b";"a" + b + "b"). In such a case, the concatenation isn’t important and the code can be rewritten as:
+var foo = "ab";Rule Details
+
+
+/*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`;
+/*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
+
+Version
+
+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)
+
+
+class A {
constructor () {
}
}
class A extends B {
constructor (value) {
super(value);
}
}Rule Details
+
+
+/*eslint no-useless-constructor: "error"*/
/*eslint-env es6*/
class A {
constructor () {
}
}
class A extends B {
constructor (...args) {
super(...args);
}
}
+/*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
+
+Version
+
+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)
+
+
+let foo = "hol\a"; // > foo = "hola"
let bar = /\:/ // same functionality with /:/Rule Details
+
+
+/*eslint no-useless-escape: "error"*/
"\'";
'\"';
"\#";
"\e";
/\!/;
/\@/;
+/*eslint no-useless-escape: "error"*/
"\"";
'\'';
"\x12";
"\u00a9";
"\371";
"xs\u2111";
/\\/g;
/\t/g;
/\\w\\$\\*\\^\\./;When Not To Use It
+
+Version
+
+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)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
+
+var and encouraging the use of const or let instead.
+/*eslint no-var: "error"*/
var x = "y";
var CONFIG = {};
+/*eslint no-var: "error"*/
/*eslint-env es6*/
let x = "y";
const CONFIG = {};When Not To Use It
+
+var to let is too costly.Version
+
+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)
+
+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: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;
})();void 0 is shorter than undefined:
+foo = void 0;
foo = undefined;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 SyntaxErrorvoid operator marking it as non-obvious and hard to read.Rule Details
+
+
+/*eslint no-void: "error"*/
void foo
var foo = void bar();When Not To Use It
+
+void operator then you can disable this rule.Further Reading
+
+
+
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+
+// TODO: do something
// FIXME: this is not a good ideaRule Details
+
+Options
+
+
+
+
+"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.{ "terms": ["todo", "fixme", "xxx"], "location": "start" } options:
+/*eslint no-warning-comments: "error"*/
function callback(err, results) {
if (err) {
console.error(err);
return;
}
// TODO
}{ "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
+
+{ "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
*/{ "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
+
+
+
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+foo. bar .baz . quzRule Details
+
+
+foo
.bar()
.baz()
.qux()
+/*eslint no-whitespace-before-property: "error"*/
foo [bar]
foo. bar
foo .bar
foo. bar. baz
foo. bar()
.baz()
foo
.bar(). baz()
+/*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
+
+Version
+
+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)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
+
+with statements.
+/*eslint no-with: "error"*/
with (point) {
r = Math.sqrt(x * x + y * y); // is r a member of point?
}
+/*eslint no-with: "error"*/
/*eslint-env es6*/
const r = ({x, y}) => Math.sqrt(x * x + y * y);When Not To Use It
+
+with statements then you can disable this rule.Further Reading
+
+
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+// 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
+
+Options
+
+
+
+
+"always" enforces a space inside of curly braces"never" disallows spaces inside of curly braces (default)
+"object-curly-spacing": ["error", "always"]“never”
+
+"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';
+/*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”
+
+"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';
+/*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';{} is always exempt from spacing requirements with this rule.Exceptions
+
+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."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.
+"object-curly-spacing": ["error", "always", {
"objectsInObjects": false,
"arraysInObjects": false
}]
+
+objectsInObjects"always" option, set objectsInObjects exception to false to
+enforce the following syntax (notice the }} at the end):
+var obj = { "foo": { "baz": 1, "bar": 2 }};"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"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" ]};"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
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+
+// 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
+
+
+/*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"
};
+/*eslint object-property-newline: "error"*/
var obj = {
foo: "foo",
bar: "bar",
baz: "baz"
};Options
+
+
+
+
+"allowMultiplePropertiesPerLine": true allows all keys and values to be on the same lineallowMultiplePropertiesPerLine
+
+{ "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
+
+Compatibility
+
+
+
+
+requireObjectKeysOnNewLineRelated Rules
+
+
+
+Version
+
+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)
+
+
+// properties
var foo = {
x: x,
y: y,
z: z,
};
// methods
var foo = {
a: function() {},
b: function() {}
};
+/*eslint-env es6*/
// properties
var foo = {x, y, z};
// methods
var foo = {
a() {},
b() {}
};Rule Details
+
+
+/*eslint object-shorthand: "error"*/
/*eslint-env es6*/
var foo = {
w: function() {},
x: function *() {},
[y]: function() {},
z: z
};
+/*eslint object-shorthand: "error"*/
/*eslint-env es6*/
var foo = {
w() {},
*x() {},
[y]() {},
z
};
+/*eslint object-shorthand: "error"*/
/*eslint-env es6*/
var foo = {
x: (y) => y
};Options
+
+
+
+
+"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.
+{
"object-shorthand": ["error", "always"]
}"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 }]
}"avoidQuotes" option:
+/*eslint object-shorthand: ["error", "always", { "avoidQuotes": true }]*/
/*eslint-env es6*/
var foo = {
"bar-baz"() {}
};"avoidQuotes" option:
+/*eslint object-shorthand: ["error", "always", { "avoidQuotes": true }]*/
/*eslint-env es6*/
var foo = {
"bar-baz": function() {},
"qux": qux
};"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 }]
}"ignoreConstructors" is enabled:
+/*eslint object-shorthand: ["error", "always", { "ignoreConstructors": true }]*/
/*eslint-env es6*/
var foo = {
ConstructorFunction: function() {}
};When Not To Use It
+
+Further Reading
+
+
+
+Version
+
+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)
+
+
+var foo, bar, baz;
+var foo,
bar,
baz;Rule Details
+
+Options
+
+
+
+
+"always" enforces a newline around each variable declaration"initializations" enforces a newline around each variable initialization (default)"always":
+/*eslint one-var-declaration-per-line: ["error", "always"]*/
/*eslint-env es6*/
var a, b;
let a, b = 0;
const a = 0, b = 0;"always":
+/*eslint one-var-declaration-per-line: ["error", "always"]*/
/*eslint-env es6*/
var a,
b;
let a,
b = 0;"initializations":
+/*eslint one-var-declaration-per-line: ["error", "initializations"]*/
/*eslint-env es6*/
var a, b, c = 0;
let a,
b = 0, c;"initializations":
+/*eslint one-var-declaration-per-line: ["error", "initializations"]*/
/*eslint-env es6*/
var a, b;
let a,
b;
let a,
b = 0;Related Rules
+
+
+
+
+Version
+
+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)
+
+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.
+
+
+
+// one variable declaration per function
function foo() {
var bar, baz;
}
// multiple variable declarations per function
function foo() {
var bar;
var baz;
}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
+
+var) or block (for let and const) scope. As such, it will warn when it encounters an unexpected number of variable declarations.Options
+
+"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.
+
+
+varletconst
+
+
+uninitializedinitialized"always" or "never". This allows you to set behavior differently for each type of declaration, or whether variables are initialized during declaration.
+"one-var": [2, "always"]
+"one-var": ["error", "never"]"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
}]"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)
}]"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;
}
}
+/*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;
}
}"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;
}
+/*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;
}
}var, let, and const are handled, or alternatively how uninitialized and initialized variables are handled (which if used will override var, let, and const).
+/*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;
}
+/*eslint one-var: ["error", { uninitialized: "always", initialized: "never" }]*/
function foo() {
var a, b, c;
var foo = true;
var bar = false;
}{ 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
+
+
+
+
+onevar JSHint rule, but allows let and const to be configured separately."disallowMultipleVarDecl"Further Reading
+
+Version
+
+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)
+
+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 | yRule Details
+
+Options
+
+always and never. The default is always.“always”
+
+"operator-assignment": ["error", "always"]
+/*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")
+/*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"]
+/*eslint operator-assignment: ["error", "never"]*/
x = x + y;
x.y = x.y / a.b;
+/*eslint operator-assignment: ["error", "never"]*/
x *= y;
x ^= (y + z) / foo();When Not To Use It
+
+Version
+
+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)
+
+
+var fullHeight = borderTop +
innerHeight +
borderBottom;
+var fullHeight = borderTop
+ innerHeight
+ borderBottom;Rule Details
+
+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
+
+"after", "before" or "none" where the default is "after" and an object for more fine-grained configuration.
+"operator-linebreak": ["error", "before", { "overrides": { "?": "after" } }]? and : following that.“after”
+
+
+/*eslint operator-linebreak: ["error", "after"]*/
foo = 1
+
2;
foo = 1
+ 2;
foo
= 5;
if (someCondition
|| otherCondition) {
}
answer = everything
? 42
: foo;
+/*eslint operator-linebreak: ["error", "after"]*/
foo = 1 + 2;
foo = 1 +
2;
foo =
5;
if (someCondition ||
otherCondition) {
}
answer = everything ?
42 :
foo;“before”
+
+
+/*eslint operator-linebreak: ["error", "before"]*/
foo = 1 +
2;
foo =
5;
if (someCondition ||
otherCondition) {
}
answer = everything ?
42 :
foo;
+/*eslint operator-linebreak: ["error", "before"]*/
foo = 1 + 2;
foo = 1
+ 2;
foo
= 5;
if (someCondition
|| otherCondition) {
}
answer = everything
? 42
: foo;“none”
+
+
+/*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;
+/*eslint operator-linebreak: ["error", "none"]*/
foo = 1 + 2;
foo = 5;
if (someCondition || otherCondition) {
}
answer = everything ? 42 : foo;Fine-grained control
+
+overrides dictionary:
+"operator-linebreak": ["error", "before", { "overrides": { "?": "after", "+=": "none" } }]“ignore” override
+
+
+/*eslint operator-linebreak: ["error", "after", { "overrides": { "?": "ignore", ":": "ignore"} }]*/
answer = everything ?
42
: foo;
answer = everything
?
42
:
foo;When Not To Use It
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+
+if (a) {
b();
}Rule Details
+
+"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.{ "blocks": "always", "switches": "always", "classes": "always" } )."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();
}"always":
+/*eslint padded-blocks: ["error", "always"]*/
if (a) {
b();
}
if (a)
{
b();
}
if (a) {
// comment
b();
}"never":
+/*eslint padded-blocks: ["error", "never"]*/
if (a) {
b();
}
if (a)
{
b();
}
if (a) {
b();
}
if (a) {
b();
}"never":
+/*eslint padded-blocks: ["error", "never"]*/
if (a) {
b();
}
if (a)
{
b();
}{ "switches": "always" }:
+/*eslint padded-blocks: ["error", { "switches": "always" }]*/
switch (a) {
case 0: foo();
}{ "switches": "always" }:
+/*eslint padded-blocks: ["error", { "switches": "always" }]*/
switch (a) {
case 0: foo();
}
if (a) {
b();
}{ "switches": "never" }:
+/*eslint padded-blocks: ["error", { "switches": "never" }]*/
switch (a) {
case 0: foo();
}{ "switches": "never" }:
+/*eslint padded-blocks: ["error", { "switches": "never" }]*/
switch (a) {
case 0: foo();
}
if (a) {
b();
}{ "classes": "always" }:
+/*eslint padded-blocks: ["error", { "classes": "always" }]*/
class A {
constructor(){
}
}{ "classes": "always" }:
+/*eslint padded-blocks: ["error", { "classes": "always" }]*/
class A {
constructor(){
}
}{ "classes": "never" }:
+/*eslint padded-blocks: ["error", { "classes": "never" }]*/
class A {
constructor(){
}
}{ "classes": "never" }:
+/*eslint padded-blocks: ["error", { "classes": "never" }]*/
class A {
constructor(){
}
}When Not To Use It
+
+Version
+
+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)
+
+
+
+
+this keywords in arrow functions bind to the upper scope’s.Rule Details
+
+
+/*eslint prefer-arrow-callback: "error"*/
foo(function(a) { return a; });
foo(function() { return this.a; }.bind(this));
+/*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
+
+allowNamedFunctions
+
+boolean option and it is false by default. When set to true, the rule doesn’t warn on named functions used as callbacks.{ "allowNamedFunctions": true } option:
+/*eslint prefer-arrow-callback: ["error", { "allowNamedFunctions": true }]*/
foo(function bar() {});allowUnboundThis
+
+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.{ "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
+
+Version
+
+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)const declaration is better.const declaration tells readers, “this variable is never reassigned,” reducing cognitive load and improving maintainability.Rule Details
+
+let keyword, but never reassigned after the initial assignment.
+/*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);
}
+/*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
+
+
+
+
+"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.{"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;{"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;{"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.*/{"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
+
+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.{"ignoreReadBeforeAssign": true} option:
+/*eslint prefer-const: ["error", {"ignoreReadBeforeAssign": true}]*/
/*eslint-env es6*/
let timer;
function initialize() {
if (foo()) {
clearInterval(timer);
}
}
timer = setInterval(initialize, 100);{"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
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+
+
+
+Reflect.apply effectively deprecates Function.prototype.apply and Function.prototype.callReflect.deleteProperty effectively deprecates the delete keywordReflect.getOwnPropertyDescriptor effectively deprecates Object.getOwnPropertyDescriptorReflect.getPrototypeOf effectively deprecates Object.getPrototypeOfReflect.setPrototypeOf effectively deprecates Object.setPrototypeOfReflect.preventExtensions effectively deprecates Object.preventExtensionsRule Details
+
+Options
+
+Exceptions
+
+
+"prefer-reflect": [<enabled>, { exceptions: [<...exceptions>] }]exceptions option allows you to pass an array of methods names you’d like to continue to use in the old style.Function.prototype.apply then your config would look like prefer-reflect: [2, { exceptions: ["apply"] }].delete keyword, then your config would look like prefer-reflect: [2, { exceptions: ["delete"] }].prefer-reflect: [2, { exceptions: ["apply", "call", "defineProperty", "getOwnPropertyDescriptor", "getPrototypeOf", "setPrototypeOf", "isExtensible", "getOwnPropertyNames", "preventExtensions", "delete"] }]Reflect.apply (Function.prototype.apply/Function.prototype.call)
+
+
+/*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);
+/*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)
+
+
+/*eslint prefer-reflect: "error"*/
Object.defineProperty({}, 'foo', {value: 1})
+/*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)
+
+
+/*eslint prefer-reflect: "error"*/
Object.getOwnPropertyDescriptor({}, 'foo')
+/*eslint prefer-reflect: "error"*/
Reflect.getOwnPropertyDescriptor({}, 'foo')prefer-reflect: ["error", { exceptions: ["getOwnPropertyDescriptor"] }]
+/*eslint prefer-reflect: ["error", { exceptions: ["getOwnPropertyDescriptor"] }]*/
Object.getOwnPropertyDescriptor({}, 'foo')
Reflect.getOwnPropertyDescriptor({}, 'foo')Reflect.getPrototypeOf (Object.getPrototypeOf)
+
+
+/*eslint prefer-reflect: "error"*/
Object.getPrototypeOf({}, 'foo')
+/*eslint prefer-reflect: "error"*/
Reflect.getPrototypeOf({}, 'foo')
+/*eslint prefer-reflect: ["error", { exceptions: ["getPrototypeOf"] }]*/
Object.getPrototypeOf({}, 'foo')
Reflect.getPrototypeOf({}, 'foo')Reflect.setPrototypeOf (Object.setPrototypeOf)
+
+
+/*eslint prefer-reflect: "error"*/
Object.setPrototypeOf({}, Object.prototype)
+/*eslint prefer-reflect: "error"*/
Reflect.setPrototypeOf({}, Object.prototype)prefer-reflect: ["error", { exceptions: ["setPrototypeOf"] }]
+/*eslint prefer-reflect: ["error", { exceptions: ["setPrototypeOf"] }]*/
Object.setPrototypeOf({}, Object.prototype)
Reflect.setPrototypeOf({}, Object.prototype)Reflect.isExtensible (Object.isExtensible)
+
+
+/*eslint prefer-reflect: "error"*/
Object.isExtensible({})
+/*eslint prefer-reflect: "error"*/
Reflect.isExtensible({})
+/*eslint prefer-reflect: ["error", { exceptions: ["isExtensible"] }]*/
Object.isExtensible({})
Reflect.isExtensible({})Reflect.getOwnPropertyNames (Object.getOwnPropertyNames)
+
+
+/*eslint prefer-reflect: "error"*/
Object.getOwnPropertyNames({})
+/*eslint prefer-reflect: "error"*/
Reflect.getOwnPropertyNames({})
+/*eslint prefer-reflect: ["error", { exceptions: ["getOwnPropertyNames"] }]*/
Object.getOwnPropertyNames({})
Reflect.getOwnPropertyNames({})Reflect.preventExtensions (Object.preventExtensions)
+
+
+/*eslint prefer-reflect: "error"*/
Object.preventExtensions({})
+/*eslint prefer-reflect: "error"*/
Reflect.preventExtensions({})
+/*eslint prefer-reflect: ["error", { exceptions: ["preventExtensions"] }]*/
Object.preventExtensions({})
Reflect.preventExtensions({})Reflect.deleteProperty (The
+
+delete keyword)
+/*eslint prefer-reflect: "error"*/
delete foo.bar;
+/*eslint prefer-reflect: "error"*/
delete bar; // Does not reference an object, just a var
Reflect.deleteProperty(foo, 'bar');
+/*eslint prefer-reflect: ["error", { exceptions: ["delete"] }]*/
delete bar
delete foo.bar
Reflect.deleteProperty(foo, 'bar');When Not To Use It
+
+Related Rules
+
+
+
+Version
+
+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)arguments variable.arguments does not have methods of Array.prototype, so it’s a bit of an inconvenience.Rule Details
+
+arguments variables.
+function foo() {
console.log(arguments);
}
function foo(action) {
var args = [].slice.call(arguments, 1);
action.apply(null, args);
}
+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
+
+arguments variables, then it’s safe to disable this rule.Related Rules
+
+
+
+
+Version
+
+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)Function.prototype.apply() to call variadic functions.
+var args = [1, 2, 3, 4];
Math.max.apply(Math, args);
+/*eslint-env es6*/
var args = [1, 2, 3, 4];
Math.max(...args);Rule Details
+
+Function.prototype.apply() that can be replaced with the spread operator.
+/*eslint prefer-spread: "error"*/
foo.apply(undefined, args);
foo.apply(null, args);
obj.foo.apply(obj, args);
+/*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]);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
+
+Function.prototype.apply() callings, you can safely disable this rule.Related Rules
+
+
+
+
+Version
+
+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)
+
+
+var str = "Hello, " + name + "!";
+/*eslint-env es6*/
var str = `Hello, ${name}!`;Rule Details
+
++ operators with strings.
+/*eslint prefer-template: "error"*/
var str = "Hello, " + name + "!";
var str = "Time: " + (12 * 60 * 60 * 1000);
+/*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
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+
+var object1 = {
property: true
};
var object2 = {
"property": true
};
+
+
+if) as a property name. This restriction was removed in ECMAScript 5."one two".
+var object = {
1e2: 1,
100: 2
};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
+
+Options
+
+"always" (default), "as-needed", "consistent" and "consistent-as-needed". You can define these options in your configuration as:
+{
"quote-props": ["error", "as-needed"]
}“always”
+
+"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
};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
};
+var object = {
'foo': 'bar',
'baz': 42,
'qux-lorem': true
};"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
};
+/*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”
+
+"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
};
+/*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;
}
};"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 }]
}keywords is set to true, the following patterns become problems:
+/*eslint quote-props: ["error", "as-needed", { "keywords": true }]*/
var x = {
while: 1,
volatile: "foo"
};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 }]
}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
};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}]
}numbers is set to true, the following patterns become problems:
+/*eslint quote-props: ["error", "as-needed", { "numbers": true }]*/
var x = {
100: 1
}
+var x = {
"100": 1
}“consistent”
+
+"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
};
+/*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”
+
+"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
};
+/*eslint quote-props: ["error", "consistent-as-needed"]*/
var object1 = {
"foo": "bar",
"baz": 42,
"qux-lorem": true
};
var object2 = {
foo: 'bar',
baz: 42
};"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 }]
}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
+
+Further Reading
+
+
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+/*eslint-env es6*/
var double = "double";
var single = 'single';
var backtick = `backtick`; // ES6 onlyRule Details
+
+
+
+
+"double", "single" or "backtick" for double-quotes, single-quotes or backticks respectively. The default is "double".
+
+ "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."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"."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.
+[2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}]avoid-escape option is a deprecated syntax and you should use the object form instead.
+/*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";
+/*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
+
+Version
+
+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)
+
+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.parseInt() to eliminate unintended consequences. So instead of doing this:
+var num = parseInt("071"); // 57
+var num = parseInt("071", 10); // 71parseInt() 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.10 may be redundant. In such a case you might want to disallow using such a radix.Rule Details
+
+10 radix if targeting modern environments only.Options
+
+
+
+
+"always" enforces providing a radix (default)"as-needed" disallows providing the 10 radixalways
+
+"always" option:
+/*eslint radix: "error"*/
var num = parseInt("071");
var num = parseInt(someValue);
var num = parseInt("071", "abc");
var num = parseInt();"always" option:
+/*eslint radix: "error"*/
var num = parseInt("071", 10);
var num = parseInt("071", 8);
var num = parseFloat(someValue);as-needed
+
+"as-needed" option:
+/*eslint radix: ["error", "as-needed"]*/
var num = parseInt("071", 10);
var num = parseInt("071", "abc");
var num = parseInt();"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
+
+10 radix value you can turn this rule off.Further Reading
+
+
+
+Version
+
+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)
+
+
+/**
* 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;
}Rule Details
+
+
+
+
+FunctionDeclarationClassDeclarationMethodDefinitionOptions
+
+require object with its properties as
+
+
+FunctionDeclaration (default: true)ClassDeclaration (default: false)MethodDefinition (default: false)
+{
"require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": false,
"ClassDeclaration": false
}
}]
}
+/*eslint "require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true
}
}]*/
function foo() {
return 10;
}
class Test{
getDate(){}
}
+/*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
+
+Related Rules
+
+
+
+
+Version
+
+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)yield keyword.Rule Details
+
+
+/*eslint require-yield: "error"*/
/*eslint-env es6*/
function* foo() {
return 10;
}
+/*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
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+var a = "b" ;
var c = "d";var e = "f";Rule Details
+
+
+
+
+( 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.for(;;)).Options
+
+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.{"before": false, "after": true}.
+ "semi-spacing": ["error", {"before": false, "after": true}]
+
+{"before": false, "after": true}
+/*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++) {}
+/*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}
+/*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++) {}
+/*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
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+var name = "ESLint"
var website = "eslint.org";
+return
{
name: "ESLint"
};return statement that returns an object literal, however, the JavaScript engine will interpret this code as:
+return;
{
name: "ESLint";
}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.
+var globalCounter = { }
(function () {
var n = 0
globalCounter.increment = function () {
return ++n
}
})()\n character always ends a statement (just like a semicolon) unless one of the following is true:
+
+
+. or ,.)-- or ++ (in which case it will decrement/increment the next token.)for(), while(), do, if(), or else, and there is no {[, (, +, *, /, -, ,, ., or some other binary operator that can only be found between two tokens in a single expression.Rule Details
+
+Options
+
+"always" or "never". The default is "always". The second one is an object for more fine-grained configuration when the first option is "always".“always”
+
+
+semi: ["error", "always"]
+/*eslint semi: "error"*/
var name = "ESLint"
object.method = function() {
// ...
}
+/*eslint semi: "error"*/
var name = "ESLint";
object.method = function() {
// ...
};Fine-grained control
+
+
+semi: ["error", "always", { "omitLastInOneLineBlock": true}]
+/*eslint semi: ["error", "always", { "omitLastInOneLineBlock": true}] */
if (foo) {
bar()
}
if (foo) { bar(); }
+/*eslint semi: ["error", "always", { "omitLastInOneLineBlock": true}] */
if (foo) { bar() }
if (foo) { bar(); baz() }“never”
+
+
+semi: [2, "never"]
+/*eslint semi: ["error", "never"]*/
var name = "ESLint";
object.method = function() {
// ...
};
+/*eslint semi: ["error", "never"]*/
var name = "ESLint"
object.method = function() {
// ...
}"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
+
+Further Reading
+
+
+
+
+Related Rules
+
+
+
+Version
+
+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)
+
+
+// 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";
+// none - Import module without exported bindings.
import "my-module.js"Rule Details
+
+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.
+/*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';
+/*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'
+/*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
+
+
+
+
+ignoreCase (default: false)ignoreMemberSort (default: false)memberSyntaxSortOrder (default: ["none", "all", "multiple", "single"])
+{
"sort-imports": ["error", {
"ignoreCase": false,
"ignoreMemberSort": false,
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
}]
}
+
+ignoreCasetrue the rule ignores the case-sensitivity of the imports local name.
+/*eslint sort-imports: ["error", { "ignoreCase": true }]*/
import B from 'foo.js';
import a from 'bar.js';
+/*eslint sort-imports: ["error", { "ignoreCase": true }]*/
import a from 'foo.js';
import B from 'bar.js';
import c from 'baz.js';false.
+
+ignoreMemberSortmultiple member import declaration.
+/*eslint sort-imports: "error"*/
import {b, a, c} from 'foo.js'
+/*eslint sort-imports: ["error", { "ignoreMemberSort": true }]*/
import {b, a, c} from 'foo.js'false.
+
+memberSyntaxSortOrder
+
+
+none - import module without exported bindings.all - import all members provided by exported bindings.multiple - import multiple members.single - import single member.
+/*eslint sort-imports: "error"*/
import a from 'foo.js';
import * as b from 'bar.js';
+/*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';["none", "all", "multiple", "single"].When Not To Use It
+
+Version
+
+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)
+
+Rule Details
+
+
+/*eslint sort-vars: "error"*/
var b, a;
var a, B, c;
var a, A;
+/*eslint sort-vars: "error"*/
var a, b, c, d;
var _a = 10;
var _b = 20;
var A, a;
var B, a, c;
+/*eslint sort-vars: "error"*/
var c, d, a, b;
+/*eslint sort-vars: "error"*/
var c, d, a, e;Options
+
+
+"sort-vars": [<enabled>, { "ignoreCase": <boolean> }]
+
+ignoreCasetrue the rule ignores the case-sensitivity of the variables order.
+/*eslint sort-vars: ["error", { "ignoreCase": true }]*/
var a, A;
var a, B, c;When Not To Use It
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.Rule Details
+
+
+
+
+=> and a block. The spacing is handled by the arrow-spacing rule.keyword-spacing rule.Options
+
+"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.{ "functions": "never", "keywords": "always", classes: "always" } )"always".“always”
+
+
+/*eslint space-before-blocks: "error"*/
if (a){
b();
}
function a(){}
for (;;){
b();
}
try {} catch(a){}
class Foo{
constructor(){}
}
+/*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”
+
+
+/*eslint space-before-blocks: ["error", "never"]*/
if (a) {
b();
}
function a() {}
for (;;) {
b();
}
try {} catch(a) {}
+/*eslint space-before-blocks: ["error", "never"]*/
if (a){
b();
}
function a(){}
for (;;){
b();
}
try{} catch(a){}
class Foo{
constructor(){}
}{ "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() {}
}{ "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(){}
}{ "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(){}
}{ "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() {}
}{ "functions": "never", "keywords": "never", classes: "always" }:
+/*eslint space-before-blocks: ["error", { "functions": "never", "keywords": "never", classes: "always" }]*/
/*eslint-env es6*/
class Foo{
constructor(){}
}{ "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
+
+space-after-keywords rule set to "never".Related Rules
+
+
+
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.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 () {};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
+
+Options
+
+"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)."always".“always”
+
+
+/*eslint space-before-function-paren: "error"*/
/*eslint-env es6*/
function foo() {
// ...
}
var bar = function() {
// ...
};
var bar = function foo() {
// ...
};
class Foo {
constructor() {
// ...
}
}
var foo = {
bar() {
// ...
}
};
+/*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”
+
+
+/*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 () {
// ...
}
};
+/*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"}
+/*eslint space-before-function-paren: ["error", { "anonymous": "always", "named": "never" }]*/
/*eslint-env es6*/
function foo () {
// ...
}
var bar = function() {
// ...
};
class Foo {
constructor () {
// ...
}
}
var foo = {
bar () {
// ...
}
};
+/*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"}
+/*eslint space-before-function-paren: ["error", { "anonymous": "never", "named": "always" }]*/
/*eslint-env es6*/
function foo() {
// ...
}
var bar = function () {
// ...
};
class Foo {
constructor() {
// ...
}
}
var foo = {
bar() {
// ...
}
};
+/*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"}
+/*eslint space-before-function-paren: ["error", { "anonymous": "ignore", "named": "always" }]*/
/*eslint-env es6*/
function foo() {
// ...
}
class Foo {
constructor() {
// ...
}
}
var foo = {
bar() {
// ...
}
};
+/*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
+
+Related Rules
+
+
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+foo( 'bar' );
var x = ( 1 + 2 ) * 3;
foo('bar');
var x = (1 + 2) * 3;Rule Details
+
+( and to the left of ). In either case, () will still be allowed.Options
+
+
+
+
+"always" enforces a space inside of parentheses"never" enforces zero spaces inside of parentheses (default)
+"space-in-parens": ["error", "always"]“always”
+
+"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'; }());
+/*eslint space-in-parens: ["error", "always"]*/
foo();
foo( 'bar' );
var foo = ( 1 + 2 ) * 3;
( function () { return 'bar'; }() );“never”
+
+"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'; }() );
+/*eslint space-in-parens: ["error", "never"]*/
foo();
foo('bar');
var foo = (1 + 2) * 3;
(function () { return 'bar'; }());Exceptions
+
+"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.["{}", "[]", "()", "empty"]."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'} );
+/*eslint space-in-parens: ["error", "always", { "exceptions": ["{}"] }]*/
foo({bar: 'baz'});
foo( 1, {bar: 'baz'});"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'});
+/*eslint space-in-parens: ["error", "never", { "exceptions": ["{}"] }]*/
foo( {bar: 'baz'} );
foo(1, {bar: 'baz'} );"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 );
+/*eslint space-in-parens: ["error", "always", { "exceptions": ["[]"] }]*/
foo([bar, baz]);
foo([bar, baz], 1 );"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);
+/*eslint space-in-parens: ["error", "never", { "exceptions": ["[]"] }]*/
foo( [bar, baz] );
foo( [bar, baz], 1);"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 );
+/*eslint space-in-parens: ["error", "always", { "exceptions": ["()"] }]*/
foo(( 1 + 2 ));
foo(( 1 + 2 ), 1 );"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);
+/*eslint space-in-parens: ["error", "never", { "exceptions": ["()"] }]*/
foo( (1 + 2) );
foo( (1 + 2), 1);"empty" exception concerns empty parentheses, and works the same way as the other exceptions, inverting the first option."space-in-parens": ["error", "always", { "exceptions": ["empty"] }], the following patterns are considered problems:
+/*eslint space-in-parens: ["error", "always", { "exceptions": ["empty"] }]*/
foo( );
+/*eslint space-in-parens: ["error", "always", { "exceptions": ["empty"] }]*/
foo();"space-in-parens": ["error", "never", { "exceptions": ["empty"] }], the following patterns are considered problems:
+/*eslint space-in-parens: ["error", "never", { "exceptions": ["empty"] }]*/
foo();
+/*eslint space-in-parens: ["error", "never", { "exceptions": ["empty"] }]*/
foo( );"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] );
+/*eslint space-in-parens: ["error", "always", { "exceptions": ["{}", "[]"] }]*/
bar({bar:'baz'});
baz( 1, [1,2]);
foo({bar: 'baz'}, [1, 2]);When Not To Use It
+
+Related Rules
+
+
+
+
+Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.
+var sum = 1 + 2;
+var sum = i+++2;Rule Details
+
+Options
+
+
+"space-infix-ops": ["error", {"int32Hint": false}]
+
+int32Hintint32Hint 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
+/*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) { }
+/*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
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.Rule Details
+
+words unary operators and after/before nonwords unary operators.words operators:
+// new
var joe = new Person();
// delete
var obj = {
foo: 'bar'
};
delete obj.foo;
// typeof
typeof {} // object
// void
void 0 // undefinednonwords operators:
+if ([1,2,3].indexOf(1) !== -1) {};
foo = --foo;
bar = bar++;
baz = !foo;
qux = !!baz;Options
+
+
+
+
+words - applies to unary word operators such as: new, delete, typeof, void, yieldnonwords - 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
}
}]new operator and required before/after a ++ operator.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)
}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
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.// 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
+
+// or /*. It also provides several
+exceptions for various documentation styles.Options
+
+
+
+
+"always" or "never". The default is "always".
+
+ "always" then the // or /* must be followed by at least one whitespace."never" then there should be no whitespace following."exceptions" and "markers".
+
+
+ "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": ["-", "+"] }]
+
+
+
+ "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": ["/"] }]
+
+"spaced-comment": ["error", "always", {
"line": {
"markers": ["/"],
"exceptions": ["-", "+"]
},
"block": {
"markers": ["!"],
"exceptions": ["*"]
}
}]always
+
+
+/*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 */
+/* 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
+
+
+/*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 */
+/*eslint spaced-comment: ["error", "never"]*/
/*This is a comment with no whitespace at the beginning */
+/*eslint spaced-comment: ["error", "never"]*/
/**
* I am jsdoc
*/exceptions
+
+
+/* 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
/*-+-+-+-+-+-+-+*/
+/* 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
+
+
+/* eslint spaced-comment: ["error", "always", { "markers": ["/"] }] */
///This is a comment with a marker but without whitespace
+/* 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*/Related Rules
+
+
+
+Version
+
+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)
+
+
+"use strict";
+function foo() {
"use strict";
return;
}
var bar = function() {
"use strict";
return;
};Rule Details
+
+Options
+
+
+
+
+"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.safe
+
+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
+
+"never" option:
+/*eslint strict: ["error", "never"]*/
"use strict";
function foo() {
"use strict";
return;
}
var bar = function() {
"use strict";
return;
};
foo();
bar();"never" option:
+/*eslint strict: ["error", "never"]*/
function foo() {
return;
}
var bar = function() {
return;
};
foo();
bar();global
+
+"global" option:
+/*eslint strict: ["error", "global"]*/
"use strict";
"use strict";
function foo() {
"use strict";
return function() {
"use strict";
"use strict";
return;
};
}
foo();"global" option:
+/*eslint strict: ["error", "global"]*/
"use strict";
function foo() {
return function() {
return;
};
}
foo();function
+
+"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();"function" option:
+/*eslint strict: ["error", "function"]*/
function foo() {
"use strict";
return function() {
return;
};
}
(function() {
"use strict";
return;
}());
foo();earlier default (removed)
+
+"function" mode is most similar to the deprecated behavior.
+// "strict": "error"
function foo() {
return true;
}
+// "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
+
+arguments.callee are invalid in strict mode. A full list of strict mode differences is available on MDN.Version
+
+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)
+
+--fix option on the command line automatically fixes problems reported by this rule.${ 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
+
+Options
+
+
+{
"template-curly-spacing": ["error", "never"]
}"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."never":
+/*eslint template-curly-spacing: "error"*/
`hello, ${ people.name}!`;
`hello, ${people.name }!`;
`hello, ${ people.name }!`;"always":
+/*eslint template-curly-spacing: ["error", "always"]*/
`hello, ${ people.name}!`;
`hello, ${people.name }!`;
`hello, ${people.name}!`;"never":
+/*eslint template-curly-spacing: "error"*/
`hello, ${people.name}!`;
`hello, ${
people.name
}!`;"always":
+/*eslint template-curly-spacing: ["error", "always"]*/
`hello, ${ people.name }!`;
`hello, ${
people.name
}!`;When Not To Use It
+
+Version
+
+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)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.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 falseNaN !== NaN or NaN != NaN evaluate to trueNumber.isNaN() or global isNaN() functions to test whether a value is NaN.Rule Details
+
+
+/*eslint use-isnan: "error"*/
if (foo == NaN) {
// ...
}
if (foo != NaN) {
// ...
}
+/*eslint use-isnan: "error"*/
if (isNaN(foo)) {
// ...
}
if (!isNaN(foo)) {
// ...
}Further Reading
+
+
+
+Version
+
+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)
+
+
+/**
* 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;
}Rule Details
+
+
+
+
+@param or @returns is used without a type specified@param or @returns is used without a description@returns@param in the JSDoc comment@params are out of order with named arguments
+/*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) {
// ...
}
+/*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
+
+@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"
}
}]@return and recommend to replace it with @returns.requireReturn
+
+@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
+
+@param. You can choose not to require descriptions for parameters by setting requireParamDescription to false.
+"valid-jsdoc": ["error", {
"requireParamDescription": false
}]requireReturnDescription
+
+@return. You can choose not to require descriptions for @return by setting requireReturnDescription to false.
+"valid-jsdoc": ["error", {
"requireReturnDescription": false
}]matchDescription
+
+
+"valid-jsdoc": ["error", {
"matchDescription": "^[A-Z][A-Za-z0-9\\s]*[.]$"
}]requireReturnType
+
+type for @return tag for every documented function.
+"valid-jsdoc": ["error", {
"requireReturnType": false
}]preferType
+
+
+"valid-jsdoc": ["error", {
"preferType": {
"String": "string",
"object": "Object",
"test": "TesT"
}
}]"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};
}"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
+
+Further Reading
+
+
+
+
+Version
+
+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)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
+
+typeof expressions to valid string literals.
+/*eslint valid-typeof: "error"*/
typeof foo === "strnig"
typeof foo == "undefimed"
typeof bar != "nunber"
typeof bar !== "fucntion"
+/*eslint valid-typeof: "error"*/
typeof foo === "string"
typeof bar == "undefined"
typeof foo === baz
typeof bar === typeof quxWhen Not To Use It
+
+typeof operator on host objects.Version
+
+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)
+
+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
+
+
+/*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;
+/*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
+
+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)
+
+
+// function expression could be unwrapped
var x = function () { return { y: 1 };}();
// function declaration must be wrapped
function () { /* side effects */ }(); // SyntaxErrorRule Details
+
+Options
+
+
+
+
+"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
+
+"outside" option:
+/*eslint wrap-iife: ["error", "outside"]*/
var x = function () { return { y: 1 };}(); // unwrapped
var x = (function () { return { y: 1 };})(); // wrapped function expression"outside" option:
+/*eslint wrap-iife: ["error", "outside"]*/
var x = (function () { return { y: 1 };}()); // wrapped call expressioninside
+
+"inside" option:
+/*eslint wrap-iife: ["error", "inside"]*/
var x = function () { return { y: 1 };}(); // unwrapped
var x = (function () { return { y: 1 };}()); // wrapped call expression"inside" option:
+/*eslint wrap-iife: ["error", "inside"]*/
var x = (function () { return { y: 1 };})(); // wrapped function expressionany
+
+"any" option:
+/*eslint wrap-iife: ["error", "any"]*/
var x = function () { return { y: 1 };}(); // unwrapped"any" option:
+/*eslint wrap-iife: ["error", "any"]*/
var x = (function () { return { y: 1 };}()); // wrapped call expression
var x = (function () { return { y: 1 };})(); // wrapped function expressionVersion
+
+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)
+
+
+function a() {
return /foo/.test("bar");
}Rule Details
+
+
+/*eslint wrap-regex: "error"*/
function a() {
return /foo/.test("bar");
}
+/*eslint wrap-regex: "error"*/
function a() {
return (/foo/).test("bar");
}Version
+
+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)--fix option on the command line automatically fixes problems reported by this rule.Rule Details
+
+* in yield* expressions.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.{"before": false, "after": true}.
+"yield-star-spacing": ["error", {"before": true, "after": false}]
+
+
+{"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"]"after" this spacing will be enforced:
+/*eslint yield-star-spacing: ["error", "after"]*/
/*eslint-env es6*/
function* generator() {
yield* other();
}"before" this spacing will be enforced:
+/*eslint yield-star-spacing: ["error", "before"]*/
/*eslint-env es6*/
function *generator() {
yield *other();
}"both" this spacing will be enforced:
+/*eslint yield-star-spacing: ["error", "both"]*/
/*eslint-env es6*/
function * generator() {
yield * other();
}"neither" this spacing will be enforced:
+/*eslint yield-star-spacing: ["error", "neither"]*/
/*eslint-env es6*/
function*generator() {
yield*other();
}es6 environment or
+set ecmaVersion to 6 in parserOptions.When Not To Use It
+
+Further Reading
+
+
+
+Version
+
+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)
+
+
+if ("red" === color) {
// ...
}
+if (color === "red") {
// ...
}= 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.= 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
+
+Options
+
+
+
+
+"never", then comparisons must never be Yoda conditions."always", then the literal value must always come first."never" option can have exception options in an object literal:
+
+
+"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."onlyEquality" property is true, the rule reports yoda conditions only for the equality operators == and ===. The default value is false.onlyEquality option allows a superset of the exceptions which exceptRange allows, thus both options are not useful together.never
+
+"never" option:
+/*eslint yoda: "error"*/
if ("red" === color) {
// ...
}
if (true == flag) {
// ...
}
if (5 > count) {
// ...
}
if (-1 < str.indexOf(substr)) {
// ...
}
if (0 <= x && x < 1) {
// ...
}"never" option:
+/*eslint yoda: "error"*/
if (5 & value) {
// ...
}
if (value === "red") {
// ...
}exceptRange
+
+"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
+
+"never", { "onlyEquality": true } options:
+/*eslint yoda: ["error", "never", { "onlyEquality": true }]*/
if (x < -1 || 9 < x) {
}
if (x !== 'foo' && 'bar' != x) {
}always
+
+"always" option:
+/*eslint yoda: ["error", "always"]*/
if (color == "blue") {
// ...
}"always" option:
+/*eslint yoda: ["error", "always"]*/
if ("blue" == value) {
// ...
}
if (-1 < str.indexOf(substr)) {
// ...
}Further Reading
+
+
+
+Version
+
+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?
strict option is set to true. Here's an
example of a function that does not run in strict mode:/*jshint strict: true */function example() { return true;}/*jshint strict: true */function example() { return true;}Why do I get this error?
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:
/*jshint strict: true */function example() { "use strict"; return true;}/*jshint strict: true */function example() { "use strict"; return true;}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.
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:
/*jshint validthis: true */function example() { "use strict"; this.x = 10;}var obj = {};example.call(obj);/*jshint validthis: true */function example() { "use strict"; this.x = 10;}var obj = {};example.call(obj);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 @@
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:
function example() { /*jshint validthis: true */ "use strict"; this.x = 10;}var obj = {};example.call(obj);function example() { /*jshint validthis: true */ "use strict"; this.x = 10;}var obj = {};example.call(obj);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 @@ -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 @@with statement in code that is running in strict mode.
Here's an example:
-function example() { "use strict"; var a = { b: 10 }; with (a) { b = 20; }}function example() { "use strict"; var a = { b: 10 }; with (a) { b = 20; }}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 @@
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:
function example() { "use strict"; var a = { b: 10 }; a.b = 20;}function example() { "use strict"; var a = { b: 10 }; a.b = 20;}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:
function example() { var a = { b: 10 }; with (a) { b = 20; }}function example() { var a = { b: 10 }; with (a) { b = 20; }}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 @@ -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:
/*jshint esnext: true */const CONST_1 = 10;const CONST_1 = 20;/*jshint esnext: true */const CONST_1 = 10;const CONST_1 = 20;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 @@
You can fix this issue by ensuring each constant declaration uses a unique identifier:
-/*jshint esnext: true */const CONST_1 = 10;const CONST_2 = 20;/*jshint esnext: true */const CONST_1 = 10;const CONST_2 = 20;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 @@
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 @@ -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:
/*jshint esnext: true */const MY_CONST = 10;MY_CONST = 20;/*jshint esnext: true */const MY_CONST = 10;MY_CONST = 20;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 @@
You can fix this issue by removing any assignments to constants declared with
the const keyword:
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:
/*jshint esnext: true */var MY_CONST = 10; // A fake constant/*jshint esnext: true */var MY_CONST = 10; // A fake constantIn 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 @@ -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 @@"=1" to
the variable x:
-var regex = /=1/;var regex = /=1/;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 @@
var x = 10;x /= 5; // Shorthand division-assignment operatorvar x = 10;x /= 5; // Shorthand division-assignment operatorThis 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:
Alternatively, you can use the RegExp constructor, which removes the need for
the ambiguous delimiting / characters:
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.
The "Unclosed regular expression" error is thrown when JSLint or JSHint encounters a regular expression literal with no closing / character. Here's an example:
var regex = /^unclosed$;var regex = /^unclosed$;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 @@
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:
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 @@ -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:
/* This is a comment * but I forgot to * close it./* This is a comment * but I forgot to * close it.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 @@
/* This is a comment * but I remembered to * close it. *//* This is a comment * but I remembered to * close it. */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 @@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:
-var myString = "my string, myNumber = 10;var myString = "my string, myNumber = 10;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:
-var myString = "my string\", myNumber = 10;var myString = "my string\", myNumber = 10;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):
-var myString = "my multiline \ stringvar myString = "my multiline \ stringThis 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 @@
' SingleStringCharactersopt '
To fix the error, simply close any unclosed strings:
- +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:
- +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 @@ -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 @@if statement with an assignment expression where
you would normally expect a conditional:
-function example() { "use strict"; example() = 1;}function example() { "use strict"; example() = 1;}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:
function example() { "use strict"; arguments.x = 1;}function example() { "use strict"; arguments.x = 1;}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 @@
=== instead of the
assignment operator =:
-function example() { "use strict"; if (example() === 1) { // Comparison return true; }}function example() { "use strict"; if (example() === 1) { // Comparison return true; }}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:
function example() { "use strict"; // arguments.x = 1; var x = 1; return x;}function example() { "use strict"; // arguments.x = 1; var x = 1; return x;}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 @@ -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 @@x with a getter and
setter. The getter is intended to always return half of the set value:
-var x = { actual: 10, get x () { "use strict"; return this.actual / 2; }, set x (value) { "use strict"; this.actual = value; }};var x = { actual: 10, get x () { "use strict"; return this.actual / 2; }, set x (value) { "use strict"; this.actual = value; }};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 @@
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:
/*jslint es5: true *//*jshint es5: true */var x = { actual: 10, get x () { "use strict"; return this.actual / 2; }, set x (value) { "use strict"; this.actual = value; }};/*jslint es5: true *//*jshint es5: true */var x = { actual: 10, get x () { "use strict"; return this.actual / 2; }, set x (value) { "use strict"; this.actual = value; }};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:
function example() { "use strict"; return true;}();function example() { "use strict"; return true;}();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 @@
(function example() { "use strict"; return true;}());(function example() { "use strict"; return true;}());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 @@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:
/*jshint passfail: true */var/*jshint passfail: true */varThis 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 @@
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 @@ + +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;
+
+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 @@ -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):
/*jshint es5: true */var x = { default: 10};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 @@
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:
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 @@ -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:
var demo = { hasOwnProperty: 1};var demo = { hasOwnProperty: 1};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 @@
/*global doSomething */var me = { name: "James", age: 23};for (var prop in me) { if (me.hasOwnProperty(prop)) { doSomething(prop); }}/*global doSomething */var me = { name: "James", age: 23};for (var prop in me) { if (me.hasOwnProperty(prop)) { doSomething(prop); }}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 @@
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:
-/*global doSomething */var me = { name: "James", age: 23, hasOwnProperty: 1 // This would cause the previous example to fail};for (var prop in me) { if (Object.hasOwnProperty.call(me, prop)) { // Use the real hasOwnProperty doSomething(prop); }}/*global doSomething */var me = { name: "James", age: 23, hasOwnProperty: 1 // This would cause the previous example to fail};for (var prop in me) { if (Object.hasOwnProperty.call(me, prop)) { // Use the real hasOwnProperty doSomething(prop); }}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.
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:
var a = 1;try { b();} catch (a) {}var a = 1;try { b();} catch (a) {}JSLint will also raise an error in this situation but it uses the more generic "'{a}' is already defined" message.
To resolve this issue simply ensure your exception parameter has an identifier unique to its scope:
- +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.
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.
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:
function test() { "use strict"; var a = 1, a = 2; return a;}function test() { "use strict"; var a = 1, a = 2; return a;}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 @@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:
- +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.
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:
-var a = 5.4.toString();var a = 5.4.toString();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 @@. 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:
- +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.
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 @@-
operator. In the following example we attempt to compute the addition of a
numeric literal and the numeric value of a variable:
-
+
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 @@
To resolve this issue the easiest fix is to wrap the unary expression in
parentheses to disambiguate the - characters:
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.
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 @@+
operator. In the following example we attempt to compute the addition of a
numeric literal and the numeric value of a variable:
-
+
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 @@
++ 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:
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.
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 @@. 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:
-var x = .5;var x = .5;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 @@
0 to your
number:
-
+
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.
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 @@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:
-var x = new Array(), y = new Array(1, 2, 3), z = new Array("not a number");var x = new Array(), y = new Array(1, 2, 3), z = new Array("not a number");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 @@
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 @@
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:
Array = 50;var x = new Array(); //TypeError: Array is not a functionArray = 50;var x = new Array(); //TypeError: Array is not a functionHowever 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:
var x = new Array(10);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.
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 @@Object constructor preceded by the new operator. Here's an
example:
-var x = new Object();var x = new Object();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:
- +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 @@
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:
Object = 50;var x = new Object(); //TypeError: Array is not a functionObject = 50;var x = new Object(); //TypeError: Array is not a functionAlways 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 @@Object.create(null)Object.prototype. If that's the case you
can create an object that doesn't have a prototype chain:
-
+
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.
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:
var x = parseInt("myString", 10);if (x === NaN) { x = 10;}var x = parseInt("myString", 10);if (x === NaN) { x = 10;}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 @@
true if its argument coerces
to NaN, and false if it does not:
-var x = parseInt("myString", 10);if (isNaN(x)) { x = 10;}var x = parseInt("myString", 10);if (isNaN(x)) { x = 10;}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.
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 @@String constructor function:
-String = function () { "use strict"; return "Overwritten";};String = function () { "use strict"; return "Overwritten";};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:
try { // Some code that might throw an exception throw new Error();} catch (e) { e = 10;}try { // Some code that might throw an exception throw new Error();} catch (e) { e = 10;}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 @@
/*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 @@
-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:
try { // Some code that might throw an exception throw new Error();} catch (e) { e = 10;}try { // Some code that might throw an exception throw new Error();} catch (e) { e = 10;}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 @@
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:
var default = 10;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:
var x = { default: "a default value"};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 @@
es5 directive (or updating to a more recent version of
JSLint):
-/*jshint es5: true */var x = { default: "a default value"};/*jshint es5: true */var x = { default: "a default value"};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:
- +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.
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 @@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:
-function () { "use strict"; return "something";}function () { "use strict"; return "something";}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 @@
function example() { "use strict"; return "something";}function example() { "use strict"; return "something";}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):
-var example = function () { "use strict"; return "something";}var example = function () { "use strict"; return "something";}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.
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:
var x = 1;x === 1; // Evaluates to 'true'var x = 1;x === 1; // Evaluates to 'true'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:
-var x = 1;x = 2; // Assignment instead of unused expressionvar x = 1;x = 2; // Assignment instead of unused expressionIn 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.
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:
/*jshint nonew: true */new Date();/*jshint nonew: true */new Date();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 @@
/*jshint nonew: true */var counter = 0;function Person(name) { "use strict"; this.name = name; counter += 1;}var me = new Person("James");new Person(); // Increments 'counter' as a side-effect/*jshint nonew: true */var counter = 0;function Person(name) { "use strict"; this.name = name; counter += 1;}var me = new Person("James");new Person(); // Increments 'counter' as a side-effectIn 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:
/*jshint nonew: true */var counter = 0;function Person(name) { "use strict"; this.name = name; counter += 1;}var me = new Person("James");counter += 1; // Don't use the constructor/*jshint nonew: true */var counter = 0;function Person(name) { "use strict"; this.name = name; counter += 1;}var me = new Person("James");counter += 1; // Don't use the constructorIn 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.
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:
function example(a) { "use strict"; if (a) { return true; };};function example(a) { "use strict"; if (a) { return true; };};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 @@
This time there is no semicolon which means its safe to remove the extra semicolons from the previous example. This will resolve the issue:
-function example(a) { "use strict"; if (a) { return true; }}function example(a) { "use strict"; if (a) { return true; }}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.
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:
function factory() { "use strict"; return function () { "use strict"; return true; };}function factory() { "use strict"; return function () { "use strict"; return true; };}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 @@
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:
function factory() { "use strict"; return function () { return true; };}function factory() { "use strict"; return function () { return true; };}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.
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.
+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:
/*property y, z */var obj = { x: 1};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.
+ +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.
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 @@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:
-var x = 0; // Variable with identifier 'x'function test(i) { "use strict";x: // Label with identifier 'x' while (i) { i -= 1; x = i; // Reference to variable 'x' if (i === 5) { break x; // Reference to label 'x' } }}test(10);var x = 0; // Variable with identifier 'x'function test(i) { "use strict";x: // Label with identifier 'x' while (i) { i -= 1; x = i; // Reference to variable 'x' if (i === 5) { break x; // Reference to label 'x' } }}test(10);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:
-var x = 0;x:for (; x < 10; x++);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 @@
You can prevent it by simply using different identifiers for labels and variables:
-var x = 0;y:for (; x < 10; x++);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.
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 @@x in the body of an if statement and then attempt to
return it from the enclosing function:
-function test(a) { "use strict"; if (a) { var x = 1; } return x;}function test(a) { "use strict"; if (a) { var x = 1; } return x;}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 @@
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:
-function test(a) { "use strict"; var x; if (a) { x = 1; } return x;}function test(a) { "use strict"; var x; if (a) { x = 1; } return x;}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.
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 @@multistr option is not set to true. In the
following example we attempt to assign a multiline string to the variable
myString:
-var myString = "Line 1 \ Line 2";var myString = "Line 1 \ Line 2";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 @@
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:
/*jshint multistr: true */var myString = "Line 1 \ Line 2";/*jshint multistr: true */var myString = "Line 1 \ Line 2";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:
/*jslint es5: true */var myString = "Line 1 \ Line 2";/*jslint es5: true */var myString = "Line 1 \ Line 2";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.
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 @@. 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:
-var x = 5.;var x = 5.;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 @@
.:
-
+
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.
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 @@delete operator followed by a single identifier. In the
following example we declare a variable x and then attempt to delete it:
-var x = 10;delete x;var x = 10;delete x;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:
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:
/*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 @@
-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:
var str = new String("hello"), num = new Number(10), bool = new Boolean(false), math = new Math(), json = new JSON({ myProp: 10 });var str = new String("hello"), num = new Number(10), bool = new Boolean(false), math = new Math(), json = new JSON({ myProp: 10 });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:
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:
var str = String(10), // "10" num = Number("123"), // 123 bool = Boolean(""); // falsevar str = String(10), // "10" num = Number("123"), // 123 bool = Boolean(""); // falseThe 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:
var json = JSON.stringify({ myProp: 10 });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.
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 @@Function constructor preceded by the new
operator. Here's a simple example which defines a function to add two numbers:
-var add = new Function("a", "b", "return a + b");var add = new Function("a", "b", "return a + b");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 @@
In simple cases like that of our example above, you can fix the issue by using a function declaration or function expression:
-var add = function (a, b) { "use strict"; return a + b;};var add = function (a, b) { "use strict"; return a + b;};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:
/*jslint evil: true */var add = new Function("a", "b", "return a + b");/*jslint evil: true */var add = new Function("a", "b", "return a + b");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.
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:
/*jshint newcap: true */function myConstructor() { "use strict"; this.property = "Something";}var myInstance = new myConstructor();/*jshint newcap: true */function myConstructor() { "use strict"; this.property = "Something";}var myInstance = new myConstructor();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":
-/*jshint newcap: true */function MyClass() { "use strict"; this.property = "Something";}var myInstance = new MyClass();/*jshint newcap: true */function MyClass() { "use strict"; this.property = "Something";}var myInstance = new MyClass();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 @@
/*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 @@
-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:
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 @@
new to an object literal:var num = new {}();var num = new {}();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.
/*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 @@
-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 @@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:
-
+
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 @@
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.
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 @@
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:
-var numbers = [1, 2, 3, 4, 5];numbers.map(function (n) { return n < 1 ? 1 : n * arguments.callee(n - 1);});// Returns [1, 2, 6, 24, 120]var numbers = [1, 2, 3, 4, 5];numbers.map(function (n) { return n < 1 ? 1 : n * arguments.callee(n - 1);});// Returns [1, 2, 6, 24, 120]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 @@
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:
-var numbers = [1, 2, 3, 4, 5];numbers.map(function factorial(n) { "use strict"; return n < 1 ? 1 : n * factorial(n - 1);});// Returns [1, 2, 6, 24, 120]var numbers = [1, 2, 3, 4, 5];numbers.map(function factorial(n) { "use strict"; return n < 1 ? 1 : n * factorial(n - 1);});// Returns [1, 2, 6, 24, 120]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 @@
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.
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 @@var myString = "x", myObject = { x: 10 }, value = eval("myObject." + myString);var myString = "x", myObject = { x: 10 }, value = eval("myObject." + myString);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:
var myString = "x", myObject = { x: 10 }, value = myObject[myString];var myString = "x", myObject = { x: 10 }, value = myObject[myString];The However, in the situation where you absolutely have to use 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 In ESLint the rule that generates this warning is named 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
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 @@ 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?
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:/*jslint evil: true */var myString = "x", myObject = { x: 10 }, value = eval("myObject." + myString);/*jslint evil: true */var myString = "x", myObject = { x: 10 }, value = eval("myObject." + myString);/*jshint
-W061 */ directive.no-eval. You can
disable it by setting it to 0, or enable it by setting it to 1.When do I get this error?
+
+ When do I get this error?
immed option is set to true. In the following example we assign the return
value of the anonymous function the variable x:/*jshint immed: true */var x = function () { "use strict"; return { y: 1 };}();/*jshint immed: true */var x = function () { "use strict"; return { y: 1 };}();Why do I get this error?
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:
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 @@
/*jshint immed: true */var x = (function () { "use strict"; return { y: 1 };}());/*jshint immed: true */var x = (function () { "use strict"; return { y: 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 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.
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:
var x = Math(), y = JSON();var x = Math(), y = JSON();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 @@
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.
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:
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 @@
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:
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.
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 @@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:
-/*jslint browser: true */setTimeout("alert('Hello!');", 1000);/*jslint browser: true */setTimeout("alert('Hello!');", 1000);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 @@
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:
/*jslint browser: true, devel: true */setTimeout(function () { "use strict"; alert('Hello!');}, 1000);/*jslint browser: true, devel: true */setTimeout(function () { "use strict"; alert('Hello!');}, 1000);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.
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 @@immed option is set to true. In the following example we assign
a function expression to a variable x:
-/*jshint immed: true */var x = (function () { "use strict"; return 10;});/*jshint immed: true */var x = (function () { "use strict"; return 10;});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:
-var x = (function () { "use strict"; return 10;}());var x = (function () { "use strict"; return 10;}());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 @@
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.
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:
var x = { prop: 10 }, y = x["prop"];var x = { prop: 10 }, y = x["prop"];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 @@
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:
var x = { "class": 10 }, y = x["class"];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.
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 @@es3 option is set to true. Here's
an example:
-/*jshint es3: true */var x = { prop1: 10, prop2: 20,};/*jshint es3: true */var x = { prop1: 10, prop2: 20,};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 @@
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:
- +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 @@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 @@
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.
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 @@maxparams option. In ESLint it's max-params. Here's an
example in which we attempt to declare a function that takes 3 arguments:
-/*jshint maxparams: 2 *//*eslint max-params: [1, 2] */function Person(name, age, gender) { "use strict"; this.name = name; this.age = age; this.gender = gender;}/*jshint maxparams: 2 *//*eslint max-params: [1, 2] */function Person(name, age, gender) { "use strict"; this.name = name; this.age = age; this.gender = gender;}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 @@
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:
-/*jshint maxparams: 2 *//*eslint max-params: [1, 2] */function Person(options) { "use strict"; this.name = options.name; this.age = options.age; this.gender = options.gender;}/*jshint maxparams: 2 *//*eslint max-params: [1, 2] */function Person(options) { "use strict"; this.name = options.name; this.age = options.age; this.gender = options.gender;}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.
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 @@y to a variable x:
-
+
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 @@
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.
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 @@var x = { actual: 10, get x (value) { "use strict"; return this.actual / 2; }, set x (value) { "use strict"; this.actual = value; }};var x = { actual: 10, get x (value) { "use strict"; return this.actual / 2; }, set x (value) { "use strict"; this.actual = value; }};| 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'. |
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 @@
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:
-var x = { actual: 10, get x () { "use strict"; return this.actual / 2; }, set x (value) { "use strict"; this.actual = value; }};var x = { actual: 10, get x () { "use strict"; return this.actual / 2; }, set x (value) { "use strict"; this.actual = value; }};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.
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:
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.
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.
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:
var x = undefined;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 @@
You can fix the error by simply removing the assignment expression from the variable statement. The variable will still have the same value:
- +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):
var x = void 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 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.
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.
x and y, with two
separate var statements:
-/*jshint onevar: true */function example() { "use strict"; var x = 10; var y = 20;}/*jshint onevar: true */function example() { "use strict"; var x = 10; var y = 20;}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 @@
/*jshint onevar: true */function example() { "use strict"; var x = 10; if (x === 10) { var y = 20; } return y; // Able to return y because of function scoping}/*jshint onevar: true */function example() { "use strict"; var x = 10; if (x === 10) { var y = 20; } return y; // Able to return y because of function scoping}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 @@
y out of the block and
combining it with the declaration of x:
-/*jshint onevar: true */function example() { "use strict"; var x = 10, y; if (x === 10) { y = 20; } return y; // Able to return y because of function scoping}/*jshint onevar: true */function example() { "use strict"; var x = 10, y; if (x === 10) { y = 20; } return y; // Able to return y because of function scoping}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 @@
/*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 @@
-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:
var x = true;if (x) { function example() { "use strict"; return true; }}var x = true;if (x) { function example() { "use strict"; return true; }}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 @@
function example() { "use strict"; return true;}var x = true;if (x) {}function example() { "use strict"; return true;}var x = true;if (x) {}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 @@
var x = true, example;if (x) { example = function () { "use strict"; return true; };}var x = true, example;if (x) { example = function () { "use strict"; return true; };}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 @@
/*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 @@
-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:
/*jslint browser: true, plusplus: true */var elems = document.getElementsByClassName("myClass"), i;for (i = 0; i < elems.length; i++) { elems[i].addEventListener("click", function () { "use strict"; this.innerHTML = i; });}/*jslint browser: true, plusplus: true */var elems = document.getElementsByClassName("myClass"), i;for (i = 0; i < elems.length; i++) { elems[i].addEventListener("click", function () { "use strict"; this.innerHTML = i; });}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 @@
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:
-/*jslint browser: true, plusplus: true */var elems = document.getElementsByClassName("myClass"), i;for (i = 0; i < elems.length; i++) { (function (iCopy) { "use strict"; elems[i].addEventListener("click", function () { this.innerHTML = iCopy; }); }(i));}/*jslint browser: true, plusplus: true */var elems = document.getElementsByClassName("myClass"), i;for (i = 0; i < elems.length; i++) { (function (iCopy) { "use strict"; elems[i].addEventListener("click", function () { this.innerHTML = iCopy; }); }(i));}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 @@
/*jslint browser: true, plusplus: true */var elems = document.getElementsByClassName("myClass"), i;function makeClickHandler(i) { "use strict"; return function () { this.innerHTML = i; };}for (i = 0; i < elems.length; i++) { elems[i].addEventListener("click", makeClickHandler(i));}/*jslint browser: true, plusplus: true */var elems = document.getElementsByClassName("myClass"), i;function makeClickHandler(i) { "use strict"; return function () { this.innerHTML = i; };}for (i = 0; i < elems.length; i++) { elems[i].addEventListener("click", makeClickHandler(i));}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.
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 @@while statement initializer. In the following example we have an if
statement with an assignment expression where you would normally expect a
conditional:
-var x, y;if (x = 0) { y = 1;}var x, y;if (x = 0) { y = 1;}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:
- +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:
-function setHeight(someNode) { "use strict"; do { someNode.height = '100px'; } while (someNode = someNode.parentNode);}function setHeight(someNode) { "use strict"; do { someNode.height = '100px'; } while (someNode = someNode.parentNode);}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:
-function setHeight(someNode) { "use strict"; do { someNode.height = '100px'; } while ((someNode = someNode.parentNode) !== null);}function setHeight(someNode) { "use strict"; do { someNode.height = '100px'; } while ((someNode = someNode.parentNode) !== null);}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.
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 @@with statement in code that is not running in strict mode.
Here's an example:
-function example() { var a = { b: 10 }, c = 20; with (a) { b = 30; c = 40; }}function example() { var a = { b: 10 }, c = 20; with (a) { b = 30; c = 40; }}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 @@
function example() { var a = { b: 10 }; a.b = 30; a.c = 40;}function example() { var a = { b: 10 }; a.b = 30; a.c = 40;}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.
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 @@debugger statement. The following
example is completely useless but is the minimum program that will generate 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 @@
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.
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 @@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:
-function test() { "use strict"; var y = {}; for ("a" in y) { // ... }}function test() { "use strict"; var y = {}; for ("a" in y) { // ... }}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:
function test() { "use strict"; var y = {}; for (x in y) { // ... }}function test() { "use strict"; var y = {}; for (x in y) { // ... }}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 @@
for-in statement:
-function test() { "use strict"; var y = {}, x; for (x in y) { // ... }}function test() { "use strict"; var y = {}, x; for (x in y) { // ... }}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 @@ -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:
/*jshint forin: true *//*eslint guard-for-in: 1 *//*global doSomething */var me = { name: "James", age: 23 }, prop;for (prop in me) { doSomething(prop);}/*jshint forin: true *//*eslint guard-for-in: 1 *//*global doSomething */var me = { name: "James", age: 23 }, prop;for (prop in me) { doSomething(prop);}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 @@
Object.prototype:
-Object.prototype.random = function () { "use strict"; return Math.random();};Object.prototype.random = function () { "use strict"; return Math.random();};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 @@
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:
/*jshint forin: true *//*eslint guard-for-in: 1 *//*global doSomething */var me = { name: "James", age: 23 }, prop;for (prop in me) { if (me.hasOwnProperty(prop)) { doSomething(prop); }}/*jshint forin: true *//*eslint guard-for-in: 1 *//*global doSomething */var me = { name: "James", age: 23 }, prop;for (prop in me) { if (me.hasOwnProperty(prop)) { doSomething(prop); }}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.
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 @@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:
-function demo() { "use strict"; var i; for (i = 0; i < 10; i += 1) { if (i === 5) { break example; } }}function demo() { "use strict"; var i; for (i = 0; i < 10; i += 1) { if (i === 5) { break example; } }}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 @@
break statement a syntax error will be thrown.
This can be avoided by removing the identifier from the break statement:
-function demo() { "use strict"; var i; for (i = 0; i < 10; i += 1) { if (i === 5) { break; } }}function demo() { "use strict"; var i; for (i = 0; i < 10; i += 1) { if (i === 5) { break; } }}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):
function demo() { "use strict"; var i;example: for (i = 0; i < 10; i += 1) { if (i === 5) { break example; } }}function demo() { "use strict"; var i;example: for (i = 0; i < 10; i += 1) { if (i === 5) { break example; } }}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.
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:
var result;function multiply(a, b) { "use strict"; return result = a * b;}var result;function multiply(a, b) { "use strict"; return result = a * b;}Since May 2013 JSLint has used the more generic "Unexpected assignment expression" warning in the same situation.
var result;function multiply(a, b) { "use strict"; result = a * b; return result;}var result;function multiply(a, b) { "use strict"; result = a * b; return result;}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 =:
var result;function multiply(a, b) { "use strict"; return result === a * b;}var result;function multiply(a, b) { "use strict"; return result === a * b;}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.
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:
-"use strict";function example() { return true;}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 @@
"use strict";function example() { return true;}function another(a) { return 010; // Octal literal, illegal in strict mode}"use strict";function example() { return true;}function another(a) { return 010; // Octal literal, illegal in strict mode}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:
- +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 @@
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.
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 @@unused option is set to true. In
the following example there are various unused identifiers:
-/*jshint unused: true */function demo(a, b) { "use strict"; var c;}/*jshint unused: true */function demo(a, b) { "use strict"; var c;}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 @@
exported directive to signify those variables:
-/*jshint unused: true *//*exported demo */function demo(a, b) { "use strict"; var c;}/*jshint unused: true *//*exported demo */function demo(a, b) { "use strict"; var c;}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:
-/*jshint unused: true, node: true *//*jslint node: true */var fs = require("fs");fs.readdir("dir", function (err, files) { "use strict"; console.log(files); // Ignoring any error in 'err'});/*jshint unused: true, node: true *//*jslint node: true */var fs = require("fs");fs.readdir("dir", function (err, files) { "use strict"; console.log(files); // Ignoring any error in '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:
/*jshint unused: true, node: true *//*jslint unparam: true, node: true */var fs = require("fs");fs.readdir("dir", function (err, files) { "use strict"; console.log(files); // Ignoring any error in 'err'});/*jshint unused: true, node: true *//*jslint unparam: true, node: true */var fs = require("fs");fs.readdir("dir", function (err, files) { "use strict"; console.log(files); // Ignoring any error in '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:
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.
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:
/*jshint nomen: true */var _x = 10, y = { z_: 20 };function _test() { "use strict"; return true;}/*jshint nomen: true */var _x = 10, y = { z_: 20 };function _test() { "use strict"; return true;}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 @@
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:
/*jslint nomen: true */var _x = 10, y = { z_: 20 };function _test() { "use strict"; return true;}/*jslint nomen: true */var _x = 10, y = { z_: 20 };function _test() { "use strict"; return true;}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):
-/*jshint nomen: true */var x = 10, y = { z: 20 };function test_with_underscores() { "use strict"; return true;}/*jshint nomen: true */var x = 10, y = { z: 20 };function test_with_underscores() { "use strict"; return true;}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.
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:
/*jshint quotmark: double */var x = 'My String';/*jshint quotmark: double */var x = 'My String';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 @@
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:
-
+
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.
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:
/*jshint quotmark: true */var x = "My String", y = 'Another string';/*jshint quotmark: true */var x = "My String", y = 'Another string';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 @@
quotmark option to
either double or single to enforce your preference:
-/*jshint quotmark: double */var x = "My String", y = "Another string";/*jshint quotmark: double */var x = "My String", y = "Another string";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.
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:
+var myString = "my string, myNumber = 10;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:
+var myString = "my string\", myNumber = 10;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):
+var myString = "my multiline \ stringThis 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:
+ +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:
+ +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 @@ -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 @@x:
-function demo() { "use strict"; return "Copyright \251";}function demo() { "use strict"; return "Copyright \251";}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 @@
function demo() { "use strict"; return "Copyright \u00A9";}function demo() { "use strict"; return "Copyright \u00A9";}However, if you would rather use the hexadecimal escape sequence, none of the three main linters will ask you to do otherwise:
-function demo() { "use strict"; return "Copyright \xA9";}function demo() { "use strict"; return "Copyright \xA9";}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.
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.
+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:
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 = 10;alert("Errors...");console.log("Errors everywhere");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:
/*jshint latedef: true */function test() { "use strict"; a = 1; var a; return a;}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:
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:
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:
/*jshint latedef: nofunc */doStuff();function doStuff() { return 1;}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.
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 @@x, y and z:
-var x = y = z = "example";var x = y = z = "example";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:
-var x;x = y = z = "example";var x;x = y = z = "example";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:
var x, y, z;x = y = z = "example";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.
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:
/*jshint freeze: true */String.prototype.reverse = function () { "use strict"; return this.split("").reverse().join("");};/*jshint freeze: true */String.prototype.reverse = function () { "use strict"; return this.split("").reverse().join("");};ESLint will also issue the warning when the Object.defineProperty method is
used. JSHint does not warn in this situation:
/*jshint freeze: true */Object.defineProperty(String.prototype, "reverse", { value: function () { "use strict"; return this.split("").reverse().join(""); }});/*jshint freeze: true */Object.defineProperty(String.prototype, "reverse", { value: function () { "use strict"; return this.split("").reverse().join(""); }});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 @@/*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 @@
-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":
function demo(a) { return typeof a === "bool";}function demo(a) { return typeof a === "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 @@typeof operator to ever return the value you're using. To solve this issue
simply use a valid value:
-
+
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.
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;| Configuration Option | Description | ||
|---|---|---|---|
space_before_bang |
Whether a space should be present before the !, as in color: #000 !important; (default true) |
@@ -15,5 +13,4 @@ space_after_bang |
Whether a space should be present after the !, as in color: #000 ! important; (default false) |
Disabled by default
Reports when a BEM selector contains more elements than a configurable +maximum number.
Bad
.block__element__subelement {
...
}Good
.block__element {
...
}| Configuration Option | +Description | +
|---|---|
max_elements |
+Maximum number of elements allowed in a BEM selector (default 1) | +
Prefer border: 0 over border: none.
Prefer the terser border: 0 over border: none.
You can specify preferring border: none over border: 0 by setting the
+convention option.
| Configuration Option | +Description | +
|---|---|
convention |
+Whether to prefer 0 (zero) or none (none) (default zero) |
+
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;
}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.
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 @@ +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.
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
+
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.
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 Option | +Description | +
|---|---|
allowed |
+Regular expression for matching allowed comments, such as '^[/* ] Copyright' | +
style |
+Style of comment to enforce (silent or loud) (default silent) |
+
scss-lint includes a set of linters for codebases which use the
-Compass framework.
Reports @debug statements (which you probably left behind accidentally).
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 @@
+
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;
}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 +
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.
#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 Option | +Description | +
|---|---|
ignore_consecutive |
+Whether to ignore consecutive duplicate properties (default false), or a whitelist. | +
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) |
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) |
Reports when you have an empty rule set.
.cat {
-}Reports when you have an empty rule set.
.cat {
}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.
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.
| Configuration Option | Description |
|---|---|
present |
Whether a final newline should be present (default true) |
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;| Configuration Option | Description |
|---|---|
style |
Prefer short or long (default short) |
Checks if hexadecimal colors are written in lowercase. You can specify which
-case with the style option.
| Configuration Option | Description |
|---|---|
style |
Prefer lowercase or uppercase (default lowercase) |
Ensure hexadecimal colors are valid (either three or six digits).
Bad
p {
- background: #ab; // Clearly a typo
-}Good
p {
- background: #abc;
-}Ensure hexadecimal colors are valid (either three or six digits).
Bad
p {
background: #ab; // Clearly a typo
}Good
p {
background: #abc;
}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 +
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 @@ -
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.
| 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) |
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;
}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.
| Configuration Option | Description | |
|---|---|---|
allow_non_nested_indentation |
+Whether 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) |
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) |
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 +
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;
- }
-}| Configuration Option | Description |
|---|---|
force_nesting |
Ensure rule sets which can be nested are nested (default true) |
whitelistFunctions, 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 +
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.
| Configuration Option | Description | |
|---|---|---|
allow_leading_underscore |
Whether to allow names to start with a single underscore (default true) |
|
convention |
-Name of convention to use (hyphenated_lowercase (default) or BEM), or a regex the name must match |
+Name of convention to use (hyphenated_lowercase (default), camel_case, snake_case), or a regex the name must match (eg: ^[a-zA-Z]+$) |
convention_explanation{type}_convention{type}s, where {type} is on of function, mixin, variable, or placeholder{type}_convention_explanation{type} convention, where {type} is one of function, mixin, variable, or placeholderAvoid 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 +
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 {
- ...
- }
- }
-}| Configuration Option | Description |
|---|---|
max_depth |
Maximum depth before reporting errors (default 3) |
ignore_parent_selectorsAlways 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 +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.
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 Option | +Description | +
|---|---|
prefix |
+Prefix used to denote "private" (default _) |
+
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 Option | +Description | +
|---|---|
include_nested |
+Whether to include the properties in nested rule sets in the count | +
max_properties |
+Maximum number of properties | +
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: concentricIf 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: concentricYou 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: trueThis 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).
| Configuration Option | Description | ||
|---|---|---|---|
ignore_unspecified |
+Whether to ignore properties that are not explicitly specified in order (default false) |
+||
min_properties |
+Minimum 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) |
+||
order |
-Array 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_unspecified |
-Whether to ignore properties that are not explicitly specified in order (default false) |
+separate_groups |
+Whether gaps between groups of properties should be enforced. |
Reports when you use an unknown CSS property (ignoring vendor-prefixed -properties).
diplay: none; // "display" is spelled incorrectlySince the list of available CSS properties is constantly changing, it's +
Reports when you use an unknown or disabled CSS property (ignoring vendor-prefixed +properties).
diplay: none; // "display" is spelled incorrectlySince 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-propertyIf 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-propertyIf you're sure the property in question is valid, +submit a request to add it to the -default whitelist.
| Configuration Option | Description |
|---|---|
extra_properties |
List of extra properties to allow |
disabled_propertiesConfigure 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 Option | +Description | +
|---|---|
global |
+List of allowed units (by default any unit is allowed) | +
properties |
+Hash of property names and their list of allowed units. (empty by default) | +
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;
}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 +
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.
| Configuration Option | Description | ||
|---|---|---|---|
allow_element_with_attribute |
Allow elements to qualify attributes (default false) | @@ -51,5 +21,4 @@allow_element_with_id |
Allow elements to qualify ids (default false) |
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 +
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.
| Configuration Option | Description |
|---|---|
max_depth |
Maximum depth before reporting errors (default 3) |
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 +
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.
| Configuration Option | Description | ||
|---|---|---|---|
convention |
-Name of convention to use (hyphenated_lowercase (default) or snake_case, camel_case, or BEM, or hyphenated_BEM), or a regex the name must match |
+Name 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_explanation |
+Custom catch-all explanation if you do not want to use the built-in explanations | ||
ignored_names |
@@ -31,20 +25,15 @@ Array containing list of types of selectors to ignore (valid values are attribute, class, element, id, placeholder) |
||
attribute_convention |
-Convention for attribute selectors only. See the convention option for possible values. |
-||
class_convention |
-Convention for class selectors only. See the convention option for possible values. |
-||
id_convention |
-Convention for id selectors only. See the convention option for possible values. |
+{type}_convention |
+Convention for {type} selectors only, where {type} is one of attribute, class, id, or placeholder. See the convention option for possible values. |
placeholder_convention |
-Convention for placeholder selectors only. See the convention option for possible values. |
+{type}_convention_explanation |
+Custom explanation for {type} selector convention, where {type} is one of attribute, class, id, or placeholder. |
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!
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;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 Option | +Description | +
|---|---|
allowed_shorthands |
+Array of allowed shorthand lengths (default [1, 2, 3]) |
+
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) |
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 +
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).
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);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 Option | +Description | +
|---|---|
style |
+one_space, or no_space or at_least_one_space (default one_space) |
+
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.
| 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) |
Properties should be formatted with no space between the name and the colon.
Bad: space before colon
margin : 0;Good
margin: 0;Properties should be formatted with no space between the name and the colon.
Bad: space before colon
margin : 0;Good
margin: 0;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 Option | +Description | +
|---|---|
style |
+one_space, no_space, at_least_one_space or one_space_or_newline (default one_space) |
+
Variables should be formatted with no space between the name and the colon.
Bad: space before colon
$my-var : 0;Good
$my-var: 0;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 Option | +Description | +
|---|---|
style |
+one_space, at_least_one_space, no_space (default one_space) |
+
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) |
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) |
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.
| Configuration Option | Description | |
|---|---|---|
style |
-
-single_quotes or double_quotes (default single_quotes) |
+single_quotes or double_quotes (default single_quotes) |
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 @@ +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 @@ -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 +
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 @@ +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;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 +
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; }$margin: 1;
p { margin: $margin / 2; }...will compile to:
p { margin: 0.5; }Do not use parent selector references (&) when they would otherwise be
-unnecessary.
Bad
.foo {
- & > .bar {
- ...
- }
-}Good
.foo {
- > .bar {
- }
-}Bad
.foo {
& > .bar {
...
}
}Good
.foo {
> .bar {
}
}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');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');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 +
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 @@ +
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
- fontNote that values like currentColor, inherit, and transparent will not be
+reported, as they are special kinds of values that convey additional meaning.
| Configuration Option | +Description | +
|---|---|
properties |
+Array of property names to check | +
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 Option | +Description | +
|---|---|
identifier_list |
+Name of predefined identifier list to use (base or bourbon) or an array of identifiers (default base) |
+
additional_identifiers |
+Identifiers to lint, in addition to the identifier_list (default []) |
+
excluded_identifiers |
+Identifers in the identifier_list and additional_identifiers to exclude from linting (default []) |
+
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 +
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 @@
+
+ Enforces vertical alignment. Helps maintain a readable, consistent style in your codebase. Three arguments may be optionally provided: Bans the use of specific functions. At this time, there is no way to disable global methods with this rule. A list of Enforces PascalCased class and interface names. Makes it easy to differentitate classes from regular variables at a glance. Not configurable. Enforces formatting rules for single-line comments. Helps maintain a consistent, readable style in your codebase. Three arguments may be optionally provided: Enforces braces for In the code above, the author almost certainly meant for both Not configurable. Ensures the file ends with a newline. It is a standard convention to end files with a newline. Not configurable. Requires a Prevents accidental interation over properties inherited from an object’s prototype.
+See MDN’s Not configurable. Enforces indentation with tabs or spaces. Using only one of tabs or spaces for indentation leads to more consistent editor behavior,
+cleaner diffs in version control, and easier programatic manipulation. One of the following arguments must be provided: Requires interface names to begin with a capital ‘I’ Makes it easy to differentitate interfaces from regular classes at a glance. One of the following two options must be provided: Enforces basic format rules for JSDoc comments. The following rules are enforced for JSDoc comments (comments starting with Helps maintain a consistent, readable style for JSDoc comments. Not configurable. Only allows labels in sensible locations. This rule only allows labels to be on Labels in JavaScript only can be used in conjunction with Not configurable. Checks that labels are defined before usage. This rule is now implemented in the TypeScript compiler and does not need to be used. Using Not configurable. Requires lines to be under a certain max length. 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. An integer indicating the max length of lines. Requires explicit visibility declarations for class members. Explicit visibility declarations can make code more readable and accessible for those new to TS. Two arguments may be optionally provided: Enforces member ordering. A consistent ordering for class members can make classes easier to read, navigate, and edit. One argument, which is an object, must be provided. It should contain an Alternatively, the value for This is useful if one of the preset orders does not meet your needs. Requires parentheses when invoking a constructor via the Maintains stylistic consistency with other function calls. Not configurable. Requires the use of Both formats of type assertions have the same effect, but only Not configurable. Diallows usages of Using Not configurable. Disallows use of Using Not configurable. Disallows bitwise operators. Specifically, the following bitwise operators are banned:
+ Bitwise operators are often typos - for example Not configurable. Disallows any type of assignment in conditionals. This applies to Assignments in conditionals are often typos:
+for example Not configurable. Disallows more than one blank line in a row. Helps maintain a readable style in your codebase. Not configurable. Bans the use of specified In general, A list of method names to ban. Disallows access to the constructors of Disallows constructor use such as There is little reason to use Not configurable. Disallows parameter properties. Parameter properties can be confusing to those new to TS as they are less explicit
+than other ways of declaring and initializing class members. Not configurable. Disallows In general, Not configurable. Disallows default exports in ES6-style modules. Use named exports instead. 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. Not configurable. Disallows duplicate keys in object literals. 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. Not configurable. Disallows duplicate variable declarations in the same block scope. This rule is only useful when using the A variable can be reassigned if necessary -
+there’s no good reason to have a duplicate variable declaration. Not configurable. Disallows empty blocks. Blocks with a comment inside are not considered empty. Empty blocks are often indicators of missing code. Not configurable. Disallows Not configurable. Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. Explicit types where they can be easily infered by the compiler make code more verbose. One argument may be optionally provided: Disallows internal Using Not configurable. Disallows using the See the rule’s author’s rationale here. One argument may be optionally provided: Disallows use of internal This rule still allows the use of ES6-style external modules are the standard way to modularize code.
+Using One argument may be optionally provided: Disallows use of the Instead of having the dual concepts of Not configurable. Disallows Using Not configurable. Disallows invocation of Prefer the newer ES6-style imports over Not configurable. Disallows shadowing variable declarations. Shadowing a variable masks access to it and obscures to what value an identifier actually refers. Not configurable. Disallows object access via string literals. Encourages using strongly-typed property access. Not configurable. Disallows falling through case statements. For example, the following is not allowed: However, fall through is allowed when case statements are consecutive or
+a magic Fall though in switch statements is often unintentional and a bug. Not configurable. Disallows trailing whitespace at the end of a line. Keeps version control diffs clean as it prevents accidental whitespace from being committed. Not configurable. Disallows unreachable code after Unreachable code is often indication of a logic error. Not configurable. Disallows unused expression statements. Unused expressions are expression statements which are not assignments or function calls
+(and thus usually no-ops). Detects potential errors where an assignment or function call was intended. Also detects constructs such as
+ Not configurable. Disallows unused imports, variables, functions and private class members. Three optional arguments may be optionally provided: Disallows usage of variables before their declaration. This rule is primarily useful when using the Not configurable. Disallows usage of the Use Not configurable. Disallows the use of require statements except in import statements. In other words, the use of forms such as Not configurable. Requires keys in object literals to be sorted alphabetically Useful in preventing merge conflicts Not configurable. Requires the specified tokens to be on the same line as the expression preceding them. Five arguments may be optionally provided: Disallows multiple variable definitions in the same declaration statement. One argument may be optionally provided: Requires single or double quotes for string literals. Five arguments may be optionally provided: Requires the radix parameter to be specified when calling 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. Not configurable. Enforces consistent semicolon usage at the end of every statement. One of the following arguments must be provided: Require a Not configurable. Requires or disallows trailing commas in array and object literals, destructuring assignments and named imports. One argument which is an object with the keys 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. Requires Two arguments may be optionally provided: Requires or disallows whitespace for type definitions. Determines if a space is required or not before the colon in a type specifier. 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 Requires type definitions to exist. Six arguments may be optionally provided: Enforces use of the Since Not configurable. Requires using ECMAScript 5’s strict mode. Two arguments may be optionally provided: Checks variable names for various errors. Five arguments may be optionally provided: Enforces whitespace style conventions. Helps maintain a readable, consistent style in your codebase. Seven arguments may be optionally provided:Details
+
+
+ Rule: align
+
+ Rationale
+ Config
+
+
+
+
+
+"parameters" checks alignment of function parameters."arguments" checks alignment of function call arguments."statements" checks alignment of statements.Examples
+
+"align": [true, "parameters", "statements"]
+
+
+Schema
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"arguments",
"parameters",
"statements"
]
}
}Details
+
+
+ Rule: ban
+
+ Config
+['object', 'method'] pairs which ban object.method().Examples
+
+"ban": [true, ["console", "log"], ["someObject", "someFunction"]]
+
+
+Schema
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "array",
"arrayMembers": [
{
"type": "string"
},
{
"type": "string"
}
]
}
}Details
+
+
+ Rule: class-name
+
+ Rationale
+ Config
+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
+
+ Rationale
+ Config
+
+
+
+
+
+"check-space" requires that all single-line comments must begin with a space, as in // comment
+
+
+ /// 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
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-space",
"check-lowercase",
"check-uppercase"
]
}
}Details
+
+
+ Rule: curly
+
+ if/for/do/while statements.Rationale
+
+
+
+if (foo === bar)
foo++;
bar++;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
+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
+
+ Rationale
+ Config
+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
+
+ for ... in statement to be filtered with an if statement.Rationale
+
+
+for (let key in someObject) {
if (someObject.hasOwnProperty(key)) {
// code here
}
}for...in
+documentation for more information about for...in loops.Config
+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
+
+ Rationale
+
+Config
+
+
+
+
+
+"spaces" enforces consistent spaces."tabs" enforces consistent tabs.Examples
+
+"indent": [true, "spaces"]
+
+
+Schema
+{
+
\ 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 @@
+
"type": "enum",
"enumValues": [
"tabs",
"spaces"
]
}Details
+
+
+ Rule: interface-name
+
+ Rationale
+ Config
+
+
+
+
+
+"always-prefix" requires interface names to start with an “I”"never-prefix" requires interface names to not have an “I” prefixExamples
+
+"interface-name": [true, "always-prefix"]
+
+"interface-name": [true, "never-prefix"]
+
+
+Schema
+{
+
\ 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 @@
+
"type": "enum",
"enumValues": [
"always-prefix",
"never-prefix"
]
}Details
+
+
+ Rule: jsdoc-format
+
+ /**):
+
+
+
+
+ /** and end with */Rationale
+ Config
+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
+
+ do/for/while/switch statements.Rationale
+
+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
+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
+
+ Rationale
+ break or continue to go to an out-of-scope label is an error in JS.Config
+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
+
+ Rationale
+
+Config
+Examples
+
+"max-line-length": [true, 120]
+
+
+Schema
+{
+
\ 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 @@
+
"type": "number"
}Details
+
+
+ Rule: member-access
+
+ Rationale
+ Config
+
+
+
+
+
+"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
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-accessor",
"check-constructor"
]
}
}Details
+
+
+ Rule: member-ordering
+
+ Rationale
+ Config
+
+order property.
+The order property should have a value of one of the following strings:
+
+
+fields-firststatics-firstinstance-sandwichorder maybe be an array consisting of the following strings:
+
+
+public-static-fieldprotected-static-fieldprivate-static-fieldpublic-instance-fieldprotected-instance-fieldprivate-instance-fieldconstructorpublic-static-methodprotected-static-methodprivate-static-methodpublic-instance-methodprotected-instance-methodprivate-instance-methodExamples
+
+"member-ordering": [true, { "order": "fields-first" }]
+
+
+Schema
+{
+
\ 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 @@
+
"type": "object",
"properties": {
"order": {
"type": "enum",
"enumValues": [
"fields-first",
"statics-first",
"instance-sandwich"
]
}
}
}Details
+
+
+ Rule: new-parens
+
+ new keyword.Rationale
+ Config
+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
+
+ as Type for type assertions instead of <Type>.Rationale
+
+as type assertions
+work in .tsx files. This rule ensures that you have a consistent type assertion style
+across your codebase.Config
+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
+
+ any as a type declaration.Rationale
+ any as a type declaration nullifies the compile-time benefits of the type system.Config
+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
+
+ arguments.callee.Rationale
+
+arguments.callee makes various performance optimizations impossible.
+See MDN
+for more details on why to avoid arguments.callee.Config
+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
+
+ &, &=, |, |=,
+^, ^=, <<, <<=,
+>>, >>=, >>>, >>>=, and ~.
+This rule does not ban the use of & and | for intersection and union types.Rationale
+
+bool1 & bool2 instead of bool1 && bool2.
+They also can be an indicator of overly clever code which decreases maintainability.Config
+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
+
+ do-while, for, if, and while statements.Rationale
+
+if (var1 = var2) instead of if (var1 == var2).
+They also can be an indicator of overly clever code which decreases maintainability.Config
+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
+
+ Rationale
+ Config
+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
+
+ console methods.Rationale
+ console methods aren’t appropriate for production code.Config
+Examples
+
+"no-console": [true, ["log", "error"]]
+
+
+Schema
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "string"
}
}Details
+
+
+ Rule: no-construct
+
+ String, Number, and Boolean.new Number(foo) but does not disallow Number(foo).Rationale
+
+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
+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
+
+ Rationale
+
+Config
+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
+
+ debugger statements.Rationale
+ debugger statements aren’t appropriate for production code.Config
+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
+
+ Rationale
+
+Config
+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
+
+ Rationale
+
+Config
+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
+
+ var keyword -
+the compiler will detect redeclarations of let and const variables.Rationale
+
+Config
+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
+
+ Rationale
+ Config
+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
+
+ 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
+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
+
+ Rationale
+ Config
+
+
+
+
+
+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
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"ignore-params"
]
}
}Details
+
+
+ Rule: no-internal-module
+
+ moduleRationale
+ module leads to a confusion of concepts with external modules. Use the newer namespace keyword instead.Config
+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
+
+ this keyword outside of classes.Rationale
+ Config
+
+
+
+
+
+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
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-function-in-method"
]
}
}Details
+
+
+ Rule: no-namespace
+
+ modules and namespaces.declare module ... {}Rationale
+
+module {} and namespace {} are outdated ways to organize TypeScript code.Config
+
+
+
+
+
+allow-declarations allows declare namespace ... {} to describe external APIs.Examples
+
+"no-namespace": true
+
+"no-namespace": [true, "allow-declarations"]
+
+
+Schema
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"allow-declarations"
]
}
}Details
+
+
+ Rule: no-null-keyword
+
+ null keyword literal.Rationale
+
+null andundefined in a codebase,
+this rule ensures that only undefined is used.Config
+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
+
+ /// <reference path=> imports (use ES6-style imports instead).Rationale
+
+/// <reference path=> comments to load other files is outdated.
+Use ES6-style imports to reference other files.Config
+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
+
+ require().Rationale
+ require().Config
+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
+
+ Rationale
+ Config
+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
+
+ Rationale
+ Config
+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
+
+
+
+switch(foo) {
case 1:
someFunc(foo);
case 2:
someOtherFunc(foo);
}/* falls through */ comment is present. The following is valid:
+
+
+
+ switch(foo) {
case 1:
someFunc(foo);
/* falls through */
case 2:
case 3:
someOtherFunc(foo);
}Rationale
+ Config
+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
+
+ Rationale
+ Config
+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
+
+ break, catch, throw, and return statements.Rationale
+ Config
+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
+
+ Rationale
+
+new SomeClass(), where a constructor is used solely for its side effects, which is considered poor style.Config
+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
+
+ Config
+
+
+
+
+
+"check-parameters" disallows unused function and constructor parameters.
+
+
+ "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
+{
+
\ 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 @@
+
"type": "array",
"arrayMembers": [
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-parameters",
"react"
]
}
},
{
"type": "object",
"properties": {
"ignore-pattern": {
"type": "string"
}
}
}
]
}Details
+
+
+ Rule: no-use-before-declare
+
+ var keyword -
+the compiler will detect if a let and const variable is used before it is declared.Config
+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
+
+ var keyword.let or const instead.Config
+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
+
+ var module = require("module") are banned.
+Instead use ES6 style imports or import foo = require('foo') imports.Config
+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
+
+ Rationale
+ Config
+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
+
+ Config
+
+
+
+
+
+"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
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-catch",
"check-finally",
"check-else",
"check-open-brace",
"check-whitespace"
]
}
}Details
+
+
+ Rule: one-variable-per-declaration
+
+ Config
+
+
+
+
+
+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
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"ignore-for-loop"
]
}
}Details
+
+
+ Rule: quotemark
+
+ Config
+
+
+
+
+
+"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
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"single",
"double",
"jsx-single",
"jsx-double",
"avoid-escape"
]
}
}Details
+
+
+ Rule: radix
+
+ parseInt.Rationale
+
+Config
+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
+
+ Config
+
+
+
+
+
+"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
+{
+
\ 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 @@
+
"type": "enum",
"enumValues": [
"always",
"never"
]
}Details
+
+
+ Rule: switch-default
+
+ default case in all switch statements.Config
+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
+
+ Config
+
+multiline and singleline.
+Both should be set to either "always" or "never".
+
+
+"multiline" checks multi-line object literals."singleline" checks single-line object literals.Examples
+
+"trailing-comma": [true, {"multiline": "always", "singleline": "never"}]
+
+
+Schema
+{
+
\ 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 @@
+
"type": "object",
"properties": {
"multiline": {
"type": "enum",
"enumValues": [
"always",
"never"
]
},
"singleline": {
"type": "enum",
"enumValues": [
"always",
"never"
]
}
}
}Details
+
+
+ Rule: triple-equals
+
+ === and !== in place of == and !=.Config
+
+
+
+
+
+"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
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"allow-null-check",
"allow-undefined-check"
]
}
}Details
+
+
+ Rule: typedef-whitespace
+
+ Config
+
+"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
+{
+
\ 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 @@
+
"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"
]
}
}
}
]
}Details
+
+
+ Rule: typedef
+
+ Config
+
+
+
+
+
+"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
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"call-signature",
"parameter",
"arrow-parameter",
"property-declaration",
"variable-declaration",
"member-variable-declaration"
]
}
}Details
+
+
+ Rule: use-isnan
+
+ isNaN() function to check for NaN references instead of a comparison to the NaN constant.Rationale
+
+NaN !== NaN, comparisons with regular operators will produce unexpected results.
+So, instead of if (myVar === NaN), do if (isNaN(myVar)).Config
+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
+
+ Config
+
+
+
+
+
+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
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-module",
"check-function"
]
}
}Details
+
+
+ Rule: variable-name
+
+ Config
+
+
+
+
+
+"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
+{
+
\ 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 @@
+
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-format",
"allow-leading-underscore",
"allow-trailing-underscore",
"allow-pascal-case",
"ban-keywords"
]
}
}Details
+
+
+ Rule: whitespace
+
+ Rationale
+ Config
+
+
+
+
+
+"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
+{
+
\ No newline at end of file
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-branch",
"check-decl",
"check-operator",
"check-module",
"check-seperator",
"check-type",
"check-typecast"
]
}
}