Skip to content

linter: eslint/no-shadow-restricted-names flags enum values #22756

@jeanne-cai

Description

@jeanne-cai

What version of Oxlint are you using?

1.67.0

What command did you run?

yarn oxlint -c oxlint.config.mjs

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

import { defineConfig } from 'oxlint';

export default defineConfig({
    categories: {
        correctness: 'off',
    },
    rules: {
        'eslint/no-shadow-restricted-names': 'error',
    },
});

What happened?

no-shadow-restricted-names incorrectly flags enum members as shadowing restricted globals.

Example:

// Incorrectly flagged
export enum Globals {
    undefined = 'undefined',
    NaN = 'nan',
    Infinity = 'infinity',
    eval = 'eval',
    arguments = 'arguments',
}

// Correctly flagged
const undefined = 5;

Output:

  × eslint(no-shadow-restricted-names): Shadowing of global properties such as `undefined` is not allowed.
   ╭─[test.ts:3:5]
 2 │ export enum Globals {
 3 │     undefined = 'undefined',
   ·     ─────────
 4 │     NaN = 'nan',
   ╰────
  help: Rename 'undefined' to avoid shadowing the global property.

  × eslint(no-shadow-restricted-names): Shadowing of global properties such as `undefined` is not allowed.
   ╭─[test.ts:4:5]
 3 │     undefined = 'undefined',
 4 │     NaN = 'nan',
   ·     ───
 5 │     Infinity = 'infinity',
   ╰────
  help: Rename 'NaN' to avoid shadowing the global property.

  × eslint(no-shadow-restricted-names): Shadowing of global properties such as `undefined` is not allowed.
   ╭─[test.ts:5:5]
 4 │     NaN = 'nan',
 5 │     Infinity = 'infinity',
   ·     ────────
 6 │     eval = 'eval',
   ╰────
  help: Rename 'Infinity' to avoid shadowing the global property.

  × eslint(no-shadow-restricted-names): Shadowing of global properties such as `undefined` is not allowed.
   ╭─[test.ts:6:5]
 5 │     Infinity = 'infinity',
 6 │     eval = 'eval',
   ·     ────
 7 │     arguments = 'arguments',
   ╰────
  help: Rename 'eval' to avoid shadowing the global property.

  × eslint(no-shadow-restricted-names): Shadowing of global properties such as `undefined` is not allowed.
   ╭─[test.ts:7:5]
 6 │     eval = 'eval',
 7 │     arguments = 'arguments',
   ·     ─────────
 8 │ }
   ╰────
  help: Rename 'arguments' to avoid shadowing the global property.

  × eslint(no-shadow-restricted-names): Shadowing of global properties such as `undefined` is not allowed.
    ╭─[test.ts:11:7]
 10 │ // Correctly flagged
 11 │ const undefined = 5;
    ·       ─────────
    ╰────
  help: Rename 'undefined' to avoid shadowing the global property.

Found 0 warnings and 6 errors.
Finished in 71ms on 1 file with 1 rules using 16 threads.

Metadata

Metadata

Assignees

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions