Skip to content

Commit

Permalink
Merge branch 'master' into comment-attach-refactor-2
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/comments.js
  • Loading branch information
fisker committed Dec 2, 2020
2 parents 794ec93 + b9aa130 commit a56e917
Show file tree
Hide file tree
Showing 65 changed files with 2,293 additions and 712 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# See https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt

# Prettier bump after release
# 2.2.1
80961835a68e3de1b14819a7b77583a54d2b63d7
# 2.2.0
cf354c205de9841a2d306387473dac369359ca2b
# 2.1.2
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Tip! Don't write this stuff manually.
-->

**Prettier 2.2.0**
**Prettier 2.2.1**
[Playground link](https://prettier.io/playground/#.....)

```sh
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BEFORE SUBMITTING AN ISSUE:

**Environments:**

- Prettier Version: 2.2.0
- Prettier Version: 2.2.1
- Running Prettier via: <!-- CLI, Node.js API, Browser API, etc. -->
- Runtime: <!-- Node.js v14, Chrome v83, etc. -->
- Operating System: <!-- Windows, Linux, macOS, etc. -->
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
# 2.2.1

[diff](https://github.com/prettier/prettier/compare/2.2.0...2.2.1)

#### Fix formatting for AssignmentExpression with ClassExpression ([#9741](https://github.com/prettier/prettier/pull/9741) by [@sosukesuzuki](https://github.com/sosukesuzuki))

<!-- prettier-ignore -->
```js
// Input
module.exports = class A extends B {
method() {
console.log("foo");
}
};

// Prettier 2.2.0
module.exports = class A extends (
B
) {
method() {
console.log("foo");
}
};

// Prettier 2.2.1
module.exports = class A extends B {
method() {
console.log("foo");
}
};
```

# 2.2.0

[diff](https://github.com/prettier/prettier/compare/2.1.2...2.2.0)
Expand Down
3 changes: 3 additions & 0 deletions changelog_unreleased/api/8105.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### Treat `.prettierrc` as `yaml` (#8105 by @fisker)

`.prettierrc` file can written in both JSON and YAML, previously we infer the parser to be `json`, if it's write in YAML, there will be a `SyntaxError` thrown when formatting it, now it's treat as a YAML file, but if it's write in JSON, it won't format as a normal YAML file, it will be formatted as JSON.
27 changes: 27 additions & 0 deletions changelog_unreleased/javascript/9672.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#### Improve comment format (#9672 by @fisker)

When multiple comments on same line, the result became unstable.

<!-- prettier-ignore -->
```jsx
// Input
a;
/*1*//*2*/
/*3*/
b;

// Prettier stable
a; /*2*/
/*1*/ /*3*/
b;

// Prettier stable (second format)
a; /*2*/ /*3*/
/*1*/ b;

// Prettier master
a;
/*1*/ /*2*/
/*3*/
b;
```
19 changes: 19 additions & 0 deletions changelog_unreleased/javascript/9704.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#### Fix node ends at `rangeStart` was formatted (#9704 by @fisker)

Previously a node ends at `rangeStart` in considered in range, now it's excluded.

<!-- prettier-ignore -->
```js
// Prettier stable
foo = 1.0000;bar = 1.0000;baz=1.0000;
^^^^^^^^^^^^^ Range

// Prettier stable
foo = 1.0;
bar = 1.0;baz=1.0000;

// Prettier master
foo = 1.0000;bar = 1.0;baz=1.0000;
```

_This effect other languages support range format too._
27 changes: 0 additions & 27 deletions changelog_unreleased/javascript/9741.md

This file was deleted.

19 changes: 19 additions & 0 deletions changelog_unreleased/javascript/9743.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#### Fix inconsistent language comment detection (#9743 by @fisker)

<!-- prettier-ignore -->
```jsx
// Input
foo /* HTML */ = `<DIV>
</DIV>`;

// Prettier stable (--parser=babel)
foo /* HTML */ = `<div></div>`;

// Prettier stable (--parser=meriyah)
foo /* HTML */ = `<DIV>
</DIV>`;

// Prettier master (All JavaScript parsers)
foo /* HTML */ = `<DIV>
</DIV>`;
```
44 changes: 44 additions & 0 deletions changelog_unreleased/markdown/9791.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#### Fix empty front matter formatting (#9791 by @fisker)

<!-- prettier-ignore -->
```markdown
<!-- Input -->
---
---

# Title

a|b|c|
|:--|:-:|--:|
|d|e|f|

---

text

<!-- Prettier stable -->
---
---
# Title

a|b|c|
|:--|:-:|--:|
|d|e|f|
---

text

<!-- Prettier master -->
---
---

# Title

| a | b | c |
| :-- | :-: | --: |
| d | e | f |

---

text
```
23 changes: 23 additions & 0 deletions changelog_unreleased/scss/9710.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#### Fix broken comment inside parens (#9710 by @fisker)

<!-- prettier-ignore -->
```scss
// Input
.simplification {
foo: (
calc() // not a comment anymore
);
}

// Prettier stable
.simplification {
foo: (calc() // not a comment anymore);
}

// Prettier master
.simplification {
foo: (
calc() // not a comment anymore
);
}
```
2 changes: 1 addition & 1 deletion commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ However, if any of the items inside the array have a hard break, the array will
];
```

Functions always break after the opening curly brace no matter what, so the array breaks as well for consistent formatting. See the implementation of `ArrayExpression` for an example.
Functions always break after the opening curly brace no matter what, so the array breaks as well for consistent formatting. See [the implementation of `ArrayExpression`](#example) for an example.

### conditionalGroup

Expand Down
12 changes: 6 additions & 6 deletions docs/browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ See [Usage](#usage) below for examples.
### Global

```html
<script src="https://unpkg.com/prettier@2.2.0/standalone.js"></script>
<script src="https://unpkg.com/prettier@2.2.0/parser-graphql.js"></script>
<script src="https://unpkg.com/prettier@2.2.1/standalone.js"></script>
<script src="https://unpkg.com/prettier@2.2.1/parser-graphql.js"></script>
<script>
prettier.format("query { }", {
parser: "graphql",
Expand All @@ -51,8 +51,8 @@ prettier.format("query { }", {

```js
define([
"https://unpkg.com/prettier@2.2.0/standalone.js",
"https://unpkg.com/prettier@2.2.0/parser-graphql.js",
"https://unpkg.com/prettier@2.2.1/standalone.js",
"https://unpkg.com/prettier@2.2.1/parser-graphql.js",
], (prettier, ...plugins) => {
prettier.format("query { }", { parser: "graphql", plugins });
});
Expand All @@ -71,7 +71,7 @@ This syntax doesn’t necessarily work in the browser, but it can be used when b
### Worker

```js
importScripts("https://unpkg.com/prettier@2.2.0/standalone.js");
importScripts("https://unpkg.com/prettier@2.2.0/parser-graphql.js");
importScripts("https://unpkg.com/prettier@2.2.1/standalone.js");
importScripts("https://unpkg.com/prettier@2.2.1/parser-graphql.js");
prettier.format("query { }", { parser: "graphql", plugins: prettierPlugins });
```
33 changes: 12 additions & 21 deletions docs/option-philosophy.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,36 @@ id: option-philosophy
title: Option Philosophy
---

> Prettier has a few options because of history. **But we don’t want more of them.**
> Prettier has a few options because of history. **But we won’t add more of them.**
>
> Read on to learn more.
Prettier is not a kitchen-sink code formatter that attempts to print your code in any way you wish. It is _opinionated._ Quoting the [Why Prettier?](why-prettier.md) page:

> By far the biggest reason for adopting Prettier is to stop all the on-going debates over styles.
> By far the biggest reason for adopting Prettier is to stop all the ongoing debates over styles.
The more options Prettier has, the further from the above goal it gets. **The debates over styles just turn into debates over which Prettier options to use.**
Yet the more options Prettier has, the further from the above goal it gets. **The debates over styles just turn into debates over which Prettier options to use.** Formatting wars break out with renewed vigour: “Which option values are better? Why? Did we make the right choices?”

The issue about [resisting adding configuration](https://github.com/prettier/prettier/issues/40) has more 👍s than any option request issue.
And it’s not the only cost options have. To learn more about their downsides, see the [issue about resisting adding configuration](https://github.com/prettier/prettier/issues/40), which has more 👍s than any option request issue.

So why are there any options at all?

- A few were added during Prettier’s infancy to make it take off at all. 🚀
- A couple were added after “great demand.” 🤔
- Some were added for compatibility reasons. 👍

What we’ve learned during the years is that it’s really hard to measure demand. Prettier has grown _a lot_ in usage. What was “great demand” back in the day is not as much today. How many is many? What about all silent users?

It’s so easy to add “just one more“ option. But where do we stop? When is one too many? There will always be a “top issue” in the issue tracker. Even if we add just that one final option.

The downside of options is that they open up for debate within teams. Which options should we use? Why? Did we make the right choices?

Every option also makes it much harder to say no to new ones. If _those_ options exist, why can’t this one?

We’ve had several users open up option requests only to close them themselves a couple of months later. They had realized that they don’t care at all about that little syntax choice they used to feel so strongly about. Examples: [#3101](https://github.com/prettier/prettier/issues/3101#issuecomment-500927917) and [#5501](https://github.com/prettier/prettier/issues/5501#issuecomment-487025417).

All of this makes the topic of options in Prettier very difficult. And mentally tiring for maintainers. What do people want? What do people _really_ want in 6 months? Are we spending time and energy on the right things?

Some options are easier to motivate:
Options that are easier to motivate include:

- `--trailing-comma es5` lets you use trailing commas in most environments without having to transpile (trailing function commas were added in ES2017).
- `--prose-wrap` is important to support all quirky markdown renderers in the wild.
- `--prose-wrap` is important to support all quirky Markdown renderers in the wild.
- `--html-whitespace-sensitivity` is needed due to the unfortunate whitespace rules of HTML.
- `--end-of-line` makes it easier for teams to keep CRLFs out of their git repositories.
- `--quote-props` is important for advanced usage of the Google Closure Compiler.

But others are harder to motivate in hindsight, and usually end up with bike shedding. `--arrow-parens`,
`--jsx-single-quote`, `--jsx-bracket-same-line` and `--no-bracket-spacing` are not the type of options we want more of. They exist (and are difficult to remove now), but should not motivate adding more options like them.
But other options are harder to motivate in hindsight: `--arrow-parens`, `--jsx-single-quote`, `--jsx-bracket-same-line` and `--no-bracket-spacing` are not the type of options we’re happy to have. They cause a lot of [bike-shedding](https://en.wikipedia.org/wiki/Law_of_triviality) in teams, and we’re sorry for that. Difficult to remove now, these options exist as a historical artifact and should not motivate adding more options (“If _those_ options exist, why can’t this one?”).

For a long time, we left option requests open in order to let discussions play out and collect feedback. What we’ve learned during those years is that it’s really hard to measure demand. Prettier has grown a lot in usage. What was “great demand” back in the day is not as much today. GitHub reactions and Twitter polls became unrepresentative. What about all silent users? It looked easy to add “just one more” option. But where should we have stopped? When is one too many? Even after adding “that one final option”, there would always be a “top issue” in the issue tracker.

However, the time to stop has come. Now that Prettier is mature enough and we see it adopted by so many organizations and projects, the research phase is over. We have enough confidence to conclude that Prettier reached a point where the set of options should be “frozen”. **Option requests aren’t accepted anymore.** We’re thankful to everyone who participated in this difficult journey.

Feel free to open issues! Prettier isn’t perfect. Many times things can be improved without adding options. But if the issue _does_ seem to need a new option, we’ll generally keep it open, to let people 👍 it and add comments.
Please note that as option requests are out of scope for Prettier, they will be closed without discussion. The same applies to requests to preserve elements of input formatting (e.g. line breaks) since that’s nothing else but an option in disguise with all the downsides of “real” options. There may be situations where adding an option can’t be avoided because of technical necessity (e.g. compatibility), but for formatting-related options, this is final.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,25 @@
"yaml-unist-parser": "1.3.1"
},
"devDependencies": {
"@babel/core": "7.12.8",
"@babel/core": "7.12.9",
"@babel/preset-env": "7.12.7",
"@babel/types": "7.12.7",
"@glimmer/reference": "0.67.0",
"@rollup/plugin-alias": "3.1.1",
"@rollup/plugin-babel": "5.2.1",
"@rollup/plugin-babel": "5.2.2",
"@rollup/plugin-commonjs": "16.0.0",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "10.0.0",
"@rollup/plugin-replace": "2.3.4",
"@types/estree": "0.0.45",
"@types/node": "14.14.0",
"@typescript-eslint/types": "4.8.2",
"@typescript-eslint/types": "4.9.0",
"babel-jest": "26.6.3",
"babel-loader": "8.2.1",
"babel-loader": "8.2.2",
"benchmark": "2.1.4",
"builtin-modules": "3.1.0",
"cross-env": "7.0.2",
"cspell": "4.2.2",
"cross-env": "7.0.3",
"cspell": "4.2.5",
"eslint": "7.14.0",
"eslint-config-prettier": "6.15.0",
"eslint-formatter-friendly": "7.0.0",
Expand All @@ -119,9 +119,9 @@
"jest-watch-typeahead": "0.6.1",
"npm-run-all": "4.1.5",
"path-browserify": "1.0.1",
"prettier": "2.2.0",
"prettier": "2.2.1",
"rimraf": "3.0.2",
"rollup": "2.33.3",
"rollup": "2.34.0",
"rollup-plugin-node-globals": "1.4.0",
"rollup-plugin-terser": "7.0.2",
"shelljs": "0.8.4",
Expand All @@ -130,7 +130,7 @@
"synchronous-promise": "2.0.15",
"tempy": "1.0.0",
"terser-webpack-plugin": "5.0.3",
"webpack": "5.6.0"
"webpack": "5.9.0"
},
"scripts": {
"prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
Expand Down
5 changes: 5 additions & 0 deletions scripts/build/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ const entries = [
`${PROJECT_ROOT}/node_modules/@angular/compiler/esm2015/src`
),
},
// Avoid rollup `SOURCEMAP_ERROR` and `THIS_IS_UNDEFINED` error
{
find: "@glimmer/syntax",
replacement: require.resolve("@glimmer/syntax"),
},
];

function webpackNativeShims(config, modules) {
Expand Down
Loading

0 comments on commit a56e917

Please sign in to comment.