Skip to content

Commit

Permalink
Fix #1794 and fix formatting integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Jul 5, 2020
1 parent de34e4d commit 0bf749a
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/dist/test/lsp",
"--user-data-dir=${workspaceFolder}/test/lsp/data-dir",
"--disable-extensions",
"${workspaceFolder}/test/lsp/fixture"
],
"stopOnEntry": false,
Expand All @@ -60,6 +61,7 @@
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/dist/test/interpolation",
"--user-data-dir=${workspaceFolder}/test/interpolation/data-dir",
"--disable-extensions",
"${workspaceFolder}/test/interpolation/fixture"
],
"stopOnEntry": false,
Expand Down Expand Up @@ -88,6 +90,7 @@
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/dist/test/grammar",
"--user-data-dir=${workspaceFolder}/test/grammar/data-dir",
"--disable-extensions",
"${workspaceFolder}/test/grammar/fixture"
],
"stopOnEntry": false,
Expand Down
2 changes: 1 addition & 1 deletion server/src/modes/script/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ export async function getJavascriptMode(
return [];
}

const parser = scriptDoc.languageId === 'javascript' ? 'babylon' : 'typescript';
const parser = scriptDoc.languageId === 'javascript' ? 'babel' : 'typescript';
const needInitialIndent = config.vetur.format.scriptInitialIndent;
const vlsFormatConfig: VLSFormatConfig = config.vetur.format;

Expand Down
1 change: 0 additions & 1 deletion test/codeTestRunner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as path from 'path';
import * as cp from 'child_process';
import * as fs from 'fs';
import * as $ from 'shelljs';
import * as minimist from 'minimist';
Expand Down
4 changes: 4 additions & 0 deletions test/lsp/fixture/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"trailingComma": "none",
"singleQuote": true
}
13 changes: 9 additions & 4 deletions test/lsp/fixture/client/formatting/Basic.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<template>
<div class="page">
<counter></counter>
</div>
<counter>


</counter>
</div>
</template>

<script>
import Counter from 'components/Counter';
import Counter from "components/Counter"
export default {
components: {
Counter
Counter
}
};
</script>
11 changes: 11 additions & 0 deletions test/lsp/fixture/client/formatting/Pug.Expected.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template lang="pug">
- var friends = 10;

case friends
when 0
p you have no friends
when 1
p you have a friend
default
p you have #{friends} friends
</template>
11 changes: 11 additions & 0 deletions test/lsp/fixture/client/formatting/Pug.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template lang="pug">
- var friends = 10;

case friends
when 0
p you have no friends
when 1
p you have a friend
default
p you have #{friends} friends
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div class="user-view">
<template v-if="user">
<h1>User : {{ user.id }}</h1>

<ul class="meta">
<li>
<span class="label">Created:</span>
Expand All @@ -14,7 +15,8 @@
<li v-if="user.about" v-html="user.about" class="about"></li>
</ul>
<p class="links">
<a :href="'https://news.ycombinator.com/submitted?id=' + user.id">submissions</a> |
<a :href="'https://news.ycombinator.com/submitted?id=' + user.id">submissions</a>
|
<a :href="'https://news.ycombinator.com/threads?id=' + user.id">comments</a>
</p>
</template>
Expand Down
41 changes: 22 additions & 19 deletions test/lsp/fixture/client/formatting/VueHNUserView.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
<template>
<div class="user-view">
<template v-if="user">
<h1>User : {{ user.id }}</h1>
<ul class="meta">
<li>
<div class="user-view">
<template v-if="user">
<h1>User : {{ user.id }}</h1>

<ul class='meta'>
<li>
<span class="label">Created:</span>
{{ user.created | timeAgo }} ago
</li>
<li>
<span class="label">Karma:</span>
{{ user.karma }}
</li>
<li>
<span class="label">Karma:</span>
{{ user.karma }}
</li>
<li v-if="user.about" v-html="user.about" class="about"></li>
</ul>
<p class="links">
<a :href="'https://news.ycombinator.com/submitted?id=' + user.id">submissions</a> |
<a :href="'https://news.ycombinator.com/threads?id=' + user.id">comments</a>
</p>
</template>
<template v-else-if="user === false">
<h1>User not found.</h1>
</template>
</div>
</ul>
<p class="links">
<a :href="'https://news.ycombinator.com/submitted?id=' + user.id">submissions</a> |


