Ask Your Question
4

How to count the total number of exported identifiers using the eslint rule?

asked 2023-05-15 16:11:47 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-05-15 16:16:01 +0000

lakamha gravatar image

To count the total number of exported identifiers using eslint rule, you can use the eslint-plugin-import rule "import/no-named-as-default-member".

This rule detects if a default import is an exported member of its own module, which could imply confusion as to which name should be imported.

The way to use this rule is to first install the eslint-plugin-import package and add it to your eslint config file:

npm install eslint-plugin-import --save-dev
{
  "plugins": [
    "import"
  ],
  "rules": {
    "import/no-named-as-default-member": "error"
  }
}

With this rule, you will get an error whenever a default import is an exported member of its own module when importing the module. You can then count the total number of errors reported by this rule in your eslint output to determine the number of exported identifiers.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-15 16:11:47 +0000

Seen: 11 times

Last updated: May 15 '23