Skip to content
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

docs: add attachComment #2555

Merged
merged 2 commits into from
Aug 4, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ mind. When in doubt, use `.parse()`.
<summary>History</summary>
| Version | Changes |
| --- | --- |
| `v7.15.0` | Added `attachComment` |
| `v7.7.0` | Added `errorRecovery` |
| `v7.5.0` | Added `allowUndeclaredExports` |
| `v7.2.0` | Added `createParenthesizedExpressions` |
Expand Down Expand Up @@ -64,6 +65,8 @@ mind. When in doubt, use `.parse()`.
to set this option to `true` to prevent the parser from prematurely
complaining about undeclared exports that will be added later.

- **attachComment**: By default, Babel attaches comments to adjacent AST nodes. When this option is set to `false`, comments are not attached. It can provide up to 30% performance improvement when the input code has _many_ comments. You probably don't need to set this option, `@babel/eslint-parser` will set it for you. It is not recommended to use `attachComment: false` with Babel transform, as it removes all the comments in output code, and renders annotations such as `/* istanbul ignore next */` nonfunctional.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably don't need to set this option, @babel/eslint-parser will set it for you.

Maybe can just say @babel/eslint-parser will set it for you if it's used for linting? I guess we could mention we may add an option for specifying it babel/babel#13229 (comment) too if we wanted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

babel/babel#13229 (comment)

I think that falls perfectly to the roadmap section. I am afraid add not-yet-implemented ideas to this section may confuse our users.


- **createParenthesizedExpressions**: By default, the parser sets `extra.parenthesized` on the expression nodes. When this option is set to `true`, `ParenthesizedExpression` AST nodes are created instead.

- **errorRecovery**: By default, Babel always throws an error when it finds some invalid
Expand Down