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

space-unary-ops errors on new Class() syntax #1946

Closed
bcomnes opened this issue Oct 26, 2023 · 4 comments
Closed

space-unary-ops errors on new Class() syntax #1946

bcomnes opened this issue Oct 26, 2023 · 4 comments

Comments

@bcomnes
Copy link
Member

bcomnes commented Oct 26, 2023

I just noticed today that I started getting space-unary-ops warnings where I shouldn't be getting them like on new Foo() syntax:

Screenshot 2023-10-26 at 1 12 31 PM

I've been running 17.1.0 everywhere for a while now, but this is the first I'm seeing of it. Seems like maybe a transitive broke something.

To reproduce, clear your node_modules and reinstall 17.1.0 and lint a class instantiation.

@missinglink
Copy link

missinglink commented Oct 26, 2023

This is super broken, it's 'fixing' new String() to newString() 🤦‍♂️

echo "new String()" | npx standard@17.1.0 --stdin --fix
newString()
standard: Use JavaScript Standard Style (https://standardjs.com)
standard:   <text>:1:1: 'newString' is not defined. (no-undef)
echo "new String()" | npx standard@17.1.0 --stdin
standard: Use JavaScript Standard Style (https://standardjs.com)
standard: Run `standard --fix` to automatically fix some problems.
  <text>:1:1: Do not use String as a constructor. (no-new-wrappers)
  <text>:1:1: Unexpected space before unary operator 'String'. (space-unary-ops)
  <text>:1:1: Do not use 'new' for side effects. (no-new)

@missinglink
Copy link

cc/ @voxpelli, this regression was introduced in the latest release.

echo "new String()" | npx standard@17.0.0 --stdin --fix
new String()
echo "new String()" | npx standard@17.1.0 --stdin --fix
newString()

@bcomnes
Copy link
Member Author

bcomnes commented Oct 26, 2023

@missinglink It seems to be a transitive somewhere in all of the 17 versions. Been running 17.1.0 for a while without issue. npx is likely running cached transitives.

@bcomnes
Copy link
Member Author

bcomnes commented Oct 26, 2023

Was an issue in acorn:

Re-installing everything and ensuring acorn 8.11.1 is in your tree fixes it.

@bcomnes bcomnes closed this as completed Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants