Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tune eslint packages test configuration #10848

Merged
merged 3 commits into from Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
34 changes: 26 additions & 8 deletions eslint/babel-eslint-parser/test/non-regression.js
Expand Up @@ -18,26 +18,23 @@ function verifyAndAssertMessagesWithSpecificESLint(
node: true,
es6: true,
},
...overrideConfig,
parserOptions: {
sourceType,
ecmaFeatures: {
globalReturn: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this? It's better to set it explicitly in the only test where we need it rather than having a default value.

},
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 +1563,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 +1573,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