Skip to content

Commit

Permalink
Fix: creating of enabledGlobals object without prototype (fixes #11929)…
Browse files Browse the repository at this point in the history
… (#11935)

* Fix: creating of enabledGlobals object without prototype

* Chore: Add test (#11935)
  • Loading branch information
finico authored and aladdin-add committed Jul 6, 2019
1 parent c2f2db9 commit 1fb3620
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 1fb3620

Please sign in to comment.