Skip to content

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

@augustjk

Description

@augustjk

💻

  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: eslintoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions