Tune eslint packages test configuration (#10848)
* Do not load root babel.config.js in esilnt tests * add testcase: sourceType: script + globalReturn: true * chore: remove globalReturn on default test config
This commit is contained in:
parent
f02e5e6d0a
commit
de1fa902f0
@ -16,6 +16,8 @@ const baseEslintOpts = {
|
|||||||
parser: "current-babel-eslint",
|
parser: "current-babel-eslint",
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
sourceType: "script",
|
sourceType: "script",
|
||||||
|
requireConfigFile: false,
|
||||||
|
babelOptions: { configFile: false }
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -18,26 +18,20 @@ function verifyAndAssertMessagesWithSpecificESLint(
|
|||||||
node: true,
|
node: true,
|
||||||
es6: true,
|
es6: true,
|
||||||
},
|
},
|
||||||
|
...overrideConfig,
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
sourceType,
|
sourceType,
|
||||||
ecmaFeatures: {
|
requireConfigFile: false,
|
||||||
globalReturn: true,
|
|
||||||
},
|
|
||||||
babelOptions: {
|
babelOptions: {
|
||||||
configFile: path.resolve(
|
configFile: path.resolve(
|
||||||
__dirname,
|
__dirname,
|
||||||
"./fixtures/config/babel.config.js",
|
"./fixtures/config/babel.config.js",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
...overrideConfig?.parserOptions,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (overrideConfig) {
|
|
||||||
for (const key in overrideConfig) {
|
|
||||||
config[key] = overrideConfig[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const messages = linter.verify(code, config);
|
const messages = linter.verify(code, config);
|
||||||
|
|
||||||
if (messages.length !== expectedMessages.length) {
|
if (messages.length !== expectedMessages.length) {
|
||||||
@ -1566,7 +1560,7 @@ describe("verify", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("no-implicit-globals in script", () => {
|
it("no-implicit-globals in script: globalReturn is false", () => {
|
||||||
verifyAndAssertMessages(
|
verifyAndAssertMessages(
|
||||||
"var leakedGlobal = 1;",
|
"var leakedGlobal = 1;",
|
||||||
{ "no-implicit-globals": 1 },
|
{ "no-implicit-globals": 1 },
|
||||||
@ -1576,7 +1570,28 @@ describe("verify", () => {
|
|||||||
"script",
|
"script",
|
||||||
{
|
{
|
||||||
env: {},
|
env: {},
|
||||||
parserOptions: { ecmaVersion: 6, sourceType: "script" },
|
parserOptions: {
|
||||||
|
ecmaVersion: 6,
|
||||||
|
sourceType: "script",
|
||||||
|
ecmaFeatures: { globalReturn: false },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("no-implicit-globals in script: globalReturn is true", () => {
|
||||||
|
verifyAndAssertMessages(
|
||||||
|
"var leakedGlobal = 1;",
|
||||||
|
{ "no-implicit-globals": 1 },
|
||||||
|
[],
|
||||||
|
"script",
|
||||||
|
{
|
||||||
|
env: {},
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 6,
|
||||||
|
sourceType: "script",
|
||||||
|
ecmaFeatures: { globalReturn: true },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user