From 4e679b134bf45aebd4cefe4dbc643fe880a2d4e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=AF=E5=88=83?= Date: Tue, 30 Jun 2020 10:30:27 +0800 Subject: [PATCH] Revert "Fix: Replace Infinity with Number.MAX_SAFE_INTEGER (fixes #13427) (#13435)" This reverts commit de77c11e7515f2097ff355ddc0d7b6db9c83c892. --- lib/cli-engine/config-array-factory.js | 7 +------ .../config-file/cloned-config/configWithInfinity.js | 6 ------ tests/lib/cli.js | 12 ++---------- 3 files changed, 3 insertions(+), 22 deletions(-) delete mode 100644 tests/fixtures/config-file/cloned-config/configWithInfinity.js diff --git a/lib/cli-engine/config-array-factory.js b/lib/cli-engine/config-array-factory.js index 39f62bb6da1..6d0992151ad 100644 --- a/lib/cli-engine/config-array-factory.js +++ b/lib/cli-engine/config-array-factory.js @@ -722,12 +722,7 @@ class ConfigArrayFactory { * * Refer https://github.com/eslint/eslint/issues/12592 */ - const clonedRulesConfig = rules && JSON.parse( - JSON.stringify( - rules, - (key, value) => (value === Infinity ? Number.MAX_SAFE_INTEGER : value) - ) - ); + const clonedRulesConfig = rules && JSON.parse(JSON.stringify((rules))); // Flatten `extends`. for (const extendName of extendList.filter(Boolean)) { diff --git a/tests/fixtures/config-file/cloned-config/configWithInfinity.js b/tests/fixtures/config-file/cloned-config/configWithInfinity.js deleted file mode 100644 index 73e3c93c085..00000000000 --- a/tests/fixtures/config-file/cloned-config/configWithInfinity.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - - rules: { - "max-len": [ "error", { code: Infinity }] - } -}; diff --git a/tests/lib/cli.js b/tests/lib/cli.js index 2f84900eefb..afb225f1f7c 100644 --- a/tests/lib/cli.js +++ b/tests/lib/cli.js @@ -1172,7 +1172,9 @@ describe("cli", () => { assert.strictEqual(exit, 0); }); + }); + describe("config file and input file", () => { it("should exit with 1 as camelcase has wrong property type", async () => { const configPath = getFixturePath("config-file", "cloned-config", "eslintConfigFail.js"); const filePath = getFixturePath("config-file", "cloned-config", "index.js"); @@ -1185,16 +1187,6 @@ describe("cli", () => { } }); - - it("should not cause an error when a rule configuration has `Infinity`", async () => { - const configPath = getFixturePath("config-file", "cloned-config", "configWithInfinity.js"); - const filePath = getFixturePath("config-file", "cloned-config", "index.js"); - const args = `--config ${configPath} ${filePath}`; - - const exit = await cli.execute(args); - - assert.strictEqual(exit, 0); - }); }); describe("inline config and input file", () => {