-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Clarify non-standard properties of AST that custom parsers should create #8956
Comments
Can we assume that |
@platinumazure Yes, I think so. We could add an internal rule to prohibit I don't think we need to officially add support for |
I agree that it's good if we can detect the use of |
We could use a custom parser when running tests on the ESLint codebase. The parser would parse the source text with espree, then traverse the AST and delete all the |
Can we go back to ESTree and suggest that any of the properties be added (even if marked as optional) to lend some normative credibility? |
I think ESTree tries to avoid having properties that provide redundant info, so I have my doubts about whether it would be accepted. |
@not-an-aardvark Well, I can certainly understand that position, but I also don't think range information is redundant. The location information tells you line and column information but wouldn't be much help with regard to things like extra whitespace; personally, I think range + line/column can give a better picture. |
I meant that |
@not-an-aardvark Yes, agreed. ESTree currently does not specify either |
@platinumazure After I searched, there seemed to be a large discussion about CST. There are the issues which mention about We look to have consensus that we use |
I think we should clarify our position about non-standard properties of AST. Especially:
node.range
node.start
node.end
ESTree does not have those properties. However, we have been using
node.range
properties to write core rules since v0.x.y.After ESLint v2.0.0, AST nodes have
node.start
andnode.end
properties as well for some reason. However, as far as I know, we have not been using those two properties in core rules, because the use of those two properties is a breaking change for custom parsers and we have not announced the change.I thought so, but in fact, we have seemed to be using
node.start
andnode.end
in core rules, e.g.padded-blocks
(1c123e2).If we clarify about non-standard properties of AST, it will become an important resource for the developer of custom parsers.
My position is:
node.range
property.node.start
andnode.end
properties (so we should not usenode.start
andnode.end
in core rules) at this time. We can addnode.start
andnode.end
in the next major release.Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
typescript-eslint-parser
What did you do? Please include the actual source code causing the issue.
$ eslint test.js --no-eslintrc --no-ignore --fix --parser typescript-eslint-parser
What did you expect to happen?
What actually happened? Please include the actual, raw output from ESLint.
The most code was lost.
The root cause is that the comment tokens of
typescript-eslint-parser
don't havestart
andend
properties butpadded-blocks
rule is using those.I'm not sure which of
padded-blocks
andtypescript-eslint-parser
I should fix because the specification of AST is unclear.The text was updated successfully, but these errors were encountered: