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

standard 14 reports parsing errors for valid public static class fields #1524

Closed
zeke opened this issue May 25, 2020 · 6 comments
Closed

standard 14 reports parsing errors for valid public static class fields #1524

zeke opened this issue May 25, 2020 · 6 comments

Comments

@zeke
Copy link
Contributor

zeke commented May 25, 2020

What version of this package are you using?

14.3.4

What operating system, Node.js, and npm version?

macOS Catalina, Node.js 12.8.0, npm 6.14.3

What happened?

This is a repeat of #940 where the use of a public static class field:

class ClassWithStaticField {
  static staticField = 'static field'
}

Causes this error:

Parsing error: Unexpected token =

Repros:

What did you expect to happen?

I do not expect to see any errors.

Are you willing to submit a pull request to fix this bug?

Perhaps!?

@zeke
Copy link
Contributor Author

zeke commented May 25, 2020

It appears that eslint comments don't work as a workaround for this either:

class AlgoliaIndex {
  static maxRecordLength = 8000 // eslint-disable-line
}

still causes this error:

> standard --fix

standard: Use JavaScript Standard Style (https://standardjs.com)
  /Users/z/git/github/docs/lib/algolia/search-index.js:12:27: Parsing error: Unexpected token =

@pal
Copy link

pal commented Oct 26, 2020

Did you find a work-around @zeke?

@feross
Copy link
Member

feross commented Oct 27, 2020

Static class features is still Stage 3 and it's ESLint policy to only support Stage 4 proposals.

In the meantime, you can enable support with babel-eslint by following the instructions here: https://standardjs.com/#how-do-i-use-experimental-javascript-es-next-features

Also, duplicate of #1478

@feross feross closed this as completed Oct 27, 2020
@balazsorban44
Copy link

balazsorban44 commented Mar 1, 2021

UPDATE: So according to #1601 (comment) my configuration below is not supported in standard. Ignore the following.

Trying to add support for this Stage 3 proposal.

Tried using the How do I use experimental JavaScript (ES Next) features? section, and added the following to my package.json:

"standard": {
  "parser": "@babel/eslint-parser"
}

Running npx standard file.js reports the following error:

standard: Use JavaScript Standard Style (https://standardjs.com)
/project/file.js:0:0: Parsing error: No Babel config file detected for /project/file.js. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files.

Tried also adding the config to package.json like the following as per the docs for @babel/eslint-parser:

"standard": {
  "parser": "@babel/eslint-parser",
    "parserOptions": {
      "babelOptions": {
        "configFile": "./config/babel.config.json"
      }
    }
  }
}

@RangerMauve
Copy link

I noticed that there's new rules being added to eslint that support this functionality.

eslint/eslint#14591

Would updating the eslint dependency in standard be enough to enable the parsing?

Do we need to wait for all the private rules to be finished before it gets added into standard, or would the partial set that's already complete be enough?

@RangerMauve
Copy link

Ah, looks like the new features are in eslint@8.0.0-beta.1, so I'm guessing we'd need to wait for the next stable version to be released.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

5 participants