Skip to content

Commit 3c755c1

Browse files
committed
docs(linter): correct docs for no-unused-vars
1 parent e285903 commit 3c755c1

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,19 @@ declare_oxc_lint!(
4646
/// A variable is _not_ considered to be used if it is only ever declared
4747
/// (`var foo = 5`) or assigned to (`foo = 7`).
4848
///
49-
/// #### Exported
50-
///
51-
/// In environments outside of CommonJS or ECMAScript modules, you may use
52-
/// `var` to create a global variable that may be used by other scripts. You
53-
/// can use the `/* exported variableName */` comment block to indicate that
54-
/// this variable is being exported and therefore should not be considered
55-
/// unused.
49+
/// #### Ignored Files
50+
/// This rule ignores `.d.ts` files and `.vue` files entirely. Variables,
51+
/// classes, interfaces, and types declared in `.d.ts` files are generally
52+
/// used by other files, which are not checked by Oxlint. Since Oxlint does
53+
/// not support parsing Vue templates, this rule cannot tell if a variable
54+
/// is used or unused in a Vue file.
5655
///
57-
/// Note that `/* exported */` has no effect for any of the following:
58-
/// * when the environment is `node` or `commonjs`
59-
/// * when `parserOptions.sourceType` is `module`
60-
/// * when `ecmaFeatures.globalReturn` is `true`
56+
/// #### Exported
6157
///
62-
/// The line comment `//exported variableName` will not work as `exported`
63-
/// is not line-specific.
58+
/// The original ESLint rule recognizes `/* exported variableName */`
59+
/// comments as a way to indicate that a variable is used in another script
60+
/// and should not be considered unused. Since ES6 modules are now a TC39
61+
/// standard, Oxlint does not support this feature.
6462
///
6563
/// ### Example
6664
///
@@ -129,10 +127,11 @@ declare_oxc_lint!(
129127
/// }
130128
/// ```
131129
///
132-
/// Examples of **correct** code for `/* exported variableName */` operation:
130+
/// Examples of **incorrect** code for `/* exported variableName */` operation:
133131
/// ```javascript
134132
/// /* exported global_var */
135133
///
134+
/// // Not respected, use ES6 modules instead.
136135
/// var global_var = 42;
137136
/// ```
138137
NoUnusedVars,

crates/oxc_linter/src/rules/eslint/no_unused_vars/options.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ pub struct NoUnusedVarsOptions {
2222
/// names match this pattern will be ignored.
2323
///
2424
/// By default, this pattern is `^_` unless options are configured with an
25-
/// object. In this case it will default to [`None`].
25+
/// object. In this case it will default to [`None`]. Note that this
26+
/// behavior deviates from both ESLint and TypeScript-ESLint, which never
27+
/// provide a default pattern.
2628
///
2729
/// ## Example
2830
///

0 commit comments

Comments
 (0)