Skip to content

Commit

Permalink
eslint-plugin/configs/recommended.js // ensure that typescript type c…
Browse files Browse the repository at this point in the history
…hecker is executed.

eslint/no-unused-vars got disabled when introducing support for TypeScript with WordPress#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: WordPress#54305
  • Loading branch information
Chrico authored Jun 27, 2024
1 parent ea72cf1 commit 3d37315
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/eslint-plugin/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3d37315

Please sign in to comment.