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

Fix: creating of enabledGlobals object without prototype (fixes #11929) #11935

Merged
merged 2 commits into from Jul 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/linter/linter.js
Expand Up @@ -262,7 +262,7 @@ function createDisableDirectives(options) {
*/
function getDirectiveComments(filename, ast, ruleMapper) {
const configuredRules = {};
const enabledGlobals = {};
const enabledGlobals = Object.create(null);
const exportedVariables = {};
const problems = [];
const disableDirectives = [];
Expand Down
10 changes: 10 additions & 0 deletions tests/lib/linter/linter.js
Expand Up @@ -1208,6 +1208,16 @@ describe("Linter", () => {
});
});

describe("when evaluating code containing a /*global */ block with specific variables", () => {
const code = "/* global toString hasOwnProperty valueOf: true */";

it("should not throw an error if comment block has global variables which are Object.prototype contains", () => {
const config = { rules: { checker: "error" } };

linter.verify(code, config);
});
});

describe("when evaluating code containing /*eslint-env */ block", () => {
it("variables should be available in global scope", () => {
const code = `/*${ESLINT_ENV} node*/ function f() {} /*${ESLINT_ENV} browser, foo*/`;
Expand Down