pegjs
pegjs copied to clipboard
Plugin for ESLint
Issue type
- Bug Report:
- Feature Request: yes
- Question:
- Not an issue:
Prerequisites
- Can you reproduce the issue?: N/A
- Did you search the repository issues?: Yes.
- Did you check the forums?: Can't find.
- Did you perform a web search (google, yahoo, etc)?: Yes.
Description
It'd make pegjs development a lot more convenient if an ESLint plugin could be made with a processor so one could lint one's JavaScript both in a head block of the document (as enclosed in {...}
) as well as the JavaScript returning functions attached to rules.
I realize this may be out of scope, but wanted to at least put it out there (I'm a bit too tied up myself with other work at the moment to add such a feature). Thanks!
The way I do this is to treat the .peg
as a build product output, then "compile" it from a peg suffix and a js prefix. That way, the prefix can be compiled down typescript with linting and unit testing and so on
One easy way to accomplish this without that would be to use the eslint enable and eslint disable global comments
Not sure I follow completely, at least re: eslint enable/disable.
FWIW, I'm thinking now that if source maps (#93) are implemented (and it appears it may not be too hard to do with https://github.com/mozilla/source-map#sourcenode ), then a linter could easily get at the source without need for separate compile steps (which could be cumbersome I would think if adding for each inline JS snippet). (And this should help solve coverage (#633) too, as nyc can ignore the generated code which doesn't map back to the user's source files.)