Skip to content

Commit

Permalink
Update: globals configuration support readonly/writable/off (fixes es…
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add committed Aug 17, 2018
1 parent 985567d commit 01ae288
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,21 @@ function parseListConfig(string) {
function addDeclaredGlobals(globalScope, configGlobals, commentDirectives) {
Object.keys(configGlobals).forEach(name => {
let variable = globalScope.set.get(name);
const value = configGlobals[name];

if (!variable) {
variable = new eslintScope.Variable(name, globalScope);
variable.eslintExplicitGlobal = false;
globalScope.variables.push(variable);
globalScope.set.set(name, variable);
}
variable.writeable = configGlobals[name];
variable.writeable = value === "writable" || value === true;
variable.turnoff = value === "off";
});

Object.keys(commentDirectives.enabledGlobals).forEach(name => {
let variable = globalScope.set.get(name);
const value = commentDirectives.enabledGlobals[name].value;

if (!variable) {
variable = new eslintScope.Variable(name, globalScope);
Expand All @@ -202,7 +205,8 @@ function addDeclaredGlobals(globalScope, configGlobals, commentDirectives) {
globalScope.variables.push(variable);
globalScope.set.set(name, variable);
}
variable.writeable = commentDirectives.enabledGlobals[name].value;
variable.writeable = value === "writable" || value === true;
variable.turnoff = value === "off";
});

// mark all exported variables as such
Expand Down

0 comments on commit 01ae288

Please sign in to comment.