with unused `oppositeDescription` parameter removed
and reordering of some other members
to resolve checkJs issues in `src/main/core-options.js`,
as verified by the following command:
npx tsc --allowJs --checkJs --noEmit --target es5 src/main/core-options.js
* get rid of TSParenthesizedType nodes before proceeding with formatting
* fix parens for TSIndexedAccessType, TSFunctionType, TSConditionalType
fixes#6603
* workaround edge cases with one-item unions and intersections
* fix parens for TSInferType
* fix parens for rest elements in tuple types
* refactoring
* fix function types in conditional types
* move tests for rest and optional tuple elements
* fix comment issues
* tests for unions and intersections
* add parens around multiline unions in tuple
* move the parens check for TS nodes closer to the one for Flow nodes
* update CHANGELOG.unreleased.md
* remove dead code
* fix parens for TSConstructorType
* better wording in CHANGELOG.unreleased.md
* Use same print width for range formatting as normal formatting.
Fixes an issue were a file would end up formatted differently
with ranged formatting (--range-start & --range-end) versus
normal whole file formatting.
* Document range bugfix in changelog.
This undoes an accidental breaking change where `prettier.getSupportInfo('1.0.0')` would report supporting the `babel` parser instead of `babylon`.
Fixes#5822
This pull requests adds a new parser option `lwc`. This is the same as the HTML parser, but it adds support for unquoted HTML attributes per the needs of LWC. See: #5627
- switch to [`htmlparser2`](https://github.com/fb55/htmlparser2)
- no need to fork
- won't generate pseudo nodes ([`parse5` will](https://github.com/prettier/prettier/issues/5098#issuecomment-423055181))
- should be [faster](https://github.com/fb55/htmlparser2#performance)
- support custom self-closing tags
- support HTML entities
- remove extra trailing newline for `<template>`
- distinguish empty/empty-string attributes (`<tag x>`/`<tag x="">`)
- rename `--parser parse5` with `--parser html`
- enable `html` since 1.15, which means it's enabled by default if you install the dev version from GitHub after this PR merged.
Sometimes we need to transform the ast to make it easier to print, but it's currently done in the parser (markdown and yaml), which leads the output ast harder to use for external users (custom parser), adding `printer.preprocess` can solve this issue.
And also this way we could move the trailing newline for json from `ast-to-doc.js` to `language-js`.
* Use destructuring for readability and optimzations at for loop length property
* Destructure variables for easy maintainability of code
* PR review fix
* refactor: fix linting
* Use destructures and refactor code for better readability
* Remove merge conflict line
* lint before commit
* Use destructuring for readability and optimzations at for loop length property
* Destructure variables for easy maintainability of code
* PR review fix
* refactor: fix linting
This allows `prettier.__debug.formatAST` to not crash when given the AST
for the below code (taken from https://astexplorer.net/), which is
useful when trying to use Prettier as a code generator for an AST
without corresponding source code (https://github.com/prettier/prettier/issues/4675)
```js
let tips = [
"Click on any AST node with a '+' to expand it",
"Hovering over a node highlights the \
corresponding part in the source code",
"Shift click on an AST node expands the whole substree"
];
function printTips() {
tips.forEach((tip, i) => console.log(`Tip ${i}:` + tip));
}
```
* Don't default parser to babylon
* Different default values according to version
* Fix error logging
* Add tests specifically for parser inference
* Add another test case
* Add API test