mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
docs(linter): correct docs for no-unused-vars (#4716)
This commit is contained in:
parent
e2859038b6
commit
4b7dfd6c7c
2 changed files with 16 additions and 15 deletions
|
|
@ -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`).
|
||||
///
|
||||
/// #### 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.
|
||||
///
|
||||
/// #### 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.
|
||||
///
|
||||
/// 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`
|
||||
///
|
||||
/// 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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
///
|
||||
|
|
|
|||
Loading…
Reference in a new issue