<a :href="'https://news.ycombinator.com/threads?id=' + user.id">comments</a>
</p>
</template>
<template v-else-if="user === false">
<h1>User not found.</h1>
</template>
</div>
</template>
3 changes: 2 additions & 1 deletion test/lsp/fixture/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@
"vuex": "^3.0.1"
},
"devDependencies": {
"@prettier/plugin-pug": "^1.4.4",
"@types/lodash": "^4.14.77",
"eslint": "^6.8.0",
"eslint-plugin-vue": "^6.2.1",
"prettier": "^1.19.1",
"prettier": "^2.0.5",
"prettier-eslint-cli": "^5.0.0",
"typescript": "^3.8.3",
"vue-template-compiler": "^2.6.11"
Expand Down
74 changes: 72 additions & 2 deletions test/lsp/fixture/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
esutils "^2.0.2"
js-tokens "^4.0.0"

"@prettier/plugin-pug@^1.4.4":
version "1.4.4"
resolved "https://registry.yarnpkg.com/@prettier/plugin-pug/-/plugin-pug-1.4.4.tgz#252c8dfac574c82d1e95492b9bd4cb59c44d3ee6"
integrity sha512-Lb3cc0a4IwUy9oNeYuN1YHg/+J5JDsJNSKFMGpcp6cq6vnMcNyWn+KNBkTo/ZYEIT2JAsl6X+KKAvjH1p+XGeQ==
dependencies:
pug-lexer "~5.0.0"

"@types/color-name@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
Expand Down Expand Up @@ -97,6 +104,11 @@ acorn@^7.1.0:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.1.tgz#e35668de0b402f359de515c5482a1ab9f89a69bf"
integrity sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==

acorn@^7.1.1:
version "7.3.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.3.1.tgz#85010754db53c3fbaf3b9ea3e083aa5c5d147ffd"
integrity sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==

ajv@^6.10.0, ajv@^6.10.2, ajv@^6.9.1:
version "6.12.0"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.0.tgz#06d60b96d87b8454a5adaba86e7854da629db4b7"
Expand Down Expand Up @@ -221,6 +233,18 @@ brace-expansion@^1.1.7:
balanced-match "^1.0.0"
concat-map "0.0.1"

buefy@^0.8.16:
version "0.8.20"
resolved "https://registry.yarnpkg.com/buefy/-/buefy-0.8.20.tgz#75708800548220654575903d031a81fc8575b7f3"
integrity sha512-pg8Cn0m9cjqp2/vaKT4VIfU8KIumuX/gAT1GtearXRs56+kKqAPx3j9O8cm9W6P4jPUCHajKX6H8AqD0ram2Bg==
dependencies:
bulma "0.7.5"

bulma@0.7.5:
version "0.7.5"
resolved "https://registry.yarnpkg.com/bulma/-/bulma-0.7.5.tgz#35066c37f82c088b68f94450be758fc00a967208"
integrity sha512-cX98TIn0I6sKba/DhW0FBjtaDpxTelU166pf7ICXpCCuplHWyu6C9LYZmL5PEsnePIeJaiorsTEzzNk3Tsm1hw==

callsites@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
Expand Down Expand Up @@ -277,6 +301,13 @@ chalk@^3.0.0:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

character-parser@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/character-parser/-/character-parser-2.2.0.tgz#c7ce28f36d4bcd9744e5ffc2c5fcde1c73261fc0"
integrity sha1-x84o821LzZdE5f/CxfzeHHMmH8A=
dependencies:
is-regex "^1.0.3"

chardet@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
Expand Down Expand Up @@ -797,6 +828,11 @@ has-flag@^4.0.0:
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==

has-symbols@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8"
integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==

he@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd"
Expand Down Expand Up @@ -888,6 +924,14 @@ inquirer@^7.0.0:
strip-ansi "^6.0.0"
through "^2.3.6"

is-expression@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/is-expression/-/is-expression-4.0.0.tgz#c33155962abf21d0afd2552514d67d2ec16fd2ab"
integrity sha512-zMIXX63sxzG3XrkHkrAPvm/OVZVSCPNkwMHU8oTX7/U3AL78I0QXCEICXUM13BIa8TYGZ68PiTKfQz3yaTNr4A==
dependencies:
acorn "^7.1.1"
object-assign "^4.1.1"

is-extglob@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
Expand Down Expand Up @@ -915,6 +959,13 @@ is-promise@^2.1.0:
resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa"
integrity sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=

is-regex@^1.0.3:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.0.tgz#ece38e389e490df0dc21caea2bd596f987f767ff"
integrity sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==
dependencies:
has-symbols "^1.0.1"

isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
Expand Down Expand Up @@ -1099,7 +1150,7 @@ normalize-wheel@^1.0.1:
resolved "https://registry.yarnpkg.com/normalize-wheel/-/normalize-wheel-1.0.1.tgz#aec886affdb045070d856447df62ecf86146ec45"
integrity sha1-rsiGr/2wRQcNhWRH32Ls+GFG7EU=

object-assign@^4.0.1:
object-assign@^4.0.1, object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
Expand Down Expand Up @@ -1259,11 +1310,16 @@ prettier-eslint@^9.0.0:
typescript "^3.2.1"
vue-eslint-parser "^2.0.2"

prettier@^1.19.1, prettier@^1.7.0:
prettier@^1.7.0:
version "1.19.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==

prettier@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4"
integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==

pretty-format@^23.0.1:
version "23.6.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-23.6.0.tgz#5eaac8eeb6b33b987b7fe6097ea6a8a146ab5760"
Expand All @@ -1277,6 +1333,20 @@ progress@^2.0.0:
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f"
integrity sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=

pug-error@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/pug-error/-/pug-error-2.0.0.tgz#5c62173cb09c34de2a2ce04f17b8adfec74d8ca5"
integrity sha512-sjiUsi9M4RAGHktC1drQfCr5C5eriu24Lfbt4s+7SykztEOwVZtbFk1RRq0tzLxcMxMYTBR+zMQaG07J/btayQ==

pug-lexer@~5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/pug-lexer/-/pug-lexer-5.0.0.tgz#0b779e7d8cbf0f103803675be96351942fd9a727"
integrity sha512-52xMk8nNpuyQ/M2wjZBN5gXQLIylaGkAoTk5Y1pBhVqaopaoj8Z0iVzpbFZAqitL4RHNVDZRnJDsqEYe99Ti0A==
dependencies:
character-parser "^2.2.0"
is-expression "^4.0.0"
pug-error "^2.0.0"

punycode@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
Expand Down

0 comments on commit 0bf749a

Please sign in to comment.