Open
Description
Which packages would you like to change?
-
espree
-
eslint-scope
-
eslint-visitor-keys
What problem do you want to solve?
Prettier currently supports both acorn
and espree
parsers.
Recently we added support for type casting comments in acorn
parser prettier/prettier#17491. We want to support it in our espree
parser as well.
var a = /** @type {string} */ (c);
To preserve parentheses in the code above, Prettier needs acorn
to create a non-standard ParenthesizedExpression
node.
Currently, espree
ignores preserveParens
However, it's still possible to hack
> require('acorn').defaultOptions.preserveParens = true
true
> require('espree').parse('(1)').body[0].expression
Node {
type: 'ParenthesizedExpression',
start: 0,
end: 3,
expression: Node { type: 'Literal', start: 1, end: 2, value: 1, raw: '1' }
}
What do you think is the correct solution?
I understand this is not wanted in ESLint, can we allow preserveParens
, but always pass false
in ESLint?
Another possible solution is allow this option after #623
Participation
- I am willing to submit a pull request for this change.
Additional comments
No response