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: ')' after argument in arrow function expression #379

Closed
hhhr opened this issue Dec 15, 2021 · 3 comments
Closed

Bug report: ')' after argument in arrow function expression #379

hhhr opened this issue Dec 15, 2021 · 3 comments

Comments

@hhhr
Copy link

hhhr commented Dec 15, 2021

Describe the bug

  1. A clear and concise description of what the bug is.
    In the Code snippet jslint complains about the ')' after the argument x. It wants it to match to the '(' of the .forEach, I guess.
    But if I leave it out it complains about not wrapping the argument x in parantheses.
  2. Jslint edition:
    v2021.11.20
  3. Code snippet (if applicable):
/*jslint devel*/
const a = [];
a.forEach((x) => delete x.unwanted_key);

Expected behavior

I expect either jslint complains about me using arrow functions instead of a function declaration
or jslint does not complain at all.

@kaizhu256
Copy link
Member

thx for reporting. this seems to be a legacy-bug (pre v2020.11.6) that might need a parser update. i'll take a closer look at it this weekend.

@kaizhu256
Copy link
Member

should be fixed in pr #384, with new warning forbidding [side-effect] statements within fat-arrow (jslint expect fat-arrows to only contain expressions)

jslint still warns against your code, but warning is a bit clearer:

1. [JSLint was unable to finish] Unexpected 'delete' after '=>'.

the new warning applies to following fat-arrow examples where it encounters a statement keyword:

(x) => async ...
(x) => await ...
(x) => break ...
(x) => const ...
(x) => continue ...
(x) => debugger ...
(x) => delete ...
(x) => do ...
(x) => export ...
(x) => for ...
(x) => function ...
(x) => if ...
(x) => import ...
(x) => let ...
(x) => return ...
(x) => switch ...
(x) => throw ...
(x) => try ...
(x) => var ...
(x) => while ...
(x) => with ...

closing issue as fixed, but feel free to re-open if you think there's a better-way to deal with the cryptic warnings.

@hhhr
Copy link
Author

hhhr commented Feb 9, 2022

thank you !

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
Development

No branches or pull requests

2 participants