Skip to content

Commit

Permalink
Tune eslint packages test configuration (#10848)
Browse files Browse the repository at this point in the history
* Do not load root babel.config.js in esilnt tests

* add testcase: sourceType: script + globalReturn: true

* chore: remove globalReturn on default test config
  • Loading branch information
JLHwung authored and nicolo-ribaudo committed Dec 10, 2019
1 parent f02e5e6 commit de1fa90
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
2 changes: 2 additions & 0 deletions eslint/babel-eslint-parser/test/integration.js
Expand Up @@ -16,6 +16,8 @@ const baseEslintOpts = {
parser: "current-babel-eslint",
parserOptions: {
sourceType: "script",
requireConfigFile: false,
babelOptions: { configFile: false }
},
};

Expand Down
37 changes: 26 additions & 11 deletions eslint/babel-eslint-parser/test/non-regression.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 },
Expand All @@ -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 },
},
},
);
});
Expand Down

0 comments on commit de1fa90

Please sign in to comment.