From f80a8135b44075cb4887f682d28b1e2bbf13b251 Mon Sep 17 00:00:00 2001 From: Amitjoiya Date: Sun, 7 Dec 2025 17:55:49 +0530 Subject: [PATCH] feat: add DISABLE_NO_UNUSED_VARS env variable to disable no-unused-vars ESLint rule (#17067) --- docusaurus/docs/advanced-configuration.md | 1 + packages/react-scripts/config/webpack.config.js | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/docusaurus/docs/advanced-configuration.md b/docusaurus/docs/advanced-configuration.md index a06c6eff6f4..bc983a4064d 100644 --- a/docusaurus/docs/advanced-configuration.md +++ b/docusaurus/docs/advanced-configuration.md @@ -29,4 +29,5 @@ You can adjust various development and production settings by setting environmen | TSC_COMPILE_ON_ERROR | ✅ Used | ✅ Used | When set to `true`, you can run and properly build TypeScript projects even if there are TypeScript type check errors. These errors are printed as warnings in the terminal and/or browser console. | | ESLINT_NO_DEV_ERRORS | ✅ Used | 🚫 Ignored | When set to `true`, ESLint errors are converted to warnings during development. As a result, ESLint output will no longer appear in the error overlay. | | DISABLE_ESLINT_PLUGIN | ✅ Used | ✅ Used | When set to `true`, [eslint-webpack-plugin](https://github.com/webpack-contrib/eslint-webpack-plugin) will be completely disabled. | +| DISABLE_NO_UNUSED_VARS | ✅ Used | ✅ Used | When set to `true`, disables the `no-unused-vars` and `@typescript-eslint/no-unused-vars` ESLint rules during builds. This is useful if you want to suppress warnings about unused variables while developing. | | DISABLE_NEW_JSX_TRANSFORM | ✅ Used | ✅ Used | When set to `true`, disables the [new JSX transform](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) introduced in React 17 and backported to React 16.14.0, 15.7.0, and 0.14.10. New projects will use a version of React that supports this by default but you may need to disable it in existing projects if you can't upgrade React. | diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index e465d8e7a00..1ce7276f16d 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -60,6 +60,7 @@ const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false'; const emitErrorsAsWarnings = process.env.ESLINT_NO_DEV_ERRORS === 'true'; const disableESLintPlugin = process.env.DISABLE_ESLINT_PLUGIN === 'true'; +const disableNoUnusedVarsRule = process.env.DISABLE_NO_UNUSED_VARS === 'true'; const imageInlineSizeLimit = parseInt( process.env.IMAGE_INLINE_SIZE_LIMIT || '10000' @@ -787,6 +788,14 @@ module.exports = function (webpackEnv) { }), }, }, + ...(disableNoUnusedVarsRule && { + overrideConfig: { + rules: { + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': 'off', + }, + }, + }), }), ].filter(Boolean), // Turn off performance processing because we utilize