Skip to content

Commit f80a813

Browse files
committed
feat: add DISABLE_NO_UNUSED_VARS env variable to disable no-unused-vars ESLint rule (#17067)
1 parent 6254386 commit f80a813

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

docusaurus/docs/advanced-configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ You can adjust various development and production settings by setting environmen
2929
| 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. |
3030
| 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. |
3131
| DISABLE_ESLINT_PLUGIN | ✅ Used | ✅ Used | When set to `true`, [eslint-webpack-plugin](https://github.com/webpack-contrib/eslint-webpack-plugin) will be completely disabled. |
32+
| 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. |
3233
| 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. |

packages/react-scripts/config/webpack.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
6060

6161
const emitErrorsAsWarnings = process.env.ESLINT_NO_DEV_ERRORS === 'true';
6262
const disableESLintPlugin = process.env.DISABLE_ESLINT_PLUGIN === 'true';
63+
const disableNoUnusedVarsRule = process.env.DISABLE_NO_UNUSED_VARS === 'true';
6364

6465
const imageInlineSizeLimit = parseInt(
6566
process.env.IMAGE_INLINE_SIZE_LIMIT || '10000'
@@ -787,6 +788,14 @@ module.exports = function (webpackEnv) {
787788
}),
788789
},
789790
},
791+
...(disableNoUnusedVarsRule && {
792+
overrideConfig: {
793+
rules: {
794+
'no-unused-vars': 'off',
795+
'@typescript-eslint/no-unused-vars': 'off',
796+
},
797+
},
798+
}),
790799
}),
791800
].filter(Boolean),
792801
// Turn off performance processing because we utilize

0 commit comments

Comments
 (0)