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

Breaking: enable no-redeclare builtinGlobals

- Fixes #11405
  • Loading branch information...
mysticatea committed Mar 15, 2019
commit 722537a56cc143a6bf48f2521605111cc617f738
@@ -36,7 +36,7 @@ module.exports = {
{
type: "object",
properties: {
builtinGlobals: { type: "boolean", default: false }
builtinGlobals: { type: "boolean", default: true }
},
additionalProperties: false
}
@@ -46,8 +46,8 @@ module.exports = {
create(context) {
const options = {
builtinGlobals: Boolean(
context.options[0] &&
context.options[0].builtinGlobals
context.options.length === 0 ||
context.options[0].builtinGlobals !== false
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
Suggested change
context.options[0].builtinGlobals !== false
context.options[0].builtinGlobals

Since default is used, I think this will always be a boolean.

)
};
const sourceCode = context.getSourceCode();
@@ -2,7 +2,6 @@
* @fileoverview Tests for eslint object.
* @author Nicholas C. Zakas
*/
/* globals window */

"use strict";

@@ -30,11 +30,9 @@ ruleTester.run("no-redeclare", rule, {
ecmaVersion: 6
}
},
"var Object = 0;",
{ code: "var Object = 0;", options: [{ builtinGlobals: false }] },
{ code: "var Object = 0;", options: [{ builtinGlobals: true }], parserOptions: { sourceType: "module" } },
{ code: "var Object = 0;", options: [{ builtinGlobals: true }], parserOptions: { ecmaFeatures: { globalReturn: true } } },
{ code: "var top = 0;", env: { browser: true } },
{ code: "var top = 0;", options: [{ builtinGlobals: true }] },
{ code: "var top = 0;", options: [{ builtinGlobals: true }], parserOptions: { ecmaFeatures: { globalReturn: true } }, env: { browser: true } },
{ code: "var top = 0;", options: [{ builtinGlobals: true }], parserOptions: { sourceType: "module" }, env: { browser: true } },
@@ -165,6 +163,20 @@ ruleTester.run("no-redeclare", rule, {
]
},

{
code: "var Object = 0;",
errors: [
{ message: "'Object' is already defined as a built-in global variable.", type: "Identifier" }
]
},
{
code: "var top = 0;",
env: { browser: true },
errors: [
{ message: "'top' is already defined as a built-in global variable.", type: "Identifier" }
]
},

// let/const
{
code: "let a; let a;",
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.