New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable import/no-anonymous-default-export
and import/no-named-default
#472
Conversation
You mean autocomplete? Why can't the IDEs just take the name from the filename? |
Yeah, type import stripWhitespace from './strip-whitespace';
stripWhitespace|
Don’t ask me, I don’t make IDEs 😅 |
I know. But I'm saying you're trying to fix it in the wrong place. This should instead be an issue on the IDE you use. I don't like having to have needlessly more verbose code just to please an IDE. |
It's not just an IDE issue, your functions will also appear as anonymous when debugging them (named |
So the debugger needs to be improved too then. The filename is available to the debugger. Which debugger are we talking about? Chrome DevTools? (I’m not saying I won’t accept this. Just something to consider.) |
The debugger shows the real function name which as per spec is
I think every debugger tries to show the function name in the stack, but yes users will see the file name as With sourcemap enabled even bundlers will show the correct filename in this case ✅ Rollup is the smartest one and the function appears as I think however naming an important function is worth it (so important in fact that it deserves its own file/module). For example this can also serve as a capitalization suggestion, no IDE will ever suggest importing the |
I'm still lukewarm about it. It does help debugging, but it also makes exports less elegant. But I'm willing to try it out. |
Some will complain that this lengthens exports that aren’t functions or classes I’m sure, since If that’s too annoying , it looks like the rule can be configured, but I guess the same principle applies in that case too: the export now has a name |
Didn't like this rule... too opinionated. IDE should become smarter instead. |
https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-anonymous-default-export.md
Reports:
Function names help automatic imports by IDEs
https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md
Reports: