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
func-style
"expression" conflicts with ESM named exports
#12829
Comments
Just to clarify the issue, I believe this configuration expects something like: /* eslint func-style: [2, "expression"] */
export const foo = function () {}; What conflict does this cause? Asking because "conflict" is mentioned in the title. |
I suppose it isn’t a conflict; it’s just that i don’t see these as the same as function declarations since they’re under a tdz, and so altho i never want declarations, i do want the export function form. |
So, the motivation is to allow hoisting only for exported functions because good practice is to define all exports at the end? foo(); // this wouldn't be possible here with export const foo = function () {};
export function foo() {}; |
Unfortunately that does result in hoisting, but in this case I don't care about it, because i don't want to create an extra variable in my named exports. |
I'm not sure that I understand the part about an extra variable, an example of code you'd like to avoid with this option would be helpful! |
i want to avoid |
Makes sense to me 👍 |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
It'd be great if this could be reopened. |
I'll champion this. |
How can I help with this? |
@krainboltgreene this enhancement doesn't have consensus from the team yet. If and when this issue gets accepted, a PR will be welcome :) |
Ahhh, that makes sense thanks! |
@mdjermanovic any update on consensus from the team? this is still an issue for all the packages I'm writing ESM wrappers for. |
@mdjermanovic you championed this initially, do you want to move forward? If so, can you explain the exact change? |
@mdjermanovic a friendly ping, waiting for your suggestion to move this issue forward, Thanks. |
@mdjermanovic still looking for your input here |
I'd still like it to move forward, as the OP :-p the exact change would be one of:
|
I don't think this rule should ignore named exports by default. We could add a boolean option to ignore named exports:
or an option to override base settings for named exports or ignore them:
The latter is similar to the original proposal, I only added Thoughts? |
An option sounds perfectly fine, thanks. |
@ljharb is that in favor of a boolean option or the |
Either is fine. |
@mdjermanovic I think either solution is fine as well, do you have a preference? |
I'd prefer "func-style": [2, "expression", {
"overrides": {
"namedExports": "declaration" // allowed values are: "expression", "declaration`, "ignore"
}
}] Marked as accepted, PR is welcome. |
What rule do you want to change?
func-style
Does this change cause the rule to produce more or fewer warnings?
Fewer or more, depending on how the option is configured.
How will the change be implemented? (New option, new default behavior, etc.)?
A new
namedExports
option, which can be set to "expression" or "declaration" or "ignore".Please provide some example code that this change will affect:
What does the rule currently do for this code?
warns
What will the rule do after it's changed?
/* eslint func-style: [2, "expression", { "namedExports": "declaration"] */
will cause no warning to be issued.Are you willing to submit a pull request to implement this change?
Yes.
The text was updated successfully, but these errors were encountered: