question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

func-names does not report default exported function

See original GitHub issue

Tell us about your environment

  • ESLint Version: 6.3.0
  • Node Version: 12

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration: func-names: [2, "always"] or func-names: [2, "as-needed"]

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

/* eslint func-names: [2, 'as-needed'] */
// or  'always'

export default function () {}

https://eslint.org/demo#eyJ0ZXh0IjoiLyogZXNsaW50IGZ1bmMtbmFtZXM6IFsyLCAnYXMtbmVlZGVkJ10gKi9cbi8vIG9yICAnYWx3YXlzJ1xuXG5leHBvcnQgZGVmYXVsdCBmdW5jdGlvbiAoKSB7fVxuIiwib3B0aW9ucyI6eyJwYXJzZXJPcHRpb25zIjp7ImVjbWFWZXJzaW9uIjo5LCJzb3VyY2VUeXBlIjoibW9kdWxlIiwiZWNtYUZlYXR1cmVzIjp7fX0sInJ1bGVzIjp7fSwiZW52Ijp7fX19

What did you expect to happen? Unnamed function to be reported.

What actually happened? Please include the actual, raw output from ESLint. No error is reported.

Are you willing to submit a pull request to fix this bug? Yes please.

Notes The main purpose of func-names is to avoid unhelpful names like “anonymous” popping up in stack trace or profiling chart. In the case of unnamed default export, the function names will be _default for babel transformed code, or default for node 12 experimental modules. These names are uninformative for debugging. So func-names should report this case.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
mysticateacommented, Sep 8, 2019

I prefer changing the default behavior on 7.0.0. I’m not sure if there are the cases we use the options.

2reactions
platinumazurecommented, Sep 6, 2019

I think it would be best to treat this as a breaking change or create an option, personally- just in case. I can see the case for it being a bug, but I’m concerned about potential large impact.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected default export of anonymous function import/no ...
In OP's code, they had export a default function without a name. However, in the above answer, we have given the function the...
Read more >
Documentation - Modules - TypeScript
Classes and function declarations can be authored directly as default exports. Default export class and function declaration names are optional.
Read more >
func-names - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
DLL Export Viewer - view exported functions list in Windows DLL
This utility displays the list of all exported functions and their virtual memory addresses for the specified DLL files. You can easily copy...
Read more >
Disallow specified names in exports (no-restricted-exports)
This rule disallows specified names from being used as exported names. Options. By default, this rule doesn't disallow any names. Only the names...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found