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",
|
||||
parserOptions: {
|
||||
sourceType: "script",
|
||||
requireConfigFile: false,
|
||||
babelOptions: { configFile: false }
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -18,26 +18,20 @@ function verifyAndAssertMessagesWithSpecificESLint(
|
||||
node: true,
|
||||
es6: true,
|
||||
},
|
||||
...overrideConfig,
|
||||
parserOptions: {
|
||||
sourceType,
|
||||
ecmaFeatures: {
|
||||
globalReturn: true,
|
||||
},
|
||||
requireConfigFile: false,
|
||||
babelOptions: {
|
||||
configFile: path.resolve(
|
||||
__dirname,
|
||||
"./fixtures/config/babel.config.js",
|
||||
),
|
||||
},
|
||||
...overrideConfig?.parserOptions,
|
||||
},
|
||||
};
|
||||
|
||||
if (overrideConfig) {
|
||||
for (const key in overrideConfig) {
|
||||
config[key] = overrideConfig[key];
|
||||
}
|
||||
}
|
||||
|
||||
const messages = linter.verify(code, config);
|
||||
|
||||
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(
|
||||
"var leakedGlobal = 1;",
|
||||
{ "no-implicit-globals": 1 },
|
||||
@ -1576,7 +1570,28 @@ describe("verify", () => {
|
||||
"script",
|
||||
{
|
||||
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