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

Indent <script> and <style> tags’ content in *.vue files #5574

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 0 additions & 4 deletions src/language-html/printer-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,6 @@ function genericPrint(path, options, print) {
? ifBreak(indent(childrenDoc), childrenDoc, {
groupId: attrGroupId
})
: isScriptLikeTag(node) &&
node.parent.type === "root" &&
options.parser === "vue"
? childrenDoc
: indent(childrenDoc))(
concat([
shouldHugContent
Expand Down
188 changes: 94 additions & 94 deletions tests/html_vue/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -287,60 +287,60 @@ export default {

=====================================output=====================================
<script>
import "./issue_card_inner";
import eventHub from "../eventhub";
import "./issue_card_inner";
import eventHub from "../eventhub";

const Store = gl.issueBoards.BoardsStore;
const Store = gl.issueBoards.BoardsStore;

export default {
name: "BoardsIssueCard",
components: {
"issue-card-inner": gl.issueBoards.IssueCardInner
},
props: {
list: Object,
issue: Object,
issueLinkBase: String,
disabled: Boolean,
index: Number,
rootPath: String
},
data() {
return {
showDetail: false,
detailIssue: Store.detail
};
},
computed: {
issueDetailVisible() {
return (
this.detailIssue.issue && this.detailIssue.issue.id === this.issue.id
);
}
},
methods: {
mouseDown() {
this.showDetail = true;
export default {
name: "BoardsIssueCard",
components: {
"issue-card-inner": gl.issueBoards.IssueCardInner
},
mouseMove() {
this.showDetail = false;
props: {
list: Object,
issue: Object,
issueLinkBase: String,
disabled: Boolean,
index: Number,
rootPath: String
},
showIssue(e) {
if (e.target.classList.contains("js-no-trigger")) return;

if (this.showDetail) {
data() {
return {
showDetail: false,
detailIssue: Store.detail
};
},
computed: {
issueDetailVisible() {
return (
this.detailIssue.issue && this.detailIssue.issue.id === this.issue.id
);
}
},
methods: {
mouseDown() {
this.showDetail = true;
},
mouseMove() {
this.showDetail = false;

if (Store.detail.issue && Store.detail.issue.id === this.issue.id) {
eventHub.$emit("clearDetailIssue");
} else {
eventHub.$emit("newDetailIssue", this.issue);
Store.detail.list = this.list;
},
showIssue(e) {
if (e.target.classList.contains("js-no-trigger")) return;

if (this.showDetail) {
this.showDetail = false;

if (Store.detail.issue && Store.detail.issue.id === this.issue.id) {
eventHub.$emit("clearDetailIssue");
} else {
eventHub.$emit("newDetailIssue", this.issue);
Store.detail.list = this.list;
}
}
}
}
}
};
};
</script>

<template>
Expand Down Expand Up @@ -453,60 +453,60 @@ export default {

=====================================output=====================================
<script>
import "./issue_card_inner";
import eventHub from "../eventhub";
import "./issue_card_inner";
import eventHub from "../eventhub";

const Store = gl.issueBoards.BoardsStore;
const Store = gl.issueBoards.BoardsStore;

export default {
name: "BoardsIssueCard",
components: {
"issue-card-inner": gl.issueBoards.IssueCardInner,
},
props: {
list: Object,
issue: Object,
issueLinkBase: String,
disabled: Boolean,
index: Number,
rootPath: String,
},
data() {
return {
showDetail: false,
detailIssue: Store.detail,
};
},
computed: {
issueDetailVisible() {
return (
this.detailIssue.issue && this.detailIssue.issue.id === this.issue.id
);
export default {
name: "BoardsIssueCard",
components: {
"issue-card-inner": gl.issueBoards.IssueCardInner,
},
},
methods: {
mouseDown() {
this.showDetail = true;
props: {
list: Object,
issue: Object,
issueLinkBase: String,
disabled: Boolean,
index: Number,
rootPath: String,
},
mouseMove() {
this.showDetail = false;
data() {
return {
showDetail: false,
detailIssue: Store.detail,
};
},
showIssue(e) {
if (e.target.classList.contains("js-no-trigger")) return;

if (this.showDetail) {
computed: {
issueDetailVisible() {
return (
this.detailIssue.issue && this.detailIssue.issue.id === this.issue.id
);
},
},
methods: {
mouseDown() {
this.showDetail = true;
},
mouseMove() {
this.showDetail = false;

if (Store.detail.issue && Store.detail.issue.id === this.issue.id) {
eventHub.$emit("clearDetailIssue");
} else {
eventHub.$emit("newDetailIssue", this.issue);
Store.detail.list = this.list;
},
showIssue(e) {
if (e.target.classList.contains("js-no-trigger")) return;

if (this.showDetail) {
this.showDetail = false;

if (Store.detail.issue && Store.detail.issue.id === this.issue.id) {
eventHub.$emit("clearDetailIssue");
} else {
eventHub.$emit("newDetailIssue", this.issue);
Store.detail.list = this.list;
}
}
}
},
},
},
};
};
</script>

<template>
Expand Down Expand Up @@ -1244,7 +1244,7 @@ foo( )
</template>

<script>
foo();
foo();
</script>

<template>
Expand Down Expand Up @@ -1289,7 +1289,7 @@ foo( )
</template>

<script>
foo();
foo();
</script>

<template>
Expand Down
4 changes: 2 additions & 2 deletions tests/insert-pragma/vue/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const x = 1;
<div>This will be pre-compiled</div>
</template>
<script>
const x = 1;
const x = 1;
</script>
<style src="./my-component.css"></style>

Expand Down Expand Up @@ -58,7 +58,7 @@ const x = 1;
<div>This will be pre-compiled</div>
</template>
<script>
const x = 1;
const x = 1;
</script>
<style src="./my-component.css"></style>

Expand Down
62 changes: 31 additions & 31 deletions tests/multiparser_vue/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export default {
</template>

<script lang="ts">
export default {
computed: {
foo(): string {
return "foo";
export default {
computed: {
foo(): string {
return "foo";
}
}
}
};
};
</script>

================================================================================
Expand All @@ -51,17 +51,17 @@ export default {

=====================================output=====================================
<script lang="tsx">
import { VNode } from "vue";
export default {
computed: {
foo(): string {
return "foo";
import { VNode } from "vue";
export default {
computed: {
foo(): string {
return "foo";
}
},
render(h): VNode {
return <div>{this.foo}</div>;
}
},
render(h): VNode {
return <div>{this.foo}</div>;
}
};
};
</script>

================================================================================
Expand Down Expand Up @@ -167,27 +167,27 @@ p { font-size : 2em ; text-align : center ; }
</template>

<script>
module.exports = {
data: function() {
return {
greeting: "Hello"
};
}
};
module.exports = {
data: function() {
return {
greeting: "Hello"
};
}
};
</script>

<style scoped>
p {
font-size: 2em;
text-align: center;
}
p {
font-size: 2em;
text-align: center;
}
</style>

<style lang="postcss">
p {
font-size: 2em;
text-align: center;
}
p {
font-size: 2em;
text-align: center;
}
</style>

================================================================================
Expand Down
12 changes: 6 additions & 6 deletions tests/range_vue/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ let Prettier = format => { your.js('though') }
</template>

<script>
let Prettier = format => {
your.js("though");
};
let Prettier = format => {
your.js("though");
};
</script>

<style>
.and {
css: too !important;
}
.and {
css: too !important;
}
</style>
================================================================================
`;
2 changes: 1 addition & 1 deletion tests/require-pragma/vue/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const x = 1;
<div>This will be pre-compiled</div>
</template>
<script>
const x = 1;
const x = 1;
</script>
<style src="./my-component.css"></style>

Expand Down