sjbarag / brs

An interpreter for the BrightScript language that runs on non-Roku platforms.
MIT License
113 stars 43 forks source link

feat: Make AST compatible with ESLint #507

Closed heftyfunseeker closed 4 years ago

heftyfunseeker commented 4 years ago

ESLint is a popular pluggable linter that semi-relies on a standardized AST format called ESTree. This change makes the ast brs produces compliant with ESLint by exposing a few fields the linter needs to walk the tree and evaluate rules.

heftyfunseeker commented 4 years ago

Changes look good, can you elaborate a little bit on how ESLinter would use the AST? is it like an argument that you can pass to the linter cli?

Yeah, ESLint supports custom parsers. So you can tell ESLint to call your parser, and as long you provide a few of the properties the Traverser is looking for on each node, it will walk your tree and build up a queue of nodes to evaluate linter rules for. https://eslint.org/docs/developer-guide/working-with-custom-parsers, https://eslint.org/docs/developer-guide/working-with-rules. I have a plugin that I've been hacking on locally that makes use of this change and will be uploaded to Hulu as a monorepo for others to use. That's the grand plan at least.