Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate jsxBracketSameLine option in favour of multi-language brack…
…etSameLine option (#11006) * deprecate jsxBracketSameLine in favour of multi-language angleBracketSameLine option * update docs and snapshots * update tests to to make them more reviewable * Rewrite angular tests * Rewrite html tests * Rewrite vue tests * Restore unnecessary changes in jsx * Fix file location * Test both `true` and `false` * Revert changes in markdown * Run tests on all js parsers * Improve html test * fix changelog comment * move bracketSameLine to common options * mark jsxBracketSameLine as deprecated * Update changelog_unreleased/html/11006.md Co-authored-by: fisker Cheung <lionkay@gmail.com> * Update 11006.md * fix tests by removing `jsxBracketSameLine` `default` property * fix style * Revert docs under website dir * Add tests for deprecated options * Fix lint problems Co-authored-by: fisker Cheung <lionkay@gmail.com> Co-authored-by: sosukesuzuki <aosukeke@gmail.com>
- Loading branch information
1 parent
af19dd1
commit 4992d97
Showing
37 changed files
with
1,207 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#### Replace `jsxBracketSameLine` option with `bracketSameLine` option (#11006 by @kurtztech) | ||
|
||
Deprecate the `jsxBracketSameLine` option in favour of new `bracketSameLine` option that will work for HTML, Angular, Vue, and JSX. | ||
|
||
<!-- prettier-ignore --> | ||
```html | ||
<!-- Input --> | ||
<div id="foo-bar-baz" | ||
class="bar-foo-baz" | ||
title="a sample title" | ||
data-foo="bar" | ||
data-bar="baz">lorem ipsum dolor sit amet</div> | ||
|
||
<!-- Prettier stable --> | ||
<div | ||
id="foo-bar-baz" | ||
class="bar-foo-baz" | ||
title="a sample title" | ||
data-foo="bar" | ||
data-bar="baz" | ||
> | ||
lorem ipsum dolor sit amet | ||
</div> | ||
|
||
<!-- Prettier main --> | ||
<!-- Options: `{bracketSameLine: true}` --> | ||
<div | ||
id="foo-bar-baz" | ||
class="bar-foo-baz" | ||
title="a sample title" | ||
data-foo="bar" | ||
data-bar="baz"> | ||
lorem ipsum dolor sit amet | ||
</div> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
tests/format/angular/bracket-same-line/__snapshots__/jsfmt.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`angularjs.html - {"bracketSameLine":false} format 1`] = ` | ||
====================================options===================================== | ||
bracketSameLine: false | ||
parsers: ["angular"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
<div ng-if="$ctrl .shouldShowWarning&&!$ctrl.loading" | ||
bindon-target=" a | b : c " | ||
(event)=" foo == $event " | ||
*ngIf=" something?true:false " [(ngModel)]="canSave">Warning!</div> | ||
<span ng-if="$ctrl .shouldShowWarning&&!$ctrl.loading" | ||
bindon-target=" a | b : c " | ||
(event)=" foo == $event " | ||
*ngIf=" something?true:false " [(ngModel)]="canSave">Warning!</span> | ||
<img ng-if="$ctrl .shouldShowWarning&&!$ctrl.loading" | ||
bindon-target=" a | b : c " | ||
(event)=" foo == $event " | ||
*ngIf=" something?true:false " [(ngModel)]="canSave"/> | ||
<script long-attribute="long_long_long_long_long_long_long_long_long_long_long_long_long_value">alert(1)</script> | ||
<div (event)=" foo == $event ">Warning!</div> | ||
<span (event)=" foo == $event ">Warning!</span> | ||
<img (event)=" foo == $event "/> | ||
<script>alert(1)</script> | ||
=====================================output===================================== | ||
<div | ||
ng-if="$ctrl.shouldShowWarning && !$ctrl.loading" | ||
bindon-target="a | b: c" | ||
(event)="(foo == $event)" | ||
*ngIf="something ? true : false" | ||
[(ngModel)]="canSave" | ||
> | ||
Warning! | ||
</div> | ||
<span | ||
ng-if="$ctrl.shouldShowWarning && !$ctrl.loading" | ||
bindon-target="a | b: c" | ||
(event)="(foo == $event)" | ||
*ngIf="something ? true : false" | ||
[(ngModel)]="canSave" | ||
>Warning!</span | ||
> | ||
<img | ||
ng-if="$ctrl.shouldShowWarning && !$ctrl.loading" | ||
bindon-target="a | b: c" | ||
(event)="(foo == $event)" | ||
*ngIf="something ? true : false" | ||
[(ngModel)]="canSave" | ||
/> | ||
<script | ||
long-attribute="long_long_long_long_long_long_long_long_long_long_long_long_long_value" | ||
> | ||
alert(1); | ||
</script> | ||
<div (event)="(foo == $event)">Warning!</div> | ||
<span (event)="(foo == $event)">Warning!</span> | ||
<img (event)="(foo == $event)" /> | ||
<script> | ||
alert(1); | ||
</script> | ||
================================================================================ | ||
`; | ||
exports[`angularjs.html - {"bracketSameLine":true} format 1`] = ` | ||
====================================options===================================== | ||
bracketSameLine: true | ||
parsers: ["angular"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
<div ng-if="$ctrl .shouldShowWarning&&!$ctrl.loading" | ||
bindon-target=" a | b : c " | ||
(event)=" foo == $event " | ||
*ngIf=" something?true:false " [(ngModel)]="canSave">Warning!</div> | ||
<span ng-if="$ctrl .shouldShowWarning&&!$ctrl.loading" | ||
bindon-target=" a | b : c " | ||
(event)=" foo == $event " | ||
*ngIf=" something?true:false " [(ngModel)]="canSave">Warning!</span> | ||
<img ng-if="$ctrl .shouldShowWarning&&!$ctrl.loading" | ||
bindon-target=" a | b : c " | ||
(event)=" foo == $event " | ||
*ngIf=" something?true:false " [(ngModel)]="canSave"/> | ||
<script long-attribute="long_long_long_long_long_long_long_long_long_long_long_long_long_value">alert(1)</script> | ||
<div (event)=" foo == $event ">Warning!</div> | ||
<span (event)=" foo == $event ">Warning!</span> | ||
<img (event)=" foo == $event "/> | ||
<script>alert(1)</script> | ||
=====================================output===================================== | ||
<div | ||
ng-if="$ctrl.shouldShowWarning && !$ctrl.loading" | ||
bindon-target="a | b: c" | ||
(event)="(foo == $event)" | ||
*ngIf="something ? true : false" | ||
[(ngModel)]="canSave"> | ||
Warning! | ||
</div> | ||
<span | ||
ng-if="$ctrl.shouldShowWarning && !$ctrl.loading" | ||
bindon-target="a | b: c" | ||
(event)="(foo == $event)" | ||
*ngIf="something ? true : false" | ||
[(ngModel)]="canSave" | ||
>Warning!</span | ||
> | ||
<img | ||
ng-if="$ctrl.shouldShowWarning && !$ctrl.loading" | ||
bindon-target="a | b: c" | ||
(event)="(foo == $event)" | ||
*ngIf="something ? true : false" | ||
[(ngModel)]="canSave" /> | ||
<script | ||
long-attribute="long_long_long_long_long_long_long_long_long_long_long_long_long_value"> | ||
alert(1); | ||
</script> | ||
<div (event)="(foo == $event)">Warning!</div> | ||
<span (event)="(foo == $event)">Warning!</span> | ||
<img (event)="(foo == $event)" /> | ||
<script> | ||
alert(1); | ||
</script> | ||
================================================================================ | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div ng-if="$ctrl .shouldShowWarning&&!$ctrl.loading" | ||
bindon-target=" a | b : c " | ||
(event)=" foo == $event " | ||
*ngIf=" something?true:false " [(ngModel)]="canSave">Warning!</div> | ||
<span ng-if="$ctrl .shouldShowWarning&&!$ctrl.loading" | ||
bindon-target=" a | b : c " | ||
(event)=" foo == $event " | ||
*ngIf=" something?true:false " [(ngModel)]="canSave">Warning!</span> | ||
<img ng-if="$ctrl .shouldShowWarning&&!$ctrl.loading" | ||
bindon-target=" a | b : c " | ||
(event)=" foo == $event " | ||
*ngIf=" something?true:false " [(ngModel)]="canSave"/> | ||
<script long-attribute="long_long_long_long_long_long_long_long_long_long_long_long_long_value">alert(1)</script> | ||
<div (event)=" foo == $event ">Warning!</div> | ||
<span (event)=" foo == $event ">Warning!</span> | ||
<img (event)=" foo == $event "/> | ||
<script>alert(1)</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
run_spec(__dirname, ["angular"], { bracketSameLine: true }); | ||
run_spec(__dirname, ["angular"], { bracketSameLine: false }); |
Oops, something went wrong.