Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Repo: Add a util for determining whether a node is a specific identifier #8327

Closed as not planned
Labels
locked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.repo maintenancethings to do with maintenance of the repo, and not with code/docswontfixThis will not be worked on
@StyleShit

Description

@StyleShit

Suggestion

Splits from#8295 (comment)

The proposal is to go over all of the places where we check if a node is a specific identifier and use a util for that. Here are a couple of examples of places we do this:

if(
node.typeName.type===AST_NODE_TYPES.Identifier&&
node.typeName.name==='Array'
){

return(
node.typeName.type===AST_NODE_TYPES.Identifier&&
node.typeName.name==='const'
);

return(
node.type===AST_NODE_TYPES.TSTypeReference&&
node.typeName.type===AST_NODE_TYPES.Identifier&&
['Array','ReadonlyArray'].includes(node.typeName.name)
);

I think we can take inspiration from this existing function and extract it to a util:

functionisIdentifier(
init:TSESTree.Expression,
...names:string[]
):boolean{
return(
init.type===AST_NODE_TYPES.Identifier&&names.includes(init.name)
);
}

It might be a nicegood first issue PR 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    locked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.repo maintenancethings to do with maintenance of the repo, and not with code/docswontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp