Skip to content

Commit

Permalink
docs(linter): correct docs for no-unused-vars
Browse files Browse the repository at this point in the history
  • Loading branch information
DonIsaac committed Aug 7, 2024
1 parent e285903 commit 3c755c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
27 changes: 13 additions & 14 deletions crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion crates/oxc_linter/src/rules/eslint/no_unused_vars/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down

0 comments on commit 3c755c1

Please sign in to comment.