Skip to content
Permalink
Browse files

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

… (#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 1fb362093a65b99456a11029967d9ee0c31fd697
Showing with 11 additions and 1 deletion.
  1. +1 −1 lib/linter/linter.js
  2. +10 −0 tests/lib/linter/linter.js
@@ -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 = [];
@@ -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*/`;

0 comments on commit 1fb3620

Please sign in to comment.
You can’t perform that action at this time.