Skip to content

Commit

Permalink
Chore: fix invalid redeclared variables in tests (#8130)
Browse files Browse the repository at this point in the history
  • Loading branch information
not-an-aardvark authored and gyandeeps committed Feb 22, 2017
1 parent 8d95598 commit 22d7fbf
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.
20 changes: 10 additions & 10 deletions tests/lib/rules/indent.js
Expand Up @@ -900,16 +900,16 @@ ruleTester.run("indent", rule, {
" a: 1,\n" +
" b: 2\n" +
" };\n" +
"let abc = 5,\n" +
" c = 2,\n" +
" xyz = \n" +
"let abc2 = 5,\n" +
" c2 = 2,\n" +
" xyz2 = \n" +
" {\n" +
" a: 1,\n" +
" b: 2\n" +
" };\n" +
"var abc = 5,\n" +
" c = 2,\n" +
" xyz = \n" +
"var abc3 = 5,\n" +
" c3 = 2,\n" +
" xyz3 = \n" +
" {\n" +
" a: 1,\n" +
" b: 2\n" +
Expand Down Expand Up @@ -2806,19 +2806,19 @@ ruleTester.run("indent", rule, {
" a: 1\n" +
" }),\n" +
" b = 4;\n" +
"const a = new Test({\n" +
"const c = new Test({\n" +
" a: 1\n" +
" }),\n" +
" b = 4;\n",
" d = 4;\n",
output:
"var a = new Test({\n" +
" a: 1\n" +
" }),\n" +
" b = 4;\n" +
"const a = new Test({\n" +
"const c = new Test({\n" +
" a: 1\n" +
" }),\n" +
" b = 4;\n",
" d = 4;\n",
options: [2, { VariableDeclarator: { var: 2 } }],
parserOptions: { ecmaVersion: 6 },
errors: expectedErrors([
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rules/no-redeclare.js
Expand Up @@ -39,7 +39,7 @@ ruleTester.run("no-redeclare", rule, {
],
invalid: [
{ code: "var a = 3; var a = 10;", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'a' is already defined.", type: "Identifier" }] },
{ code: "switch(foo) { case a: let b = 3;\ncase b: let b = 4}", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'b' is already defined.", type: "Identifier" }] },
{ code: "switch(foo) { case a: var b = 3;\ncase b: var b = 4}", errors: [{ message: "'b' is already defined.", type: "Identifier" }] },
{ code: "var a = 3; var a = 10;", errors: [{ message: "'a' is already defined.", type: "Identifier" }] },
{ code: "var a = {}; var a = [];", errors: [{ message: "'a' is already defined.", type: "Identifier" }] },
{ code: "var a; function a() {}", errors: [{ message: "'a' is already defined.", type: "Identifier" }] },
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rules/no-shadow.js
Expand Up @@ -27,7 +27,7 @@ ruleTester.run("no-shadow", rule, {
{ code: "class A {}", parserOptions: { ecmaVersion: 6 } },
{ code: "class A { constructor() { var a; } }", parserOptions: { ecmaVersion: 6 } },
{ code: "(function() { var A = class A {}; })()", parserOptions: { ecmaVersion: 6 } },
{ code: "{ var a; } let a;", parserOptions: { ecmaVersion: 6 } }, // this case reports `no-redeclare`, not shadowing.
{ code: "{ var a; } var a;", parserOptions: { ecmaVersion: 6 } }, // this case reports `no-redeclare`, not shadowing.
{ code: "{ let a; } let a;", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
{ code: "{ let a; } var a;", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
{ code: "{ let a; } function a() {}", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
Expand Down
8 changes: 1 addition & 7 deletions tests/lib/rules/prefer-const.js
Expand Up @@ -92,13 +92,7 @@ ruleTester.run("prefer-const", rule, {
{
code: "let x; function foo() { bar(x); } x = 0;",
options: [{ ignoreReadBeforeAssign: true }]
},

// https://github.com/eslint/eslint/issues/7712
// https://github.com/ternjs/acorn/issues/487
// This should be a SyntaxError, but espree parses it correctly. Don't throw an error if the variable has multiple declarations.
"let foo; const foo = 1;"

}
],
invalid: [
{
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/rules/sort-imports.js
Expand Up @@ -57,7 +57,7 @@ ruleTester.run("sort-imports", rule, {
{
code:
"import {a, b} from 'bar.js';\n" +
"import {b, c} from 'foo.js';"
"import {c, d} from 'foo.js';"
},
{
code:
Expand All @@ -72,7 +72,7 @@ ruleTester.run("sort-imports", rule, {
{
code:
"import a, * as b from 'foo.js';\n" +
"import b from 'bar.js';"
"import c from 'bar.js';"
},
{
code:
Expand Down Expand Up @@ -147,7 +147,7 @@ ruleTester.run("sort-imports", rule, {
{
code:
"import {b, c} from 'foo.js';\n" +
"import {a, b} from 'bar.js';",
"import {a, d} from 'bar.js';",
errors: [expectedError]
},
{
Expand Down

0 comments on commit 22d7fbf

Please sign in to comment.