Skip to content

Commit

Permalink
Merge branch 'master' of github.com:prettier/prettier into next
Browse files Browse the repository at this point in the history
* 'master' of github.com:prettier/prettier: (43 commits)
  Update `postcss-less` to v2 (#6778)
  Show invalid config filename in error message (#6865)
  Change external links to https (#6874)
  Bump @babel/parser from 7.7.0 to 7.7.2 (#6862)
  Fix nullish coalescing parenthesis with mixed logical operators (#6863)
  Remove handlebars@4.4.5 requirement in yarn.lock (#6867)
  Update browerslist in yarn.lock (#6868)
  fix formatting of comments in flow enums (#6860)
  better formatting for AwaitExpression in CallExpression/MemberExpression (#6856)
  Bump @typescript-eslint/typescript-estree from 2.6.0 to 2.6.1 (#6805)
  test: issue #6283 (#6855)
  audit(critical): handlebars@4.4.5 in package resolutions (#6853)
  Flow enums (#6833)
  Add mongo as a VS Code supported language (#6848)
  Bump `eslint` from 6.5.1 to 6.6.0 (#6846)
  Upgrade flow-parser from 0.89 to 0.111 (#6830)
  Bump @babel/preset-react from 7.6.3 to 7.7.0 in /website (#6827)
  Bump typescript from 3.7.1-rc to 3.7.2 (#6832)
  Bump rollup from 1.26.0 to 1.26.3 (#6821)
  update Babel to 7.7.0 and enable error recovery (#6816)
  ...
  • Loading branch information
lipis committed Nov 8, 2019
2 parents c9bc9c5 + 85912a7 commit ae1d9af
Show file tree
Hide file tree
Showing 102 changed files with 2,358 additions and 1,381 deletions.
2 changes: 2 additions & 0 deletions .azure-pipelines/jobs/dev-lint.yml
Expand Up @@ -3,6 +3,8 @@ steps:
- template: ../steps/install-dependencies.yml
- script: yarn check-deps
displayName: "Check dependencies"
- script: yarn check-types
displayName: "Check JSDoc types"
- script: yarn lint
displayName: "Lint code"
- script: yarn lint-docs
Expand Down
209 changes: 182 additions & 27 deletions CHANGELOG.unreleased.md
Expand Up @@ -123,25 +123,28 @@ class C extends B {
}
```

#### TypeScript: Prettier removed `?` from optional computed class fields ([#6657] by [@cryrivers])
#### TypeScript: Fix optional computed class fields and methods ([#6657] by [@cryrivers], [#6673] by [@thorn0])

Still happens if the field key is a complex expression, but has been fixed in this case:
Still broken if the key is a complex expression, but has been fixed in these cases:

<!-- prettier-ignore -->
```ts
// Input
class Foo {
[bar]?: number;
protected [s]?() {}
}

// Output (Prettier stable)
class Foo {
[bar]: number;
protected [s?]() {};
}

// Output (Prettier master)
class Foo {
[bar]?: number;
protected [s]?() {}
}
```
Expand Down Expand Up @@ -480,20 +483,23 @@ Previously, Prettier would sometimes ignore whitespace when formatting comments.
</div>
```
#### JavaScript: Update `??` precedence to match stage 3 proposal ([#6404] by [@vjeux])
#### JavaScript: Update `??` precedence to match stage 3 proposal ([#6404] by [@vjeux], [#6863] by [@jridgewell])
We've updated Prettier's support for the nullish coalescing operator to match a spec update that no longer allows it to immediately contain, or be contained within an `&&` or `||` operation.
We've updated Prettier's support for the nullish coalescing operator to match a spec update that no longer allows it to immediately contain, or be contained within, an `&&` or `||` operation.
<!-- prettier-ignore -->
```js
// Input
(foo ?? baz) || baz;
(foo ?? bar) || baz;
(foo || bar) ?? baz;

// Output (Prettier stable)
foo ?? baz || baz;
foo ?? bar || baz;
foo || bar ?? baz;

// Output (Prettier master)
(foo ?? baz) || baz;
(foo ?? bar) || baz;
(foo || bar) ?? baz;
```
Please note, as we update our parsers with versions that support this spec update, code without the parenthesis will throw a parse error.
Expand Down Expand Up @@ -676,6 +682,26 @@ Previously, even if the line length was shorter than `printWidth`, Prettier woul
</template>
```

#### HTML: Add support for `&excl;` and other entities ([#6785] by [@lydell])

Previously, Prettier only supported the most common HTML entities, such as `&nbsp;` and `&quot;`. Now, Prettier supports every HTML entity in the HTML spec, such as `&excl;` and `&pitchfork;`.

<!-- prettier-ignore -->
```html
<!-- Input -->
<p>Hi&excl;</p>
<!-- Output (Prettier stable)
[error] stdin: SyntaxError: Unknown entity "excl" - use the "&#<decimal>;" or "&#x<hex>;" syntax (1:6)
[error] > 1 | <p>Hi&excl;</p>
[error] | ^
[error] 2 |
-->
<!-- Output (Prettier master) -->
<p>Hi&excl;</p>
```

#### JavaScript: Empty lines in destructured arrow function parameters could break indentation and idempotence ([#6301] & [#6382] by [@sosukesuzuki])

Previously, Prettier indented code strangely when an arrow function whose parameters included an object pattern was passed to a function call as an argument. Also, it broke idempotence. Please see [#6294](https://github.com/prettier/prettier/issues/6294) for details.
Expand Down Expand Up @@ -1097,26 +1123,6 @@ class A {
}
```

#### TypeScript: Fix optional computed methods ([#6673] by [@thorn0])
<!-- prettier-ignore -->
```ts
// Input
class A {
protected [s]?() {}
}
// Output (Prettier stable)
class A {
protected [s?]() {}
}
// Output (Prettier master)
class A {
protected [s]?() {}
}
```
#### Angular: Put a closing parenthesis onto a new line after ternaries passed to pipes ([#5682] by [@selvazhagan])

<!-- prettier-ignore -->
Expand Down Expand Up @@ -1294,6 +1300,140 @@ export class User {
}
```

#### Flow: Parentheses around arrow functions' return types that have `FunctionTypeAnnotation` nested in `ObjectTypeAnnotation` ([#6717] by [@sosukesuzuki])

This is a workaround for a [bug](https://github.com/facebook/flow/pull/8163) in the Flow parser. Without the parentheses, the parser throws an error.

```js
// Input
const example1 = (): { p: (string => string) } => (0: any);
// Output (Prettier stable)
const example1 = (): { p: string => string } => (0: any);
// Output (Prettier master)
const example1 = (): ({ p: string => string }) => (0: any);
```

#### CLI: Handle errors when reading stdin ([#6708] by [@andersk] and [@lydell])

If you had an error in your `.prettierrc` Prettier used to crash when formatting stdin. Such errors are now handled properly.

```
# Prettier stable
$ prettier --parser babel < test.js
(node:21531) UnhandledPromiseRejectionWarning: Error: Invalid printWidth value. Expected an integer, but received "nope".
at _loop (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:7887:63)
at Normalizer._applyNormalization (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:8000:13)
at applyNormalization (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:7817:49)
at Normalizer.normalize (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:7823:9)
at normalizeOptions$1 (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:8760:31)
at Object.normalizeApiOptions (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:8918:10)
at getOptionsForFile (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:44160:69)
at /home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:44214:22
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:21531) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:21531) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
# Prettier master
$ prettier --parser babel < test.js
[error] Invalid printWidth value. Expected an integer, but received "nope".
```

#### CLI: Gracefully handle nonexistent paths passed to --stdin-filepath ([#6687] by [@voithos])

Previously, if you passed a nonexistent subdirectory to --stdin-filepath, Prettier would throw an error. Now, Prettier gracefully handles this.

```
# Prettier stable
$ prettier --stdin-filepath does/not/exist.js < test.js
[error] Invalid configuration file: ENOENT: no such file or directory, scandir '/home/lydell/forks/prettier/does/not'
# Prettier master
$ prettier --stdin-filepath does/not/exist.js < test.js
test;
```

#### JavaScript: Numeric separators were removed from BigInt literals ([#6796] by [@thorn0])

<!-- prettier-ignore -->
```js
// Input
const bigints = [200_000n, 0x0000_000An, 0b0111_1111n];
// Output (Prettier stable)
const bigints = [200000n, 0x0000000an, 0b01111111n];
// Output (Prettier master)
const bigints = [200_000n, 0x0000_000an, 0b0111_1111n];
```

#### VS Code: add support for .mongo files ([#6848] by [@aymericbouzy])

When using the Azure Cosmos DB extension for VS Code, you can create .mongo files to write MongoDB queries, which use Javascript syntax. This change allows VS Code to format your file using Prettier.

```js
db.users.find({ someField: { $exists: true } });
```

#### JavaScript: Better formatting for inline `await` expression nested in calls ([#6856] by [@thorn0])

<!-- prettier-ignore -->
```js
// Input
async function f() {
const admins = (await(db.select('*').from('admins').leftJoin('bla').where('id', 'in', [1,2,3,4]))).map(({id, name})=>({id, name}))
}
// Output (Prettier stable)
async function f() {
const admins = (await db
.select("*")
.from("admins")
.leftJoin("bla")
.where("id", "in", [1, 2, 3, 4])).map(({ id, name }) => ({ id, name }));
}
// Output (Prettier master)
async function f() {
const admins = (
await db
.select("*")
.from("admins")
.leftJoin("bla")
.where("id", "in", [1, 2, 3, 4])
).map(({ id, name }) => ({ id, name }));
}
```

#### CLI: Display invalid config filename in error message ([#6865] by [@fisker])

<!-- prettier-ignore -->
```bash
# Input
$ prettier filename.js --config .invalid-config
# Output (Prettier stable)
Invalid configuration file: ...
# Output (Prettier master)
Invalid configuration file `.invalid-config`: ...
```

#### Less: don't lowercase variable names, remove whitespace between variable and colon ([#6778] by [@fisker])

<!-- prettier-ignore -->
```less
// Input
@FoO : bar;
// Output (Prettier stable)
@foo : bar;
// Output (Prettier master)
@FoO: bar;
```

[#5682]: https://github.com/prettier/prettier/pull/5682
[#6657]: https://github.com/prettier/prettier/pull/6657
[#5910]: https://github.com/prettier/prettier/pull/5910
Expand All @@ -1306,6 +1446,7 @@ export class User {
[#6236]: https://github.com/prettier/prettier/pull/6236
[#6270]: https://github.com/prettier/prettier/pull/6270
[#6284]: https://github.com/prettier/prettier/pull/6284
[#6785]: https://github.com/prettier/prettier/pull/6785
[#6289]: https://github.com/prettier/prettier/pull/6289
[#6301]: https://github.com/prettier/prettier/pull/6301
[#6307]: https://github.com/prettier/prettier/pull/6307
Expand Down Expand Up @@ -1336,7 +1477,16 @@ export class User {
[#6673]: https://github.com/prettier/prettier/pull/6673
[#6695]: https://github.com/prettier/prettier/pull/6695
[#6694]: https://github.com/prettier/prettier/pull/6694
[#6717]: https://github.com/prettier/prettier/pull/6717
[#6728]: https://github.com/prettier/prettier/pull/6728
[#6708]: https://github.com/prettier/prettier/pull/6708
[#6687]: https://github.com/prettier/prettier/pull/6687
[#6796]: https://github.com/prettier/prettier/pull/6796
[#6778]: https://github.com/prettier/prettier/pull/6778
[#6848]: https://github.com/prettier/prettier/pull/6848
[#6856]: https://github.com/prettier/prettier/pull/6856
[#6865]: https://github.com/prettier/prettier/pull/6865
[#6863]: https://github.com/prettier/prettier/pull/6863
[@brainkim]: https://github.com/brainkim
[@duailibe]: https://github.com/duailibe
[@gavinjoyce]: https://github.com/gavinjoyce
Expand All @@ -1355,3 +1505,8 @@ export class User {
[@kaicataldo]: https://github.com/kaicataldo
[@cryrivers]: https://github.com/Cryrivers
[@voithos]: https://github.com/voithos
[@andersk]: https://github.com/andersk
[@lydell]: https://github.com/lydell
[@aymericbouzy]: https://github.com/aymericbouzy
[@fisker]: https://github.com/fisker
[@jridgewell]: https://github.com/jridgewell
36 changes: 18 additions & 18 deletions azure-pipelines.yml
Expand Up @@ -9,69 +9,69 @@ variables:

jobs:
- job: Dev_Lint
displayName: Dev Lint on Linux Node v10
displayName: Dev Lint on Linux Node v12
pool:
vmImage: "Ubuntu 16.04"
variables:
node_version: 10
node_version: 12
steps:
- template: .azure-pipelines/jobs/dev-lint.yml

- job: Dev_Test_Windows
displayName: Dev Test on Windows Node v10
displayName: Dev Test on Windows Node v12
pool:
vmImage: vs2017-win2016
variables:
node_version: 10
node_version: 12
TEST_CRLF: true
steps:
- template: .azure-pipelines/jobs/dev-test.yml

- job: Dev_Test_macOS
displayName: Dev Test on macOS Node v10
displayName: Dev Test on macOS Node v12
pool:
vmImage: macos-10.13
variables:
node_version: 10
node_version: 12
ENABLE_CODE_COVERAGE: true
steps:
- template: .azure-pipelines/jobs/dev-test.yml

- job: Dev_Test_Linux
displayName: Dev Test on Linux Node v10
displayName: Dev Test on Linux Node v12
pool:
vmImage: "Ubuntu 16.04"
variables:
node_version: 10
node_version: 12
steps:
- template: .azure-pipelines/jobs/dev-test.yml

- job: Prod_Build
displayName: Prod Build on Linux Node v10
displayName: Prod Build on Linux Node v12
pool:
vmImage: "Ubuntu 16.04"
variables:
node_version: 10
node_version: 12
steps:
- template: .azure-pipelines/jobs/prod-build.yml

- job: Prod_Pack
dependsOn: Prod_Build
displayName: Prod Pack on Linux Node v10
displayName: Prod Pack on Linux Node v12
pool:
vmImage: "Ubuntu 16.04"
variables:
node_version: 10
node_version: 12
steps:
- template: .azure-pipelines/jobs/prod-pack.yml

- job: Prod_Lint
dependsOn: Prod_Build
displayName: Prod Lint on Linux Node v10
displayName: Prod Lint on Linux Node v12
pool:
vmImage: "Ubuntu 16.04"
variables:
node_version: 10
node_version: 12
steps:
- template: .azure-pipelines/jobs/prod-lint.yml

Expand All @@ -85,10 +85,10 @@ jobs:
Node_v4:
node_version: 4
ENABLE_TEST_RESULTS: "" # jest-junit requires node v6+
Node_v10:
node_version: 10
Node_v10_standalone:
node_version: 10
Node_v12:
node_version: 12
Node_v12_standalone:
node_version: 12
TEST_STANDALONE: true
steps:
- template: .azure-pipelines/jobs/prod-test.yml

0 comments on commit ae1d9af

Please sign in to comment.