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

Comment parser breaks with numeric literal separators #137

Open
pumpkinlink opened this issue Nov 6, 2024 · 3 comments
Open

Comment parser breaks with numeric literal separators #137

pumpkinlink opened this issue Nov 6, 2024 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@pumpkinlink
Copy link

pumpkinlink commented Nov 6, 2024

the comment parser breaks if the controller file has a number with javascript literal number separator (underscore), like 1_000_000 for one million, instead of 1000000. This feature is part of Javascript as of ES2021: https://v8.dev/features/numeric-separators

affected controller example:

export default class ImagemController {

  private readonly pageSize = 10_000 // <------ the JSDoc only works if the underscore is removed

  /**
   * @findByKM
   * @paramQuery id - id do km -  @type(number) @required
   * @paramQuery type - tipo da foto - @type(string)
   */
  async findByKM({ request }: HttpContext) {    
    const page = 1
    const perPage = this.pageSize
    const result = await Imagem.query()
      .where('id_km_trecho_gasoduto', request.qs().id)
      .if(
        request.qs().type === '',
        (query) => query.whereNull('tipo_foto'),
        (query) => query.where('tipo_foto', request.qs()['type'])
      )
      .paginate(page, perPage)
    return result.serialize()
}

this seems to be a limitation in the Esprima library.
you can debug the problem by putting a breakpoint in this block inside the tokenize() function in esprima.js

catch (e) {
	  tokenizer.errorHandler.tolerate(e);
}
@pumpkinlink
Copy link
Author

related issue: jquery/esprima#1989

@pumpkinlink
Copy link
Author

It seems Esprima only supports up to ES2019. And the project is abandoned and scheduled for archival.

There is an older fork called esprima-next with stable ES2022 support, and a more mantained fork by the Eslint team called Espree

@ad-on-is
Copy link
Owner

ad-on-is commented Jan 11, 2025

dang! unfortunately nothing I can do here... It's an upstream issue.

I can only mention it in the readme, for others to be aware of

@ad-on-is ad-on-is added the documentation Improvements or additions to documentation label Jan 11, 2025
@ad-on-is ad-on-is reopened this Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants