Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking: make no-redeclare stricter (fixes #11370, fixes #11405) #11509

Merged
merged 17 commits into from Apr 25, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

chore: fix test-case-property-ordering

  • Loading branch information...
mysticatea committed Mar 15, 2019
commit 9493cd49c6dc32cfecd218daa3e4b16bdf6421a7
@@ -17,7 +17,22 @@ module.exports = {
"eslint-plugin/prefer-placeholders": "error",
"eslint-plugin/report-message-format": ["error", "[^a-z].*\\.$"],
"eslint-plugin/require-meta-type": "error",
"eslint-plugin/test-case-property-ordering": "error",
"eslint-plugin/test-case-property-ordering": [
"error",

// https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/79
[
"filename",
"code",
"output",
"options",
"parser",
"parserOptions",
"globals",
"env",
"errors"
]
],
This conversation was marked as resolved by mysticatea

This comment has been minimized.

Copy link
@not-an-aardvark

not-an-aardvark Mar 15, 2019

Member

Can we make this change in a separate PR? (To avoid merge conflicts later, we could merge it as a Chore soon, before v6 prereleases start.)

This comment has been minimized.

Copy link
@mysticatea

mysticatea Mar 15, 2019

Author Member

Done #11511

"eslint-plugin/test-case-shorthand-strings": "error",
"internal-rules/multiline-comment-style": "error"
},
@@ -174,8 +174,8 @@ ruleTester.run("array-bracket-spacing", rule, {
{ code: "var obj = {'foo': [1, 2]}", options: ["never"] },

// destructuring with type annotation
{ code: "([ a, b ]: Array<any>) => {}", options: ["always"], parserOptions: { ecmaVersion: 6 }, parser: parser("flow-destructuring-1") },
{ code: "([a, b]: Array< any >) => {}", options: ["never"], parserOptions: { ecmaVersion: 6 }, parser: parser("flow-destructuring-2") }
{ code: "([ a, b ]: Array<any>) => {}", options: ["always"], parser: parser("flow-destructuring-1"), parserOptions: { ecmaVersion: 6 } },
{ code: "([a, b]: Array< any >) => {}", options: ["never"], parser: parser("flow-destructuring-2"), parserOptions: { ecmaVersion: 6 } }
],

invalid: [
@@ -830,6 +830,7 @@ ruleTester.run("array-bracket-spacing", rule, {
code: "([ a, b ]: Array<any>) => {}",
output: "([a, b]: Array<any>) => {}",
options: ["never"],
parser: parser("flow-destructuring-1"),
parserOptions: {
ecmaVersion: 6
},
@@ -852,13 +853,13 @@ ruleTester.run("array-bracket-spacing", rule, {
line: 1,
column: 9
}
],
parser: parser("flow-destructuring-1")
]
},
{
code: "([a, b]: Array< any >) => {}",
output: "([ a, b ]: Array< any >) => {}",
options: ["always"],
parser: parser("flow-destructuring-2"),
parserOptions: {
ecmaVersion: 6
},
@@ -881,8 +882,7 @@ ruleTester.run("array-bracket-spacing", rule, {
line: 1,
column: 7
}
],
parser: parser("flow-destructuring-2")
]
}
]
});
@@ -1410,29 +1410,29 @@ let d = 0;export {d,};
code: "function foo({a}: {a: string,}) {}",
output: "function foo({a,}: {a: string,}) {}",
options: ["always"],
errors: [{ messageId: "missing" }],
parser: parser("object-pattern-1")
parser: parser("object-pattern-1"),
errors: [{ messageId: "missing" }]
},
{
code: "function foo({a,}: {a: string}) {}",
output: "function foo({a}: {a: string}) {}",
options: ["never"],
errors: [{ messageId: "unexpected" }],
parser: parser("object-pattern-2")
parser: parser("object-pattern-2"),
errors: [{ messageId: "unexpected" }]
},
{
code: "function foo(a): {b: boolean,} {}",
output: "function foo(a,): {b: boolean,} {}",
options: [{ functions: "always" }],
errors: [{ messageId: "missing" }],
parser: parser("return-type-1")
parser: parser("return-type-1"),
errors: [{ messageId: "missing" }]
},
{
code: "function foo(a,): {b: boolean} {}",
output: "function foo(a): {b: boolean} {}",
options: [{ functions: "never" }],
errors: [{ messageId: "unexpected" }],
parser: parser("return-type-2")
parser: parser("return-type-2"),
errors: [{ messageId: "unexpected" }]
}
]
});
@@ -8686,8 +8686,8 @@ ruleTester.run("indent", rule, {
}
}
`,
errors: expectedErrors([[3, 8, 4, "Identifier"], [6, 8, 4, "Keyword"]]),
parser: parser("unknown-nodes/namespace-invalid")
parser: parser("unknown-nodes/namespace-invalid"),
errors: expectedErrors([[3, 8, 4, "Identifier"], [6, 8, 4, "Keyword"]])
},
{
code: unIndent`
@@ -8718,8 +8718,8 @@ ruleTester.run("indent", rule, {
}
}
`,
errors: expectedErrors([[4, 12, 8, "Identifier"], [7, 12, 8, "Identifier"], [10, 8, 4, "Identifier"]]),
parser: parser("unknown-nodes/abstract-class-invalid")
parser: parser("unknown-nodes/abstract-class-invalid"),
errors: expectedErrors([[4, 12, 8, "Identifier"], [7, 12, 8, "Identifier"], [10, 8, 4, "Identifier"]])
},
{
code: unIndent`
@@ -8748,14 +8748,14 @@ ruleTester.run("indent", rule, {
}
}
`,
parser: parser("unknown-nodes/functions-with-abstract-class-invalid"),
errors: expectedErrors([
[4, 12, 8, "Keyword"],
[5, 16, 8, "Keyword"],
[6, 20, 8, "Identifier"],
[7, 16, 8, "Punctuator"],
[8, 12, 8, "Punctuator"]
]),
parser: parser("unknown-nodes/functions-with-abstract-class-invalid")
])
},
{
code: unIndent`
@@ -8788,11 +8788,11 @@ ruleTester.run("indent", rule, {
}
}
`,
parser: parser("unknown-nodes/namespace-with-functions-with-abstract-class-invalid"),
errors: expectedErrors([
[3, 8, 4, "Keyword"],
[7, 24, 20, "Identifier"]
]),
parser: parser("unknown-nodes/namespace-with-functions-with-abstract-class-invalid")
])
},

//----------------------------------------------------------------------
@@ -9369,8 +9369,8 @@ ruleTester.run("indent", rule, {
foo
}: bar) => baz
`,
errors: expectedErrors([3, 0, 4, "Punctuator"]),
parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-annotation")
parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-annotation"),
errors: expectedErrors([3, 0, 4, "Punctuator"])
},
{
code: unIndent`
@@ -9383,8 +9383,8 @@ ruleTester.run("indent", rule, {
foo
]: bar) => baz
`,
errors: expectedErrors([3, 0, 4, "Punctuator"]),
parser: require.resolve("../../fixtures/parsers/babel-eslint7/array-pattern-with-annotation")
parser: require.resolve("../../fixtures/parsers/babel-eslint7/array-pattern-with-annotation"),
errors: expectedErrors([3, 0, 4, "Punctuator"])
},
{
code: unIndent`
@@ -9397,8 +9397,8 @@ ruleTester.run("indent", rule, {
foo
}: {}) => baz
`,
errors: expectedErrors([3, 0, 4, "Punctuator"]),
parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-object-annotation")
parser: require.resolve("../../fixtures/parsers/babel-eslint7/object-pattern-with-object-annotation"),
errors: expectedErrors([3, 0, 4, "Punctuator"])
},
{
code: unIndent`
@@ -3135,8 +3135,8 @@ ruleTester.run("keyword-spacing", rule, {
{
code: "class Foo { @desc({set a(value) {}, get a() {}, async c() {}}) async[foo]() {} }",
output: "class Foo { @desc({set a(value) {}, get a() {}, async c() {}}) async [foo]() {} }",
errors: expectedAfter("async"),
parser: parser("typescript-parsers/decorator-with-keywords-class-method")
parser: parser("typescript-parsers/decorator-with-keywords-class-method"),
errors: expectedAfter("async")
}
]
});
@@ -58,6 +58,6 @@ ruleTester.run("no-console", rule, {
{ code: "console.warn(foo)", options: [{ allow: ["info", "log"] }], errors: [{ messageId: "unexpected", type: "MemberExpression" }] },

// In case that implicit global variable of 'console' exists
{ code: "console.log(foo)", errors: [{ messageId: "unexpected", type: "MemberExpression" }], env: { node: true } }
{ code: "console.log(foo)", env: { node: true }, errors: [{ messageId: "unexpected", type: "MemberExpression" }] }
]
});
@@ -72,17 +72,17 @@ ruleTester.run("no-eval", rule, {

// Indirect eval
{ code: "(0, eval)('foo')", errors: [{ messageId: "unexpected", type: "Identifier" }] },
{ code: "(0, window.eval)('foo')", errors: [{ messageId: "unexpected", type: "MemberExpression" }], env: { browser: true } },
{ code: "(0, window['eval'])('foo')", errors: [{ messageId: "unexpected", type: "MemberExpression" }], env: { browser: true } },
{ code: "(0, window.eval)('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "MemberExpression" }] },
{ code: "(0, window['eval'])('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "MemberExpression" }] },
{ code: "var EVAL = eval; EVAL('foo')", errors: [{ messageId: "unexpected", type: "Identifier" }] },
{ code: "var EVAL = this.eval; EVAL('foo')", errors: [{ messageId: "unexpected", type: "MemberExpression" }] },
{ code: "(function(exe){ exe('foo') })(eval);", errors: [{ messageId: "unexpected", type: "Identifier" }] },
{ code: "window.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { browser: true } },
{ code: "window.window.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { browser: true } },
{ code: "window.window['eval']('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { browser: true } },
{ code: "global.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { node: true } },
{ code: "global.global.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { node: true } },
{ code: "global.global[`eval`]('foo')", parserOptions: { ecmaVersion: 6 }, errors: [{ messageId: "unexpected", type: "CallExpression" }], env: { node: true } },
{ code: "window.eval('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] },
{ code: "window.window.eval('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] },
{ code: "window.window['eval']('foo')", env: { browser: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] },
{ code: "global.eval('foo')", env: { node: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] },
{ code: "global.global.eval('foo')", env: { node: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] },
{ code: "global.global[`eval`]('foo')", parserOptions: { ecmaVersion: 6 }, env: { node: true }, errors: [{ messageId: "unexpected", type: "CallExpression" }] },
{ code: "this.eval('foo')", errors: [{ messageId: "unexpected", type: "CallExpression" }] },
{ code: "function foo() { this.eval('foo') }", errors: [{ messageId: "unexpected", type: "CallExpression" }] }
]
@@ -42,18 +42,18 @@ ruleTester.run("no-global-assign", rule, {
},
{
code: "top = 0;",
errors: [{ message: "Read-only global 'top' should not be modified.", type: "Identifier" }],
env: { browser: true }
env: { browser: true },
errors: [{ message: "Read-only global 'top' should not be modified.", type: "Identifier" }]
},
{
code: "require = 0;",
errors: [{ message: "Read-only global 'require' should not be modified.", type: "Identifier" }],
env: { node: true }
env: { node: true },
errors: [{ message: "Read-only global 'require' should not be modified.", type: "Identifier" }]
},

// Notifications of readonly are moved from no-undef: https://github.com/eslint/eslint/issues/4504
{ code: "/*global b:false*/ function f() { b = 1; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] },
{ code: "function f() { b = 1; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }], globals: { b: false } },
{ code: "function f() { b = 1; }", globals: { b: false }, errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] },
{ code: "/*global b:false*/ function f() { b++; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] },
{ code: "/*global b*/ b = 1;", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] },
{ code: "Array = 1;", errors: [{ message: "Read-only global 'Array' should not be modified.", type: "Identifier" }] }
@@ -83,8 +83,8 @@ ruleTester.run("no-magic-numbers", rule, {
options: [{
enforceConst: true
}],
errors: [{ messageId: "useConst" }],
env: { es6: true }
env: { es6: true },
errors: [{ messageId: "useConst" }]
},
{
code: "var foo = 0 + 1;",
@@ -189,15 +189,15 @@ ruleTester.run("no-magic-numbers", rule, {
"function invokeInTen(func) {\n" +
"setTimeout(func, 10);\n" +
"}\n",
env: { es6: true },
errors: [
{ messageId: "noMagic", data: { raw: "10" }, line: 7 },
{ messageId: "noMagic", data: { raw: "10" }, line: 7 },
{ messageId: "noMagic", data: { raw: "24" }, line: 11 },
{ messageId: "noMagic", data: { raw: "1000" }, line: 15 },
{ messageId: "noMagic", data: { raw: "0" }, line: 19 },
{ messageId: "noMagic", data: { raw: "10" }, line: 22 }
],
env: { es6: true }
]
},
{
code: "var data = ['foo', 'bar', 'baz']; var third = data[3];",
@@ -136,27 +136,27 @@ ruleTester.run("no-mixed-spaces-and-tabs", rule, {
{
code: "`foo${\n \t 5 }bar`;",
options: ["smart-tabs"],
env: { es6: true },
errors: [
{
message: "Mixed spaces and tabs.",
type: "Program",
line: 2,
column: 2
}
],
env: { es6: true }
]
},
{
code: "`foo${\n\t 5 }bar`;",
env: { es6: true },
errors: [
{
message: "Mixed spaces and tabs.",
type: "Program",
line: 2,
column: 2
}
],
env: { es6: true }
]
}
]
});
@@ -43,18 +43,18 @@ ruleTester.run("no-native-reassign", rule, {
},
{
code: "top = 0;",
errors: [{ message: "Read-only global 'top' should not be modified.", type: "Identifier" }],
env: { browser: true }
env: { browser: true },
errors: [{ message: "Read-only global 'top' should not be modified.", type: "Identifier" }]
},
{
code: "require = 0;",
errors: [{ message: "Read-only global 'require' should not be modified.", type: "Identifier" }],
env: { node: true }
env: { node: true },
errors: [{ message: "Read-only global 'require' should not be modified.", type: "Identifier" }]
},

// Notifications of readonly are moved from no-undef: https://github.com/eslint/eslint/issues/4504
{ code: "/*global b:false*/ function f() { b = 1; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] },
{ code: "function f() { b = 1; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }], globals: { b: false } },
{ code: "function f() { b = 1; }", globals: { b: false }, errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] },
{ code: "/*global b:false*/ function f() { b++; }", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] },
{ code: "/*global b*/ b = 1;", errors: [{ message: "Read-only global 'b' should not be modified.", type: "Identifier" }] },
{ code: "Array = 1;", errors: [{ message: "Read-only global 'Array' should not be modified.", type: "Identifier" }] }
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.