diff --git a/Makefile.js b/Makefile.js index 10203f5ed4a..83c6d4095de 100644 --- a/Makefile.js +++ b/Makefile.js @@ -809,17 +809,10 @@ target.checkRuleFiles = function() { * @param {string} id id to check for * @returns {boolean} true if present * @private + * @todo Will remove this check when the main heading is automatically generated from rule metadata. */ function hasIdInTitle(id) { - const idOldAtEndOfTitleRegExp = new RegExp(`^# (.*?) \\(${id}\\)`, "u"); // original format - const idNewAtBeginningOfTitleRegExp = new RegExp(`^# ${id}: `, "u"); // new format is same as rules index - /* - * 1. Added support for new format. - * 2. Will remove support for old format after all docs files have new format. - * 3. Will remove this check when the main heading is automatically generated from rule metadata. - */ - - return idNewAtBeginningOfTitleRegExp.test(docText) || idOldAtEndOfTitleRegExp.test(docText); + return new RegExp(`^# ${id}`, "u").test(docText); } /** @@ -879,7 +872,7 @@ target.checkRuleFiles = function() { errors++; } else { - // check for proper doc format + // check for proper doc h1 format if (!hasIdInTitle(basename)) { console.error("Missing id in the doc page's title of rule %s", basename); errors++; diff --git a/docs/rules/accessor-pairs.md b/docs/rules/accessor-pairs.md index dd64562e67e..03adbd58e74 100644 --- a/docs/rules/accessor-pairs.md +++ b/docs/rules/accessor-pairs.md @@ -1,4 +1,6 @@ -# Enforces getter/setter pairs in objects and classes (accessor-pairs) +# accessor-pairs + +Enforces getter/setter pairs in objects and classes. 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. diff --git a/docs/rules/array-bracket-newline.md b/docs/rules/array-bracket-newline.md index d62b61e337f..cdcc07b12a1 100644 --- a/docs/rules/array-bracket-newline.md +++ b/docs/rules/array-bracket-newline.md @@ -1,4 +1,6 @@ -# enforce line breaks after opening and before closing array brackets (array-bracket-newline) +# array-bracket-newline + +Enforces line breaks after opening and before closing array brackets. A number of style guides require or disallow line breaks inside of array brackets. diff --git a/docs/rules/array-bracket-spacing.md b/docs/rules/array-bracket-spacing.md index a8c745fd51f..0c2659d716c 100644 --- a/docs/rules/array-bracket-spacing.md +++ b/docs/rules/array-bracket-spacing.md @@ -1,4 +1,6 @@ -# Disallow or enforce spaces inside of brackets (array-bracket-spacing) +# array-bracket-spacing + +Disallows or enforce spaces inside of brackets. 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). diff --git a/docs/rules/array-callback-return.md b/docs/rules/array-callback-return.md index f95b7256e6e..264d16be1b5 100644 --- a/docs/rules/array-callback-return.md +++ b/docs/rules/array-callback-return.md @@ -1,4 +1,6 @@ -# Enforces return statements in callbacks of array's methods (array-callback-return) +# array-callback-return + +Enforces return statements in callbacks of array's methods. `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. If you don't want to use a return or don't need the returned results, consider using [.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) instead. diff --git a/docs/rules/array-element-newline.md b/docs/rules/array-element-newline.md index dabb5542394..9c99fb7881d 100644 --- a/docs/rules/array-element-newline.md +++ b/docs/rules/array-element-newline.md @@ -1,4 +1,6 @@ -# enforce line breaks between array elements (array-element-newline) +# array-element-newline + +Enforces line breaks between array elements. A number of style guides require or disallow line breaks between array elements. diff --git a/docs/rules/arrow-body-style.md b/docs/rules/arrow-body-style.md index 31c0cfe0eeb..f257ccaec1d 100644 --- a/docs/rules/arrow-body-style.md +++ b/docs/rules/arrow-body-style.md @@ -1,4 +1,6 @@ -# Require braces in arrow function body (arrow-body-style) +# arrow-body-style + +Requires braces in arrow function bodies. Arrow functions have two syntactic forms for their function bodies. They may be defined with a *block* body (denoted by curly braces) `() => { ... }` or with a single expression `() => ...`, whose value is implicitly returned. diff --git a/docs/rules/arrow-parens.md b/docs/rules/arrow-parens.md index 8a133cdf452..c8068742939 100644 --- a/docs/rules/arrow-parens.md +++ b/docs/rules/arrow-parens.md @@ -1,4 +1,6 @@ -# Require parens in arrow function arguments (arrow-parens) +# arrow-parens + +Requires parens in arrow function arguments. 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. diff --git a/docs/rules/arrow-spacing.md b/docs/rules/arrow-spacing.md index d0cea1b523b..27f49397539 100644 --- a/docs/rules/arrow-spacing.md +++ b/docs/rules/arrow-spacing.md @@ -1,4 +1,6 @@ -# Require space before/after arrow function's arrow (arrow-spacing) +# arrow-spacing + +Requires space before/after arrow function's arrow. This rule normalize style of spacing before/after an arrow function's arrow(`=>`). diff --git a/docs/rules/block-scoped-var.md b/docs/rules/block-scoped-var.md index 9c308feb2b0..412da19ea6a 100644 --- a/docs/rules/block-scoped-var.md +++ b/docs/rules/block-scoped-var.md @@ -1,4 +1,6 @@ -# Treat var as Block Scoped (block-scoped-var) +# block-scoped-var + +Enforces treating `var` as block scoped. The `block-scoped-var` rule generates warnings when variables are used outside of the block in which they were defined. This emulates C-style block scope. diff --git a/docs/rules/block-spacing.md b/docs/rules/block-spacing.md index 04c7aeb6176..37a0a6be1d6 100644 --- a/docs/rules/block-spacing.md +++ b/docs/rules/block-spacing.md @@ -1,4 +1,6 @@ -# Disallow or enforce spaces inside of blocks after opening block and before closing block (block-spacing) +# block-spacing + +Disallows or enforces spaces inside of blocks after opening blocks and before closing blocks. ## Rule Details diff --git a/docs/rules/brace-style.md b/docs/rules/brace-style.md index c22c790ec27..197eeffc5f1 100644 --- a/docs/rules/brace-style.md +++ b/docs/rules/brace-style.md @@ -1,4 +1,6 @@ -# Require Brace Style (brace-style) +# brace-style + +Enforces consistent brace style for blocks. Brace style is closely related to [indent style](https://en.wikipedia.org/wiki/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. diff --git a/docs/rules/callback-return.md b/docs/rules/callback-return.md index b722e297562..d375e37d39e 100644 --- a/docs/rules/callback-return.md +++ b/docs/rules/callback-return.md @@ -1,4 +1,6 @@ -# Enforce Return After Callback (callback-return) +# callback-return + +Enforces return after callback. This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). diff --git a/docs/rules/camelcase.md b/docs/rules/camelcase.md index da9dcda50e5..a79ef401261 100644 --- a/docs/rules/camelcase.md +++ b/docs/rules/camelcase.md @@ -1,4 +1,6 @@ -# Require CamelCase (camelcase) +# camelcase + +Enforces camelcase naming convention. When it comes to naming variables, style guides generally fall into one of two camps: camelcase (`variableName`) and underscores (`variable_name`). This rule focuses on using the camelcase approach. If your style guide calls for camelCasing your variable names, then this rule is for you! diff --git a/docs/rules/capitalized-comments.md b/docs/rules/capitalized-comments.md index ec3253b3171..4de1556f5fe 100644 --- a/docs/rules/capitalized-comments.md +++ b/docs/rules/capitalized-comments.md @@ -1,4 +1,6 @@ -# enforce or disallow capitalization of the first letter of a comment (capitalized-comments) +# capitalized-comments + +Enforces or disallows capitalization of the first letter of a comment. Comments are useful for leaving information for future developers. In order for that information to be useful and not distracting, it is sometimes desirable for comments to follow a particular style. One element of comment formatting styles is whether the first word of a comment should be capitalized or lowercase. diff --git a/docs/rules/class-methods-use-this.md b/docs/rules/class-methods-use-this.md index 518a891d38d..663ed65bbea 100644 --- a/docs/rules/class-methods-use-this.md +++ b/docs/rules/class-methods-use-this.md @@ -1,4 +1,6 @@ -# Enforce that class methods utilize `this` (class-methods-use-this) +# class-methods-use-this + +Enforces that class methods utilize `this`. If a class method does not use `this`, it can *sometimes* be made into a static function. If you do convert the method into a static function, instances of the class that call that particular method have to be converted to a static call as well (`MyClass.callStaticMethod()`) diff --git a/docs/rules/comma-dangle.md b/docs/rules/comma-dangle.md index ef92342050a..f215b70dbc0 100644 --- a/docs/rules/comma-dangle.md +++ b/docs/rules/comma-dangle.md @@ -1,4 +1,6 @@ -# require or disallow trailing commas (comma-dangle) +# comma-dangle + +Requires or disallows trailing commas. 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. diff --git a/docs/rules/comma-spacing.md b/docs/rules/comma-spacing.md index d6a01563f8f..d7566aee431 100644 --- a/docs/rules/comma-spacing.md +++ b/docs/rules/comma-spacing.md @@ -1,4 +1,6 @@ -# Enforces spacing around commas (comma-spacing) +# comma-spacing + +Enforces spacing around commas. Spacing around commas improves 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. diff --git a/docs/rules/comma-style.md b/docs/rules/comma-style.md index bae9a149531..75419a3ac23 100644 --- a/docs/rules/comma-style.md +++ b/docs/rules/comma-style.md @@ -1,4 +1,6 @@ -# Comma style (comma-style) +# comma-style + +Enforces consistent comma styles. The Comma Style rule enforces styles for comma-separated lists. There are two comma styles primarily used in JavaScript: diff --git a/docs/rules/complexity.md b/docs/rules/complexity.md index 5f33334a6b8..a993aec00e8 100644 --- a/docs/rules/complexity.md +++ b/docs/rules/complexity.md @@ -1,4 +1,6 @@ -# Limit Cyclomatic Complexity (complexity) +# complexity + +Enforces a maximum cyclomatic complexity. Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold. diff --git a/docs/rules/computed-property-spacing.md b/docs/rules/computed-property-spacing.md index 903642391b0..9f60ab8047b 100644 --- a/docs/rules/computed-property-spacing.md +++ b/docs/rules/computed-property-spacing.md @@ -1,4 +1,6 @@ -# Disallow or enforce spaces inside of computed properties (computed-property-spacing) +# computed-property-spacing + +Disallows or enforces spaces inside of computed properties. While formatting preferences are very personal, a number of style guides require or disallow spaces between computed properties in the following situations: diff --git a/docs/rules/consistent-return.md b/docs/rules/consistent-return.md index bf4b4708323..8028b7af001 100644 --- a/docs/rules/consistent-return.md +++ b/docs/rules/consistent-return.md @@ -1,4 +1,6 @@ -# require `return` statements to either always or never specify values (consistent-return) +# consistent-return + +Requires `return` statements to either always or never specify values. Unlike statically-typed languages which enforce that a function returns a specified type of value, JavaScript allows different code paths in a function to return different types of values. diff --git a/docs/rules/consistent-this.md b/docs/rules/consistent-this.md index 39212321f24..46d5ecf2c7a 100644 --- a/docs/rules/consistent-this.md +++ b/docs/rules/consistent-this.md @@ -1,4 +1,6 @@ -# Require Consistent This (consistent-this) +# consistent-this + +Enforces consistent naming when capturing the current execution context. 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: diff --git a/docs/rules/constructor-super.md b/docs/rules/constructor-super.md index bf43888d1eb..80471e3dfc7 100644 --- a/docs/rules/constructor-super.md +++ b/docs/rules/constructor-super.md @@ -1,4 +1,6 @@ -# Verify calls of `super()` in constructors (constructor-super) +# constructor-super + +Verifies calls of `super()` in constructors. Constructors of derived classes must call `super()`. Constructors of non derived classes must not call `super()`. diff --git a/docs/rules/curly.md b/docs/rules/curly.md index aecbca5576e..6eb76071f9b 100644 --- a/docs/rules/curly.md +++ b/docs/rules/curly.md @@ -1,4 +1,6 @@ -# Require Following Curly Brace Conventions (curly) +# curly + +Requires following curly brace conventions. 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: diff --git a/docs/rules/default-case-last.md b/docs/rules/default-case-last.md index a82530de1da..e626715854a 100644 --- a/docs/rules/default-case-last.md +++ b/docs/rules/default-case-last.md @@ -1,4 +1,6 @@ -# Enforce default clauses in switch statements to be last (default-case-last) +# default-case-last + +Enforces default clauses in switch statements to be last. A `switch` statement can optionally have a `default` clause. diff --git a/docs/rules/default-case.md b/docs/rules/default-case.md index ba134078c7a..d6d2110f7f3 100644 --- a/docs/rules/default-case.md +++ b/docs/rules/default-case.md @@ -1,4 +1,6 @@ -# Require Default Case in Switch Statements (default-case) +# default-case + +Requires a `default` case in switch statements. Some code conventions require that all `switch` statements have a `default` case, even if the default case is empty, such as: @@ -13,7 +15,7 @@ switch (foo) { break; default: - // do nothing + // do nothing } ``` diff --git a/docs/rules/default-param-last.md b/docs/rules/default-param-last.md index 97bba70fa8c..3944d27bbb3 100644 --- a/docs/rules/default-param-last.md +++ b/docs/rules/default-param-last.md @@ -1,4 +1,6 @@ -# enforce default parameters to be last (default-param-last) +# default-param-last + +Enforces default parameters to be last. Putting default parameter at last allows function calls to omit optional tail arguments. diff --git a/docs/rules/dot-location.md b/docs/rules/dot-location.md index 82f0d94a5b9..b8285664b26 100644 --- a/docs/rules/dot-location.md +++ b/docs/rules/dot-location.md @@ -1,4 +1,6 @@ -# Enforce newline before and after dot (dot-location) +# dot-location + +Enforces newline before and after dots. JavaScript allows you to place newlines before or after a dot in a member expression. diff --git a/docs/rules/dot-notation.md b/docs/rules/dot-notation.md index 26c77756c4b..3495b0a4dc0 100644 --- a/docs/rules/dot-notation.md +++ b/docs/rules/dot-notation.md @@ -1,4 +1,6 @@ -# Require Dot Notation (dot-notation) +# dot-notation + +Enforces dot notation whenever possible. In JavaScript, one can access properties using the dot notation (`foo.bar`) or square-bracket notation (`foo["bar"]`). However, the dot notation is often preferred because it is easier to read, less verbose, and works better with aggressive JavaScript minimizers. diff --git a/docs/rules/eol-last.md b/docs/rules/eol-last.md index ce6203bb11f..63fbee0a007 100644 --- a/docs/rules/eol-last.md +++ b/docs/rules/eol-last.md @@ -1,4 +1,6 @@ -# require or disallow newline at the end of files (eol-last) +# eol-last + +Requires or disallows newline at the end of files. 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 diff --git a/docs/rules/eqeqeq.md b/docs/rules/eqeqeq.md index 4849f999967..ec6932957fe 100644 --- a/docs/rules/eqeqeq.md +++ b/docs/rules/eqeqeq.md @@ -1,4 +1,6 @@ -# Require === and !== (eqeqeq) +# eqeqeq + +Requires the use of `===` and `!==`. It is considered good practice to use the type-safe equality operators `===` and `!==` instead of their regular counterparts `==` and `!=`. diff --git a/docs/rules/for-direction.md b/docs/rules/for-direction.md index ecacabc2cac..6b0c68f4500 100644 --- a/docs/rules/for-direction.md +++ b/docs/rules/for-direction.md @@ -1,4 +1,6 @@ -# Enforce "for" loop update clause moving the counter in the right direction. (for-direction) +# for-direction + +Enforces `for` loop update clause moving the counter in the right direction. ## Rule Details diff --git a/docs/rules/func-call-spacing.md b/docs/rules/func-call-spacing.md index 45660fc444e..a5b2db9c619 100644 --- a/docs/rules/func-call-spacing.md +++ b/docs/rules/func-call-spacing.md @@ -1,4 +1,6 @@ -# require or disallow spacing between function identifiers and their invocations (func-call-spacing) +# func-call-spacing + +Requires or disallows spacing between function identifiers and their invocations. When calling a function, developers may insert optional whitespace between the function's name and the parentheses that invoke it. The following pairs of function calls are equivalent: diff --git a/docs/rules/func-name-matching.md b/docs/rules/func-name-matching.md index 39ee411f035..d1b85c926f6 100644 --- a/docs/rules/func-name-matching.md +++ b/docs/rules/func-name-matching.md @@ -1,4 +1,6 @@ -# require function names to match the name of the variable or property to which they are assigned (func-name-matching) +# func-name-matching + +Requires function names to match the name of the variable or property to which they are assigned. ## Rule Details diff --git a/docs/rules/func-names.md b/docs/rules/func-names.md index 829cb99dd04..48f3ba2e871 100644 --- a/docs/rules/func-names.md +++ b/docs/rules/func-names.md @@ -1,4 +1,6 @@ -# Require or disallow named `function` expressions (func-names) +# func-names + +Requires or disallows named `function` expressions. A pattern that's becoming more common is to give function expressions names to aid in debugging. For example: diff --git a/docs/rules/func-style.md b/docs/rules/func-style.md index c197403d989..a157f499658 100644 --- a/docs/rules/func-style.md +++ b/docs/rules/func-style.md @@ -1,4 +1,6 @@ -# enforce the consistent use of either `function` declarations or expressions (func-style) +# func-style + +Enforces the consistent use of either `function` declarations or expressions. There are two ways of defining functions in JavaScript: `function` declarations and `function` expressions. Declarations contain the `function` keyword first, followed by a name and then its arguments and the function body, for example: diff --git a/docs/rules/function-call-argument-newline.md b/docs/rules/function-call-argument-newline.md index abe0d495651..8e5bb17dae9 100644 --- a/docs/rules/function-call-argument-newline.md +++ b/docs/rules/function-call-argument-newline.md @@ -1,4 +1,6 @@ -# enforce line breaks between arguments of a function call (function-call-argument-newline) +# function-call-argument-newline + +Enforces line breaks between arguments of a function call. A number of style guides require or disallow line breaks between arguments of a function call. diff --git a/docs/rules/function-paren-newline.md b/docs/rules/function-paren-newline.md index ab86680ddff..9447e957dad 100644 --- a/docs/rules/function-paren-newline.md +++ b/docs/rules/function-paren-newline.md @@ -1,4 +1,6 @@ -# enforce consistent line breaks inside function parentheses (function-paren-newline) +# function-paren-newline + +Enforces consistent line breaks inside function parentheses. Many style guides require or disallow newlines inside of function parentheses. diff --git a/docs/rules/generator-star-spacing.md b/docs/rules/generator-star-spacing.md index 00a9ada9194..e61ff04e824 100644 --- a/docs/rules/generator-star-spacing.md +++ b/docs/rules/generator-star-spacing.md @@ -1,4 +1,6 @@ -# Enforce spacing around the * in generator functions (generator-star-spacing) +# generator-star-spacing + +Enforces spacing around the `*` in generator functions. Generators are a new type of function in ECMAScript 6 that can return multiple values over time. These special functions are indicated by placing an `*` after the `function` keyword. diff --git a/docs/rules/generator-star.md b/docs/rules/generator-star.md index f344cc469e1..fd0af59395b 100644 --- a/docs/rules/generator-star.md +++ b/docs/rules/generator-star.md @@ -1,4 +1,6 @@ -# generator-star: enforce consistent spacing around the asterisk in generator functions +# generator-star + +Enforces consistent spacing around the asterisk in generator functions. (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [generator-star-spacing](generator-star-spacing.md) rule. diff --git a/docs/rules/getter-return.md b/docs/rules/getter-return.md index 631de805966..3d8d23594d1 100644 --- a/docs/rules/getter-return.md +++ b/docs/rules/getter-return.md @@ -1,4 +1,6 @@ -# Enforces that a return statement is present in property getters (getter-return) +# getter-return + +Enforces that a `return` statement is present in property getters. The get syntax binds an object property to a function that will be called when that property is looked up. It was first introduced in ECMAScript 5: diff --git a/docs/rules/global-require.md b/docs/rules/global-require.md index a81d5a3a506..0312a91cb73 100644 --- a/docs/rules/global-require.md +++ b/docs/rules/global-require.md @@ -1,4 +1,6 @@ -# Enforce require() on the top-level module scope (global-require) +# global-require + +Enforces `require()` on the top-level module scope. This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). @@ -12,7 +14,6 @@ While `require()` may be called anywhere in code, some style guides prescribe th ```js function foo() { - if (condition) { var fs = require("fs"); } @@ -35,26 +36,34 @@ Examples of **incorrect** code for this rule: // calling require() inside of a function is not allowed function readFile(filename, callback) { - var fs = require('fs'); - fs.readFile(filename, callback) + var fs = require("fs"); + fs.readFile(filename, callback); } // conditional requires like this are also not allowed -if (DEBUG) { require('debug'); } +if (DEBUG) { + require("debug"); +} // a require() in a switch statement is also flagged -switch(x) { case '1': require('1'); break; } +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); } +function getModule(name) { + return require(name); +} // you may not require() inside of a try/catch block try { require(unsafeModule); -} catch(e) { +} catch (e) { console.log(e); } ``` @@ -65,19 +74,19 @@ Examples of **correct** code for this rule: /*eslint global-require: "error"*/ // all these variations of require() are ok -require('x'); -var y = require('y'); +require("x"); +var y = require("y"); var z; -z = require('z').initialize(); +z = require("z").initialize(); // requiring a module and using it in a function is ok -var fs = require('fs'); +var fs = require("fs"); function readFile(filename, callback) { - fs.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'); +var logger = DEBUG ? require("dev-logger") : require("logger"); // if you want you can require() at the end of your module function doSomethingA() {} diff --git a/docs/rules/global-strict.md b/docs/rules/global-strict.md index 5fbba7b9d64..4be8d7f960b 100644 --- a/docs/rules/global-strict.md +++ b/docs/rules/global-strict.md @@ -1,4 +1,6 @@ -# global-strict: require or disallow strict mode directives in the global scope +# global-strict + +Requires or disallows strict mode directives in the global scope. (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [strict](strict.md) rule. The `"global"` option in the new rule is most similar to the removed rule. diff --git a/docs/rules/grouped-accessor-pairs.md b/docs/rules/grouped-accessor-pairs.md index d77c8abbfaa..c46c18f6ee1 100644 --- a/docs/rules/grouped-accessor-pairs.md +++ b/docs/rules/grouped-accessor-pairs.md @@ -1,4 +1,6 @@ -# Require grouped accessor pairs in object literals and classes (grouped-accessor-pairs) +# grouped-accessor-pairs + +Requires grouped accessor pairs in object literals and classes. A getter and setter for the same property don't necessarily have to be defined adjacent to each other. diff --git a/docs/rules/guard-for-in.md b/docs/rules/guard-for-in.md index 28dc1637ff4..36287a522a3 100644 --- a/docs/rules/guard-for-in.md +++ b/docs/rules/guard-for-in.md @@ -1,4 +1,6 @@ -# Require Guarding for-in (guard-for-in) +# guard-for-in + +Requires `for in` loops to include an `if` statement. Looping over objects with a `for in` loop will include properties that are inherited through the prototype chain. This behavior can lead to unexpected items in your for loop. diff --git a/docs/rules/handle-callback-err.md b/docs/rules/handle-callback-err.md index dad537e9695..d1346cb6e0e 100644 --- a/docs/rules/handle-callback-err.md +++ b/docs/rules/handle-callback-err.md @@ -1,4 +1,6 @@ -# Enforce Callback Error Handling (handle-callback-err) +# handle-callback-err + +Enforces callback error handling. This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). diff --git a/docs/rules/id-blacklist.md b/docs/rules/id-blacklist.md index 87a7d9503bb..12bac041c8c 100644 --- a/docs/rules/id-blacklist.md +++ b/docs/rules/id-blacklist.md @@ -1,3 +1,5 @@ -# disallow specified identifiers (id-blacklist) +# id-blacklist + +Disallows specified identifiers. This rule was **deprecated** in ESLint v7.5.0 and replaced by the [id-denylist](id-denylist.md) rule. diff --git a/docs/rules/id-denylist.md b/docs/rules/id-denylist.md index 1da92bb1785..283efb6ffeb 100644 --- a/docs/rules/id-denylist.md +++ b/docs/rules/id-denylist.md @@ -1,4 +1,6 @@ -# disallow specified identifiers (id-denylist) +# id-denylist + +Disallows specified identifiers. > "There are only two hard things in Computer Science: cache invalidation and naming things." — Phil Karlton diff --git a/docs/rules/id-length.md b/docs/rules/id-length.md index d8b1b45d212..c3450db1f50 100644 --- a/docs/rules/id-length.md +++ b/docs/rules/id-length.md @@ -1,4 +1,6 @@ -# enforce minimum and maximum identifier lengths (id-length) +# id-length + +Enforces minimum and maximum identifier lengths. Very short identifier names like `e`, `x`, `_t` or very long ones like `hashGeneratorResultOutputContainerObject` can make code harder to read and potentially less maintainable. To prevent this, one may enforce a minimum and/or maximum identifier length. diff --git a/docs/rules/id-match.md b/docs/rules/id-match.md index 5bb2a1d94c8..016466e4167 100644 --- a/docs/rules/id-match.md +++ b/docs/rules/id-match.md @@ -1,4 +1,6 @@ -# require identifiers to match a specified regular expression (id-match) +# id-match + +Requires identifiers to match a specified regular expression. > "There are only two hard things in Computer Science: cache invalidation and naming things." — Phil Karlton diff --git a/docs/rules/implicit-arrow-linebreak.md b/docs/rules/implicit-arrow-linebreak.md index 5558dc503ba..bc3fbf4dd6d 100644 --- a/docs/rules/implicit-arrow-linebreak.md +++ b/docs/rules/implicit-arrow-linebreak.md @@ -1,4 +1,6 @@ -# Enforce the location of arrow function bodies with implicit returns (implicit-arrow-linebreak) +# implicit-arrow-linebreak + +Enforces the location of arrow function bodies with implicit returns. An arrow function body can contain an implicit return as an expression instead of a block body. It can be useful to enforce a consistent location for the implicitly returned expression. diff --git a/docs/rules/indent-legacy.md b/docs/rules/indent-legacy.md index 2711ccc6987..053136bd0ad 100644 --- a/docs/rules/indent-legacy.md +++ b/docs/rules/indent-legacy.md @@ -1,4 +1,6 @@ -# enforce consistent indentation (indent-legacy) +# indent-legacy + +Enforces consistent indentation. This rule was **deprecated** in ESLint v4.0.0. diff --git a/docs/rules/indent.md b/docs/rules/indent.md index bd4e86ea945..f8dc70aa22c 100644 --- a/docs/rules/indent.md +++ b/docs/rules/indent.md @@ -1,4 +1,6 @@ -# enforce consistent indentation (indent) +# indent + +Enforces consistent indentation. There are several common guidelines which require specific indentation of nested blocks and statements, like: diff --git a/docs/rules/init-declarations.md b/docs/rules/init-declarations.md index 97c831a9834..b9031529c2e 100644 --- a/docs/rules/init-declarations.md +++ b/docs/rules/init-declarations.md @@ -1,4 +1,6 @@ -# require or disallow initialization in variable declarations (init-declarations) +# init-declarations + +Requires or disallows initialization in variable declarations. In JavaScript, variables can be assigned during declaration, or at any point afterwards using an assignment statement. For example, in the following code, `foo` is initialized during declaration, while `bar` is initialized later. diff --git a/docs/rules/jsx-quotes.md b/docs/rules/jsx-quotes.md index ba0b8762ea1..25e7bafd111 100644 --- a/docs/rules/jsx-quotes.md +++ b/docs/rules/jsx-quotes.md @@ -1,4 +1,6 @@ -# enforce the consistent use of either double or single quotes in JSX attributes (jsx-quotes) +# jsx-quotes + +Enforces the consistent use of either double or single quotes in JSX attributes. JSX attribute values can contain string literals, which are delimited with single or double quotes. diff --git a/docs/rules/key-spacing.md b/docs/rules/key-spacing.md index c94b11f6db9..f4668142c05 100644 --- a/docs/rules/key-spacing.md +++ b/docs/rules/key-spacing.md @@ -1,4 +1,6 @@ -# enforce consistent spacing between keys and values in object literal properties (key-spacing) +# key-spacing + +Enforces consistent spacing between keys and values in object literal properties. 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. diff --git a/docs/rules/keyword-spacing.md b/docs/rules/keyword-spacing.md index 031873b5ed8..71d372b3596 100644 --- a/docs/rules/keyword-spacing.md +++ b/docs/rules/keyword-spacing.md @@ -1,4 +1,6 @@ -# enforce consistent spacing before and after keywords (keyword-spacing) +# keyword-spacing + +Enforces consistent spacing before and after keywords. Keywords are syntax elements of JavaScript, such as `try` and `if`. These keywords have special meaning to the language and so often appear in a different color in code editors. diff --git a/docs/rules/line-comment-position.md b/docs/rules/line-comment-position.md index 2e0eef8530a..d18dc927ed9 100644 --- a/docs/rules/line-comment-position.md +++ b/docs/rules/line-comment-position.md @@ -1,4 +1,6 @@ -# enforce position of line comments (line-comment-position) +# line-comment-position + +Enforces position of line comments. Line comments can be positioned above or beside code. This rule helps teams maintain a consistent style. diff --git a/docs/rules/linebreak-style.md b/docs/rules/linebreak-style.md index 5143ae49dfc..2c823a5c75f 100644 --- a/docs/rules/linebreak-style.md +++ b/docs/rules/linebreak-style.md @@ -1,4 +1,6 @@ -# enforce consistent linebreak style (linebreak-style) +# linebreak-style + +Enforces consistent linebreak style. 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). diff --git a/docs/rules/lines-around-comment.md b/docs/rules/lines-around-comment.md index b13d525326a..759c50c382d 100644 --- a/docs/rules/lines-around-comment.md +++ b/docs/rules/lines-around-comment.md @@ -1,4 +1,6 @@ -# require empty lines around comments (lines-around-comment) +# lines-around-comment + +Requires empty lines around comments. 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. diff --git a/docs/rules/lines-around-directive.md b/docs/rules/lines-around-directive.md index 6aa9f1da7e4..e88e0707faa 100644 --- a/docs/rules/lines-around-directive.md +++ b/docs/rules/lines-around-directive.md @@ -1,4 +1,6 @@ -# require or disallow newlines around directives (lines-around-directive) +# lines-around-directive + +Requires or disallow newlines around directives. This rule was **deprecated** in ESLint v4.0.0 and replaced by the [padding-line-between-statements](padding-line-between-statements.md) rule. diff --git a/docs/rules/lines-between-class-members.md b/docs/rules/lines-between-class-members.md index 27084c28346..0654a3953b1 100644 --- a/docs/rules/lines-between-class-members.md +++ b/docs/rules/lines-between-class-members.md @@ -1,4 +1,6 @@ -# require or disallow an empty line between class members (lines-between-class-members) +# lines-between-class-members + +Requires or disallows an empty line between class members. This rule improves readability by enforcing lines between class members. It will not check empty lines before the first member and after the last member, since that is already taken care of by padded-blocks. diff --git a/docs/rules/max-classes-per-file.md b/docs/rules/max-classes-per-file.md index dac65de9d57..dab6e77dbaa 100644 --- a/docs/rules/max-classes-per-file.md +++ b/docs/rules/max-classes-per-file.md @@ -1,4 +1,6 @@ -# enforce a maximum number of classes per file (max-classes-per-file) +# max-classes-per-file + +Enforces a maximum number of classes per file. Files containing multiple classes can often result in a less navigable and poorly structured codebase. Best practice is to keep each file diff --git a/docs/rules/max-depth.md b/docs/rules/max-depth.md index ae8121e6930..85b7a63e438 100644 --- a/docs/rules/max-depth.md +++ b/docs/rules/max-depth.md @@ -1,4 +1,6 @@ -# enforce a maximum depth that blocks can be nested (max-depth) +# max-depth + +Enforces a maximum depth that blocks can be nested. Many developers consider code difficult to read if blocks are nested beyond a certain depth. diff --git a/docs/rules/max-len.md b/docs/rules/max-len.md index 7aa755a34b2..61804d57057 100644 --- a/docs/rules/max-len.md +++ b/docs/rules/max-len.md @@ -1,4 +1,6 @@ -# enforce a maximum line length (max-len) +# max-len + +Enforces a maximum line length. 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). diff --git a/docs/rules/max-lines-per-function.md b/docs/rules/max-lines-per-function.md index 3b01f7d24e0..21c49146818 100644 --- a/docs/rules/max-lines-per-function.md +++ b/docs/rules/max-lines-per-function.md @@ -1,4 +1,6 @@ -# enforce a maximum function length (max-lines-per-function) +# max-lines-per-function + +Enforces a maximum function length. Some people consider large functions a code smell. Large functions tend to do a lot of things and can make it hard following what's going on. Many coding style guides dictate a limit of the number of lines that a function can comprise of. This rule can help enforce that style. diff --git a/docs/rules/max-lines.md b/docs/rules/max-lines.md index 3842edc92b5..8ced25fceab 100644 --- a/docs/rules/max-lines.md +++ b/docs/rules/max-lines.md @@ -1,4 +1,6 @@ -# enforce a maximum file length (max-lines) +# max-lines + +Enforces a maximum file length. Some people consider large files a code smell. Large files tend to do a lot of things and can make it hard following what's going. While there is not an objective maximum number of lines considered acceptable in a file, most people would agree it should not be in the thousands. Recommendations usually range from 100 to 500 lines. diff --git a/docs/rules/max-nested-callbacks.md b/docs/rules/max-nested-callbacks.md index 3b4ac5ee9ff..c7b85c783d8 100644 --- a/docs/rules/max-nested-callbacks.md +++ b/docs/rules/max-nested-callbacks.md @@ -1,4 +1,6 @@ -# enforce a maximum depth that callbacks can be nested (max-nested-callbacks) +# max-nested-callbacks + +Enforces a maximum depth that callbacks can be nested. 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. diff --git a/docs/rules/max-params.md b/docs/rules/max-params.md index 050d2a34850..0f8c2d1b4e6 100644 --- a/docs/rules/max-params.md +++ b/docs/rules/max-params.md @@ -1,4 +1,6 @@ -# enforce a maximum number of parameters in function definitions (max-params) +# max-params + +Enforces a maximum number of parameters in function definitions. 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. diff --git a/docs/rules/max-statements-per-line.md b/docs/rules/max-statements-per-line.md index e8462b664cd..ef17951a765 100644 --- a/docs/rules/max-statements-per-line.md +++ b/docs/rules/max-statements-per-line.md @@ -1,4 +1,6 @@ -# enforce a maximum number of statements allowed per line (max-statements-per-line) +# max-statements-per-line + +Enforces a maximum number of statements allowed per line. A line of code containing too many statements can be difficult to read. Code is generally read from the top down, especially when scanning, so limiting the number of statements allowed on a single line can be very beneficial for readability and maintainability. diff --git a/docs/rules/max-statements.md b/docs/rules/max-statements.md index c2a67331063..11ac27871c5 100644 --- a/docs/rules/max-statements.md +++ b/docs/rules/max-statements.md @@ -1,4 +1,6 @@ -# enforce a maximum number of statements allowed in function blocks (max-statements) +# max-statements + +Enforces a maximum number of statements allowed in function blocks. The `max-statements` rule allows you to specify the maximum number of statements allowed in a function. diff --git a/docs/rules/multiline-comment-style.md b/docs/rules/multiline-comment-style.md index 32bedddd936..db7a01865d2 100644 --- a/docs/rules/multiline-comment-style.md +++ b/docs/rules/multiline-comment-style.md @@ -1,4 +1,6 @@ -# enforce a particular style for multiline comments (multiline-comment-style) +# multiline-comment-style + +Enforces a particular style for multiline comments. Many style guides require a particular style for comments that span multiple lines. For example, some style guides prefer the use of a single block comment for multiline comments, whereas other style guides prefer consecutive line comments. diff --git a/docs/rules/multiline-ternary.md b/docs/rules/multiline-ternary.md index 0c38bf7d3f1..a987b6a80fa 100644 --- a/docs/rules/multiline-ternary.md +++ b/docs/rules/multiline-ternary.md @@ -1,4 +1,6 @@ -# Enforce or disallow newlines between operands of ternary expressions (multiline-ternary) +# multiline-ternary + +Enforces or disallows newlines between operands of ternary expressions. JavaScript allows operands of ternary expressions to be separated by newlines, which can improve the readability of your program. diff --git a/docs/rules/new-cap.md b/docs/rules/new-cap.md index ef8c61508c6..eb7afc9405e 100644 --- a/docs/rules/new-cap.md +++ b/docs/rules/new-cap.md @@ -1,4 +1,6 @@ -# require constructor names to begin with a capital letter (new-cap) +# new-cap + +Requires constructor names to begin with a capital letter. The `new` operator in JavaScript creates a new instance of a particular type of object. That type of object is represented by a constructor function. Since constructor functions are just regular functions, the only defining characteristic is that `new` is being used as part of the call. Native JavaScript functions begin with an uppercase letter to distinguish those functions that are to be used as constructors from functions that are not. Many style guides recommend following this pattern to more easily determine which functions are to be used as constructors. diff --git a/docs/rules/new-parens.md b/docs/rules/new-parens.md index 5237abdd4ec..88fe89ec19a 100644 --- a/docs/rules/new-parens.md +++ b/docs/rules/new-parens.md @@ -1,4 +1,6 @@ -# require parentheses when invoking a constructor with no arguments (new-parens) +# new-parens + +Requires parentheses when invoking a constructor with no arguments. JavaScript allows the omission of parentheses when invoking a function via the `new` keyword and the constructor has no arguments. However, some coders believe that omitting the parentheses is inconsistent with the rest of the language and thus makes code less clear. diff --git a/docs/rules/newline-after-var.md b/docs/rules/newline-after-var.md index 43ec9ba8ac0..5e3b20444d1 100644 --- a/docs/rules/newline-after-var.md +++ b/docs/rules/newline-after-var.md @@ -1,4 +1,6 @@ -# require or disallow an empty line after variable declarations (newline-after-var) +# newline-after-var + +Requires or disallows an empty line after variable declarations. This rule was **deprecated** in ESLint v4.0.0 and replaced by the [padding-line-between-statements](padding-line-between-statements.md) rule. diff --git a/docs/rules/newline-before-return.md b/docs/rules/newline-before-return.md index 670953404e1..378948ea3ad 100644 --- a/docs/rules/newline-before-return.md +++ b/docs/rules/newline-before-return.md @@ -1,4 +1,6 @@ -# require an empty line before `return` statements (newline-before-return) +# newline-before-return + +Requires an empty line before `return` statements. This rule was **deprecated** in ESLint v4.0.0 and replaced by the [padding-line-between-statements](padding-line-between-statements.md) rule. diff --git a/docs/rules/newline-per-chained-call.md b/docs/rules/newline-per-chained-call.md index c4227c03ea8..9e3004f8e1e 100644 --- a/docs/rules/newline-per-chained-call.md +++ b/docs/rules/newline-per-chained-call.md @@ -1,4 +1,6 @@ -# require a newline after each call in a method chain (newline-per-chained-call) +# newline-per-chained-call + +Requires a newline after each call in a method chain. 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. diff --git a/docs/rules/no-alert.md b/docs/rules/no-alert.md index 6b7e6643e6a..956aff81114 100644 --- a/docs/rules/no-alert.md +++ b/docs/rules/no-alert.md @@ -1,4 +1,6 @@ -# Disallow Use of Alert (no-alert) +# no-alert + +Disallows the use of `alert`, `confirm`, and `prompt`. JavaScript's `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. diff --git a/docs/rules/no-array-constructor.md b/docs/rules/no-array-constructor.md index 22fbde64ef0..06a8276ecca 100644 --- a/docs/rules/no-array-constructor.md +++ b/docs/rules/no-array-constructor.md @@ -1,4 +1,6 @@ -# disallow `Array` constructors (no-array-constructor) +# no-array-constructor + +Disallows `Array` constructors. Use of the `Array` constructor to construct a new array is generally discouraged in favor of array literal notation because of the single-argument diff --git a/docs/rules/no-arrow-condition.md b/docs/rules/no-arrow-condition.md index faa556667bb..2052f02e3bd 100644 --- a/docs/rules/no-arrow-condition.md +++ b/docs/rules/no-arrow-condition.md @@ -1,4 +1,6 @@ -# no-arrow-condition: disallow arrow functions where test conditions are expected +# no-arrow-condition + +Disallows arrow functions where test conditions are expected. (removed) This rule was **removed** in ESLint v2.0 and **replaced** by a combination of the [no-confusing-arrow](no-confusing-arrow.md) and [no-constant-condition](no-constant-condition.md) rules. diff --git a/docs/rules/no-async-promise-executor.md b/docs/rules/no-async-promise-executor.md index 58655b79e79..3f9cf9627ad 100644 --- a/docs/rules/no-async-promise-executor.md +++ b/docs/rules/no-async-promise-executor.md @@ -1,4 +1,6 @@ -# disallow using an async function as a Promise executor (no-async-promise-executor) +# no-async-promise-executor + +Disallows using an async function as a Promise executor. The `new Promise` constructor accepts an *executor* function as an argument, which has `resolve` and `reject` parameters that can be used to control the state of the created Promise. For example: diff --git a/docs/rules/no-await-in-loop.md b/docs/rules/no-await-in-loop.md index eebf1423746..2395956c357 100644 --- a/docs/rules/no-await-in-loop.md +++ b/docs/rules/no-await-in-loop.md @@ -1,4 +1,6 @@ -# Disallow `await` inside of loops (no-await-in-loop) +# no-await-in-loop + +Disallows `await` inside of loops. Performing an operation on each element of an iterable is a common task. However, performing an `await` as part of each operation is an indication that the program is not taking full advantage of diff --git a/docs/rules/no-bitwise.md b/docs/rules/no-bitwise.md index 252f0cf0c1e..b79a9dc7d9b 100644 --- a/docs/rules/no-bitwise.md +++ b/docs/rules/no-bitwise.md @@ -1,4 +1,6 @@ -# disallow bitwise operators (no-bitwise) +# no-bitwise + +Disallows bitwise operators. The use of bitwise operators in JavaScript is very rare and often `&` or `|` is simply a mistyped `&&` or `||`, which will lead to unexpected behavior. diff --git a/docs/rules/no-buffer-constructor.md b/docs/rules/no-buffer-constructor.md index 9902a71605f..4e1e7728a8e 100644 --- a/docs/rules/no-buffer-constructor.md +++ b/docs/rules/no-buffer-constructor.md @@ -1,4 +1,6 @@ -# disallow use of the Buffer() constructor (no-buffer-constructor) +# no-buffer-constructor + +Disallows use of the `Buffer()` constructor. This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). diff --git a/docs/rules/no-caller.md b/docs/rules/no-caller.md index f5688df385e..280d2f6fdac 100644 --- a/docs/rules/no-caller.md +++ b/docs/rules/no-caller.md @@ -1,4 +1,6 @@ -# Disallow Use of caller/callee (no-caller) +# no-caller + +Disallows use of `caller`/`callee`. The use of `arguments.caller` and `arguments.callee` make several code optimizations impossible. They have been deprecated in future versions of JavaScript and their use is forbidden in ECMAScript 5 while in strict mode. diff --git a/docs/rules/no-case-declarations.md b/docs/rules/no-case-declarations.md index 3652c7481e9..8a73e5136bb 100644 --- a/docs/rules/no-case-declarations.md +++ b/docs/rules/no-case-declarations.md @@ -1,4 +1,6 @@ -# Disallow lexical declarations in case/default clauses (no-case-declarations) +# no-case-declarations + +Disallows lexical declarations in case/default clauses. This rule disallows lexical declarations (`let`, `const`, `function` and `class`) in `case`/`default` clauses. The reason is that the lexical declaration is visible diff --git a/docs/rules/no-catch-shadow.md b/docs/rules/no-catch-shadow.md index cd57ac8f7ed..ebd18479198 100644 --- a/docs/rules/no-catch-shadow.md +++ b/docs/rules/no-catch-shadow.md @@ -1,4 +1,6 @@ -# Disallow Shadowing of Variables Inside of catch (no-catch-shadow) +# no-catch-shadow + +Disallows shadowing of variables inside of catch. This rule was **deprecated** in ESLint v5.1.0. diff --git a/docs/rules/no-class-assign.md b/docs/rules/no-class-assign.md index 62c8a71e96b..ca57fd95f82 100644 --- a/docs/rules/no-class-assign.md +++ b/docs/rules/no-class-assign.md @@ -1,4 +1,6 @@ -# Disallow modifying variables of class declarations (no-class-assign) +# no-class-assign + +Disallows modifying variables of class declarations. `ClassDeclaration` creates a variable, and we can modify the variable. diff --git a/docs/rules/no-comma-dangle.md b/docs/rules/no-comma-dangle.md index d8396bad261..64fa4fd62c7 100644 --- a/docs/rules/no-comma-dangle.md +++ b/docs/rules/no-comma-dangle.md @@ -1,4 +1,6 @@ -# no-comma-dangle: disallow trailing commas in object and array literals +# no-comma-dangle + +Disallows trailing commas in object and array literals. (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [comma-dangle](comma-dangle.md) rule. diff --git a/docs/rules/no-compare-neg-zero.md b/docs/rules/no-compare-neg-zero.md index cfbe545e285..ba34e1f025a 100644 --- a/docs/rules/no-compare-neg-zero.md +++ b/docs/rules/no-compare-neg-zero.md @@ -1,8 +1,10 @@ -# disallow comparing against -0 (no-compare-neg-zero) +# no-compare-neg-zero + +Disallows comparing against `-0`. ## Rule Details -The rule should warn against code that tries to compare against -0, since that will not work as intended. That is, code like x === -0 will pass for both +0 and -0. The author probably intended Object.is(x, -0). +The rule should warn against code that tries to compare against `-0`, since that will not work as intended. That is, code like `x === -0` will pass for both `+0` and `-0`. The author probably intended `Object.is(x, -0)`. Examples of **incorrect** code for this rule: diff --git a/docs/rules/no-cond-assign.md b/docs/rules/no-cond-assign.md index f1738fa4970..1ac17b85063 100644 --- a/docs/rules/no-cond-assign.md +++ b/docs/rules/no-cond-assign.md @@ -1,4 +1,6 @@ -# disallow assignment operators in conditional statements (no-cond-assign) +# no-cond-assign + +Disallows assignment operators in conditional statements. In conditional statements, it is very easy to mistype a comparison operator (such as `==`) as an assignment operator (such as `=`). For example: diff --git a/docs/rules/no-confusing-arrow.md b/docs/rules/no-confusing-arrow.md index dccf11e9f1b..3671163eadf 100644 --- a/docs/rules/no-confusing-arrow.md +++ b/docs/rules/no-confusing-arrow.md @@ -1,4 +1,6 @@ -# Disallow arrow functions where they could be confused with comparisons (no-confusing-arrow) +# no-confusing-arrow + +Disallows arrow functions where they could be confused with comparisons. Arrow functions (`=>`) are similar in syntax to some comparison operators (`>`, `<`, `<=`, and `>=`). This rule warns against using the arrow function syntax in places where it could be confused with a comparison operator. diff --git a/docs/rules/no-console.md b/docs/rules/no-console.md index b1e4e601c0f..39b52822b9c 100644 --- a/docs/rules/no-console.md +++ b/docs/rules/no-console.md @@ -1,4 +1,6 @@ -# disallow the use of `console` (no-console) +# no-console + +Disallows the use of `console`. In JavaScript that is designed to be executed in the browser, it's considered a best practice to avoid using methods on `console`. Such messages are considered to be for debugging purposes and therefore not suitable to ship to the client. In general, calls using `console` should be stripped before being pushed to production. diff --git a/docs/rules/no-const-assign.md b/docs/rules/no-const-assign.md index 3969767e76b..422859fbc19 100644 --- a/docs/rules/no-const-assign.md +++ b/docs/rules/no-const-assign.md @@ -1,4 +1,6 @@ -# Disallow modifying variables that are declared using `const` (no-const-assign) +# no-const-assign + +Disallows modifying variables that are declared using `const`. We cannot modify variables that are declared using `const` keyword. It will raise a runtime error. diff --git a/docs/rules/no-constant-condition.md b/docs/rules/no-constant-condition.md index 8de5e69f3f8..3ecf499eaa2 100644 --- a/docs/rules/no-constant-condition.md +++ b/docs/rules/no-constant-condition.md @@ -1,4 +1,6 @@ -# disallow constant expressions in conditions (no-constant-condition) +# no-constant-condition + +Disallows constant expressions in conditions. 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. diff --git a/docs/rules/no-constructor-return.md b/docs/rules/no-constructor-return.md index 284b757488e..c2f15fd20d6 100644 --- a/docs/rules/no-constructor-return.md +++ b/docs/rules/no-constructor-return.md @@ -1,4 +1,6 @@ -# Disallow returning value in constructor (no-constructor-return) +# no-constructor-return + +Disallows returning values in constructor. In JavaScript, returning a value in the constructor of a class may be a mistake. Forbidding this pattern prevents mistakes resulting from unfamiliarity with the language or a copy-paste error. diff --git a/docs/rules/no-continue.md b/docs/rules/no-continue.md index 37c1188be36..b2f8409b6d2 100644 --- a/docs/rules/no-continue.md +++ b/docs/rules/no-continue.md @@ -1,4 +1,6 @@ -# disallow `continue` statements (no-continue) +# no-continue + +Disallows `continue` statements. The `continue` statement terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration. When used incorrectly it makes code less testable, less readable and less maintainable. Structured control flow statements such as `if` should be used instead. diff --git a/docs/rules/no-control-regex.md b/docs/rules/no-control-regex.md index 01a55fbe2d7..dcc7df4ca1c 100644 --- a/docs/rules/no-control-regex.md +++ b/docs/rules/no-control-regex.md @@ -1,4 +1,6 @@ -# disallow control characters in regular expressions (no-control-regex) +# no-control-regex + +Disallows control characters in regular expressions. 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. diff --git a/docs/rules/no-debugger.md b/docs/rules/no-debugger.md index 5ff4da3fe9c..b7d27b1a0da 100644 --- a/docs/rules/no-debugger.md +++ b/docs/rules/no-debugger.md @@ -1,4 +1,6 @@ -# disallow the use of `debugger` (no-debugger) +# no-debugger + +Disallows the use of `debugger`. The `debugger` statement is used to tell the executing JavaScript environment to stop execution and start up a debugger at the current point in the code. This has fallen out of favor as a good practice with the advent of modern debugging and development tools. Production code should definitely not contain `debugger`, as it will cause the browser to stop executing code and open an appropriate debugger. diff --git a/docs/rules/no-delete-var.md b/docs/rules/no-delete-var.md index ab90d11395d..e1224a22506 100644 --- a/docs/rules/no-delete-var.md +++ b/docs/rules/no-delete-var.md @@ -1,4 +1,6 @@ -# disallow deleting variables (no-delete-var) +# no-delete-var + +Disallows deleting variables. The purpose of the `delete` operator is to remove a property from an object. Using the `delete` operator on a variable might lead to unexpected behavior. diff --git a/docs/rules/no-div-regex.md b/docs/rules/no-div-regex.md index 211525b3ba3..dda12a725bf 100644 --- a/docs/rules/no-div-regex.md +++ b/docs/rules/no-div-regex.md @@ -1,4 +1,6 @@ -# Disallow Regular Expressions That Look Like Division (no-div-regex) +# no-div-regex + +Disallows regular expressions that look like division. Require regex literals to escape division operators. diff --git a/docs/rules/no-dupe-args.md b/docs/rules/no-dupe-args.md index 80a3d85cf94..5c2dead0639 100644 --- a/docs/rules/no-dupe-args.md +++ b/docs/rules/no-dupe-args.md @@ -1,4 +1,6 @@ -# disallow duplicate arguments in `function` definitions (no-dupe-args) +# no-dupe-args + +Disallows duplicate arguments in `function` definitions. 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. diff --git a/docs/rules/no-dupe-class-members.md b/docs/rules/no-dupe-class-members.md index 48b22e88598..c825634f07d 100644 --- a/docs/rules/no-dupe-class-members.md +++ b/docs/rules/no-dupe-class-members.md @@ -1,4 +1,6 @@ -# Disallow duplicate name in class members (no-dupe-class-members) +# no-dupe-class-members + +Disallows duplicate name in class members. If there are declarations of the same name in class members, the last declaration overwrites other declarations silently. It can cause unexpected behaviors. diff --git a/docs/rules/no-dupe-else-if.md b/docs/rules/no-dupe-else-if.md index 8b91c83224b..9c4138695b2 100644 --- a/docs/rules/no-dupe-else-if.md +++ b/docs/rules/no-dupe-else-if.md @@ -1,4 +1,6 @@ -# Disallow duplicate conditions in `if-else-if` chains (no-dupe-else-if) +# no-dupe-else-if + +Disallows duplicate conditions in `if-else-if` chains. `if-else-if` chains are commonly used when there is a need to execute only one branch (or at most one branch) out of several possible branches, based on certain conditions. diff --git a/docs/rules/no-dupe-keys.md b/docs/rules/no-dupe-keys.md index 0d892ef1df2..0698a7e286e 100644 --- a/docs/rules/no-dupe-keys.md +++ b/docs/rules/no-dupe-keys.md @@ -1,4 +1,6 @@ -# disallow duplicate keys in object literals (no-dupe-keys) +# no-dupe-keys + +Disallows duplicate keys in object literals. Multiple properties with the same key in object literals can cause unexpected behavior in your application. diff --git a/docs/rules/no-duplicate-case.md b/docs/rules/no-duplicate-case.md index c728bdf4651..32c25fdb5ab 100644 --- a/docs/rules/no-duplicate-case.md +++ b/docs/rules/no-duplicate-case.md @@ -1,4 +1,6 @@ -# Rule to disallow a duplicate case label (no-duplicate-case) +# no-duplicate-case + +Disallows duplicate `case` labels. If a `switch` statement has duplicate test expressions in `case` clauses, it is likely that a programmer copied a `case` clause but forgot to change the test expression. diff --git a/docs/rules/no-duplicate-imports.md b/docs/rules/no-duplicate-imports.md index 437d2c3daa1..7b6e6d53c1f 100644 --- a/docs/rules/no-duplicate-imports.md +++ b/docs/rules/no-duplicate-imports.md @@ -1,4 +1,6 @@ -# Disallow duplicate imports (no-duplicate-imports) +# no-duplicate-imports + +Disallows duplicate imports. Using a single `import` statement per module will make the code clearer because you can see everything being imported from that module on one line. diff --git a/docs/rules/no-else-return.md b/docs/rules/no-else-return.md index 2f3f83d73cf..37f5db789ac 100644 --- a/docs/rules/no-else-return.md +++ b/docs/rules/no-else-return.md @@ -1,4 +1,6 @@ -# Disallow return before else (no-else-return) +# no-else-return + +Disallows `return` before `else`. If an `if` block contains a `return` statement, the `else` block becomes unnecessary. Its contents can be placed outside of the block. diff --git a/docs/rules/no-empty-character-class.md b/docs/rules/no-empty-character-class.md index c587e9d962e..7bbdc72b45e 100644 --- a/docs/rules/no-empty-character-class.md +++ b/docs/rules/no-empty-character-class.md @@ -1,4 +1,6 @@ -# disallow empty character classes in regular expressions (no-empty-character-class) +# no-empty-character-class + +Disallows empty character classes in regular expressions. Because empty character classes in regular expressions do not match anything, they might be typing mistakes. diff --git a/docs/rules/no-empty-class.md b/docs/rules/no-empty-class.md index 6ed02673e51..f39f1598329 100644 --- a/docs/rules/no-empty-class.md +++ b/docs/rules/no-empty-class.md @@ -1,4 +1,6 @@ -# no-empty-class: disallow empty character classes in regular expressions +# no-empty-class + +Disallows empty character classes in regular expressions. (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [no-empty-character-class](no-empty-character-class.md) rule. diff --git a/docs/rules/no-empty-function.md b/docs/rules/no-empty-function.md index 19110312a64..9d053950d55 100644 --- a/docs/rules/no-empty-function.md +++ b/docs/rules/no-empty-function.md @@ -1,4 +1,6 @@ -# Disallow empty functions (no-empty-function) +# no-empty-function + +Disallows empty functions. 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. diff --git a/docs/rules/no-empty-label.md b/docs/rules/no-empty-label.md index b887c87a590..ed9d64193db 100644 --- a/docs/rules/no-empty-label.md +++ b/docs/rules/no-empty-label.md @@ -1,4 +1,6 @@ -# no-empty-label: disallow labels for anything other than loops and switches +# no-empty-label + +Disallows labels for anything other than loops and switches. (removed) This rule was **removed** in ESLint v2.0 and **replaced** by the [no-labels](no-labels.md) rule. diff --git a/docs/rules/no-empty-pattern.md b/docs/rules/no-empty-pattern.md index 94599157605..407b26d1698 100644 --- a/docs/rules/no-empty-pattern.md +++ b/docs/rules/no-empty-pattern.md @@ -1,4 +1,6 @@ -# Disallow empty destructuring patterns (no-empty-pattern) +# no-empty-pattern + +Disallows empty destructuring patterns. 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: diff --git a/docs/rules/no-empty.md b/docs/rules/no-empty.md index a088708b0b9..50fd84d1672 100644 --- a/docs/rules/no-empty.md +++ b/docs/rules/no-empty.md @@ -1,4 +1,6 @@ -# disallow empty block statements (no-empty) +# no-empty + +Disallows empty block statements. Empty block statements, while not technically errors, usually occur due to refactoring that wasn't completed. They can cause confusion when reading code. diff --git a/docs/rules/no-eq-null.md b/docs/rules/no-eq-null.md index c06287fd859..ef810798b32 100644 --- a/docs/rules/no-eq-null.md +++ b/docs/rules/no-eq-null.md @@ -1,4 +1,6 @@ -# Disallow Null Comparisons (no-eq-null) +# no-eq-null + +Disallows `null` comparisons without type-checking operators, Comparing to `null` without a type-checking operator (`==` or `!=`), can have unintended results as the comparison will evaluate to true when comparing to not just a `null`, but also an `undefined` value. diff --git a/docs/rules/no-eval.md b/docs/rules/no-eval.md index eaa628f754b..d73f90539a6 100644 --- a/docs/rules/no-eval.md +++ b/docs/rules/no-eval.md @@ -1,4 +1,6 @@ -# Disallow eval() (no-eval) +# no-eval + +Disallows eval(). JavaScript's `eval()` function is potentially dangerous and is often misused. Using `eval()` on untrusted code can open a program up to several different injection attacks. The use of `eval()` in most contexts can be substituted for a better, alternative approach to a problem. diff --git a/docs/rules/no-ex-assign.md b/docs/rules/no-ex-assign.md index 11745daf262..17055994b4d 100644 --- a/docs/rules/no-ex-assign.md +++ b/docs/rules/no-ex-assign.md @@ -1,4 +1,6 @@ -# disallow reassigning exceptions in `catch` clauses (no-ex-assign) +# no-ex-assign + +Disallows reassigning exceptions in `catch` clauses. If a `catch` clause in a `try` statement accidentally (or purposely) assigns another value to the exception parameter, it impossible to refer to the error from that point on. Since there is no `arguments` object to offer alternative access to this data, assignment of the parameter is absolutely destructive. diff --git a/docs/rules/no-extend-native.md b/docs/rules/no-extend-native.md index c3ccaeba66a..b562fdc3e0a 100644 --- a/docs/rules/no-extend-native.md +++ b/docs/rules/no-extend-native.md @@ -1,4 +1,6 @@ -# Disallow Extending of Native Objects (no-extend-native) +# no-extend-native + +Disallows extending of native objects. 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. diff --git a/docs/rules/no-extra-bind.md b/docs/rules/no-extra-bind.md index 6d6bf138d33..90d95ab6831 100644 --- a/docs/rules/no-extra-bind.md +++ b/docs/rules/no-extra-bind.md @@ -1,4 +1,6 @@ -# Disallow unnecessary function binding (no-extra-bind) +# no-extra-bind + +Disallows unnecessary function binding. The `bind()` method is used to create functions with specific `this` values and, optionally, binds arguments to specific values. When used to specify the value of `this`, it's important that the function actually uses `this` in its function body. For example: diff --git a/docs/rules/no-extra-boolean-cast.md b/docs/rules/no-extra-boolean-cast.md index 5c7d2007fe8..67814ac2926 100644 --- a/docs/rules/no-extra-boolean-cast.md +++ b/docs/rules/no-extra-boolean-cast.md @@ -1,4 +1,6 @@ -# disallow unnecessary boolean casts (no-extra-boolean-cast) +# no-extra-boolean-cast + +Disallows unnecessary boolean casts. In contexts such as an `if` statement's test where the result of the expression will already be coerced to a Boolean, casting to a Boolean via double negation (`!!`) or a `Boolean` call is unnecessary. For example, these `if` statements are equivalent: diff --git a/docs/rules/no-extra-label.md b/docs/rules/no-extra-label.md index 5c7c11454a1..3a7068e5c65 100644 --- a/docs/rules/no-extra-label.md +++ b/docs/rules/no-extra-label.md @@ -1,4 +1,6 @@ -# Disallow Unnecessary Labels (no-extra-label) +# no-extra-label + +Disallows unnecessary labels. If a loop contains no nested loops or switches, labeling the loop is unnecessary. diff --git a/docs/rules/no-extra-parens.md b/docs/rules/no-extra-parens.md index 4b703a8d3f8..ccebf2dbc98 100644 --- a/docs/rules/no-extra-parens.md +++ b/docs/rules/no-extra-parens.md @@ -1,4 +1,6 @@ -# disallow unnecessary parentheses (no-extra-parens) +# no-extra-parens + +Disallows unnecessary parentheses. This rule restricts the use of parentheses to only where they are necessary. diff --git a/docs/rules/no-extra-semi.md b/docs/rules/no-extra-semi.md index a33a493c817..c37ca03a054 100644 --- a/docs/rules/no-extra-semi.md +++ b/docs/rules/no-extra-semi.md @@ -1,4 +1,6 @@ -# disallow unnecessary semicolons (no-extra-semi) +# no-extra-semi + +Disallows unnecessary semicolons. 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. diff --git a/docs/rules/no-extra-strict.md b/docs/rules/no-extra-strict.md index a350f77a391..f39848be3bd 100644 --- a/docs/rules/no-extra-strict.md +++ b/docs/rules/no-extra-strict.md @@ -1,4 +1,6 @@ -# no-extra-strict: disallow strict mode directives when already in strict mode +# no-extra-strict + +Disallows strict mode directives when already in strict mode. (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [strict](strict.md) rule. The `"global"` or `"function"` options in the new rule are similar to the removed rule. diff --git a/docs/rules/no-fallthrough.md b/docs/rules/no-fallthrough.md index 81b428cf070..8adb37629c1 100644 --- a/docs/rules/no-fallthrough.md +++ b/docs/rules/no-fallthrough.md @@ -1,4 +1,6 @@ -# Disallow Case Statement Fallthrough (no-fallthrough) +# no-fallthrough + +Disallows case statement fallthroughs. The `switch` statement in JavaScript is one of the more error-prone constructs of the language thanks in part to the ability to "fall through" from one `case` to the next. For example: diff --git a/docs/rules/no-floating-decimal.md b/docs/rules/no-floating-decimal.md index 880bc0705fa..991cf65e772 100644 --- a/docs/rules/no-floating-decimal.md +++ b/docs/rules/no-floating-decimal.md @@ -1,4 +1,6 @@ -# Disallow Floating Decimals (no-floating-decimal) +# no-floating-decimal + +Disallows leading or trailing decimal points in numeric literals. 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: diff --git a/docs/rules/no-func-assign.md b/docs/rules/no-func-assign.md index e35b0ed5169..24ba713d12f 100644 --- a/docs/rules/no-func-assign.md +++ b/docs/rules/no-func-assign.md @@ -1,4 +1,6 @@ -# disallow reassigning `function` declarations (no-func-assign) +# no-func-assign + +Disallows reassigning `function` declarations. JavaScript functions can be written as a FunctionDeclaration `function foo() { ... }` or as a FunctionExpression `var foo = function() { ... };`. While a JavaScript interpreter might tolerate it, overwriting/reassigning a function written as a FunctionDeclaration is often indicative of a mistake or issue. diff --git a/docs/rules/no-global-assign.md b/docs/rules/no-global-assign.md index b3718d178b2..cd18f8a6d40 100644 --- a/docs/rules/no-global-assign.md +++ b/docs/rules/no-global-assign.md @@ -1,4 +1,6 @@ -# Disallow assignment to native objects or read-only global variables (no-global-assign) +# no-global-assign + +Disallows assignment to native objects or read-only global variables. JavaScript environments contain a number of built-in global variables, such as `window` in browsers and `process` in Node.js. In almost all cases, you don't want to assign a value to these global variables as doing so could result in losing access to important functionality. For example, you probably don't want to do this in browser code: diff --git a/docs/rules/no-implicit-coercion.md b/docs/rules/no-implicit-coercion.md index 9ad0b77100e..6c77b25fb23 100644 --- a/docs/rules/no-implicit-coercion.md +++ b/docs/rules/no-implicit-coercion.md @@ -1,4 +1,6 @@ -# Disallow the type conversion with shorter notations. (no-implicit-coercion) +# no-implicit-coercion + +Disallows shorthand type conversions. In JavaScript, there are a lot of different ways to convert value types. Some of them might be hard to read and understand. diff --git a/docs/rules/no-implicit-globals.md b/docs/rules/no-implicit-globals.md index a7c03dc3bc4..efc3a6f28ff 100644 --- a/docs/rules/no-implicit-globals.md +++ b/docs/rules/no-implicit-globals.md @@ -1,4 +1,6 @@ -# Disallow declarations in the global scope (no-implicit-globals) +# no-implicit-globals + +Disallows declarations in the global scope. It is the best practice to avoid 'polluting' the global scope with variables that are intended to be local to the script. diff --git a/docs/rules/no-implied-eval.md b/docs/rules/no-implied-eval.md index cbf7c67c2b8..59d1ac976b5 100644 --- a/docs/rules/no-implied-eval.md +++ b/docs/rules/no-implied-eval.md @@ -1,4 +1,6 @@ -# Disallow Implied eval() (no-implied-eval) +# no-implied-eval + +Disallows the use of `eval()`-like methods. It's considered a good practice to avoid using `eval()` in JavaScript. There are security and performance implications involved with doing so, which is why many linters (including ESLint) recommend disallowing `eval()`. However, there are some other ways to pass a string and have it interpreted as JavaScript code that have similar concerns. diff --git a/docs/rules/no-import-assign.md b/docs/rules/no-import-assign.md index 49595cda2f8..9aa66b8efc1 100644 --- a/docs/rules/no-import-assign.md +++ b/docs/rules/no-import-assign.md @@ -1,4 +1,6 @@ -# disallow assigning to imported bindings (no-import-assign) +# no-import-assign + +Disallows assigning to imported bindings. The updates of imported bindings by ES Modules cause runtime errors. diff --git a/docs/rules/no-inline-comments.md b/docs/rules/no-inline-comments.md index 237b2485a72..504f77bc1c3 100644 --- a/docs/rules/no-inline-comments.md +++ b/docs/rules/no-inline-comments.md @@ -1,4 +1,6 @@ -# disallow inline comments after code (no-inline-comments) +# no-inline-comments + +Disallows inline comments after code. 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. diff --git a/docs/rules/no-inner-declarations.md b/docs/rules/no-inner-declarations.md index 7c64e9dc19e..a6d1e899db3 100644 --- a/docs/rules/no-inner-declarations.md +++ b/docs/rules/no-inner-declarations.md @@ -1,4 +1,6 @@ -# disallow variable or `function` declarations in nested blocks (no-inner-declarations) +# no-inner-declarations + +Disallows variable or `function` declarations in nested blocks. 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](https://code.google.com/p/esprima/issues/detail?id=422). This only applies to function declarations; named or anonymous function expressions can occur anywhere an expression is permitted. diff --git a/docs/rules/no-invalid-regexp.md b/docs/rules/no-invalid-regexp.md index 478cbee9565..1dccd68f593 100644 --- a/docs/rules/no-invalid-regexp.md +++ b/docs/rules/no-invalid-regexp.md @@ -1,4 +1,6 @@ -# disallow invalid regular expression strings in `RegExp` constructors (no-invalid-regexp) +# no-invalid-regexp + +Disallows invalid regular expression strings in `RegExp` constructors. An invalid pattern in a regular expression literal is a `SyntaxError` when the code is parsed, but an invalid string in `RegExp` constructors throws a `SyntaxError` only when the code is executed. diff --git a/docs/rules/no-invalid-this.md b/docs/rules/no-invalid-this.md index f2f17d41a95..91e460da797 100644 --- a/docs/rules/no-invalid-this.md +++ b/docs/rules/no-invalid-this.md @@ -1,4 +1,6 @@ -# Disallow `this` keywords outside of classes or class-like objects. (no-invalid-this) +# no-invalid-this + +Disallows `this` keywords outside of classes or class-like objects. Under the strict mode, `this` keywords outside of classes or class-like objects might be `undefined` and raise a `TypeError`. diff --git a/docs/rules/no-irregular-whitespace.md b/docs/rules/no-irregular-whitespace.md index a24de703ab2..3545cd82839 100644 --- a/docs/rules/no-irregular-whitespace.md +++ b/docs/rules/no-irregular-whitespace.md @@ -1,4 +1,6 @@ -# disallow irregular whitespace (no-irregular-whitespace) +# no-irregular-whitespace + +Disallows irregular whitespace characters. 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. diff --git a/docs/rules/no-iterator.md b/docs/rules/no-iterator.md index 95b42a9ea1a..7405dd1295d 100644 --- a/docs/rules/no-iterator.md +++ b/docs/rules/no-iterator.md @@ -1,4 +1,6 @@ -# Disallow Iterator (no-iterator) +# no-iterator + +Disallows the use of the `__iterator__` property. The `__iterator__` property was a SpiderMonkey extension to JavaScript that could be used to create custom iterators that are compatible with JavaScript's `for in` and `for each` constructs. However, this property is now obsolete, so it should not be used. Here's an example of how this used to work: diff --git a/docs/rules/no-label-var.md b/docs/rules/no-label-var.md index 9541dea7b14..a4a101f1a38 100644 --- a/docs/rules/no-label-var.md +++ b/docs/rules/no-label-var.md @@ -1,4 +1,6 @@ -# Disallow Labels That Are Variables Names (no-label-var) +# no-label-var + +Disallows labels that are variable names. ## Rule Details diff --git a/docs/rules/no-labels.md b/docs/rules/no-labels.md index ea46ef00c08..6758a14329f 100644 --- a/docs/rules/no-labels.md +++ b/docs/rules/no-labels.md @@ -1,4 +1,6 @@ -# Disallow Labeled Statements (no-labels) +# no-labels + +Disallows labeled statements. Labeled statements in JavaScript are used in conjunction with `break` and `continue` to control flow around multiple loops. For example: diff --git a/docs/rules/no-lone-blocks.md b/docs/rules/no-lone-blocks.md index 49fdda6f8ac..2856c92820f 100644 --- a/docs/rules/no-lone-blocks.md +++ b/docs/rules/no-lone-blocks.md @@ -1,4 +1,6 @@ -# Disallow Unnecessary Nested Blocks (no-lone-blocks) +# no-lone-blocks + +Disallows unnecessary nested blocks. In JavaScript, prior to ES6, standalone code blocks delimited by curly braces do not create a new scope and have no use. For example, these curly braces do nothing to `foo`: diff --git a/docs/rules/no-lonely-if.md b/docs/rules/no-lonely-if.md index 4dab7ef7b63..25c8d39f9b1 100644 --- a/docs/rules/no-lonely-if.md +++ b/docs/rules/no-lonely-if.md @@ -1,4 +1,6 @@ -# disallow `if` statements as the only statement in `else` blocks (no-lonely-if) +# no-lonely-if + +Disallows `if` statements as the only statement in `else` blocks. If an `if` statement is the only statement in the `else` block, it is often clearer to use an `else if` form. diff --git a/docs/rules/no-loop-func.md b/docs/rules/no-loop-func.md index f39b868e5e3..05b3ad88ba2 100644 --- a/docs/rules/no-loop-func.md +++ b/docs/rules/no-loop-func.md @@ -1,4 +1,6 @@ -# Disallow Functions in Loops (no-loop-func) +# no-loop-func + +Disallows functions in loops. Writing functions within loops tends to result in errors due to the way the function creates a closure around the loop. For example: diff --git a/docs/rules/no-loss-of-precision.md b/docs/rules/no-loss-of-precision.md index 62d065981e6..f2dcf99d717 100644 --- a/docs/rules/no-loss-of-precision.md +++ b/docs/rules/no-loss-of-precision.md @@ -1,4 +1,6 @@ -# Disallow Number Literals That Lose Precision (no-loss-of-precision) +# no-loss-of-precision + +Disallows number literals that lose precision. This rule would disallow the use of number literals that immediately lose precision at runtime when converted to a JS `Number` due to 64-bit floating-point rounding. diff --git a/docs/rules/no-magic-numbers.md b/docs/rules/no-magic-numbers.md index dfe21d83c1b..9e59c736e79 100644 --- a/docs/rules/no-magic-numbers.md +++ b/docs/rules/no-magic-numbers.md @@ -1,4 +1,6 @@ -# Disallow Magic Numbers (no-magic-numbers) +# no-magic-numbers + +Disallows magic numbers. 'Magic numbers' are numbers that occur multiple times in code without an explicit meaning. They should preferably be replaced by named constants. diff --git a/docs/rules/no-misleading-character-class.md b/docs/rules/no-misleading-character-class.md index f6ef2fb9aa6..18744bf8456 100644 --- a/docs/rules/no-misleading-character-class.md +++ b/docs/rules/no-misleading-character-class.md @@ -1,4 +1,6 @@ -# Disallow characters which are made with multiple code points in character class syntax (no-misleading-character-class) +# no-misleading-character-class + +Disallows characters which are made with multiple code points in character class syntax. Unicode includes the characters which are made with multiple code points. RegExp character class syntax (`/[abc]/`) cannot handle characters which are made by multiple code points as a character; those characters will be dissolved to each code point. For example, `❇️` is made by `❇` (`U+2747`) and VARIATION SELECTOR-16 (`U+FE0F`). If this character is in RegExp character class, it will match to either `❇` (`U+2747`) or VARIATION SELECTOR-16 (`U+FE0F`) rather than `❇️`. diff --git a/docs/rules/no-mixed-operators.md b/docs/rules/no-mixed-operators.md index d1eac54945d..a5df9f0e887 100644 --- a/docs/rules/no-mixed-operators.md +++ b/docs/rules/no-mixed-operators.md @@ -1,4 +1,6 @@ -# Disallow mixes of different operators (no-mixed-operators) +# no-mixed-operators + +Disallows mixes of different operators. Enclosing complex expressions by parentheses clarifies the developer's intention, which makes the code more readable. This rule warns when different operators are used consecutively without parentheses in an expression. diff --git a/docs/rules/no-mixed-requires.md b/docs/rules/no-mixed-requires.md index c697d04e865..9b22c18588a 100644 --- a/docs/rules/no-mixed-requires.md +++ b/docs/rules/no-mixed-requires.md @@ -1,4 +1,6 @@ -# disallow `require` calls to be mixed with regular variable declarations (no-mixed-requires) +# no-mixed-requires + +Disallows `require` calls to be mixed with regular variable declarations. This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). diff --git a/docs/rules/no-mixed-spaces-and-tabs.md b/docs/rules/no-mixed-spaces-and-tabs.md index 9f156bb2b3f..4333a835c90 100644 --- a/docs/rules/no-mixed-spaces-and-tabs.md +++ b/docs/rules/no-mixed-spaces-and-tabs.md @@ -1,4 +1,6 @@ -# disallow mixed spaces and tabs for indentation (no-mixed-spaces-and-tabs) +# no-mixed-spaces-and-tabs + +Disallows mixed spaces and tabs for indentation. 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. diff --git a/docs/rules/no-multi-assign.md b/docs/rules/no-multi-assign.md index 14721dab0d8..8c49635d5d9 100644 --- a/docs/rules/no-multi-assign.md +++ b/docs/rules/no-multi-assign.md @@ -1,4 +1,6 @@ -# Disallow Use of Chained Assignment Expressions (no-multi-assign) +# no-multi-assign + +Disallows use of chained assignment expressions. Chaining the assignment of variables can lead to unexpected results and be difficult to read. diff --git a/docs/rules/no-multi-spaces.md b/docs/rules/no-multi-spaces.md index c4b12e938e8..47fa143cc98 100644 --- a/docs/rules/no-multi-spaces.md +++ b/docs/rules/no-multi-spaces.md @@ -1,4 +1,6 @@ -# Disallow multiple spaces (no-multi-spaces) +# no-multi-spaces + +Disallows multiple consecutive spaces. Multiple spaces in a row that are not used for indentation are typically mistakes. For example: diff --git a/docs/rules/no-multi-str.md b/docs/rules/no-multi-str.md index 2796bc8d3a3..e520a824061 100644 --- a/docs/rules/no-multi-str.md +++ b/docs/rules/no-multi-str.md @@ -1,4 +1,6 @@ -# Disallow Multiline Strings (no-multi-str) +# no-multi-str + +Disallows multiline strings. It's possible to create multiline strings in JavaScript by using a slash before a newline, such as: diff --git a/docs/rules/no-multiple-empty-lines.md b/docs/rules/no-multiple-empty-lines.md index 2e1bd0e529c..3bb7a6dc2a4 100644 --- a/docs/rules/no-multiple-empty-lines.md +++ b/docs/rules/no-multiple-empty-lines.md @@ -1,4 +1,6 @@ -# disallow multiple empty lines (no-multiple-empty-lines) +# no-multiple-empty-lines + +Disallows multiple empty lines. Some developers prefer to have multiple blank lines removed, while others feel that it helps improve readability. Whitespace is useful for separating logical sections of code, but excess whitespace takes up more of the screen. diff --git a/docs/rules/no-native-reassign.md b/docs/rules/no-native-reassign.md index bfb511de15e..ca668413818 100644 --- a/docs/rules/no-native-reassign.md +++ b/docs/rules/no-native-reassign.md @@ -1,4 +1,6 @@ -# Disallow Reassignment of Native Objects (no-native-reassign) +# no-native-reassign + +Disallows reassignment of native objects. This rule was **deprecated** in ESLint v3.3.0 and replaced by the [no-global-assign](no-global-assign.md) rule. diff --git a/docs/rules/no-negated-condition.md b/docs/rules/no-negated-condition.md index 58addae69b3..cb2b3f66bcf 100644 --- a/docs/rules/no-negated-condition.md +++ b/docs/rules/no-negated-condition.md @@ -1,4 +1,6 @@ -# disallow negated conditions (no-negated-condition) +# no-negated-condition + +Disallows negated conditions. Negated conditions are more difficult to understand. Code can be made more readable by inverting the condition instead. diff --git a/docs/rules/no-negated-in-lhs.md b/docs/rules/no-negated-in-lhs.md index 8961944ab60..16bdfd09288 100644 --- a/docs/rules/no-negated-in-lhs.md +++ b/docs/rules/no-negated-in-lhs.md @@ -1,4 +1,6 @@ -# disallow negating the left operand in `in` expressions (no-negated-in-lhs) +# no-negated-in-lhs + +Disallows negating the left operand in `in` expressions. This rule was **deprecated** in ESLint v3.3.0 and replaced by the [no-unsafe-negation](no-unsafe-negation.md) rule. diff --git a/docs/rules/no-nested-ternary.md b/docs/rules/no-nested-ternary.md index 8c9cb0dbf07..9f359360db0 100644 --- a/docs/rules/no-nested-ternary.md +++ b/docs/rules/no-nested-ternary.md @@ -1,4 +1,6 @@ -# disallow nested ternary expressions (no-nested-ternary) +# no-nested-ternary + +Disallows nested ternary expressions. Nesting ternary expressions can make code more difficult to understand. diff --git a/docs/rules/no-new-func.md b/docs/rules/no-new-func.md index 7bdfc9ec732..dd2b325aead 100644 --- a/docs/rules/no-new-func.md +++ b/docs/rules/no-new-func.md @@ -1,4 +1,6 @@ -# Disallow Function Constructor (no-new-func) +# no-new-func + +Disallows `new` operators with the `Function` object. It's possible to create functions in JavaScript from strings at runtime using the `Function` constructor, such as: diff --git a/docs/rules/no-new-object.md b/docs/rules/no-new-object.md index aef055c810b..7dd70053596 100644 --- a/docs/rules/no-new-object.md +++ b/docs/rules/no-new-object.md @@ -1,4 +1,6 @@ -# disallow `Object` constructors (no-new-object) +# no-new-object + +Disallows `new` operators with the `Object` object. The `Object` constructor is used to create new generic objects in JavaScript, such as: diff --git a/docs/rules/no-new-require.md b/docs/rules/no-new-require.md index 6cf1242f72b..69001bc168b 100644 --- a/docs/rules/no-new-require.md +++ b/docs/rules/no-new-require.md @@ -1,4 +1,6 @@ -# Disallow new require (no-new-require) +# no-new-require + +Disallows `new` operators with calls to `require`. This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). diff --git a/docs/rules/no-new-symbol.md b/docs/rules/no-new-symbol.md index 66167cf6b2b..e5684e7911e 100644 --- a/docs/rules/no-new-symbol.md +++ b/docs/rules/no-new-symbol.md @@ -1,4 +1,6 @@ -# Disallow Symbol Constructor (no-new-symbol) +# no-new-symbol + +Disallows `new` operators with the `Symbol` object. `Symbol` is not intended to be used with the `new` operator, but to be called as a function. diff --git a/docs/rules/no-new-wrappers.md b/docs/rules/no-new-wrappers.md index 50fdacd784b..04ef96117ac 100644 --- a/docs/rules/no-new-wrappers.md +++ b/docs/rules/no-new-wrappers.md @@ -1,4 +1,6 @@ -# Disallow Primitive Wrapper Instances (no-new-wrappers) +# no-new-wrappers + +Disallows `new` operators with the `String`, `Number`, and `Boolean` objects. There are three primitive types in JavaScript that have wrapper objects: string, number, and boolean. These are represented by the constructors `String`, `Number`, and `Boolean`, respectively. The primitive wrapper types are used whenever one of these primitive values is read, providing them with object-like capabilities such as methods. Behind the scenes, an object of the associated wrapper type is created and then destroyed, which is why you can call methods on primitive values, such as: diff --git a/docs/rules/no-new.md b/docs/rules/no-new.md index 19ae097192d..0e7020c87e6 100644 --- a/docs/rules/no-new.md +++ b/docs/rules/no-new.md @@ -1,4 +1,6 @@ -# Disallow new For Side Effects (no-new) +# no-new + +Disallows `new` operators outside of assignments or comparisons. The goal of using `new` with a constructor is typically to create an object of a particular type and store that object in a variable, such as: diff --git a/docs/rules/no-nonoctal-decimal-escape.md b/docs/rules/no-nonoctal-decimal-escape.md index ad210a7375b..db8bf55193f 100644 --- a/docs/rules/no-nonoctal-decimal-escape.md +++ b/docs/rules/no-nonoctal-decimal-escape.md @@ -1,4 +1,6 @@ -# Disallow `\8` and `\9` escape sequences in string literals (no-nonoctal-decimal-escape) +# no-nonoctal-decimal-escape + +Disallows `\8` and `\9` escape sequences in string literals. Although not being specified in the language until ECMAScript 2021, `\8` and `\9` escape sequences in string literals were allowed in most JavaScript engines, and treated as "useless" escapes: diff --git a/docs/rules/no-obj-calls.md b/docs/rules/no-obj-calls.md index 7c8f715cedc..0d0c1e8b146 100644 --- a/docs/rules/no-obj-calls.md +++ b/docs/rules/no-obj-calls.md @@ -1,4 +1,6 @@ -# disallow calling global object properties as functions (no-obj-calls) +# no-obj-calls + +Disallows calling global object properties as functions. ECMAScript provides several global objects that are intended to be used as-is. Some of these objects look as if they could be constructors due their capitalization (such as `Math` and `JSON`) but will throw an error if you try to execute them as functions. diff --git a/docs/rules/no-octal-escape.md b/docs/rules/no-octal-escape.md index f595217f9c2..3ff43f00c90 100644 --- a/docs/rules/no-octal-escape.md +++ b/docs/rules/no-octal-escape.md @@ -1,4 +1,6 @@ -# disallow octal escape sequences in string literals (no-octal-escape) +# no-octal-escape + +Disallows octal escape sequences in string literals. 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. diff --git a/docs/rules/no-octal.md b/docs/rules/no-octal.md index a84fcce04aa..4757385c20d 100644 --- a/docs/rules/no-octal.md +++ b/docs/rules/no-octal.md @@ -1,4 +1,6 @@ -# disallow octal literals (no-octal) +# no-octal + +Disallows octal literals. Octal literals are numerals that begin with a leading zero, such as: diff --git a/docs/rules/no-param-reassign.md b/docs/rules/no-param-reassign.md index 29952c370ea..b5c86797769 100644 --- a/docs/rules/no-param-reassign.md +++ b/docs/rules/no-param-reassign.md @@ -1,4 +1,6 @@ -# Disallow Reassignment of Function Parameters (no-param-reassign) +# no-param-reassign + +Disallows reassignment of function parameters. Assignment to variables declared as function parameters can be misleading and lead to confusing behavior, as modifying function parameters will also mutate the `arguments` object. Often, assignment to function parameters is unintended and indicative of a mistake or programmer error. diff --git a/docs/rules/no-path-concat.md b/docs/rules/no-path-concat.md index fddf27b9e45..23ed0cd6e40 100644 --- a/docs/rules/no-path-concat.md +++ b/docs/rules/no-path-concat.md @@ -1,4 +1,6 @@ -# Disallow string concatenation when using `__dirname` and `__filename` (no-path-concat) +# no-path-concat + +Disallows string concatenation when using `__dirname` and `__filename`. This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). diff --git a/docs/rules/no-plusplus.md b/docs/rules/no-plusplus.md index e1b1ca337d1..f0c3b768440 100644 --- a/docs/rules/no-plusplus.md +++ b/docs/rules/no-plusplus.md @@ -1,4 +1,6 @@ -# disallow the unary operators `++` and `--` (no-plusplus) +# no-plusplus + +Disallows the unary operators `++` and `--`. Because the unary `++` and `--` operators are subject to automatic semicolon insertion, differences in whitespace can change semantics of source code. diff --git a/docs/rules/no-process-env.md b/docs/rules/no-process-env.md index 4655e965ef7..d7ce5a78165 100644 --- a/docs/rules/no-process-env.md +++ b/docs/rules/no-process-env.md @@ -1,4 +1,6 @@ -# Disallow process.env (no-process-env) +# no-process-env + +Disallows the use of `process.env`. This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). diff --git a/docs/rules/no-process-exit.md b/docs/rules/no-process-exit.md index 54f2661ae2c..53ddf1c4576 100644 --- a/docs/rules/no-process-exit.md +++ b/docs/rules/no-process-exit.md @@ -1,4 +1,6 @@ -# Disallow process.exit() (no-process-exit) +# no-process-exit + +Disallows the use of `process.exit()`. This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). diff --git a/docs/rules/no-promise-executor-return.md b/docs/rules/no-promise-executor-return.md index 87611c914ed..59076b55f4b 100644 --- a/docs/rules/no-promise-executor-return.md +++ b/docs/rules/no-promise-executor-return.md @@ -1,4 +1,6 @@ -# Disallow returning values from Promise executor functions (no-promise-executor-return) +# no-promise-executor-return + +Disallows returning values from Promise executor functions. The `new Promise` constructor accepts a single argument, called an *executor*. diff --git a/docs/rules/no-proto.md b/docs/rules/no-proto.md index 9543b7ef20e..fbc6b46114a 100644 --- a/docs/rules/no-proto.md +++ b/docs/rules/no-proto.md @@ -1,4 +1,6 @@ -# Disallow Use of `__proto__` (no-proto) +# no-proto + +Disallows the use of the `__proto__` property. `__proto__` property has been deprecated as of ECMAScript 3.1 and shouldn't be used in the code. Use `Object.getPrototypeOf` and `Object.setPrototypeOf` instead. diff --git a/docs/rules/no-prototype-builtins.md b/docs/rules/no-prototype-builtins.md index 7132bcbdfd4..93423d90845 100644 --- a/docs/rules/no-prototype-builtins.md +++ b/docs/rules/no-prototype-builtins.md @@ -1,4 +1,6 @@ -# Disallow use of Object.prototypes builtins directly (no-prototype-builtins) +# no-prototype-builtins + +Disallows calling some `Object.prototype` methods directly on objects. In ECMAScript 5.1, `Object.create` was added, which enables the creation of objects with a specified `[[Prototype]]`. `Object.create(null)` is a common pattern used to create objects that will be used as a Map. This can lead to errors when it is assumed that objects will have properties from `Object.prototype`. This rule prevents calling some `Object.prototype` methods directly from an object. diff --git a/docs/rules/no-redeclare.md b/docs/rules/no-redeclare.md index bd029ebc1d4..ed107f28c58 100644 --- a/docs/rules/no-redeclare.md +++ b/docs/rules/no-redeclare.md @@ -1,4 +1,6 @@ -# disallow variable redeclaration (no-redeclare) +# no-redeclare + +Disallows variable redeclarations. In JavaScript, it's possible to redeclare the same variable name using `var`. This can lead to confusion as to where the variable is actually declared and initialized. diff --git a/docs/rules/no-regex-spaces.md b/docs/rules/no-regex-spaces.md index 63a5174c494..158ee9ce878 100644 --- a/docs/rules/no-regex-spaces.md +++ b/docs/rules/no-regex-spaces.md @@ -1,4 +1,6 @@ -# disallow multiple spaces in regular expression literals (no-regex-spaces) +# no-regex-spaces + +Disallows multiple spaces in regular expression literals. 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: diff --git a/docs/rules/no-reserved-keys.md b/docs/rules/no-reserved-keys.md index f1f8e41d27e..8eb2b56ed3d 100644 --- a/docs/rules/no-reserved-keys.md +++ b/docs/rules/no-reserved-keys.md @@ -1,4 +1,6 @@ -# no-reserved-keys: disallow unquoted reserved words as property names in object literals +# no-reserved-keys + +Disallows unquoted reserved words as property names in object literals. (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [quote-props](quote-props.md) rule. diff --git a/docs/rules/no-restricted-exports.md b/docs/rules/no-restricted-exports.md index 667a9c3fd17..9474e6eae29 100644 --- a/docs/rules/no-restricted-exports.md +++ b/docs/rules/no-restricted-exports.md @@ -1,4 +1,6 @@ -# Disallow specified names in exports (no-restricted-exports) +# no-restricted-exports + +Disallows specified names in exports. In a project, certain names may be disallowed from being used as exported names for various reasons. diff --git a/docs/rules/no-restricted-globals.md b/docs/rules/no-restricted-globals.md index dd3e15b7b60..4b7b9dfbb9b 100644 --- a/docs/rules/no-restricted-globals.md +++ b/docs/rules/no-restricted-globals.md @@ -1,4 +1,6 @@ -# Disallow specific global variables (no-restricted-globals) +# no-restricted-globals + +Disallows specific global variables. 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. diff --git a/docs/rules/no-restricted-imports.md b/docs/rules/no-restricted-imports.md index 3a88fabcacd..3337ab83217 100644 --- a/docs/rules/no-restricted-imports.md +++ b/docs/rules/no-restricted-imports.md @@ -1,4 +1,6 @@ -# Disallow specific imports (no-restricted-imports) +# no-restricted-imports + +Disallows specific imports. Imports are an ES6/ES2015 standard for making the functionality of other modules available in your current module. In CommonJS this is implemented through the `require()` call which makes this ESLint rule roughly equivalent to its CommonJS counterpart `no-restricted-modules`. diff --git a/docs/rules/no-restricted-modules.md b/docs/rules/no-restricted-modules.md index 3bce058049e..b82ebe40df7 100644 --- a/docs/rules/no-restricted-modules.md +++ b/docs/rules/no-restricted-modules.md @@ -1,4 +1,6 @@ -# Disallow Node.js modules (no-restricted-modules) +# no-restricted-modules + +Disallows Node.js modules. This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). diff --git a/docs/rules/no-restricted-properties.md b/docs/rules/no-restricted-properties.md index 468d0b36a1b..b2b2f128a9b 100644 --- a/docs/rules/no-restricted-properties.md +++ b/docs/rules/no-restricted-properties.md @@ -1,4 +1,6 @@ -# disallow certain object properties (no-restricted-properties) +# no-restricted-properties + +Disallows certain object properties. Certain properties on objects may be disallowed in a codebase. This is useful for deprecating an API or restricting usage of a module's methods. For example, you may want to disallow using `describe.only` when using Mocha or telling people to use `Object.assign` instead of `_.extend`. diff --git a/docs/rules/no-restricted-syntax.md b/docs/rules/no-restricted-syntax.md index 06651672177..9b21aea5ba4 100644 --- a/docs/rules/no-restricted-syntax.md +++ b/docs/rules/no-restricted-syntax.md @@ -1,4 +1,6 @@ -# disallow specified syntax (no-restricted-syntax) +# no-restricted-syntax + +Disallows specified syntax. JavaScript has a lot of language features, and not everyone likes all of them. As a result, some projects choose to disallow the use of certain language features altogether. For instance, you might decide to disallow the use of `try-catch` or `class`, or you might decide to disallow the use of the `in` operator. diff --git a/docs/rules/no-return-assign.md b/docs/rules/no-return-assign.md index ed40c275437..60d18a0805f 100644 --- a/docs/rules/no-return-assign.md +++ b/docs/rules/no-return-assign.md @@ -1,4 +1,6 @@ -# Disallow Assignment in return Statement (no-return-assign) +# no-return-assign + +Disallows assignment operators in `return` statements. One of the interesting, and sometimes confusing, aspects of JavaScript is that assignment can happen at almost any point. Because of this, an errant equals sign can end up causing assignment when the true intent was to do a comparison. This is especially true when using a `return` statement. For example: diff --git a/docs/rules/no-return-await.md b/docs/rules/no-return-await.md index fa7c7fc8e5c..1108ff1f146 100644 --- a/docs/rules/no-return-await.md +++ b/docs/rules/no-return-await.md @@ -1,4 +1,6 @@ -# Disallows unnecessary `return await` (no-return-await) +# no-return-await + +Disallows unnecessary `return await`. Using `return await` inside an `async function` keeps the current function in the call stack until the Promise that is being awaited has resolved, at the cost of an extra microtask before resolving the outer Promise. `return await` can also be used in a try/catch statement to catch errors from another function that returns a Promise. diff --git a/docs/rules/no-script-url.md b/docs/rules/no-script-url.md index 5c71eb41327..82280bd9b38 100644 --- a/docs/rules/no-script-url.md +++ b/docs/rules/no-script-url.md @@ -1,4 +1,6 @@ -# Disallow Script URLs (no-script-url) +# no-script-url + +Disallows `javascript:` URLs. Using `javascript:` URLs is considered by some as a form of `eval`. Code passed in `javascript:` URLs has to be parsed and evaluated by the browser in the same way that `eval` is processed. diff --git a/docs/rules/no-self-assign.md b/docs/rules/no-self-assign.md index 8b90cdfd3f1..e648f8fb895 100644 --- a/docs/rules/no-self-assign.md +++ b/docs/rules/no-self-assign.md @@ -1,4 +1,6 @@ -# Disallow Self Assignment (no-self-assign) +# no-self-assign + +Disallows assignments where both sides are exactly the same. 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. diff --git a/docs/rules/no-self-compare.md b/docs/rules/no-self-compare.md index a745de404fd..00e09f8e3ae 100644 --- a/docs/rules/no-self-compare.md +++ b/docs/rules/no-self-compare.md @@ -1,4 +1,6 @@ -# Disallow Self Compare (no-self-compare) +# no-self-compare + +Disallows comparisons where both sides are exactly the same. Comparing a variable against itself is usually an error, either a typo or refactoring error. It is confusing to the reader and may potentially introduce a runtime error. diff --git a/docs/rules/no-sequences.md b/docs/rules/no-sequences.md index f12c46573b7..b6dfaf7a006 100644 --- a/docs/rules/no-sequences.md +++ b/docs/rules/no-sequences.md @@ -1,4 +1,6 @@ -# Disallow Use of the Comma Operator (no-sequences) +# no-sequences + +Disallows use of the comma operator. 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: diff --git a/docs/rules/no-setter-return.md b/docs/rules/no-setter-return.md index 7e3b1323ff1..9c39199020f 100644 --- a/docs/rules/no-setter-return.md +++ b/docs/rules/no-setter-return.md @@ -1,4 +1,6 @@ -# Disallow returning values from setters (no-setter-return) +# no-setter-return + +Disallows returning values from setters. Setters cannot return values. diff --git a/docs/rules/no-shadow-restricted-names.md b/docs/rules/no-shadow-restricted-names.md index f7e6530d4a3..7b2328f3b90 100644 --- a/docs/rules/no-shadow-restricted-names.md +++ b/docs/rules/no-shadow-restricted-names.md @@ -1,4 +1,6 @@ -# Disallow Shadowing of Restricted Names (no-shadow-restricted-names) +# no-shadow-restricted-names + +Disallows identifiers from shadowing restricted names. ES5 §15.1.1 Value Properties of the Global Object (`NaN`, `Infinity`, `undefined`) as well as strict mode restricted identifiers `eval` and `arguments` are considered to be restricted names in JavaScript. Defining them to mean something else can have unintended consequences and confuse others reading the code. For example, there's nothing preventing you from writing: diff --git a/docs/rules/no-shadow.md b/docs/rules/no-shadow.md index bf8400a4239..605a0eb2dfc 100644 --- a/docs/rules/no-shadow.md +++ b/docs/rules/no-shadow.md @@ -1,4 +1,6 @@ -# disallow variable declarations from shadowing variables declared in the outer scope (no-shadow) +# no-shadow + +Disallows variable declarations from shadowing variables declared in the outer scope. Shadowing is the process by which a local variable shares the same name as a variable in its containing scope. For example: diff --git a/docs/rules/no-space-before-semi.md b/docs/rules/no-space-before-semi.md index 2e142ddee02..a309312c372 100644 --- a/docs/rules/no-space-before-semi.md +++ b/docs/rules/no-space-before-semi.md @@ -1,4 +1,6 @@ -# no-space-before-semi: disallow spaces before semicolons +# no-space-before-semi + +Disallows spaces before semicolons. (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [semi-spacing](semi-spacing.md) rule. diff --git a/docs/rules/no-spaced-func.md b/docs/rules/no-spaced-func.md index d424049b21a..e4bf0993989 100644 --- a/docs/rules/no-spaced-func.md +++ b/docs/rules/no-spaced-func.md @@ -1,4 +1,6 @@ -# disallow spacing between function identifiers and their applications (no-spaced-func) +# no-spaced-func + +Disallows spacing between function identifiers and their applications. This rule was **deprecated** in ESLint v3.3.0 and replaced by the [func-call-spacing](func-call-spacing.md) rule. diff --git a/docs/rules/no-sparse-arrays.md b/docs/rules/no-sparse-arrays.md index 826cfd87f78..6720c4b9c38 100644 --- a/docs/rules/no-sparse-arrays.md +++ b/docs/rules/no-sparse-arrays.md @@ -1,4 +1,6 @@ -# disallow sparse arrays (no-sparse-arrays) +# no-sparse-arrays + +Disallows sparse arrays. Sparse arrays contain empty slots, most frequently due to multiple commas being used in an array literal, such as: diff --git a/docs/rules/no-sync.md b/docs/rules/no-sync.md index 949df6d36b4..57d33d93343 100644 --- a/docs/rules/no-sync.md +++ b/docs/rules/no-sync.md @@ -1,4 +1,6 @@ -# Disallow Synchronous Methods (no-sync) +# no-sync + +Disallows synchronous methods. This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node). diff --git a/docs/rules/no-tabs.md b/docs/rules/no-tabs.md index 4e02d9a04c6..29d8f34cc6a 100644 --- a/docs/rules/no-tabs.md +++ b/docs/rules/no-tabs.md @@ -1,4 +1,6 @@ -# disallow all tabs (no-tabs) +# no-tabs + +Disallows all tabs. Some style guides don't allow the use of tab characters at all, including within comments. diff --git a/docs/rules/no-template-curly-in-string.md b/docs/rules/no-template-curly-in-string.md index 68a237de988..e8e0d7349e8 100644 --- a/docs/rules/no-template-curly-in-string.md +++ b/docs/rules/no-template-curly-in-string.md @@ -1,4 +1,6 @@ -# Disallow template literal placeholder syntax in regular strings (no-template-curly-in-string) +# no-template-curly-in-string + +Disallows template literal placeholder syntax in regular strings. ECMAScript 6 allows programmers to create strings containing variable or expressions using template literals, instead of string concatenation, by writing expressions like `${variable}` between two backtick quotes (\`). It can be easy to use the wrong quotes when wanting to use template literals, by writing `"${variable}"`, and end up with the literal value `"${variable}"` instead of a string containing the value of the injected expressions. diff --git a/docs/rules/no-ternary.md b/docs/rules/no-ternary.md index 3c95f827d1e..357da016630 100644 --- a/docs/rules/no-ternary.md +++ b/docs/rules/no-ternary.md @@ -1,4 +1,6 @@ -# disallow ternary operators (no-ternary) +# no-ternary + +Disallows ternary operators. 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. diff --git a/docs/rules/no-this-before-super.md b/docs/rules/no-this-before-super.md index 53223b704b3..e783a876c33 100644 --- a/docs/rules/no-this-before-super.md +++ b/docs/rules/no-this-before-super.md @@ -1,4 +1,6 @@ -# Disallow use of `this`/`super` before calling `super()` in constructors. (no-this-before-super) +# no-this-before-super + +Disallows use of `this`/`super` before calling `super()` in constructors. In the constructor of derived classes, if `this`/`super` are used before `super()` calls, it raises a reference error. diff --git a/docs/rules/no-throw-literal.md b/docs/rules/no-throw-literal.md index ecb19edd16e..452a8afb755 100644 --- a/docs/rules/no-throw-literal.md +++ b/docs/rules/no-throw-literal.md @@ -1,4 +1,6 @@ -# Restrict what can be thrown as an exception (no-throw-literal) +# no-throw-literal + +Restricts what can be thrown as an exception. It is considered good practice to only `throw` the `Error` object itself or an object using the `Error` object as base objects for user-defined exceptions. The fundamental benefit of `Error` objects is that they automatically keep track of where they were built and originated. diff --git a/docs/rules/no-trailing-spaces.md b/docs/rules/no-trailing-spaces.md index e0724b7a40a..0a94173ed84 100644 --- a/docs/rules/no-trailing-spaces.md +++ b/docs/rules/no-trailing-spaces.md @@ -1,4 +1,6 @@ -# disallow trailing whitespace at the end of lines (no-trailing-spaces) +# no-trailing-spaces + +Disallows trailing whitespace at the end of lines. 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 check-in. diff --git a/docs/rules/no-undef-init.md b/docs/rules/no-undef-init.md index 10bde7769bc..f0dda6fab7a 100644 --- a/docs/rules/no-undef-init.md +++ b/docs/rules/no-undef-init.md @@ -1,4 +1,6 @@ -# Disallow Initializing to undefined (no-undef-init) +# no-undef-init + +Disallows initializing variables to `undefined`. In JavaScript, a variable that is declared and not initialized to any value automatically gets the value of `undefined`. For example: diff --git a/docs/rules/no-undef.md b/docs/rules/no-undef.md index f31f2877c23..71f6b03294d 100644 --- a/docs/rules/no-undef.md +++ b/docs/rules/no-undef.md @@ -1,4 +1,6 @@ -# Disallow Undeclared Variables (no-undef) +# no-undef + +Disallows the use of undeclared variables unless mentioned in `/*global */` comments. This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for example, from forgetting the `var` keyword in a `for` loop initializer). diff --git a/docs/rules/no-undefined.md b/docs/rules/no-undefined.md index 3d97d5b1d24..9313dfb23ba 100644 --- a/docs/rules/no-undefined.md +++ b/docs/rules/no-undefined.md @@ -1,4 +1,6 @@ -# Disallow Use of `undefined` Variable (no-undefined) +# no-undefined + +Disallows the use of `undefined` as an identifier. The `undefined` variable in JavaScript 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: diff --git a/docs/rules/no-underscore-dangle.md b/docs/rules/no-underscore-dangle.md index 5e33ed5d0fd..a4535d3f481 100644 --- a/docs/rules/no-underscore-dangle.md +++ b/docs/rules/no-underscore-dangle.md @@ -1,4 +1,6 @@ -# disallow dangling underscores in identifiers (no-underscore-dangle) +# no-underscore-dangle + +Disallows dangling underscores in identifiers. 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: diff --git a/docs/rules/no-unexpected-multiline.md b/docs/rules/no-unexpected-multiline.md index a328f83b280..65b18bf8389 100644 --- a/docs/rules/no-unexpected-multiline.md +++ b/docs/rules/no-unexpected-multiline.md @@ -1,4 +1,6 @@ -# disallow confusing multiline expressions (no-unexpected-multiline) +# no-unexpected-multiline + +Disallows confusing multiline expressions. Semicolons are usually optional in JavaScript, because of automatic semicolon insertion (ASI). You can require or disallow semicolons with the [semi](./semi.md) rule. diff --git a/docs/rules/no-unmodified-loop-condition.md b/docs/rules/no-unmodified-loop-condition.md index 7d9bceeedef..8a4c8cc9f5b 100644 --- a/docs/rules/no-unmodified-loop-condition.md +++ b/docs/rules/no-unmodified-loop-condition.md @@ -1,4 +1,6 @@ -# Disallow unmodified conditions of loops (no-unmodified-loop-condition) +# no-unmodified-loop-condition + +Disallows unmodified conditions of loops. Variables in a loop condition often are modified in the loop. If not, it's possibly a mistake. diff --git a/docs/rules/no-unneeded-ternary.md b/docs/rules/no-unneeded-ternary.md index e5d4e80112d..5d8575f5888 100644 --- a/docs/rules/no-unneeded-ternary.md +++ b/docs/rules/no-unneeded-ternary.md @@ -1,4 +1,6 @@ -# disallow ternary operators when simpler alternatives exist (no-unneeded-ternary) +# no-unneeded-ternary + +Disallows ternary operators when simpler alternatives exist. 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: diff --git a/docs/rules/no-unreachable-loop.md b/docs/rules/no-unreachable-loop.md index 88324df8d0d..24668e9760c 100644 --- a/docs/rules/no-unreachable-loop.md +++ b/docs/rules/no-unreachable-loop.md @@ -1,4 +1,6 @@ -# Disallow loops with a body that allows only one iteration (no-unreachable-loop) +# no-unreachable-loop + +Disallows loops with a body that allows only one iteration. A loop that can never reach the second iteration is a possible error in the code. diff --git a/docs/rules/no-unreachable.md b/docs/rules/no-unreachable.md index 2fe8a6916e3..d4689c0b1ee 100644 --- a/docs/rules/no-unreachable.md +++ b/docs/rules/no-unreachable.md @@ -1,4 +1,6 @@ -# disallow unreachable code after `return`, `throw`, `continue`, and `break` statements (no-unreachable) +# no-unreachable + +Disallows unreachable code after `return`, `throw`, `continue`, and `break` statements. Because the `return`, `throw`, `break`, and `continue` statements unconditionally exit a block of code, any statements after them cannot be executed. Unreachable statements are usually a mistake. diff --git a/docs/rules/no-unsafe-finally.md b/docs/rules/no-unsafe-finally.md index fb3bb1ea5be..56325e2a9c7 100644 --- a/docs/rules/no-unsafe-finally.md +++ b/docs/rules/no-unsafe-finally.md @@ -1,4 +1,6 @@ -# disallow control flow statements in `finally` blocks (no-unsafe-finally) +# no-unsafe-finally + +Disallows control flow statements in `finally` blocks. JavaScript suspends the control flow statements of `try` and `catch` blocks until the execution of `finally` block finishes. So, when `return`, `throw`, `break`, or `continue` is used in `finally`, control flow statements inside `try` and `catch` are overwritten, which is considered as unexpected behavior. Such as: diff --git a/docs/rules/no-unsafe-negation.md b/docs/rules/no-unsafe-negation.md index a8728474514..066bb5df6ee 100644 --- a/docs/rules/no-unsafe-negation.md +++ b/docs/rules/no-unsafe-negation.md @@ -1,4 +1,6 @@ -# disallow negating the left operand of relational operators (no-unsafe-negation) +# no-unsafe-negation + +Disallows negating the left operand of relational operators. Just as developers might type `-a + b` when they mean `-(a + b)` for the negative of a sum, they might type `!key in object` by mistake when they almost certainly mean `!(key in object)` to test that a key is not in an object. `!obj instanceof Ctor` is similar. diff --git a/docs/rules/no-unsafe-optional-chaining.md b/docs/rules/no-unsafe-optional-chaining.md index 28b4c40540d..e57d6cd28d7 100644 --- a/docs/rules/no-unsafe-optional-chaining.md +++ b/docs/rules/no-unsafe-optional-chaining.md @@ -1,4 +1,6 @@ -# disallow use of optional chaining in contexts where the `undefined` value is not allowed (no-unsafe-optional-chaining) +# no-unsafe-optional-chaining + +Disallows use of optional chaining in contexts where the `undefined` value is not allowed. The optional chaining (`?.`) expression can short-circuit with a return value of `undefined`. Therefore, treating an evaluated optional chaining expression as a function, object, number, etc., can cause TypeError or unexpected results. For example: diff --git a/docs/rules/no-unused-expressions.md b/docs/rules/no-unused-expressions.md index 89cfb334e80..c6a3fab9af2 100644 --- a/docs/rules/no-unused-expressions.md +++ b/docs/rules/no-unused-expressions.md @@ -1,4 +1,6 @@ -# Disallow Unused Expressions (no-unused-expressions) +# no-unused-expressions + +Disallows unused expressions. An unused expression which has no effect on the state of the program indicates a logic error. diff --git a/docs/rules/no-unused-labels.md b/docs/rules/no-unused-labels.md index 97b21badd26..f400697cf3b 100644 --- a/docs/rules/no-unused-labels.md +++ b/docs/rules/no-unused-labels.md @@ -1,4 +1,6 @@ -# Disallow Unused Labels (no-unused-labels) +# no-unused-labels + +Disallows unused labels. Labels that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. diff --git a/docs/rules/no-unused-private-class-members.md b/docs/rules/no-unused-private-class-members.md index 2eb9f4bf485..092f1fe61ad 100644 --- a/docs/rules/no-unused-private-class-members.md +++ b/docs/rules/no-unused-private-class-members.md @@ -1,4 +1,6 @@ -# Disallow Unused Private Class Members (no-unused-private-class-members) +# no-unused-private-class-members + +Disallows unused private class members. Private class members that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such class members take up space in the code and can lead to confusion by readers. diff --git a/docs/rules/no-unused-vars.md b/docs/rules/no-unused-vars.md index 24eb337c637..09761271bdf 100644 --- a/docs/rules/no-unused-vars.md +++ b/docs/rules/no-unused-vars.md @@ -1,4 +1,6 @@ -# Disallow Unused Variables (no-unused-vars) +# no-unused-vars + +Disallows unused variables. 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. diff --git a/docs/rules/no-use-before-define.md b/docs/rules/no-use-before-define.md index 8af260ea0ad..1fb9dfaf80b 100644 --- a/docs/rules/no-use-before-define.md +++ b/docs/rules/no-use-before-define.md @@ -1,4 +1,6 @@ -# Disallow Early Use (no-use-before-define) +# no-use-before-define + +Disallows the use of variables before they are defined. 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. diff --git a/docs/rules/no-useless-backreference.md b/docs/rules/no-useless-backreference.md index e72b050d02e..c488f922fa3 100644 --- a/docs/rules/no-useless-backreference.md +++ b/docs/rules/no-useless-backreference.md @@ -1,4 +1,6 @@ -# Disallow useless backreferences in regular expressions (no-useless-backreference) +# no-useless-backreference + +Disallows useless backreferences in regular expressions. In JavaScript regular expressions, it's syntactically valid to define a backreference to a group that belongs to another alternative part of the pattern, a backreference to a group that appears after the backreference, a backreference to a group that contains that backreference, or a backreference to a group that is inside a negative lookaround. However, by the specification, in any of these cases the backreference always ends up matching only zero-length (the empty string), regardless of the context in which the backreference and the group appear. diff --git a/docs/rules/no-useless-call.md b/docs/rules/no-useless-call.md index 196cc6df36a..5f252cf1654 100644 --- a/docs/rules/no-useless-call.md +++ b/docs/rules/no-useless-call.md @@ -1,4 +1,6 @@ -# Disallow unnecessary `.call()` and `.apply()`. (no-useless-call) +# no-useless-call + +Disallows unnecessary `.call()` and `.apply()`. The function invocation can be written by `Function.prototype.call()` and `Function.prototype.apply()`. But `Function.prototype.call()` and `Function.prototype.apply()` are slower than the normal function invocation. diff --git a/docs/rules/no-useless-catch.md b/docs/rules/no-useless-catch.md index 0562063f634..12c5bc30664 100644 --- a/docs/rules/no-useless-catch.md +++ b/docs/rules/no-useless-catch.md @@ -1,4 +1,6 @@ -# Disallow unnecessary catch clauses (no-useless-catch) +# no-useless-catch + +Disallows unnecessary catch clauses. A `catch` clause that only rethrows the original error is redundant, and has no effect on the runtime behavior of the program. These redundant clauses can be a source of confusion and code bloat, so it's better to disallow these unnecessary `catch` clauses. diff --git a/docs/rules/no-useless-computed-key.md b/docs/rules/no-useless-computed-key.md index 2d3ddb3d50b..ce31c51aa87 100644 --- a/docs/rules/no-useless-computed-key.md +++ b/docs/rules/no-useless-computed-key.md @@ -1,4 +1,6 @@ -# Disallow unnecessary computed property keys in objects and classes (no-useless-computed-key) +# no-useless-computed-key + +Disallows unnecessary computed property keys in objects and classes. It's unnecessary to use computed properties with literals such as: diff --git a/docs/rules/no-useless-concat.md b/docs/rules/no-useless-concat.md index 5dc5f1fc0d2..fcfca8329ac 100644 --- a/docs/rules/no-useless-concat.md +++ b/docs/rules/no-useless-concat.md @@ -1,4 +1,6 @@ -# Disallow unnecessary concatenation of strings (no-useless-concat) +# no-useless-concat + +Disallows unnecessary concatenation of strings. It's unnecessary to concatenate two strings together, such as: diff --git a/docs/rules/no-useless-constructor.md b/docs/rules/no-useless-constructor.md index cdfe5052ff4..6a628759ca9 100644 --- a/docs/rules/no-useless-constructor.md +++ b/docs/rules/no-useless-constructor.md @@ -1,4 +1,6 @@ -# Disallow unnecessary constructor (no-useless-constructor) +# no-useless-constructor + +Disallows unnecessary constructors. 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: diff --git a/docs/rules/no-useless-escape.md b/docs/rules/no-useless-escape.md index 1f54b588d9b..ef093c39a0e 100644 --- a/docs/rules/no-useless-escape.md +++ b/docs/rules/no-useless-escape.md @@ -1,4 +1,6 @@ -# Disallow unnecessary escape usage (no-useless-escape) +# no-useless-escape + +Disallows unnecessary escape characters. Escaping non-special characters in strings, template literals, and regular expressions doesn't have any effect, as demonstrated in the following example: diff --git a/docs/rules/no-useless-rename.md b/docs/rules/no-useless-rename.md index 1a827288c4b..dfdc914488c 100644 --- a/docs/rules/no-useless-rename.md +++ b/docs/rules/no-useless-rename.md @@ -1,4 +1,6 @@ -# Disallow renaming import, export, and destructured assignments to the same name (no-useless-rename) +# no-useless-rename + +Disallows renaming import, export, and destructured assignments to the same name. ES2015 allows for the renaming of references in import and export statements as well as destructuring assignments. This gives programmers a concise syntax for performing these operations while renaming these references: diff --git a/docs/rules/no-useless-return.md b/docs/rules/no-useless-return.md index 4e8de6820ec..67ad47541f0 100644 --- a/docs/rules/no-useless-return.md +++ b/docs/rules/no-useless-return.md @@ -1,4 +1,6 @@ -# Disallow redundant return statements (no-useless-return) +# no-useless-return + +Disallows redundant return statements. A `return;` statement with nothing after it is redundant, and has no effect on the runtime behavior of a function. This can be confusing, so it's better to disallow these redundant statements. diff --git a/docs/rules/no-var.md b/docs/rules/no-var.md index 83950c32bfe..19a4cc2d737 100644 --- a/docs/rules/no-var.md +++ b/docs/rules/no-var.md @@ -1,4 +1,6 @@ -# require `let` or `const` instead of `var` (no-var) +# no-var + +Requires `let` or `const` instead of `var`. ECMAScript 6 allows programmers to create variables with block scope instead of function scope using the `let` and `const` keywords. Block scope is common in many other programming languages and helps programmers avoid mistakes diff --git a/docs/rules/no-void.md b/docs/rules/no-void.md index 4f6a976f320..a4897f45ede 100644 --- a/docs/rules/no-void.md +++ b/docs/rules/no-void.md @@ -1,4 +1,6 @@ -# Disallow use of the void operator. (no-void) +# no-void + +Disallows use of the void operator. The `void` operator takes an operand and returns `undefined`: `void expression` will evaluate `expression` and return `undefined`. It can be used to ignore any side effects `expression` may produce: diff --git a/docs/rules/no-warning-comments.md b/docs/rules/no-warning-comments.md index 48365601b10..befb259fcb8 100644 --- a/docs/rules/no-warning-comments.md +++ b/docs/rules/no-warning-comments.md @@ -1,4 +1,6 @@ -# Disallow Warning Comments (no-warning-comments) +# no-warning-comments + +Disallows specified warning terms in comments. Developers often add comments to code which is not complete or needs review. Most likely you want to fix or review the code, and then remove the comment, before you consider the code to be production ready. diff --git a/docs/rules/no-whitespace-before-property.md b/docs/rules/no-whitespace-before-property.md index 70ecc141dd1..d6aa32c8e3f 100644 --- a/docs/rules/no-whitespace-before-property.md +++ b/docs/rules/no-whitespace-before-property.md @@ -1,4 +1,6 @@ -# disallow whitespace before properties (no-whitespace-before-property) +# no-whitespace-before-property + +Disallows whitespace before properties. JavaScript allows whitespace between objects and their properties. However, inconsistent spacing can make code harder to read and can lead to errors. diff --git a/docs/rules/no-with.md b/docs/rules/no-with.md index 979c58b0ae9..b485838ba27 100644 --- a/docs/rules/no-with.md +++ b/docs/rules/no-with.md @@ -1,4 +1,6 @@ -# disallow `with` statements (no-with) +# no-with + +Disallows `with` statements. The `with` statement is potentially problematic because it adds members of an object to the current scope, making it impossible to tell what a variable inside the block actually refers to. diff --git a/docs/rules/no-wrap-func.md b/docs/rules/no-wrap-func.md index 5193d79ec2c..6580ea4e26c 100644 --- a/docs/rules/no-wrap-func.md +++ b/docs/rules/no-wrap-func.md @@ -1,4 +1,6 @@ -# no-wrap-func: disallow unnecessary parentheses around function expressions +# no-wrap-func + +Disallows unnecessary parentheses around function expressions. (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [no-extra-parens](no-extra-parens.md) rule. The `"functions"` option in the new rule is equivalent to the removed rule. diff --git a/docs/rules/nonblock-statement-body-position.md b/docs/rules/nonblock-statement-body-position.md index c2de17d9216..6c0c545e195 100644 --- a/docs/rules/nonblock-statement-body-position.md +++ b/docs/rules/nonblock-statement-body-position.md @@ -1,4 +1,6 @@ -# enforce the location of single-line statements (nonblock-statement-body-position) +# nonblock-statement-body-position + +Enforces the location of single-line statements. When writing `if`, `else`, `while`, `do-while`, and `for` statements, the body can be a single statement instead of a block. It can be useful to enforce a consistent location for these single statements. diff --git a/docs/rules/object-curly-newline.md b/docs/rules/object-curly-newline.md index e7089d291a7..31f7810840f 100644 --- a/docs/rules/object-curly-newline.md +++ b/docs/rules/object-curly-newline.md @@ -1,4 +1,6 @@ -# enforce consistent line breaks after opening and before closing braces (object-curly-newline) +# object-curly-newline + +Enforces consistent line breaks after opening and before closing braces. A number of style guides require or disallow line breaks inside of object braces and other tokens. diff --git a/docs/rules/object-curly-spacing.md b/docs/rules/object-curly-spacing.md index e7b054cdd72..7b48bd19d31 100644 --- a/docs/rules/object-curly-spacing.md +++ b/docs/rules/object-curly-spacing.md @@ -1,4 +1,6 @@ -# enforce consistent spacing inside braces (object-curly-spacing) +# object-curly-spacing + +Enforces consistent spacing inside braces. While formatting preferences are very personal, a number of style guides require or disallow spaces between curly braces in the following situations: diff --git a/docs/rules/object-property-newline.md b/docs/rules/object-property-newline.md index 8c18decb1b6..c1a1af6607e 100644 --- a/docs/rules/object-property-newline.md +++ b/docs/rules/object-property-newline.md @@ -1,4 +1,6 @@ -# enforce placing object properties on separate lines (object-property-newline) +# object-property-newline + +Enforces placing object properties on separate lines. This rule permits you to restrict the locations of property specifications in object literals. You may prohibit any part of any property specification from appearing on the same line as any part of any other property specification. You may make this prohibition absolute, or, by invoking an object option, you may allow an exception, permitting an object literal to have all parts of all of its property specifications on a single line. diff --git a/docs/rules/object-shorthand.md b/docs/rules/object-shorthand.md index 0cbf90b4ba0..4f196bf1d96 100644 --- a/docs/rules/object-shorthand.md +++ b/docs/rules/object-shorthand.md @@ -1,4 +1,6 @@ -# Require Object Literal Shorthand Syntax (object-shorthand) +# object-shorthand + +Requires or disallows method and property shorthand syntax for object literals. ECMAScript 6 provides a concise form for defining object literal methods and properties. This syntax can make defining complex object literals much cleaner. diff --git a/docs/rules/one-var-declaration-per-line.md b/docs/rules/one-var-declaration-per-line.md index 90f67a921ad..33069c5891c 100644 --- a/docs/rules/one-var-declaration-per-line.md +++ b/docs/rules/one-var-declaration-per-line.md @@ -1,4 +1,6 @@ -# require or disallow newlines around variable declarations (one-var-declaration-per-line) +# one-var-declaration-per-line + +Requires or disallows newlines around variable declarations. Some developers declare multiple var statements on the same line: diff --git a/docs/rules/one-var.md b/docs/rules/one-var.md index df7ee1f60d5..b19ac515b1b 100644 --- a/docs/rules/one-var.md +++ b/docs/rules/one-var.md @@ -1,4 +1,6 @@ -# enforce variables to be declared either together or separately in functions (one-var) +# one-var + +Enforces variables to be declared either together or separately in functions. Variables can be declared at any point in JavaScript code using `var`, `let`, or `const`. There are many styles and preferences related to the declaration of variables, and one of those is deciding on how many variable declarations should be allowed in a single function. diff --git a/docs/rules/operator-assignment.md b/docs/rules/operator-assignment.md index b926462b309..84fbf1c6239 100644 --- a/docs/rules/operator-assignment.md +++ b/docs/rules/operator-assignment.md @@ -1,4 +1,6 @@ -# require or disallow assignment operator shorthand where possible (operator-assignment) +# operator-assignment + +Requires or disallows assignment operator shorthand where possible. JavaScript provides shorthand operators that combine variable assignment and some simple mathematical operations. For example, `x = x + 4` can be shortened to `x += 4`. The supported shorthand forms are as follows: diff --git a/docs/rules/operator-linebreak.md b/docs/rules/operator-linebreak.md index 6ae484ea5cd..ab3b821196b 100644 --- a/docs/rules/operator-linebreak.md +++ b/docs/rules/operator-linebreak.md @@ -1,4 +1,6 @@ -# enforce consistent linebreak style for operators (operator-linebreak) +# operator-linebreak + +Enforces consistent linebreak style for operators. 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. diff --git a/docs/rules/padded-blocks.md b/docs/rules/padded-blocks.md index 85c0a8b9ced..3361f7bf59f 100644 --- a/docs/rules/padded-blocks.md +++ b/docs/rules/padded-blocks.md @@ -1,4 +1,6 @@ -# require or disallow padding within blocks (padded-blocks) +# padded-blocks + +Requires or disallows padding within blocks. Some style guides require block statements to start and end with blank lines. The goal is to improve readability by visually separating the block content and the surrounding code. diff --git a/docs/rules/padding-line-between-statements.md b/docs/rules/padding-line-between-statements.md index 9cf15fc3794..8b10438a3b2 100644 --- a/docs/rules/padding-line-between-statements.md +++ b/docs/rules/padding-line-between-statements.md @@ -1,4 +1,6 @@ -# Require or disallow padding lines between statements (padding-line-between-statements) +# padding-line-between-statements + +Requires or disallows padding lines between statements. This rule requires or disallows blank lines between the given 2 kinds of statements. Properly blank lines help developers to understand the code. diff --git a/docs/rules/prefer-arrow-callback.md b/docs/rules/prefer-arrow-callback.md index 94020f809b7..dc395b82746 100644 --- a/docs/rules/prefer-arrow-callback.md +++ b/docs/rules/prefer-arrow-callback.md @@ -1,4 +1,6 @@ -# Require using arrow functions for callbacks (prefer-arrow-callback) +# prefer-arrow-callback + +Requires using arrow functions for callbacks. Arrow functions can be an attractive alternative to function expressions for callbacks or function arguments. diff --git a/docs/rules/prefer-const.md b/docs/rules/prefer-const.md index 3cdba9e4da0..48cc3338d2f 100644 --- a/docs/rules/prefer-const.md +++ b/docs/rules/prefer-const.md @@ -1,4 +1,6 @@ -# Suggest using `const` (prefer-const) +# prefer-const + +Requires `const` declarations for variables that are never reassigned after declared. If a variable is never reassigned, using the `const` declaration is better. diff --git a/docs/rules/prefer-destructuring.md b/docs/rules/prefer-destructuring.md index f07c03b3170..252199adc93 100644 --- a/docs/rules/prefer-destructuring.md +++ b/docs/rules/prefer-destructuring.md @@ -1,4 +1,6 @@ -# Prefer destructuring from arrays and objects (prefer-destructuring) +# prefer-destructuring + +Requires destructuring from arrays and/or objects. With JavaScript ES6, a new syntax was added for creating variables from an array index or object property, called [destructuring](#further-reading). This rule enforces usage of destructuring instead of accessing a property through a member expression. diff --git a/docs/rules/prefer-exponentiation-operator.md b/docs/rules/prefer-exponentiation-operator.md index f5f9e47db5a..15f120c900b 100644 --- a/docs/rules/prefer-exponentiation-operator.md +++ b/docs/rules/prefer-exponentiation-operator.md @@ -1,4 +1,6 @@ -# Disallow the use of `Math.pow` in favor of the `**` operator (prefer-exponentiation-operator) +# prefer-exponentiation-operator + +Disallows the use of `Math.pow` in favor of the `**` operator. Introduced in ES2016, the infix exponentiation operator `**` is an alternative for the standard `Math.pow` function. diff --git a/docs/rules/prefer-named-capture-group.md b/docs/rules/prefer-named-capture-group.md index f48ec8003fc..5667dd0d7c1 100644 --- a/docs/rules/prefer-named-capture-group.md +++ b/docs/rules/prefer-named-capture-group.md @@ -1,4 +1,6 @@ -# Suggest using named capture group in regular expression (prefer-named-capture-group) +# prefer-named-capture-group + +Suggest using named capture group in regular expression. ## Rule Details diff --git a/docs/rules/prefer-numeric-literals.md b/docs/rules/prefer-numeric-literals.md index bf81e5ec336..b5dc6448ec7 100644 --- a/docs/rules/prefer-numeric-literals.md +++ b/docs/rules/prefer-numeric-literals.md @@ -1,4 +1,6 @@ -# disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals (prefer-numeric-literals) +# prefer-numeric-literals + +Disallows `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals. The `parseInt()` and `Number.parseInt()` functions can be used to turn binary, octal, and hexadecimal strings into integers. As binary, octal, and hexadecimal literals are supported in ES6, this rule encourages use of those numeric literals instead of `parseInt()` or `Number.parseInt()`. diff --git a/docs/rules/prefer-object-has-own.md b/docs/rules/prefer-object-has-own.md index 4c90078c063..a0bc201b7a9 100644 --- a/docs/rules/prefer-object-has-own.md +++ b/docs/rules/prefer-object-has-own.md @@ -1,4 +1,6 @@ -# Prefer `Object.hasOwn()` over `Object.prototype.hasOwnProperty.call()` (prefer-object-has-own) +# prefer-object-has-own + +Prefer `Object.hasOwn()` over `Object.prototype.hasOwnProperty.call()`. It is very common to write code like: diff --git a/docs/rules/prefer-object-spread.md b/docs/rules/prefer-object-spread.md index 50d721b79ad..34a815c1bac 100644 --- a/docs/rules/prefer-object-spread.md +++ b/docs/rules/prefer-object-spread.md @@ -1,4 +1,6 @@ -# Prefer use of an object spread over `Object.assign` (prefer-object-spread) +# prefer-object-spread + +Prefer use of an object spread over `Object.assign`. When Object.assign is called using an object literal as the first argument, this rule requires using the object spread syntax instead. This rule also warns on cases where an `Object.assign` call is made using a single argument that is an object literal, in this case, the `Object.assign` call is not needed. diff --git a/docs/rules/prefer-promise-reject-errors.md b/docs/rules/prefer-promise-reject-errors.md index 0cff0ea0a46..d0993d43b4b 100644 --- a/docs/rules/prefer-promise-reject-errors.md +++ b/docs/rules/prefer-promise-reject-errors.md @@ -1,4 +1,6 @@ -# require using Error objects as Promise rejection reasons (prefer-promise-reject-errors) +# prefer-promise-reject-errors + +Requires using Error objects as Promise rejection reasons. It is considered good practice to only pass instances of the built-in `Error` object to the `reject()` function for user-defined errors in Promises. `Error` objects automatically store a stack trace, which can be used to debug an error by determining where it came from. If a Promise is rejected with a non-`Error` value, it can be difficult to determine where the rejection occurred. diff --git a/docs/rules/prefer-reflect.md b/docs/rules/prefer-reflect.md index af0838efba9..d332f371255 100644 --- a/docs/rules/prefer-reflect.md +++ b/docs/rules/prefer-reflect.md @@ -1,4 +1,6 @@ -# Suggest using Reflect methods where applicable (prefer-reflect) +# prefer-reflect + +Suggest using Reflect methods where applicable. This rule was **deprecated** in ESLint v3.9.0 and will not be replaced. The original intent of this rule now seems misguided as we have come to understand that `Reflect` methods are not actually intended to replace the `Object` counterparts the rule suggests, but rather exist as low-level primitives to be used with proxies in order to replicate the default behavior of various previously existing functionality. diff --git a/docs/rules/prefer-regex-literals.md b/docs/rules/prefer-regex-literals.md index 2ba8cacc08d..7c01166b642 100644 --- a/docs/rules/prefer-regex-literals.md +++ b/docs/rules/prefer-regex-literals.md @@ -1,4 +1,6 @@ -# Disallow use of the `RegExp` constructor in favor of regular expression literals (prefer-regex-literals) +# prefer-regex-literals + +Disallows use of the `RegExp` constructor in favor of regular expression literals. There are two ways to create a regular expression: diff --git a/docs/rules/prefer-rest-params.md b/docs/rules/prefer-rest-params.md index c67e744cc59..d36127caae7 100644 --- a/docs/rules/prefer-rest-params.md +++ b/docs/rules/prefer-rest-params.md @@ -1,4 +1,6 @@ -# Suggest using the rest parameters instead of `arguments` (prefer-rest-params) +# prefer-rest-params + +Suggests using rest parameters instead of `arguments`. There are rest parameters in ES2015. We can use that feature for variadic functions instead of the `arguments` variable. diff --git a/docs/rules/prefer-spread.md b/docs/rules/prefer-spread.md index 0011560c3ce..00adc3d9018 100644 --- a/docs/rules/prefer-spread.md +++ b/docs/rules/prefer-spread.md @@ -1,4 +1,6 @@ -# Suggest using spread syntax instead of `.apply()`. (prefer-spread) +# prefer-spread + +Suggests using spread syntax instead of `.apply()`. Before ES2015, one must use `Function.prototype.apply()` to call variadic functions. diff --git a/docs/rules/prefer-template.md b/docs/rules/prefer-template.md index 234bd02a06c..bfea4a26e47 100644 --- a/docs/rules/prefer-template.md +++ b/docs/rules/prefer-template.md @@ -1,4 +1,6 @@ -# Suggest using template literals instead of string concatenation. (prefer-template) +# prefer-template + +Suggests using template literals instead of string concatenation. In ES2015 (ES6), we can use template literals instead of string concatenation. diff --git a/docs/rules/quote-props.md b/docs/rules/quote-props.md index cccb48d7917..9e2a7fb602e 100644 --- a/docs/rules/quote-props.md +++ b/docs/rules/quote-props.md @@ -1,4 +1,6 @@ -# require quotes around object literal property names (quote-props) +# quote-props + +Requires quotes around object literal property names. Object literal property names can be defined in two ways: using literals or using strings. For example, these two objects are equivalent: diff --git a/docs/rules/quotes.md b/docs/rules/quotes.md index 7c113a836b4..545c5347f86 100644 --- a/docs/rules/quotes.md +++ b/docs/rules/quotes.md @@ -1,4 +1,6 @@ -# enforce the consistent use of either backticks, double, or single quotes (quotes) +# quotes + +Enforces the consistent use of either backticks, double, or single quotes. JavaScript allows you to define strings in one of three ways: double quotes, single quotes, and backticks (as of ECMAScript 6). For example: diff --git a/docs/rules/radix.md b/docs/rules/radix.md index 4453a648f38..a1033fe8502 100644 --- a/docs/rules/radix.md +++ b/docs/rules/radix.md @@ -1,4 +1,6 @@ -# Require Radix Parameter (radix) +# radix + +Enforces the consistent use of the radix argument when using `parseInt()`. When using the `parseInt()` function it is common to omit the second argument, the radix, and let the function try to determine from the first argument what type of number it is. By default, `parseInt()` will autodetect decimal and hexadecimal (via `0x` prefix). Prior to ECMAScript 5, `parseInt()` also autodetected octal literals, which caused problems because many developers assumed a leading `0` would be ignored. diff --git a/docs/rules/require-atomic-updates.md b/docs/rules/require-atomic-updates.md index 64fae21d619..2b107d53646 100644 --- a/docs/rules/require-atomic-updates.md +++ b/docs/rules/require-atomic-updates.md @@ -1,4 +1,6 @@ -# Disallow assignments that can lead to race conditions due to usage of `await` or `yield` (require-atomic-updates) +# require-atomic-updates + +Disallows assignments that can lead to race conditions due to usage of `await` or `yield`. When writing asynchronous code, it is possible to create subtle race condition bugs. Consider the following example: diff --git a/docs/rules/require-await.md b/docs/rules/require-await.md index 9c84d439360..250d0e673f3 100644 --- a/docs/rules/require-await.md +++ b/docs/rules/require-await.md @@ -1,4 +1,6 @@ -# Disallow async functions which have no `await` expression (require-await) +# require-await + +Disallows async functions which have no `await` expression. Asynchronous functions in JavaScript behave differently than other functions in two important ways: diff --git a/docs/rules/require-jsdoc.md b/docs/rules/require-jsdoc.md index 1e31aedf74c..14a3dda51c4 100644 --- a/docs/rules/require-jsdoc.md +++ b/docs/rules/require-jsdoc.md @@ -1,4 +1,6 @@ -# require JSDoc comments (require-jsdoc) +# require-jsdoc + +Requires JSDoc comments. This rule was [**deprecated**](https://eslint.org/blog/2018/11/jsdoc-end-of-life) in ESLint v5.10.0. diff --git a/docs/rules/require-unicode-regexp.md b/docs/rules/require-unicode-regexp.md index 3077d4dacff..f920764e605 100644 --- a/docs/rules/require-unicode-regexp.md +++ b/docs/rules/require-unicode-regexp.md @@ -1,4 +1,6 @@ -# Enforce the use of `u` flag on RegExp (require-unicode-regexp) +# require-unicode-regexp + +Enforces the use of `u` flag on RegExp. RegExp `u` flag has two effects: diff --git a/docs/rules/require-yield.md b/docs/rules/require-yield.md index 22c262bf03e..5c073194ff3 100644 --- a/docs/rules/require-yield.md +++ b/docs/rules/require-yield.md @@ -1,4 +1,6 @@ -# Disallow generator functions that do not have `yield` (require-yield) +# require-yield + +Disallows generator functions that do not have `yield`. ## Rule Details diff --git a/docs/rules/rest-spread-spacing.md b/docs/rules/rest-spread-spacing.md index d8d6063b94d..33a1f51a8e3 100644 --- a/docs/rules/rest-spread-spacing.md +++ b/docs/rules/rest-spread-spacing.md @@ -1,4 +1,6 @@ -# Enforce spacing between rest and spread operators and their expressions (rest-spread-spacing) +# rest-spread-spacing + +Enforces spacing between rest and spread operators and their expressions. ES2015 introduced the rest and spread operators, which expand an iterable structure into its individual parts. Some examples of their usage are as follows: diff --git a/docs/rules/semi-spacing.md b/docs/rules/semi-spacing.md index 4db5e188b96..9b8d368740b 100644 --- a/docs/rules/semi-spacing.md +++ b/docs/rules/semi-spacing.md @@ -1,4 +1,6 @@ -# Enforce spacing before and after semicolons (semi-spacing) +# semi-spacing + +Enforces spacing before and after semicolons. JavaScript allows you to place unnecessary spaces before or after a semicolon. diff --git a/docs/rules/semi-style.md b/docs/rules/semi-style.md index 7d08d7665d1..6f22daaae5b 100644 --- a/docs/rules/semi-style.md +++ b/docs/rules/semi-style.md @@ -1,4 +1,6 @@ -# Enforce location of semicolons (semi-style) +# semi-style + +Enforces location of semicolons. Generally, semicolons are at the end of lines. However, in semicolon-less style, semicolons are at the beginning of lines. This rule enforces that semicolons are at the configured location. diff --git a/docs/rules/semi.md b/docs/rules/semi.md index 2e82a4509ea..3f6857cfd3f 100644 --- a/docs/rules/semi.md +++ b/docs/rules/semi.md @@ -1,4 +1,6 @@ -# require or disallow semicolons instead of ASI (semi) +# semi + +Requires or disallows semicolons instead of ASI. JavaScript 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: diff --git a/docs/rules/sort-imports.md b/docs/rules/sort-imports.md index 08c2cf36684..087a008bb6f 100644 --- a/docs/rules/sort-imports.md +++ b/docs/rules/sort-imports.md @@ -1,4 +1,6 @@ -# Import Sorting (sort-imports) +# sort-imports + +Enforces sorted import declarations within modules. 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: diff --git a/docs/rules/sort-keys.md b/docs/rules/sort-keys.md index bf4813ec424..27368412fd9 100644 --- a/docs/rules/sort-keys.md +++ b/docs/rules/sort-keys.md @@ -1,4 +1,6 @@ -# require object keys to be sorted (sort-keys) +# sort-keys + +Requires object keys to be sorted. When declaring multiple properties, some developers prefer to sort property names alphabetically to more easily find and/or diff necessary properties at a later time. Others feel that it adds complexity and becomes burden to maintain. diff --git a/docs/rules/sort-vars.md b/docs/rules/sort-vars.md index 8a201f358bf..63c3df6e526 100644 --- a/docs/rules/sort-vars.md +++ b/docs/rules/sort-vars.md @@ -1,4 +1,6 @@ -# Variable Sorting (sort-vars) +# sort-vars + +Requires variables within the same declaration block to be sorted. 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. diff --git a/docs/rules/space-after-function-name.md b/docs/rules/space-after-function-name.md index 6cceaab12f4..fee100a4b29 100644 --- a/docs/rules/space-after-function-name.md +++ b/docs/rules/space-after-function-name.md @@ -1,4 +1,6 @@ -# space-after-function-name: enforce consistent spacing after name in function definitions +# space-after-function-name + +Enforces consistent spacing after name in function definitions. (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [space-before-function-paren](space-before-function-paren.md) rule. diff --git a/docs/rules/space-after-keywords.md b/docs/rules/space-after-keywords.md index 7f6182b227a..7a061d815e3 100644 --- a/docs/rules/space-after-keywords.md +++ b/docs/rules/space-after-keywords.md @@ -1,4 +1,6 @@ -# space-after-keywords: enforce consistent spacing after keywords +# space-after-keywords + +Enforces consistent spacing after keywords. (removed) This rule was **removed** in ESLint v2.0 and replaced by the [keyword-spacing](keyword-spacing.md) rule. diff --git a/docs/rules/space-before-blocks.md b/docs/rules/space-before-blocks.md index 35a4c16c3ce..758fda803f9 100644 --- a/docs/rules/space-before-blocks.md +++ b/docs/rules/space-before-blocks.md @@ -1,4 +1,6 @@ -# Require Or Disallow Space Before Blocks (space-before-blocks) +# space-before-blocks + +Requires Or disallows space before blocks. Consistency is an important part of any style guide. While it is a personal preference where to put the opening brace of blocks, diff --git a/docs/rules/space-before-function-paren.md b/docs/rules/space-before-function-paren.md index c9d0c39857d..547e26c0c06 100644 --- a/docs/rules/space-before-function-paren.md +++ b/docs/rules/space-before-function-paren.md @@ -1,4 +1,6 @@ -# Require or disallow a space before function parenthesis (space-before-function-paren) +# space-before-function-paren + +Requires or disallows a space before function parenthesis. When formatting a function, whitespace is allowed between the function name or `function` keyword and the opening paren. Named functions also require a space between the `function` keyword and the function name, but anonymous functions require no whitespace. For example: diff --git a/docs/rules/space-before-function-parentheses.md b/docs/rules/space-before-function-parentheses.md index 3856c22359c..a5d869866ba 100644 --- a/docs/rules/space-before-function-parentheses.md +++ b/docs/rules/space-before-function-parentheses.md @@ -1,4 +1,6 @@ -# space-before-function-parentheses: enforce consistent spacing before opening parenthesis in function definitions +# space-before-function-parentheses + +Enforces consistent spacing before opening parenthesis in function definitions. (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [space-before-function-paren](space-before-function-paren.md) rule. The name of the rule changed from "parentheses" to "paren" for consistency with the names of other rules. diff --git a/docs/rules/space-before-keywords.md b/docs/rules/space-before-keywords.md index 077c9a322fa..2c77bc1d8af 100644 --- a/docs/rules/space-before-keywords.md +++ b/docs/rules/space-before-keywords.md @@ -1,4 +1,6 @@ -# space-before-keywords: enforce consistent spacing before keywords +# space-before-keywords + +Enforces consistent spacing before keywords. (removed) This rule was **removed** in ESLint v2.0 and **replaced** by the [keyword-spacing](keyword-spacing.md) rule. diff --git a/docs/rules/space-in-brackets.md b/docs/rules/space-in-brackets.md index 330609acd25..363bd3053d2 100644 --- a/docs/rules/space-in-brackets.md +++ b/docs/rules/space-in-brackets.md @@ -1,4 +1,6 @@ -# space-in-brackets: enforce consistent spacing inside braces of object literals and brackets of array literals +# space-in-brackets + +Enforces consistent spacing inside braces of object literals and brackets of array literals. (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [object-curly-spacing](object-curly-spacing.md) and [array-bracket-spacing](array-bracket-spacing.md) rules. diff --git a/docs/rules/space-in-parens.md b/docs/rules/space-in-parens.md index 33970366131..f9be1bc1d0d 100644 --- a/docs/rules/space-in-parens.md +++ b/docs/rules/space-in-parens.md @@ -1,4 +1,6 @@ -# Disallow or enforce spaces inside of parentheses (space-in-parens) +# space-in-parens + +Disallows or enforce spaces inside of parentheses. Some style guides require or disallow spaces inside of parentheses: diff --git a/docs/rules/space-infix-ops.md b/docs/rules/space-infix-ops.md index 6a00e50edde..2b6bd8867eb 100644 --- a/docs/rules/space-infix-ops.md +++ b/docs/rules/space-infix-ops.md @@ -1,4 +1,6 @@ -# require spacing around infix operators (space-infix-ops) +# space-infix-ops + +Requires spacing around infix operators. While formatting preferences are very personal, a number of style guides require spaces around operators, such as: diff --git a/docs/rules/space-return-throw-case.md b/docs/rules/space-return-throw-case.md index ff55f7f5eff..9df4f681ee3 100644 --- a/docs/rules/space-return-throw-case.md +++ b/docs/rules/space-return-throw-case.md @@ -1,4 +1,6 @@ -# space-return-throw-case: require spaces after `return`, `throw`, and `case` keywords +# space-return-throw-case + +Requires spaces after `return`, `throw`, and `case` keywords. (removed) This rule was **removed** in ESLint v2.0 and **replaced** by the [keyword-spacing](keyword-spacing.md) rule. diff --git a/docs/rules/space-unary-ops.md b/docs/rules/space-unary-ops.md index 676a921bf63..39eb9cbf050 100644 --- a/docs/rules/space-unary-ops.md +++ b/docs/rules/space-unary-ops.md @@ -1,4 +1,6 @@ -# Require or disallow spaces before/after unary operators (space-unary-ops) +# space-unary-ops + +Requires or disallow spaces before/after unary operators. Some style guides 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. diff --git a/docs/rules/space-unary-word-ops.md b/docs/rules/space-unary-word-ops.md index a1558660ac9..4d4fb85cd5f 100644 --- a/docs/rules/space-unary-word-ops.md +++ b/docs/rules/space-unary-word-ops.md @@ -1,4 +1,6 @@ -# space-unary-word-ops: require spaces after unary word operators +# space-unary-word-ops + +Requires spaces after unary word operators. (removed) This rule was **removed** in ESLint v0.10.0 and **replaced** by the [space-unary-ops](space-unary-ops.md) rule. diff --git a/docs/rules/spaced-comment.md b/docs/rules/spaced-comment.md index 66f8f708667..965a274e276 100644 --- a/docs/rules/spaced-comment.md +++ b/docs/rules/spaced-comment.md @@ -1,4 +1,6 @@ -# Requires or disallows a whitespace (space or tab) beginning a comment (spaced-comment) +# spaced-comment + +Enforces consistent spacing after the `//` or `/*` in a comment. Some style guides require or disallow a whitespace immediately after the initial `//` or `/*` of a comment. Whitespace after the `//` or `/*` makes it easier to read text in comments. diff --git a/docs/rules/spaced-line-comment.md b/docs/rules/spaced-line-comment.md index aaaa27a181f..b33124bf341 100644 --- a/docs/rules/spaced-line-comment.md +++ b/docs/rules/spaced-line-comment.md @@ -1,4 +1,6 @@ -# spaced-line-comment: enforce consistent spacing after `//` in line comments +# spaced-line-comment + +Enforces consistent spacing after `//` in line comments. (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [spaced-comment](spaced-comment.md) rule. diff --git a/docs/rules/strict.md b/docs/rules/strict.md index 97285afc025..077ca95a87e 100644 --- a/docs/rules/strict.md +++ b/docs/rules/strict.md @@ -1,4 +1,6 @@ -# require or disallow strict mode directives (strict) +# strict + +Requires or disallow strict mode directives. A strict mode directive is a `"use strict"` literal at the beginning of a script or function body. It enables strict mode semantics. diff --git a/docs/rules/switch-colon-spacing.md b/docs/rules/switch-colon-spacing.md index 094aef22cff..5380ea59ca1 100644 --- a/docs/rules/switch-colon-spacing.md +++ b/docs/rules/switch-colon-spacing.md @@ -1,4 +1,6 @@ -# Enforce spacing around colons of switch statements (switch-colon-spacing) +# switch-colon-spacing + +Enforces spacing around colons of switch statements. Spacing around colons improves readability of `case`/`default` clauses. diff --git a/docs/rules/symbol-description.md b/docs/rules/symbol-description.md index 7743867d290..625d5ab5377 100644 --- a/docs/rules/symbol-description.md +++ b/docs/rules/symbol-description.md @@ -1,4 +1,6 @@ -# require symbol description (symbol-description) +# symbol-description + +Requires symbol descriptions. The `Symbol` function may have an optional description: diff --git a/docs/rules/template-curly-spacing.md b/docs/rules/template-curly-spacing.md index f7e071428bc..65f89f4ff9d 100644 --- a/docs/rules/template-curly-spacing.md +++ b/docs/rules/template-curly-spacing.md @@ -1,4 +1,6 @@ -# Enforce Usage of Spacing in Template Strings (template-curly-spacing) +# template-curly-spacing + +Enforces usage of spacing in template strings. We can embed expressions in template strings with using a pair of `${` and `}`. diff --git a/docs/rules/template-tag-spacing.md b/docs/rules/template-tag-spacing.md index 58cd166f54d..6bbf3e783d4 100644 --- a/docs/rules/template-tag-spacing.md +++ b/docs/rules/template-tag-spacing.md @@ -1,4 +1,6 @@ -# Require or disallow spacing between template tags and their literals (template-tag-spacing) +# template-tag-spacing + +Requires or disallow spacing between template tags and their literals. With ES6, it's possible to create functions called [tagged template literals](#further-reading) where the function parameters consist of a template literal's strings and expressions. diff --git a/docs/rules/unicode-bom.md b/docs/rules/unicode-bom.md index bb9925204d4..160440e5237 100644 --- a/docs/rules/unicode-bom.md +++ b/docs/rules/unicode-bom.md @@ -1,4 +1,6 @@ -# Require or disallow the Unicode Byte Order Mark (BOM) (unicode-bom) +# unicode-bom + +Requires or disallows the Unicode Byte Order Mark (BOM). The Unicode Byte Order Mark (BOM) is used to specify whether code units are big endian or little endian. That is, whether the most significant or least diff --git a/docs/rules/use-isnan.md b/docs/rules/use-isnan.md index 67c83c96a90..1560ee254ea 100644 --- a/docs/rules/use-isnan.md +++ b/docs/rules/use-isnan.md @@ -1,4 +1,6 @@ -# require calls to `isNaN()` when checking for `NaN` (use-isnan) +# use-isnan + +Requires calls to `isNaN()` when checking for `NaN`. In JavaScript, `NaN` is a special value of the `Number` type. It's used to represent any of the "not-a-number" values represented by the double-precision 64-bit format as specified by the IEEE Standard for Binary Floating-Point Arithmetic. diff --git a/docs/rules/valid-jsdoc.md b/docs/rules/valid-jsdoc.md index 5741402b59d..a57a3f65ff1 100644 --- a/docs/rules/valid-jsdoc.md +++ b/docs/rules/valid-jsdoc.md @@ -1,4 +1,6 @@ -# enforce valid JSDoc comments (valid-jsdoc) +# valid-jsdoc + +Enforces valid JSDoc comments. This rule was [**deprecated**](https://eslint.org/blog/2018/11/jsdoc-end-of-life) in ESLint v5.10.0. diff --git a/docs/rules/valid-typeof.md b/docs/rules/valid-typeof.md index 825e3bfae13..fcf60a97538 100644 --- a/docs/rules/valid-typeof.md +++ b/docs/rules/valid-typeof.md @@ -1,4 +1,6 @@ -# enforce comparing `typeof` expressions against valid strings (valid-typeof) +# valid-typeof + +Enforces comparing `typeof` expressions against valid strings. For a vast majority of use cases, the result of the `typeof` operator is one of the following string literals: `"undefined"`, `"object"`, `"boolean"`, `"number"`, `"string"`, `"function"`, `"symbol"`, and `"bigint"`. It is usually a typing mistake to compare the result of a `typeof` operator to other string literals. diff --git a/docs/rules/vars-on-top.md b/docs/rules/vars-on-top.md index c8ce81e8191..216a16d9d7f 100644 --- a/docs/rules/vars-on-top.md +++ b/docs/rules/vars-on-top.md @@ -1,4 +1,6 @@ -# Require Variable Declarations to be at the top of their scope (vars-on-top) +# vars-on-top + +Requires variable declarations to be at the top of their scope. The `vars-on-top` rule generates warnings when variable declarations are not used serially at the top of a function scope or the top of a program. By default variable declarations are always moved (“hoisted”) invisibly to the top of their containing scope by the JavaScript interpreter. diff --git a/docs/rules/wrap-iife.md b/docs/rules/wrap-iife.md index 28653aba603..4e5e252b04d 100644 --- a/docs/rules/wrap-iife.md +++ b/docs/rules/wrap-iife.md @@ -1,4 +1,6 @@ -# Require IIFEs to be Wrapped (wrap-iife) +# wrap-iife + +Requires IIFEs to be wrapped. 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. diff --git a/docs/rules/wrap-regex.md b/docs/rules/wrap-regex.md index df8003fdd80..e8b5e24b8f3 100644 --- a/docs/rules/wrap-regex.md +++ b/docs/rules/wrap-regex.md @@ -1,4 +1,6 @@ -# Require Regex Literals to be Wrapped (wrap-regex) +# wrap-regex + +Requires regex literals to be wrapped. When a regular expression is used in certain situations, it can end up looking like a division operator. For example: diff --git a/docs/rules/yield-star-spacing.md b/docs/rules/yield-star-spacing.md index f8c27e6feba..cc82ee3e63d 100644 --- a/docs/rules/yield-star-spacing.md +++ b/docs/rules/yield-star-spacing.md @@ -1,4 +1,6 @@ -# Enforce spacing around the `*` in `yield*` expressions (yield-star-spacing) +# yield-star-spacing + +Enforces spacing around the `*` in `yield*` expressions. ## Rule Details diff --git a/docs/rules/yoda.md b/docs/rules/yoda.md index 9a23a55c86b..2a22f11d0a2 100644 --- a/docs/rules/yoda.md +++ b/docs/rules/yoda.md @@ -1,4 +1,6 @@ -# Require or disallow Yoda Conditions (yoda) +# yoda + +Requires or disallows "Yoda" conditions. 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: