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

Add rslint-pragma to specify the source type of a file #39

Open
RDambrosio016 opened this issue Oct 9, 2020 · 0 comments
Open

Add rslint-pragma to specify the source type of a file #39

RDambrosio016 opened this issue Oct 9, 2020 · 0 comments
Labels
C-enhancement Category: enhancement E-medium Fixing/implementing this issue is moderately hard and you may need some prior experience T-Runner This issue primary relates to the lint runner, rslint_core

Comments

@RDambrosio016
Copy link
Collaborator

I noticed this being talked about in a deno_lint issue, and i think it would work well (but sadly deno_lint cannot implement it efficiently since they would need a lossless lexer to run on the code first or parse the code twice). To get this to work for us we would simply have to refactor a couple of things:

  • Make the core runner first run rslint_parser::tokenize
  • Do some kind of preprocessing by going through each comment token and checking its source
  • If a source type is specified then get that, or get the default one (script for .js, module for .mjs)
  • Make a new rslint_parser::TokenSource
  • Spawn an appropriate parser with new_module or new
  • Use the appropriate parser function from the syntax::program module and get the parser events and process then with a new LosslessTreeSink (theres instructions here on how it works)

There would be no need to run through a proper directive parser, just check for rslint-pragma script and rslint-pragma module.

@RDambrosio016 RDambrosio016 added T-Runner This issue primary relates to the lint runner, rslint_core E-medium Fixing/implementing this issue is moderately hard and you may need some prior experience C-enhancement Category: enhancement labels Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: enhancement E-medium Fixing/implementing this issue is moderately hard and you may need some prior experience T-Runner This issue primary relates to the lint runner, rslint_core
Projects
None yet
Development

No branches or pull requests

1 participant