From de1fa902f092222a095f9a005a2e547eae18824b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Mon, 9 Dec 2019 19:14:29 -0500 Subject: [PATCH] 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 --- .../babel-eslint-parser/test/integration.js | 2 + .../test/non-regression.js | 37 +++++++++++++------ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/eslint/babel-eslint-parser/test/integration.js b/eslint/babel-eslint-parser/test/integration.js index ecad41bdd0..d2df877c56 100644 --- a/eslint/babel-eslint-parser/test/integration.js +++ b/eslint/babel-eslint-parser/test/integration.js @@ -16,6 +16,8 @@ const baseEslintOpts = { parser: "current-babel-eslint", parserOptions: { sourceType: "script", + requireConfigFile: false, + babelOptions: { configFile: false } }, }; diff --git a/eslint/babel-eslint-parser/test/non-regression.js b/eslint/babel-eslint-parser/test/non-regression.js index b1feb30eab..63aadea4b3 100644 --- a/eslint/babel-eslint-parser/test/non-regression.js +++ b/eslint/babel-eslint-parser/test/non-regression.js @@ -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 }, + }, }, ); });