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
Split source elements relative to their language. #3069
Conversation
Colliding node types which are not source elements in every language. Example ObjectExpression in JSON / JS
index.js
Outdated
case "flow": | ||
case "babylon": | ||
case "typescript": | ||
return jsSourceElements.includes(node.type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's end tests, but I'm not sure .includes is in node 4...
case "ScalarTypeDefinition": // GraphQL | ||
return true; | ||
// JS and JS like to avoid repetitions | ||
const jsSourceElements = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the rule with global variables? those const ...SourceElements
could be defined outside.
a: 1, | ||
},<<<PRETTIER_RANGE_START>>> | ||
{ | ||
a: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add an additional property to this object? Otherwise it could be treated as a block + label.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it's certainly clearer than trying to find a semicolon {a: 1;}
.
Done.
ObjectExpression vs BlockStatement & LabeledStatement
case "UnionTypeDefinition": // GraphQL | ||
case "ScalarTypeDefinition": // GraphQL | ||
return true; | ||
// JS and JS like to avoid repetitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be "JS and TS like to avoid repetitions"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I interpreted as JS-like
= flow, TypeScript.
Oh, that makes more sense. I had overlooked "like".
|
Fix #3068 : Colliding node types which are not source elements in every language.
Example:
ObjectExpression
in JSON / JSSource Elements are now based on the parser.