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]: Unexpected StringLiteral node in @babel/eslint-parser #14037

Closed
1 task
fisker opened this issue Dec 9, 2021 · 2 comments 路 Fixed by #14039
Closed
1 task

[Bug]: Unexpected StringLiteral node in @babel/eslint-parser #14037

fisker opened this issue Dec 9, 2021 · 2 comments 路 Fixed by #14039
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: register

Comments

@fisker
Copy link
Contributor

fisker commented Dec 9, 2021

馃捇

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

const {ast} = require('@babel/eslint-parser').parseForESLint('export { "a" } from "a";', {requireConfigFile: false})
ast.body[0].specifiers[0]
Node {
  type: 'ExportSpecifier',
  start: 9,
  end: 12,
  loc: SourceLocation {
    start: Position { line: 1, column: 9 },
    end: Position { line: 1, column: 12 },
    filename: undefined,
    identifierName: undefined
  },
  range: [ 9, 12 ],
  local: Node {
    type: 'Literal',
    start: 9,
    end: 12,
    loc: SourceLocation {
      start: [Position],
      end: [Position],
      filename: undefined,
      identifierName: undefined
    },
    range: [ 9, 12 ],
    value: 'a',
    raw: '"a"'
  },
  exported: Node {
    type: 'StringLiteral',    // <------------ Here
    start: 9,
    end: 12,
    loc: SourceLocation {
      start: [Position],
      end: [Position],
      filename: undefined,
      identifierName: undefined
    },
    range: [ 9, 12 ],
    extra: undefined,
    value: 'a'
  }
}

Configuration file name

No response

Configuration

No response

Current and expected behavior

StringLiteral should be Literal with string value.

Environment

Latest version of @babel/eslint-parser

Possible solution

No response

Additional context

Similar to #13329, but only happens when specifier is shorthand.

@babel-bot
Copy link
Collaborator

Hey @fisker! 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 Dec 9, 2021

This is a regression introduced in #13611.

The cloneStringLiteral method always set type to StringLiteral:

cloned.type = "StringLiteral";

we can override cloneStringLiteral in estree plugin.

@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 Mar 11, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: register
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants