Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
Merge pull request #285 from josh/revert-282-no-implicit-globals-regr…
Browse files Browse the repository at this point in the history
…ession

Revert "Fix processing sourceType: script"
  • Loading branch information
hzoo committed Mar 31, 2016
2 parents 32b6723 + ac8f2f5 commit 6512450
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 50 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function monkeypatch() {
var analyze = escope.analyze;
escope.analyze = function (ast, opts) {
opts.ecmaVersion = 6;
opts.sourceType = "module";

var results = analyze.call(this, ast, opts);
return results;
Expand Down
69 changes: 19 additions & 50 deletions test/non-regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,27 @@
"use strict";
var eslint = require("eslint");

function verifyAndAssertMessages(code, rules, expectedMessages, sourceType, overrideConfig) {
var config = {
parser: require.resolve(".."),
rules: rules,
env: {
node: true,
es6: true
},
parserOptions: {
ecmaVersion: 6,
ecmaFeatures: {
jsx: true,
experimentalObjectRestSpread: true,
globalReturn: true
function verifyAndAssertMessages(code, rules, expectedMessages, sourceType) {
var messages = eslint.linter.verify(
code,
{
parser: require.resolve(".."),
rules: rules,
env: {
node: true,
es6: true
},
sourceType: sourceType || "module"
}
}

if (overrideConfig) {
for (var key in overrideConfig) {
config[key] = overrideConfig[key]
parserOptions: {
ecmaVersion: 6,
ecmaFeatures: {
jsx: true,
experimentalObjectRestSpread: true,
globalReturn: true
},
sourceType: sourceType || "module"
}
}
}

var messages = eslint.linter.verify(code, config);
);

if (messages.length !== expectedMessages.length) {
throw new Error("Expected " + expectedMessages.length + " message(s), got " + messages.length + " " + JSON.stringify(messages));
Expand Down Expand Up @@ -1142,32 +1137,6 @@ describe("verify", function () {
);
});

it("no-implicit-globals in script", function () {
verifyAndAssertMessages(
"var leakedGlobal = 1;",
{ "no-implicit-globals": 1 },
[ "1:5 Implicit global variable, assign as global property instead. no-implicit-globals" ],
"script",
{
env: {},
parserOptions: { ecmaVersion: 6, sourceType: "script" }
}
);
});

it("no-implicit-globals in module", function () {
verifyAndAssertMessages(
"var leakedGlobal = 1;",
{ "no-implicit-globals": 1 },
[],
"module",
{
env: {},
parserOptions: { ecmaVersion: 6, sourceType: "module" }
}
);
});

// This two tests are disabled, as the feature to visit properties when
// there is a spread/rest operator has been removed as it caused problems
// with other rules #249
Expand Down

0 comments on commit 6512450

Please sign in to comment.