From aeb51f463cdd7bffa05ef7bfec4e4006a2f1089a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Sat, 9 May 2020 22:12:28 +0200 Subject: [PATCH] Do not remove `"estree": null` in ESLint tests --- eslint/babel-eslint-parser/test/index.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/eslint/babel-eslint-parser/test/index.js b/eslint/babel-eslint-parser/test/index.js index 6fd61c8414..240d00d4d1 100644 --- a/eslint/babel-eslint-parser/test/index.js +++ b/eslint/babel-eslint-parser/test/index.js @@ -15,30 +15,27 @@ const PROPS_TO_REMOVE = [ "variance", "typeArguments", ]; -// We can remove needing to drop "exported" if null once this lands: -// https://github.com/acornjs/acorn/pull/889 -const PROPS_TO_REMOVE_IF_NULL = ["exported"]; -function deeplyRemoveProperties(obj, props, propsIfNull) { +function deeplyRemoveProperties(obj, props) { for (const [k, v] of Object.entries(obj)) { if (typeof v === "object") { if (Array.isArray(v)) { for (const el of v) { if (el != null) { - deeplyRemoveProperties(el, props, propsIfNull); + deeplyRemoveProperties(el, props); } } } - if (props.includes(k) || (propsIfNull.includes(k) && v === null)) { + if (props.includes(k)) { delete obj[k]; } else if (v != null) { - deeplyRemoveProperties(v, props, propsIfNull); + deeplyRemoveProperties(v, props); } continue; } - if (props.includes(k) || (propsIfNull.includes(k) && v === null)) { + if (props.includes(k)) { delete obj[k]; } } @@ -72,7 +69,7 @@ describe("Babel and Espree", () => { eslintScopeManager: true, babelOptions: BABEL_OPTIONS, }).ast; - deeplyRemoveProperties(babelAST, PROPS_TO_REMOVE, PROPS_TO_REMOVE_IF_NULL); + deeplyRemoveProperties(babelAST, PROPS_TO_REMOVE); expect(babelAST).toEqual(espreeAST); }