From 795c8f4fabde3f7d7f0aeee79df8ab6e89589d2a Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 27 Jul 2023 20:16:35 -0400 Subject: [PATCH 1/2] docs: explain no-unused-vars advantages over TypeScript --- .../docs/rules/no-unused-vars.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/no-unused-vars.md b/packages/eslint-plugin/docs/rules/no-unused-vars.md index 8fd90f74ae5a..dc8736cc3a52 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-vars.md +++ b/packages/eslint-plugin/docs/rules/no-unused-vars.md @@ -6,7 +6,22 @@ description: 'Disallow unused variables.' > > See **https://typescript-eslint.io/rules/no-unused-vars** for documentation. -## Examples - This rule extends the base [`eslint/no-unused-vars`](https://eslint.org/docs/rules/no-unused-vars) rule. It adds support for TypeScript features, such as types. + +## Benefits Over TypeScript + +TypeScript provides [`noUnusedLocals`](https://www.typescriptlang.org/tsconfig#noUnusedLocals) and [`noUnusedParameters`](https://www.typescriptlang.org/tsconfig#noUnusedParameters) compiler options that can report errors on unused local variables or parameters, respectively. +Those compiler options can be convenient to use if you don't want to set up ESLint and typescript-eslint. +However: + +- These lint rules are more configurable than TypeScript's compiler options. + - For example, the [`varsIgnorePattern` option](https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern) can customize what names are always allowed to be exempted. TypeScript hardcodes its exemptions to names starting with `_`. +- [ESLint can be configured](https://eslint.org/docs/latest/use/configure/rules) within lines, files, and folders. TypeScript compiler options are linked to their TSConfig file. +- Many projects configure TypeScript's reported errors tend to block builds more aggressively than ESLint complaints. Blocking builds on unused variables can be inconvenient. + +We generally recommend using `@typescript-eslint/no-unused-vars` to flag unused locals and parameters instead of TypeScript. + +:::tip +Editors such as VS Code will still generally "grey out" unused variables even if `noUnusedLocals` and `noUnusedParameters` are not enabled in a project. +::: From 983010fea2644b81db7ee5ca7af88d7c13859218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Mon, 31 Jul 2023 11:24:15 -0400 Subject: [PATCH 2/2] Update packages/eslint-plugin/docs/rules/no-unused-vars.md --- packages/eslint-plugin/docs/rules/no-unused-vars.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/docs/rules/no-unused-vars.md b/packages/eslint-plugin/docs/rules/no-unused-vars.md index dc8736cc3a52..eef57d3830dd 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-vars.md +++ b/packages/eslint-plugin/docs/rules/no-unused-vars.md @@ -18,7 +18,7 @@ However: - These lint rules are more configurable than TypeScript's compiler options. - For example, the [`varsIgnorePattern` option](https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern) can customize what names are always allowed to be exempted. TypeScript hardcodes its exemptions to names starting with `_`. - [ESLint can be configured](https://eslint.org/docs/latest/use/configure/rules) within lines, files, and folders. TypeScript compiler options are linked to their TSConfig file. -- Many projects configure TypeScript's reported errors tend to block builds more aggressively than ESLint complaints. Blocking builds on unused variables can be inconvenient. +- Many projects configure TypeScript's reported errors to block builds more aggressively than ESLint complaints. Blocking builds on unused variables can be inconvenient. We generally recommend using `@typescript-eslint/no-unused-vars` to flag unused locals and parameters instead of TypeScript. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy