From 3c755c1d4622b7608ae088c97ffd22389a4b2b88 Mon Sep 17 00:00:00 2001 From: Don Isaac Date: Tue, 6 Aug 2024 19:55:14 -0400 Subject: [PATCH] docs(linter): correct docs for no-unused-vars --- .../src/rules/eslint/no_unused_vars/mod.rs | 27 +++++++++---------- .../rules/eslint/no_unused_vars/options.rs | 4 ++- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs index f319e64720c13..e4377114d28c4 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs @@ -46,21 +46,19 @@ declare_oxc_lint!( /// A variable is _not_ considered to be used if it is only ever declared /// (`var foo = 5`) or assigned to (`foo = 7`). /// - /// #### Exported - /// - /// In environments outside of CommonJS or ECMAScript modules, you may use - /// `var` to create a global variable that may be used by other scripts. You - /// can use the `/* exported variableName */` comment block to indicate that - /// this variable is being exported and therefore should not be considered - /// unused. + /// #### Ignored Files + /// This rule ignores `.d.ts` files and `.vue` files entirely. Variables, + /// classes, interfaces, and types declared in `.d.ts` files are generally + /// used by other files, which are not checked by Oxlint. Since Oxlint does + /// not support parsing Vue templates, this rule cannot tell if a variable + /// is used or unused in a Vue file. /// - /// Note that `/* exported */` has no effect for any of the following: - /// * when the environment is `node` or `commonjs` - /// * when `parserOptions.sourceType` is `module` - /// * when `ecmaFeatures.globalReturn` is `true` + /// #### Exported /// - /// The line comment `//exported variableName` will not work as `exported` - /// is not line-specific. + /// The original ESLint rule recognizes `/* exported variableName */` + /// comments as a way to indicate that a variable is used in another script + /// and should not be considered unused. Since ES6 modules are now a TC39 + /// standard, Oxlint does not support this feature. /// /// ### Example /// @@ -129,10 +127,11 @@ declare_oxc_lint!( /// } /// ``` /// - /// Examples of **correct** code for `/* exported variableName */` operation: + /// Examples of **incorrect** code for `/* exported variableName */` operation: /// ```javascript /// /* exported global_var */ /// + /// // Not respected, use ES6 modules instead. /// var global_var = 42; /// ``` NoUnusedVars, diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/options.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/options.rs index 8180502d98ce6..76859f3ac0fbf 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/options.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/options.rs @@ -22,7 +22,9 @@ pub struct NoUnusedVarsOptions { /// names match this pattern will be ignored. /// /// By default, this pattern is `^_` unless options are configured with an - /// object. In this case it will default to [`None`]. + /// object. In this case it will default to [`None`]. Note that this + /// behavior deviates from both ESLint and TypeScript-ESLint, which never + /// provide a default pattern. /// /// ## Example ///