From 3d373156e32b34adc519b06ccd754b3a2c05a170 Mon Sep 17 00:00:00 2001 From: Christian Leucht Date: Thu, 27 Jun 2024 14:57:12 +0200 Subject: [PATCH] eslint-plugin/configs/recommended.js // ensure that typescript type checker is executed. eslint/no-unused-vars got disabled when introducing support for TypeScript with #27143 (2-3 years ago) when Gutenberg was moving to Typescript. By disabling this feature, the Typescript type checker will not be executed. We actively enable "no-unused-vars" and "@typescript-eslint/no-unused-vars" and additionally setting "ignoreRestSiblings" to "true", which is actively used in Gutenberg. See more information in: #54305 --- packages/eslint-plugin/configs/recommended.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/configs/recommended.js b/packages/eslint-plugin/configs/recommended.js index 72425c493fe41..f60064e80349c 100644 --- a/packages/eslint-plugin/configs/recommended.js +++ b/packages/eslint-plugin/configs/recommended.js @@ -55,8 +55,12 @@ if ( isPackageInstalled( 'typescript' ) ) { // Don't require redundant JSDoc types in TypeScript files. 'jsdoc/require-param-type': 'off', 'jsdoc/require-returns-type': 'off', - // Handled by TS itself. - 'no-unused-vars': 'off', + // Setting "no-unused-vars" to "off" will also disable + // the typescript type checker. So we need to explicitly enable it, + // but want to ignore "unused rest siblings". + // @issue https://github.com/WordPress/gutenberg/issues/54305 + 'no-unused-vars': [ 'error', { ignoreRestSiblings: true } ], + '@typescript-eslint/no-unused-vars': [ 'error', { ignoreRestSiblings: true } ], // no-shadow doesn't work correctly in TS, so let's use a TS-dedicated version instead. 'no-shadow': 'off', '@typescript-eslint/no-shadow': 'error',