Skip to content

Commit

Permalink
Chore: fix invalid test cases (#8030)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea authored and alberto committed Feb 7, 2017
1 parent 8ea98f9 commit 7bc92d9
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
16 changes: 8 additions & 8 deletions tests/lib/rules/id-length.js
Expand Up @@ -52,16 +52,16 @@ ruleTester.run("id-length", rule, {
{ code: "var { prop: [x] } = {};", parserOptions: { ecmaVersion: 6 } },
{ code: "import something from 'y';", parserOptions: { sourceType: "module" } },
{ code: "export var num = 0;", parserOptions: { sourceType: "module" } },
{ code: "({ prop: obj.x.y.something }) = {};", parserOptions: { ecmaVersion: 6 } },
{ code: "({ prop: obj.longName }) = {};", parserOptions: { ecmaVersion: 6 } },
{ code: "({ prop: obj.x.y.something } = {});", parserOptions: { ecmaVersion: 6 } },
{ code: "({ prop: obj.longName } = {});", parserOptions: { ecmaVersion: 6 } },
{ code: "var obj = { a: 1, bc: 2 };", options: [{ properties: "never" }] },
{ code: "var obj = {}; obj.a = 1; obj.bc = 2;", options: [{ properties: "never" }] },
{ code: "({ a: obj.x.y.z }) = {};", options: [{ properties: "never" }], parserOptions: { ecmaVersion: 6 } },
{ code: "({ prop: obj.x }) = {};", options: [{ properties: "never" }], parserOptions: { ecmaVersion: 6 } },
{ code: "({ a: obj.x.y.z } = {});", options: [{ properties: "never" }], parserOptions: { ecmaVersion: 6 } },
{ code: "({ prop: obj.x } = {});", options: [{ properties: "never" }], parserOptions: { ecmaVersion: 6 } },
{ code: "var obj = { aaaaa: 1 };", options: [{ max: 4, properties: "never" }] },
{ code: "var obj = {}; obj.aaaaa = 1;", options: [{ max: 4, properties: "never" }] },
{ code: "({ a: obj.x.y.z }) = {};", options: [{ max: 4, properties: "never" }], parserOptions: { ecmaVersion: 6 } },
{ code: "({ prop: obj.xxxxx }) = {};", options: [{ max: 4, properties: "never" }], parserOptions: { ecmaVersion: 6 } }
{ code: "({ a: obj.x.y.z } = {});", options: [{ max: 4, properties: "never" }], parserOptions: { ecmaVersion: 6 } },
{ code: "({ prop: obj.xxxxx } = {});", options: [{ max: 4, properties: "never" }], parserOptions: { ecmaVersion: 6 } }
],
invalid: [
{ code: "var x = 1;", errors: [{ message: "Identifier name 'x' is too short (< 2).", type: "Identifier" }] },
Expand Down Expand Up @@ -111,11 +111,11 @@ ruleTester.run("id-length", rule, {
{ code: "export var x = 0;", parserOptions: { sourceType: "module" }, errors: [
{ message: "Identifier name 'x' is too short (< 2).", type: "Identifier" }
] },
{ code: "({ a: obj.x.y.z }) = {};", parserOptions: { ecmaVersion: 6 }, errors: [
{ code: "({ a: obj.x.y.z } = {});", parserOptions: { ecmaVersion: 6 }, errors: [
{ message: "Identifier name 'a' is too short (< 2).", type: "Identifier" },
{ message: "Identifier name 'z' is too short (< 2).", type: "Identifier" }
] },
{ code: "({ prop: obj.x }) = {};", parserOptions: { ecmaVersion: 6 }, errors: [
{ code: "({ prop: obj.x } = {});", parserOptions: { ecmaVersion: 6 }, errors: [
{ message: "Identifier name 'x' is too short (< 2).", type: "Identifier" }
] },
{ code: "var x = 1;", options: [{ properties: "never" }], errors: [{ message: "Identifier name 'x' is too short (< 2).", type: "Identifier" }] }
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/rules/no-class-assign.js
Expand Up @@ -40,11 +40,11 @@ ruleTester.run("no-class-assign", rule, {
errors: [{ message: "'A' is a class.", type: "Identifier" }]
},
{
code: "class A { } ({A}) = 0;",
code: "class A { } ({A} = 0);",
errors: [{ message: "'A' is a class.", type: "Identifier" }]
},
{
code: "class A { } ({b: A = 0}) = {};",
code: "class A { } ({b: A = 0} = {});",
errors: [{ message: "'A' is a class.", type: "Identifier" }]
},
{
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/rules/no-const-assign.js
Expand Up @@ -45,11 +45,11 @@ ruleTester.run("no-const-assign", rule, {
errors: [{ message: "'x' is constant.", type: "Identifier" }]
},
{
code: "const x = 0; ({x}) = {x: 1};",
code: "const x = 0; ({x} = {x: 1});",
errors: [{ message: "'x' is constant.", type: "Identifier" }]
},
{
code: "const x = 0; ({a: x = 1}) = {};",
code: "const x = 0; ({a: x = 1} = {});",
errors: [{ message: "'x' is constant.", type: "Identifier" }]
},
{
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rules/no-ex-assign.js
Expand Up @@ -28,7 +28,7 @@ ruleTester.run("no-ex-assign", rule, {
{ code: "try { } catch (e) { e = 10; }", errors: [{ message: "Do not assign to the exception parameter.", type: "Identifier" }] },
{ code: "try { } catch (ex) { ex = 10; }", errors: [{ message: "Do not assign to the exception parameter.", type: "Identifier" }] },
{ code: "try { } catch (ex) { [ex] = []; }", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Do not assign to the exception parameter.", type: "Identifier" }] },
{ code: "try { } catch (ex) { ({x: ex = 0}) = {}; }", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Do not assign to the exception parameter.", type: "Identifier" }] },
{ code: "try { } catch (ex) { ({x: ex = 0} = {}); }", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Do not assign to the exception parameter.", type: "Identifier" }] },
{ code: "try { } catch ({message}) { message = 10; }", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Do not assign to the exception parameter.", type: "Identifier" }] }
]
});
4 changes: 2 additions & 2 deletions tests/lib/rules/no-func-assign.js
Expand Up @@ -33,8 +33,8 @@ ruleTester.run("no-func-assign", rule, {
{ code: "function foo() { foo = bar; }", errors: [{ message: "'foo' is a function.", type: "Identifier" }] },
{ code: "foo = bar; function foo() { };", errors: [{ message: "'foo' is a function.", type: "Identifier" }] },
{ code: "[foo] = bar; function foo() { };", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'foo' is a function.", type: "Identifier" }] },
{ code: "({x: foo = 0}) = bar; function foo() { };", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'foo' is a function.", type: "Identifier" }] },
{ code: "({x: foo = 0} = bar); function foo() { };", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'foo' is a function.", type: "Identifier" }] },
{ code: "function foo() { [foo] = bar; }", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'foo' is a function.", type: "Identifier" }] },
{ code: "(function() { ({x: foo = 0}) = bar; function foo() { }; })();", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'foo' is a function.", type: "Identifier" }] }
{ code: "(function() { ({x: foo = 0} = bar); function foo() { }; })();", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'foo' is a function.", type: "Identifier" }] }
]
});
4 changes: 2 additions & 2 deletions tests/lib/rules/no-param-reassign.js
Expand Up @@ -43,8 +43,8 @@ ruleTester.run("no-param-reassign", rule, {
{ code: "function foo(bar) { bar--; }", errors: [{ message: "Assignment to function parameter 'bar'." }] },
{ code: "function foo({bar}) { bar = 13; }", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Assignment to function parameter 'bar'." }] },
{ code: "function foo([, {bar}]) { bar = 13; }", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Assignment to function parameter 'bar'." }] },
{ code: "function foo(bar) { ({bar}) = {}; }", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Assignment to function parameter 'bar'." }] },
{ code: "function foo(bar) { ({x: [, bar = 0]}) = {}; }", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Assignment to function parameter 'bar'." }] },
{ code: "function foo(bar) { ({bar} = {}); }", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Assignment to function parameter 'bar'." }] },
{ code: "function foo(bar) { ({x: [, bar = 0]} = {}); }", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Assignment to function parameter 'bar'." }] },

{
code: "function foo(bar) { bar.a = 0; }",
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/rules/no-undef.js
Expand Up @@ -51,8 +51,8 @@ ruleTester.run("no-undef", rule, {
{ code: "import Warning from '../lib/warning'; var warn = new Warning('text');", parserOptions: { sourceType: "module" } },
{ code: "import * as Warning from '../lib/warning'; var warn = new Warning('text');", parserOptions: { sourceType: "module" } },
{ code: "var a; [a] = [0];", parserOptions: { ecmaVersion: 6 } },
{ code: "var a; ({a}) = {};", parserOptions: { ecmaVersion: 6 } },
{ code: "var a; ({b: a}) = {};", parserOptions: { ecmaVersion: 6 } },
{ code: "var a; ({a} = {});", parserOptions: { ecmaVersion: 6 } },
{ code: "var a; ({b: a} = {});", parserOptions: { ecmaVersion: 6 } },
{ code: "var obj; [obj.a, obj.b] = [0, 1];", parserOptions: { ecmaVersion: 6 } },
{ code: "URLSearchParams;", env: { browser: true } },
{ code: "Intl;", env: { browser: true } },
Expand Down Expand Up @@ -95,8 +95,8 @@ ruleTester.run("no-undef", rule, {
{ code: "var React; React.render(<img attr={a} />);", errors: [{ message: "'a' is not defined." }], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } },
{ code: "var React, App; React.render(<App attr={a} />);", errors: [{ message: "'a' is not defined." }], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } },
{ code: "[a] = [0];", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'a' is not defined." }] },
{ code: "({a}) = {};", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'a' is not defined." }] },
{ code: "({b: a}) = {};", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'a' is not defined." }] },
{ code: "({a} = {});", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'a' is not defined." }] },
{ code: "({b: a} = {});", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'a' is not defined." }] },
{ code: "[obj.a, obj.b] = [0, 1];", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'obj' is not defined." }, { message: "'obj' is not defined." }] },

// Experimental
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/rules/no-unused-vars.js
Expand Up @@ -125,8 +125,8 @@ ruleTester.run("no-unused-vars", rule, {
{ code: "const x = 1; const {z: [y = x]} = {}; foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "const x = []; const {z: [y] = x} = {}; foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "const x = 1; let y; [y = x] = []; foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "const x = 1; let y; ({z: [y = x]}) = {}; foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "const x = []; let y; ({z: [y] = x}) = {}; foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "const x = 1; let y; ({z: [y = x]} = {}); foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "const x = []; let y; ({z: [y] = x} = {}); foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "const x = 1; function foo(y = x) { bar(y); } foo();", parserOptions: { ecmaVersion: 6 } },
{ code: "const x = 1; function foo({y = x} = {}) { bar(y); } foo();", parserOptions: { ecmaVersion: 6 } },
{ code: "const x = 1; function foo(y = function(z = x) { bar(z); }) { y(); } foo();", parserOptions: { ecmaVersion: 6 } },
Expand All @@ -136,8 +136,8 @@ ruleTester.run("no-unused-vars", rule, {
{ code: "var x = 1; var {z: [y = x]} = {}; foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "var x = []; var {z: [y] = x} = {}; foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "var x = 1, y; [y = x] = []; foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "var x = 1, y; ({z: [y = x]}) = {}; foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "var x = [], y; ({z: [y] = x}) = {}; foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "var x = 1, y; ({z: [y = x]} = {}); foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "var x = [], y; ({z: [y] = x} = {}); foo(y);", parserOptions: { ecmaVersion: 6 } },
{ code: "var x = 1; function foo(y = x) { bar(y); } foo();", parserOptions: { ecmaVersion: 6 } },
{ code: "var x = 1; function foo({y = x} = {}) { bar(y); } foo();", parserOptions: { ecmaVersion: 6 } },
{ code: "var x = 1; function foo(y = function(z = x) { bar(z); }) { y(); } foo();", parserOptions: { ecmaVersion: 6 } },
Expand Down

0 comments on commit 7bc92d9

Please sign in to comment.