Merge pull request babel/babel-eslint#285 from josh/revert-282-no-implicit-globals-regression
Revert "Fix processing sourceType: script"
This commit is contained in:
parent
1fe0d4a94b
commit
3c9ef8ec7e
@ -76,6 +76,7 @@ function monkeypatch() {
|
|||||||
var analyze = escope.analyze;
|
var analyze = escope.analyze;
|
||||||
escope.analyze = function (ast, opts) {
|
escope.analyze = function (ast, opts) {
|
||||||
opts.ecmaVersion = 6;
|
opts.ecmaVersion = 6;
|
||||||
|
opts.sourceType = "module";
|
||||||
|
|
||||||
var results = analyze.call(this, ast, opts);
|
var results = analyze.call(this, ast, opts);
|
||||||
return results;
|
return results;
|
||||||
|
|||||||
@ -2,8 +2,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var eslint = require("eslint");
|
var eslint = require("eslint");
|
||||||
|
|
||||||
function verifyAndAssertMessages(code, rules, expectedMessages, sourceType, overrideConfig) {
|
function verifyAndAssertMessages(code, rules, expectedMessages, sourceType) {
|
||||||
var config = {
|
var messages = eslint.linter.verify(
|
||||||
|
code,
|
||||||
|
{
|
||||||
parser: require.resolve(".."),
|
parser: require.resolve(".."),
|
||||||
rules: rules,
|
rules: rules,
|
||||||
env: {
|
env: {
|
||||||
@ -20,14 +22,7 @@ function verifyAndAssertMessages(code, rules, expectedMessages, sourceType, over
|
|||||||
sourceType: sourceType || "module"
|
sourceType: sourceType || "module"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
);
|
||||||
if (overrideConfig) {
|
|
||||||
for (var key in overrideConfig) {
|
|
||||||
config[key] = overrideConfig[key]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var messages = eslint.linter.verify(code, config);
|
|
||||||
|
|
||||||
if (messages.length !== expectedMessages.length) {
|
if (messages.length !== expectedMessages.length) {
|
||||||
throw new Error("Expected " + expectedMessages.length + " message(s), got " + messages.length + " " + JSON.stringify(messages));
|
throw new Error("Expected " + expectedMessages.length + " message(s), got " + messages.length + " " + JSON.stringify(messages));
|
||||||
@ -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
|
// 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
|
// there is a spread/rest operator has been removed as it caused problems
|
||||||
// with other rules #249
|
// with other rules #249
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user