From a442ffd4009994ea6e4bec03258bef999ec528f9 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Thu, 21 Sep 2023 11:12:04 +0200 Subject: [PATCH] fix(eslint-plugin): cache access to `NODE_ENV` (#2693) --- .changeset/tasty-stingrays-add.md | 5 +++++ packages/eslint-plugin/src/rules/no-export-all.js | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/tasty-stingrays-add.md diff --git a/.changeset/tasty-stingrays-add.md b/.changeset/tasty-stingrays-add.md new file mode 100644 index 000000000..2f2c3da67 --- /dev/null +++ b/.changeset/tasty-stingrays-add.md @@ -0,0 +1,5 @@ +--- +"@rnx-kit/eslint-plugin": patch +--- + +Cache access to `NODE_ENV` diff --git a/packages/eslint-plugin/src/rules/no-export-all.js b/packages/eslint-plugin/src/rules/no-export-all.js index d1b7b16b7..147c826d8 100644 --- a/packages/eslint-plugin/src/rules/no-export-all.js +++ b/packages/eslint-plugin/src/rules/no-export-all.js @@ -41,6 +41,8 @@ const DEFAULT_CONFIG = { eslintScopeManager: true, }; +const NODE_ENV = process.env.NODE_ENV; + /** * Returns whether there are any named exports. * @param {NamedExports?} namedExports @@ -93,7 +95,7 @@ const resolveFrom = /** @type {() => (fromDir: string, moduleId: string) => string} */ ( () => { - if (process.env.NODE_ENV === "test") { + if (NODE_ENV === "test") { return (_, moduleId) => moduleId; }