diff --git a/docs/src/rules/arrow-body-style.md b/docs/src/rules/arrow-body-style.md index 1975af13eed..1bfdb5a7308 100644 --- a/docs/src/rules/arrow-body-style.md +++ b/docs/src/rules/arrow-body-style.md @@ -45,7 +45,7 @@ Examples of **correct** code for this rule with the `"always"` option: let foo = () => { return 0; }; -let foo = (retv, name) => { +let bar = (retv, name) => { retv[name] = true; return retv; }; @@ -66,7 +66,7 @@ Examples of **incorrect** code for this rule with the default `"as-needed"` opti let foo = () => { return 0; }; -let foo = () => { +let bar = () => { return { bar: { foo: 1, @@ -86,24 +86,24 @@ Examples of **correct** code for this rule with the default `"as-needed"` option /*eslint arrow-body-style: ["error", "as-needed"]*/ /*eslint-env es6*/ -let foo = () => 0; -let foo = (retv, name) => { +let foo1 = () => 0; +let foo2 = (retv, name) => { retv[name] = true; return retv; }; -let foo = () => ({ +let foo3 = () => ({ bar: { foo: 1, bar: 2, } }); -let foo = () => { bar(); }; -let foo = () => {}; -let foo = () => { /* do nothing */ }; -let foo = () => { +let foo4 = () => { bar(); }; +let foo5 = () => {}; +let foo6 = () => { /* do nothing */ }; +let foo7 = () => { // do nothing. }; -let foo = () => ({ bar: 0 }); +let foo8 = () => ({ bar: 0 }); ``` ::: @@ -120,7 +120,7 @@ Examples of **incorrect** code for this rule with the `{ "requireReturnForObject /*eslint arrow-body-style: ["error", "as-needed", { "requireReturnForObjectLiteral": true }]*/ /*eslint-env es6*/ let foo = () => ({}); -let foo = () => ({ bar: 0 }); +let bar = () => ({ bar: 0 }); ``` ::: @@ -134,7 +134,7 @@ Examples of **correct** code for this rule with the `{ "requireReturnForObjectLi /*eslint-env es6*/ let foo = () => {}; -let foo = () => { return { bar: 0 }; }; +let bar = () => { return { bar: 0 }; }; ``` ::: @@ -152,7 +152,7 @@ Examples of **incorrect** code for this rule with the `"never"` option: let foo = () => { return 0; }; -let foo = (retv, name) => { +let bar = (retv, name) => { retv[name] = true; return retv; }; @@ -169,7 +169,7 @@ Examples of **correct** code for this rule with the `"never"` option: /*eslint-env es6*/ let foo = () => 0; -let foo = () => ({ foo: 0 }); +let bar = () => ({ foo: 0 }); ``` ::: diff --git a/docs/src/rules/camelcase.md b/docs/src/rules/camelcase.md index aa75b231bec..536fba9439b 100644 --- a/docs/src/rules/camelcase.md +++ b/docs/src/rules/camelcase.md @@ -49,11 +49,11 @@ function foo({ no_camelcased }) { // ... }; -function foo({ isCamelcased: no_camelcased }) { +function bar({ isCamelcased: no_camelcased }) { // ... } -function foo({ no_camelcased = 'default value' }) { +function baz({ no_camelcased = 'default value' }) { // ... }; @@ -63,7 +63,7 @@ var obj = { var { category_id = 1 } = query; -var { foo: no_camelcased } = bar; +var { foo: snake_cased } = bar; var { foo: bar_baz = 1 } = quz; ``` @@ -83,8 +83,8 @@ var myFavoriteColor = "#112C85"; var _myFavoriteColor = "#112C85"; var myFavoriteColor_ = "#112C85"; var MY_FAVORITE_COLOR = "#112C85"; -var foo = bar.baz_boom; -var foo = { qux: bar.baz_boom }; +var foo1 = bar.baz_boom; +var foo2 = { qux: bar.baz_boom }; obj.do_something(); do_something(); @@ -96,11 +96,11 @@ function foo({ isCamelCased }) { // ... }; -function foo({ isCamelCased: isAlsoCamelCased }) { +function bar({ isCamelCased: isAlsoCamelCased }) { // ... } -function foo({ isCamelCased = 'default value' }) { +function baz({ isCamelCased = 'default value' }) { // ... }; @@ -143,9 +143,9 @@ Examples of **incorrect** code for this rule with the default `{ "ignoreDestruct var { category_id } = query; -var { category_id = 1 } = query; +var { category_name = 1 } = query; -var { category_id: category_id } = query; +var { category_id: category_title } = query; var { category_id: category_alias } = query; diff --git a/docs/src/rules/class-methods-use-this.md b/docs/src/rules/class-methods-use-this.md index 2269fac8eff..5a12f9af3c9 100644 --- a/docs/src/rules/class-methods-use-this.md +++ b/docs/src/rules/class-methods-use-this.md @@ -86,13 +86,13 @@ class A { } } -class A { +class B { constructor() { // OK. constructor is exempt } } -class A { +class C { static foo() { // OK. static methods aren't expected to use this. } diff --git a/docs/src/rules/constructor-super.md b/docs/src/rules/constructor-super.md index 7c19df77dba..c6f008f13d6 100644 --- a/docs/src/rules/constructor-super.md +++ b/docs/src/rules/constructor-super.md @@ -14,6 +14,16 @@ This rule checks whether or not there is a valid `super()` call. This rule is aimed to flag invalid/missing `super()` calls. +This is a syntax error because there is no `extends` clause in the class: + +```js +class A { + constructor() { + super(); + } +} +``` + Examples of **incorrect** code for this rule: :::incorrect @@ -22,24 +32,18 @@ Examples of **incorrect** code for this rule: /*eslint constructor-super: "error"*/ /*eslint-env es6*/ -class A { - constructor() { - super(); // This is a SyntaxError. - } -} - class A extends B { constructor() { } // Would throw a ReferenceError. } // Classes which inherits from a non constructor are always problems. -class A extends null { +class C extends null { constructor() { super(); // Would throw a TypeError. } } -class A extends null { +class D extends null { constructor() { } // Would throw a ReferenceError. } ``` @@ -58,7 +62,7 @@ class A { constructor() { } } -class A extends B { +class B extends C { constructor() { super(); } diff --git a/docs/src/rules/id-denylist.md b/docs/src/rules/id-denylist.md index 850f5923e83..82859ec8b43 100644 --- a/docs/src/rules/id-denylist.md +++ b/docs/src/rules/id-denylist.md @@ -46,7 +46,7 @@ Examples of **incorrect** code for this rule with sample `"data", "callback"` re ```js /*eslint id-denylist: ["error", "data", "callback"] */ -var data = {...}; +var data = { ...values }; function callback() { // ... @@ -57,23 +57,23 @@ element.callback = function() { }; var itemSet = { - data: [...] + data: [...values] }; class Foo { data = []; } -class Foo { +class Bar { #data = []; } -class Foo { - callback( {); +class Baz { + callback() {} } -class Foo { - #callback( {); +class Qux { + #callback() {} } ``` @@ -86,7 +86,7 @@ Examples of **correct** code for this rule with sample `"data", "callback"` rest ```js /*eslint id-denylist: ["error", "data", "callback"] */ -var encodingOptions = {...}; +var encodingOptions = {...values}; function processFileResult() { // ... @@ -97,7 +97,7 @@ element.successHandler = function() { }; var itemSet = { - entities: [...] + entities: [...values] }; callback(); // all function calls are ignored @@ -110,16 +110,16 @@ class Foo { items = []; } -class Foo { +class Bar { #items = []; } -class Foo { - method( {); +class Baz { + method() {} } -class Foo { - #method( {); +class Qux { + #method() {} } ``` diff --git a/docs/src/rules/id-length.md b/docs/src/rules/id-length.md index aed5ada0a7c..ea5d2fa9d1a 100644 --- a/docs/src/rules/id-length.md +++ b/docs/src/rules/id-length.md @@ -41,16 +41,16 @@ try { } var myObj = { a: 1 }; (a) => { a * a }; -class x { } +class y { } class Foo { x() {} } -class Foo { #x() {} } -class Foo { x = 1 } -class Foo { #x = 1 } -function foo(...x) { } -function foo([x]) { } +class Bar { #x() {} } +class Baz { x = 1 } +class Qux { #x = 1 } +function bar(...x) { } +function baz([x]) { } var [x] = arr; var { prop: [x]} = {}; -function foo({x}) { } +function qux({x}) { } var { x } = {}; var { prop: a} = {}; ({ prop: obj.x } = {}); @@ -78,19 +78,19 @@ try { } var myObj = { apple: 1 }; (num) => { num * num }; -function foo(num = 0) { } +function bar(num = 0) { } class MyClass { } class Foo { method() {} } -class Foo { #method() {} } -class Foo { field = 1 } -class Foo { #field = 1 } -function foo(...args) { } -function foo([longName]) { } +class Bar { #method() {} } +class Baz { field = 1 } +class Qux { #field = 1 } +function baz(...args) { } +function qux([longName]) { } var { prop } = {}; var { prop: [longName] } = {}; var [longName] = arr; -function foo({ prop }) { } -function foo({ a: prop }) { } +function foobar({ prop }) { } +function foobaz({ a: prop }) { } var { prop } = {}; var { a: prop } = {}; ({ prop: obj.longName } = {}); @@ -129,9 +129,9 @@ try { } var myObj = { a: 1 }; (val) => { val * val }; -class x { } +class y { } class Foo { x() {} } -function foo(...x) { } +function bar(...x) { } var { x } = {}; var { prop: a} = {}; var [x] = arr; @@ -151,7 +151,7 @@ Examples of **correct** code for this rule with the `{ "min": 4 }` option: var value = 5; function func() { return 42; } -obj.element = document.body; +object.element = document.body; var foobar = function (event) { /* do stuff */ }; try { dangerousStuff(); @@ -168,7 +168,7 @@ var { prop } = {}; var [longName] = foo; var { a: [prop] } = {}; var { a: longName } = {}; -({ prop: obj.name } = {}); +({ prop: object.name } = {}); var data = { "x": 1 }; // excused because of quotes data["y"] = 3; // excused because of calculated property access ``` @@ -242,16 +242,16 @@ var myObj = { a: 1 }; ### exceptions -Examples of additional **correct** code for this rule with the `{ "exceptions": ["x"] }` option: +Examples of additional **correct** code for this rule with the `{ "exceptions": ["x", "y", "z", "ζ"] }` option: ::: correct ```js -/*eslint id-length: ["error", { "exceptions": ["x"] }]*/ +/*eslint id-length: ["error", { "exceptions": ["x", "y", "z", "ζ"] }]*/ /*eslint-env es6*/ var x = 5; -function x() { return 42; } +function y() { return 42; } obj.x = document.body; var foo = function (x) { /* do stuff */ }; try { @@ -261,8 +261,8 @@ try { } (x) => { return x * x; }; var [x] = arr; -const { x } = foo; -const { a: x } = foo; +const { z } = foo; +const { a: ζ } = foo; ``` ::: diff --git a/docs/src/rules/id-match.md b/docs/src/rules/id-match.md index 08d5ff3ba9c..6d15d19e859 100644 --- a/docs/src/rules/id-match.md +++ b/docs/src/rules/id-match.md @@ -42,17 +42,13 @@ function do_something() { // ... } -obj.do_something = function() { - // ... -}; - class My_Class {} class myClass { do_something() {} } -class myClass { +class anotherClass { #do_something() {} } ``` @@ -76,11 +72,11 @@ var obj = { class myClass {} -class myClass { +class anotherClass { doSomething() {} } -class myClass { +class oneMoreClass { #doSomething() {} } ``` @@ -110,6 +106,10 @@ Examples of **incorrect** code for this rule with the `"^[a-z]+([A-Z][a-z]+)*$", var obj = { my_pref: 1 }; + +obj.do_something = function() { + // ... +}; ``` ::: @@ -121,13 +121,13 @@ Examples of **incorrect** code for this rule with the `"^[a-z]+([A-Z][a-z]+)*$", ::: incorrect ```js -/*eslint id-match: ["error", "^[a-z]+([A-Z][a-z]+)*$", { "properties": true }]*/ +/*eslint id-match: ["error", "^[a-z]+([A-Z][a-z]+)*$", { "classFields": true }]*/ class myClass { my_pref = 1; } -class myClass { +class anotherClass { #my_pref = 1; } ``` diff --git a/docs/src/rules/indent-legacy.md b/docs/src/rules/indent-legacy.md index 97372ebc8ff..c3543133be4 100644 --- a/docs/src/rules/indent-legacy.md +++ b/docs/src/rules/indent-legacy.md @@ -39,7 +39,7 @@ For example, for 2-space indentation: ```json { - "indent": ["error", 2] + "indent-legacy": ["error", 2] } ``` @@ -47,7 +47,7 @@ Or for tabbed indentation: ```json { - "indent": ["error", "tab"] + "indent-legacy": ["error", "tab"] } ``` @@ -56,7 +56,7 @@ Examples of **incorrect** code for this rule with the default options: ::: incorrect ```js -/*eslint indent: "error"*/ +/*eslint indent-legacy: "error"*/ if (a) { b=c; @@ -73,7 +73,7 @@ Examples of **correct** code for this rule with the default options: ::: correct ```js -/*eslint indent: "error"*/ +/*eslint indent-legacy: "error"*/ if (a) { b=c; @@ -126,7 +126,7 @@ Examples of **incorrect** code for this rule with the `"tab"` option: ::: incorrect ```js -/*eslint indent: ["error", "tab"]*/ +/*eslint indent-legacy: ["error", "tab"]*/ if (a) { b=c; @@ -143,7 +143,7 @@ Examples of **correct** code for this rule with the `"tab"` option: ::: correct ```js -/*eslint indent: ["error", "tab"]*/ +/*eslint indent-legacy: ["error", "tab"]*/ if (a) { /*tab*/b=c; @@ -162,7 +162,7 @@ Examples of **incorrect** code for this rule with the `2, { "SwitchCase": 1 }` o ::: incorrect ```js -/*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/ +/*eslint indent-legacy: ["error", 2, { "SwitchCase": 1 }]*/ switch(a){ case "a": @@ -179,7 +179,7 @@ Examples of **correct** code for this rule with the `2, { "SwitchCase": 1 }` opt ::: correct ```js -/*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/ +/*eslint indent-legacy: ["error", 2, { "SwitchCase": 1 }]*/ switch(a){ case "a": @@ -198,18 +198,18 @@ Examples of **incorrect** code for this rule with the `2, { "VariableDeclarator" ::: incorrect ```js -/*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/ +/*eslint indent-legacy: ["error", 2, { "VariableDeclarator": 1 }]*/ /*eslint-env es6*/ var a, b, c; -let a, - b, - c; -const a = 1, - b = 2, - c = 3; +let d, + e, + f; +const g = 1, + h = 2, + i = 3; ``` ::: @@ -219,18 +219,18 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator": ::: correct ```js -/*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/ +/*eslint indent-legacy: ["error", 2, { "VariableDeclarator": 1 }]*/ /*eslint-env es6*/ var a, b, c; -let a, - b, - c; -const a = 1, - b = 2, - c = 3; +let d, + e, + f; +const g = 1, + h = 2, + i = 3; ``` ::: @@ -240,18 +240,18 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator": ::: correct ```js -/*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/ +/*eslint indent-legacy: ["error", 2, { "VariableDeclarator": 2 }]*/ /*eslint-env es6*/ var a, b, c; -let a, - b, - c; -const a = 1, - b = 2, - c = 3; +let d, + e, + f; +const g = 1, + h = 2, + i = 3; ``` ::: @@ -261,18 +261,18 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator": ::: correct ```js -/*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/ +/*eslint indent-legacy: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/ /*eslint-env es6*/ var a, b, c; -let a, - b, - c; -const a = 1, - b = 2, - c = 3; +let e, + f, + g; +const h = 1, + i = 2, + j = 3; ``` ::: @@ -284,7 +284,7 @@ Examples of **incorrect** code for this rule with the options `2, { "outerIIFEBo ::: incorrect ```js -/*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/ +/*eslint indent-legacy: ["error", 2, { "outerIIFEBody": 0 }]*/ (function() { @@ -306,7 +306,7 @@ Examples of **correct** code for this rule with the options `2, {"outerIIFEBody" ::: correct ```js -/*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/ +/*eslint indent-legacy: ["error", 2, { "outerIIFEBody": 0 }]*/ (function() { @@ -330,7 +330,7 @@ Examples of **incorrect** code for this rule with the `2, { "MemberExpression": ::: incorrect ```js -/*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/ +/*eslint indent-legacy: ["error", 2, { "MemberExpression": 1 }]*/ foo .bar @@ -344,7 +344,7 @@ Examples of **correct** code for this rule with the `2, { "MemberExpression": 1 ::: correct ```js -/*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/ +/*eslint indent-legacy: ["error", 2, { "MemberExpression": 1 }]*/ foo .bar @@ -364,7 +364,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionDeclaration ::: incorrect ```js -/*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/ +/*eslint indent-legacy: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/ function foo(bar, baz, @@ -380,7 +380,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionDeclaration": ::: correct ```js -/*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/ +/*eslint indent-legacy: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/ function foo(bar, baz, @@ -396,7 +396,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionDeclaration ::: incorrect ```js -/*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/ +/*eslint indent-legacy: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/ function foo(bar, baz, qux, boop) { @@ -411,7 +411,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionDeclaration": ::: correct ```js -/*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/ +/*eslint indent-legacy: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/ function foo(bar, baz, qux, boop) { @@ -428,7 +428,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionExpression" ::: incorrect ```js -/*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/ +/*eslint indent-legacy: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/ var foo = function(bar, baz, @@ -444,7 +444,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionExpression": ::: correct ```js -/*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/ +/*eslint indent-legacy: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/ var foo = function(bar, baz, @@ -460,7 +460,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionExpression" ::: incorrect ```js -/*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/ +/*eslint indent-legacy: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/ var foo = function(bar, baz, qux, boop) { @@ -475,7 +475,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionExpression": ::: correct ```js -/*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/ +/*eslint indent-legacy: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/ var foo = function(bar, baz, qux, boop) { @@ -492,7 +492,7 @@ Examples of **incorrect** code for this rule with the `2, { "CallExpression": {" ::: incorrect ```js -/*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/ +/*eslint indent-legacy: ["error", 2, { "CallExpression": {"arguments": 1} }]*/ foo(bar, baz, @@ -507,7 +507,7 @@ Examples of **correct** code for this rule with the `2, { "CallExpression": {"ar ::: correct ```js -/*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/ +/*eslint indent-legacy: ["error", 2, { "CallExpression": {"arguments": 1} }]*/ foo(bar, baz, @@ -522,7 +522,7 @@ Examples of **incorrect** code for this rule with the `2, { "CallExpression": {" ::: incorrect ```js -/*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/ +/*eslint indent-legacy: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/ foo(bar, baz, baz, boop, beep); @@ -535,7 +535,7 @@ Examples of **correct** code for this rule with the `2, { "CallExpression": {"ar ::: correct ```js -/*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/ +/*eslint indent-legacy: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/ foo(bar, baz, baz, boop, beep); @@ -550,7 +550,7 @@ Examples of **incorrect** code for this rule with the `2, { "ArrayExpression": 1 ::: incorrect ```js -/*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/ +/*eslint indent-legacy: ["error", 2, { "ArrayExpression": 1 }]*/ var foo = [ bar, @@ -566,7 +566,7 @@ Examples of **correct** code for this rule with the `2, { "ArrayExpression": 1 } ::: correct ```js -/*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/ +/*eslint indent-legacy: ["error", 2, { "ArrayExpression": 1 }]*/ var foo = [ bar, @@ -582,7 +582,7 @@ Examples of **incorrect** code for this rule with the `2, { "ArrayExpression": " ::: incorrect ```js -/*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/ +/*eslint indent-legacy: ["error", 2, {"ArrayExpression": "first"}]*/ var foo = [bar, baz, @@ -597,7 +597,7 @@ Examples of **correct** code for this rule with the `2, { "ArrayExpression": "fi ::: correct ```js -/*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/ +/*eslint indent-legacy: ["error", 2, {"ArrayExpression": "first"}]*/ var foo = [bar, baz, @@ -614,7 +614,7 @@ Examples of **incorrect** code for this rule with the `2, { "ObjectExpression": ::: incorrect ```js -/*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/ +/*eslint indent-legacy: ["error", 2, { "ObjectExpression": 1 }]*/ var foo = { bar: 1, @@ -630,7 +630,7 @@ Examples of **correct** code for this rule with the `2, { "ObjectExpression": 1 ::: correct ```js -/*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/ +/*eslint indent-legacy: ["error", 2, { "ObjectExpression": 1 }]*/ var foo = { bar: 1, @@ -646,7 +646,7 @@ Examples of **incorrect** code for this rule with the `2, { "ObjectExpression": ::: incorrect ```js -/*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/ +/*eslint indent-legacy: ["error", 2, {"ObjectExpression": "first"}]*/ var foo = { bar: 1, baz: 2 }; @@ -659,7 +659,7 @@ Examples of **correct** code for this rule with the `2, { "ObjectExpression": "f ::: correct ```js -/*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/ +/*eslint indent-legacy: ["error", 2, {"ObjectExpression": "first"}]*/ var foo = { bar: 1, baz: 2 }; diff --git a/docs/src/rules/indent.md b/docs/src/rules/indent.md index 7f81c0fd57b..e53a1f9a6e1 100644 --- a/docs/src/rules/indent.md +++ b/docs/src/rules/indent.md @@ -248,12 +248,12 @@ Examples of **incorrect** code for this rule with the `2, { "VariableDeclarator" var a, b, c; -let a, - b, - c; -const a = 1, - b = 2, - c = 3; +let d, + e, + f; +const g = 1, + h = 2, + i = 3; ``` ::: @@ -269,12 +269,12 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator": var a, b, c; -let a, - b, - c; -const a = 1, - b = 2, - c = 3; +let d, + e, + f; +const g = 1, + h = 2, + i = 3; ``` ::: @@ -290,12 +290,12 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator": var a, b, c; -let a, - b, - c; -const a = 1, - b = 2, - c = 3; +let d, + e, + f; +const g = 1, + h = 2, + i = 3; ``` ::: @@ -311,12 +311,12 @@ Examples of **incorrect** code for this rule with the `2, { "VariableDeclarator" var a, b, c; -let a, - b, - c; -const a = 1, - b = 2, - c = 3; +let d, + e, + f; +const g = 1, + h = 2, + i = 3; ``` ::: @@ -332,12 +332,12 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator": var a, b, c; -let a, - b, - c; -const a = 1, - b = 2, - c = 3; +let d, + e, + f; +const g = 1, + h = 2, + i = 3; ``` ::: @@ -353,12 +353,12 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator": var a, b, c; -let a, - b, - c; -const a = 1, - b = 2, - c = 3; +let d, + e, + f; +const g = 1, + h = 2, + i = 3; ``` ::: @@ -858,6 +858,14 @@ import { foo, bar, baz, } from 'qux'; +``` + +::: + +::: correct + +```js +/*eslint indent: ["error", 4, { "ImportDeclaration": 1 }]*/ import { foo, diff --git a/docs/src/rules/jsx-quotes.md b/docs/src/rules/jsx-quotes.md index ddb20002b8a..4e079968755 100644 --- a/docs/src/rules/jsx-quotes.md +++ b/docs/src/rules/jsx-quotes.md @@ -9,17 +9,17 @@ related_rules: JSX attribute values can contain string literals, which are delimited with single or double quotes. -```xml - - +```jsx +; +; ``` Unlike string literals in JavaScript, string literals within JSX attributes can’t contain escaped quotes. If you want to have e.g. a double quote within a JSX attribute value, you have to use single quotes as string delimiter. -```xml - - +```jsx +; +; ``` ## Rule Details @@ -42,7 +42,7 @@ Examples of **incorrect** code for this rule with the default `"prefer-double"` ```jsx /*eslint jsx-quotes: ["error", "prefer-double"]*/ - +; ``` ::: @@ -54,8 +54,8 @@ Examples of **correct** code for this rule with the default `"prefer-double"` op ```jsx /*eslint jsx-quotes: ["error", "prefer-double"]*/ - - +; +; ``` ::: @@ -69,7 +69,7 @@ Examples of **incorrect** code for this rule with the `"prefer-single"` option: ```jsx /*eslint jsx-quotes: ["error", "prefer-single"]*/ - +; ``` ::: @@ -81,8 +81,8 @@ Examples of **correct** code for this rule with the `"prefer-single"` option: ```jsx /*eslint jsx-quotes: ["error", "prefer-single"]*/ - - +; +; ``` ::: diff --git a/docs/src/rules/keyword-spacing.md b/docs/src/rules/keyword-spacing.md index 9c1ca55fc38..0ffe1e13df6 100644 --- a/docs/src/rules/keyword-spacing.md +++ b/docs/src/rules/keyword-spacing.md @@ -77,30 +77,30 @@ let a = [this]; let b = [function() {}]; // Avoid conflict with `arrow-spacing` -let a = ()=> this.foo; +let c = ()=> this.foo; // Avoid conflict with `block-spacing` {function foo() {}} // Avoid conflict with `comma-spacing` -let a = [100,this.foo, this.bar]; +let d = [100,this.foo, this.bar]; // Avoid conflict with `computed-property-spacing` obj[this.foo] = 0; // Avoid conflict with `generator-star-spacing` -function *foo() {} +function *bar() {} // Avoid conflict with `key-spacing` -let obj = { +let obj1 = { foo:function() {} }; // Avoid conflict with `object-curly-spacing` -let obj = {foo: this}; +let obj2 = {foo: this}; // Avoid conflict with `semi-spacing` -let a = this;function foo() {} +let e = this;function foo() {} // Avoid conflict with `space-in-parens` (function () {})(); @@ -110,7 +110,7 @@ if ("foo"in {foo: 0}) {} if (10+this.foo<= this.bar) {} // Avoid conflict with `jsx-curly-spacing` -let a = +let f = ``` ::: @@ -190,10 +190,10 @@ if (foo) { let a = [this]; // Avoid conflict with `arrow-spacing` -let a = ()=> this.foo; +let b = ()=> this.foo; // Avoid conflict with `comma-spacing` -let a = [100, this.foo, this.bar]; +let c = [100, this.foo, this.bar]; // Avoid conflict with `computed-property-spacing` obj[this.foo] = 0; @@ -202,42 +202,42 @@ obj[this.foo] = 0; function* foo() {} // Avoid conflict with `key-spacing` -let obj = { +let obj1 = { foo:function() {} }; // Avoid conflict with `func-call-spacing` -class A { +class A extends B { constructor() { super(); } } // Avoid conflict with `object-curly-spacing` -let obj = {foo: this}; +let obj2 = {foo: this}; // Avoid conflict with `semi-spacing` -let a = this;function foo() {} +let d = this;function bar() {} // Avoid conflict with `space-before-function-paren` -function() {} +(function() {})(); // Avoid conflict with `space-infix-ops` if ("foo"in{foo: 0}) {} if (10+this.foo<= this.bar) {} // Avoid conflict with `space-unary-ops` -function* foo(a) { +function* baz(a) { return yield+a; } // Avoid conflict with `yield-star-spacing` -function* foo(a) { +function* qux(a) { return yield* a; } // Avoid conflict with `jsx-curly-spacing` -let a = +let e = ``` ::: diff --git a/docs/src/rules/lines-around-comment.md b/docs/src/rules/lines-around-comment.md index 924ba66cf1a..0cafa6df703 100644 --- a/docs/src/rules/lines-around-comment.md +++ b/docs/src/rules/lines-around-comment.md @@ -663,7 +663,7 @@ Examples of **correct** code for the `ignorePattern` option: /*eslint lines-around-comment: ["error"]*/ foo(); -/* eslint mentioned in this comment */, +/* eslint mentioned in this comment */ bar(); /*eslint lines-around-comment: ["error", { "ignorePattern": "pragma" }] */ diff --git a/docs/src/rules/lines-between-class-members.md b/docs/src/rules/lines-between-class-members.md index 55627501096..42c20b92ddd 100644 --- a/docs/src/rules/lines-between-class-members.md +++ b/docs/src/rules/lines-between-class-members.md @@ -97,9 +97,15 @@ class Foo{ bar(){} baz(){} } +``` + +::: +::: incorrect + +```js /* eslint lines-between-class-members: ["error", "never"]*/ -class Foo{ +class Bar{ x; bar(){} @@ -123,9 +129,15 @@ class Foo{ baz(){} } +``` + +::: +::: correct + +```js /* eslint lines-between-class-members: ["error", "never"]*/ -class Foo{ +class Bar{ x; bar(){} baz(){} diff --git a/docs/src/rules/max-params.md b/docs/src/rules/max-params.md index 681723fb811..b0a55e9009f 100644 --- a/docs/src/rules/max-params.md +++ b/docs/src/rules/max-params.md @@ -42,11 +42,11 @@ Examples of **incorrect** code for this rule with the default `{ "max": 3 }` opt /*eslint max-params: ["error", 3]*/ /*eslint-env es6*/ -function foo (bar, baz, qux, qxx) { +function foo1 (bar, baz, qux, qxx) { doSomething(); } -let foo = (bar, baz, qux, qxx) => { +let foo2 = (bar, baz, qux, qxx) => { doSomething(); }; ``` @@ -61,11 +61,11 @@ Examples of **correct** code for this rule with the default `{ "max": 3 }` optio /*eslint max-params: ["error", 3]*/ /*eslint-env es6*/ -function foo (bar, baz, qux) { +function foo1 (bar, baz, qux) { doSomething(); } -let foo = (bar, baz, qux) => { +let foo2 = (bar, baz, qux) => { doSomething(); }; ``` diff --git a/docs/src/rules/max-statements.md b/docs/src/rules/max-statements.md index d41f7f2de4d..4462011db74 100644 --- a/docs/src/rules/max-statements.md +++ b/docs/src/rules/max-statements.md @@ -63,7 +63,7 @@ function foo() { var foo11 = 11; // Too many. } -let foo = () => { +let bar = () => { var foo1 = 1; var foo2 = 2; var foo3 = 3; @@ -109,7 +109,7 @@ function foo() { }; } -let foo = () => { +let bar = () => { var foo1 = 1; var foo2 = 2; var foo3 = 3; diff --git a/docs/src/rules/newline-after-var.md b/docs/src/rules/newline-after-var.md index db11e25471c..9d6dc216ece 100644 --- a/docs/src/rules/newline-after-var.md +++ b/docs/src/rules/newline-after-var.md @@ -52,9 +52,9 @@ var greet = "hello,", name = "world"; console.log(greet, name); -let greet = "hello,", - name = "world"; -console.log(greet, name); +let hello = "hello,", + world = "world"; +console.log(hello, world); var greet = "hello,"; const NAME = "world"; @@ -81,10 +81,10 @@ var greet = "hello,", console.log(greet, name); -let greet = "hello,", - name = "world"; +let hello = "hello,", + world = "world"; -console.log(greet, name); +console.log(hello, world); var greet = "hello,"; const NAME = "world"; @@ -115,10 +115,10 @@ var greet = "hello,", console.log(greet, name); -let greet = "hello,", - name = "world"; +let hello = "hello,", + world = "world"; -console.log(greet, name); +console.log(hello, world); var greet = "hello,"; const NAME = "world"; @@ -146,9 +146,9 @@ var greet = "hello,", name = "world"; console.log(greet, name); -let greet = "hello,", - name = "world"; -console.log(greet, name); +let hello = "hello,", + world = "world"; +console.log(hello, world); var greet = "hello,"; const NAME = "world"; diff --git a/docs/src/rules/no-dupe-class-members.md b/docs/src/rules/no-dupe-class-members.md index 216f3c9fecd..6565c9f15ee 100644 --- a/docs/src/rules/no-dupe-class-members.md +++ b/docs/src/rules/no-dupe-class-members.md @@ -34,27 +34,27 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-dupe-class-members: "error"*/ -class Foo { +class A { bar() { } bar() { } } -class Foo { +class B { bar() { } get bar() { } } -class Foo { +class C { bar; bar; } -class Foo { +class D { bar; bar() { } } -class Foo { +class E { static bar() { } static bar() { } } @@ -69,27 +69,27 @@ Examples of **correct** code for this rule: ```js /*eslint no-dupe-class-members: "error"*/ -class Foo { +class A { bar() { } qux() { } } -class Foo { +class B { get bar() { } set bar(value) { } } -class Foo { +class C { bar; qux; } -class Foo { +class D { bar; qux() { } } -class Foo { +class E { static bar() { } bar() { } } diff --git a/docs/src/rules/no-empty-static-block.md b/docs/src/rules/no-empty-static-block.md index 283a4e21b77..1825e5c7832 100644 --- a/docs/src/rules/no-empty-static-block.md +++ b/docs/src/rules/no-empty-static-block.md @@ -42,7 +42,7 @@ class Foo { } } -class Foo { +class Bar { static { // comment } diff --git a/docs/src/rules/no-extra-parens.md b/docs/src/rules/no-extra-parens.md index 1a4d8e2d48a..5fcbcc63926 100644 --- a/docs/src/rules/no-extra-parens.md +++ b/docs/src/rules/no-extra-parens.md @@ -83,8 +83,6 @@ typeof (a); (Object.prototype.toString.call()); -(function(){} ? a() : b()); - class A { [(x)] = 1; } @@ -218,8 +216,8 @@ Examples of **correct** code for this rule with the `all` and `{ "ignoreJSX": "a ```jsx /* eslint no-extra-parens: ["error", "all", { ignoreJSX: "all" }] */ -const Component = (
) -const Component = ( +const ThisComponent = () +const ThatComponent = ( @@ -234,8 +232,8 @@ Examples of **incorrect** code for this rule with the `all` and `{ "ignoreJSX": ```jsx /* eslint no-extra-parens: ["error", "all", { ignoreJSX: "multi-line" }] */ -const Component = () -const Component = (