Skip to content

Rule Change: ignore type annotations in no-restricted-globals #19769

@sethamus

Description

@sethamus

What rule do you want to change?

no-restricted-globals

What change do you want to make?

Generate fewer warnings

How do you think the change should be implemented?

A new option

Example code

/* eslint no-restricted-globals: ["error", "Promise"] */

// Correct error on Promise.resolve
// Incorrect error on Promise<any>
const x: Promise<any> = Promise.resolve();

// Correct no error on window.Promise.resolve
// Incorrect error on Promise<any>
const x: Promise<any> = window.Promise.resolve();

What does the rule currently do for this code?

The rule reports an error on the type annotation (Promise<any>)

What will the rule do after it's changed?

With a new option (e.g. ignoreTypeAnnotation: true), the rule will ignore restricted globals used in type annotations

Participation

  • I am willing to submit a pull request to implement this change.

Additional comments

No response

Metadata

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionenhancementThis change enhances an existing feature of ESLintruleRelates to ESLint's core rules

Type

No type

Projects

Status

Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions