Skip to content
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

Bug report: Fart function with destructuring #382

Closed
nikoskalogridis opened this issue Jan 12, 2022 · 3 comments · Fixed by #386 or #414
Closed

Bug report: Fart function with destructuring #382

nikoskalogridis opened this issue Jan 12, 2022 · 3 comments · Fixed by #386 or #414

Comments

@nikoskalogridis
Copy link

Describe the bug
Wondering what is the violation of using a fart function here

  1. Jslint edition:

v2021.12.20

  1. Code snippet (if applicable):
export default Object.freeze({
    pickOne: ({one}) => one
});

Expected behavior
Should allow usage of fart function

@nikoskalogridis nikoskalogridis changed the title Bug report: Your title here Fart function with destructuring Jan 12, 2022
@nikoskalogridis nikoskalogridis changed the title Fart function with destructuring Bug report: Fart function with destructuring Jan 12, 2022
@kaizhu256
Copy link
Member

its a long-running bug that jslint crashes with cryptic-warnings when parsing fat-arrows that are anything but toy-case. the crashing-and-cryptic-warning-part should ideally be fixed, when maintainers find the time to do so.

whether destructuring in fat-arrows should be tolerated however, is up to debate.

@nikoskalogridis
Copy link
Author

Thank you for your quick response.

I cannot think of any issues with destructuring a parameter on a fart function but if that is to be avoided I guess there should be a mention on the help page.

Probably when jslint gets smarter it might produce a more helpful error message.

@kaizhu256
Copy link
Member

should be fixed by following 2 pr's:

// old warning
Expected 'function' before '('.
    pickOne: ({one}) => one
Expected '{' and instead saw '=>'.
    pickOne: ({one}) => one

// new warning
Use 'function (...)', not '(...) =>' when arrow functions become too complex.
    pickOne: ({one}) => one

image

kaizhu256 added a commit to kaizhu256/jslint that referenced this issue Feb 20, 2022
- test - migrate all tests to use jstestDescribe(), jstestIt()
- fs - rename jslint-wrapper-files to jslint_wrapper_xxx.xxx
- bugfix - fix issue jslint-org#382 - make fart-related warnings more readable
- bugfix - fix issue jslint-org#382 - fix warnings against destructured fart
- bugfix - fix issue jslint-org#379 - warn against naked-statement in fart.
- update commonjs-wrapper jslint.cjs to load jslint in strict-mode.
@kaizhu256 kaizhu256 mentioned this issue Feb 20, 2022
kaizhu256 added a commit that referenced this issue Feb 20, 2022
- test - migrate all tests to use jstestDescribe(), jstestIt()
- fs - rename jslint-wrapper-files to jslint_wrapper_xxx.xxx
- bugfix - fix issue #382 - make fart-related warnings more readable
- bugfix - fix issue #382 - fix warnings against destructured fart
- bugfix - fix issue #379 - warn against naked-statement in fart.
- update commonjs-wrapper jslint.cjs to load jslint in strict-mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants