From e4e1af723697f2efd98765cb2c968568910cd1f9 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Mon, 27 Feb 2023 17:12:38 -0500 Subject: [PATCH] [eslint] Ignore _ prefixed unused variables --- compiler/forget/.eslintrc.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/compiler/forget/.eslintrc.js b/compiler/forget/.eslintrc.js index 01eb3cfd11..a9b49faeeb 100644 --- a/compiler/forget/.eslintrc.js +++ b/compiler/forget/.eslintrc.js @@ -29,10 +29,17 @@ module.exports = { "@typescript-eslint/no-inferrable-types": "off", "@typescript-eslint/explicit-function-return-type": "error", - // Unused variables are frequently a bug. Ideally this rule would ignore identifiers - // prefixed with "_", though, so that we don't need suppressions in legit cases. - // TODO: build a custom version of this rule that understands "_" as a prefix. - "@typescript-eslint/no-unused-vars": "error", + // Unused variables are frequently a bug. Prefix unused variables with an _ to fix, but note + // that eslint won't warn you that an underscore prefixed variable is used and that the prefix + // should be dropped. + "@typescript-eslint/no-unused-vars": [ + "error", + { + argsIgnorePattern: "^_", + varsIgnorePattern: "^_", + caughtErrorsIgnorePattern: "^_", + }, + ], // Consider enabling for consistency. Ideally violations could be auto-fixed. "@typescript-eslint/consistent-generic-constructors": [