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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: @babel/eslint-parser using @babel/plugin-proposal-decorators errors on class fields with accessor keyword #16020

Closed
1 task
augustjk opened this issue Oct 6, 2023 · 2 comments 路 Fixed by #16023
Labels
area: eslint i: enhancement outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@augustjk
Copy link

augustjk commented Oct 6, 2023

馃捇

  • Would you like to work on a fix?

How are you using Babel?

@babel/eslint-parser

Input code

function logged(value, { kind, name }) {
  // implementation
}

class C {
  @logged accessor x = 1;
  //               ^ error  'x' is not defined  no-undef (eslint)
}

Configuration file name

babel.config.json

Configuration

{
  "plugins": [["@babel/plugin-proposal-decorators", { "version": "2023-05" }]]
}

Current and expected behavior

Stackblitz repro: https://stackblitz.com/edit/stackblitz-starters-jypgau?file=index.js

Notice that eslint command produces an error.

Expectation is to have no error as this is valid syntax.

The actual compilation with @babel/cli works properly and the output runs as expected.

Environment

  System:
    OS: Linux 5.0 undefined
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.6.12 - /usr/local/bin/pnpm
  npmPackages:
    @babel/cli: ^7.23.0 => 7.23.0 
    @babel/core: ^7.23.0 => 7.23.0 
    @babel/eslint-parser: ^7.22.15 => 7.22.15 
    @babel/plugin-proposal-decorators: ^7.23.0 => 7.23.0 
    eslint: ^8.50.0 => 8.50.0

Possible solution

No response

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @augustjk! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@JLHwung
Copy link
Contributor

JLHwung commented Oct 6, 2023

The decorators syntax are stage 3 features, which is not supported by ESLint. ESLint only supports stage 4 features.

The @babel/eslint-parser enables ESLint to parse such syntax, but it does not guarantee that ESLint's rule actually work with the new syntax. The @babel/eslint-plugin is to enhance the ESLint rules so that they can work with the experimental syntax. Unfortunately the current @babel/eslint-plugin does not support the no-undef rule, so supporting accessors can be a feature request.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Feb 28, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: eslint i: enhancement outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants