Skip to content

Commit

Permalink
Chore: add test for vue parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 authored and not-an-aardvark committed Jan 16, 2018
1 parent eba622e commit 1ab43fd
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"mocha": "^3.1.2",
"moment": "^2.18.1",
"prettier": "^1.10.2",
"semver": "^5.3.0"
"semver": "^5.3.0",
"vue-eslint-parser": "^2.0.2"
},
"engines": {
"node": ">=4.0.0"
Expand Down
26 changes: 26 additions & 0 deletions test/invalid/vue.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
CODE:
<template>
<div>hi</div>
</template>
<script>
a();;;;;;
</script>

OUTPUT:
<template>
<div>hi</div>
</template>
<script>
a();
</script>

OPTIONS:
[]

ERRORS:
[
{
message: 'Delete `;;;;;`',
line: 5, column: 5, endLine: 5, endColumn: 10,
},
]
18 changes: 18 additions & 0 deletions test/prettier.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ ruleTester.run('prettier', rule, {
].map(loadInvalidFixture)
});

const vueRuleTester = new RuleTester({
parser: require.resolve('vue-eslint-parser')
});

vueRuleTester.run('prettier', rule, {
valid: [
{
code: `<template>foo</template>\n<script>\n"";\n</script>\n`,
filename: 'valid.vue'
}
],
invalid: [
Object.assign(loadInvalidFixture('vue'), {
filename: 'invalid.vue'
})
]
});

describe('generateDifferences', () => {
it('operation: insert', () => {
const differences = eslintPluginPrettier.generateDifferences(
Expand Down
45 changes: 44 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ acorn@^5.0.1:
version "5.0.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.0.3.tgz#c460df08491463f028ccb82eab3730bf01087b3d"

acorn@^5.2.1:
version "5.3.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822"

ajv-keywords@^1.0.0:
version "1.5.1"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c"
Expand Down Expand Up @@ -162,6 +166,12 @@ debug@2.6.0, debug@^2.1.1:
dependencies:
ms "0.7.2"

debug@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
dependencies:
ms "2.0.0"

deep-is@~0.1.3:
version "0.1.3"
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
Expand Down Expand Up @@ -282,6 +292,17 @@ eslint-plugin-self@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-self/-/eslint-plugin-self-1.0.1.tgz#50efd8acf33a399670b7ce7c12b2fd9868b41e7e"

eslint-scope@^3.7.1:
version "3.7.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"
dependencies:
esrecurse "^4.1.0"
estraverse "^4.1.1"

eslint-visitor-keys@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d"

eslint@^3.14.1:
version "3.19.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc"
Expand Down Expand Up @@ -329,6 +350,13 @@ espree@^3.4.0:
acorn "^5.0.1"
acorn-jsx "^3.0.0"

espree@^3.5.2:
version "3.5.2"
resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca"
dependencies:
acorn "^5.2.1"
acorn-jsx "^3.0.0"

esprima@^3.1.1:
version "3.1.3"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633"
Expand Down Expand Up @@ -643,7 +671,7 @@ lodash.keys@^3.0.0:
lodash.isarguments "^3.0.0"
lodash.isarray "^3.0.0"

lodash@^4.0.0, lodash@^4.3.0:
lodash@^4.0.0, lodash@^4.17.4, lodash@^4.3.0:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"

Expand Down Expand Up @@ -687,6 +715,10 @@ ms@0.7.2:
version "0.7.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765"

ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"

mute-stream@0.0.5:
version "0.0.5"
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0"
Expand Down Expand Up @@ -948,6 +980,17 @@ util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"

vue-eslint-parser@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-2.0.2.tgz#8d603545e9d7c134699075bd1772af1ffd86b744"
dependencies:
debug "^3.1.0"
eslint-scope "^3.7.1"
eslint-visitor-keys "^1.0.0"
espree "^3.5.2"
esquery "^1.0.0"
lodash "^4.17.4"

wordwrap@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
Expand Down

0 comments on commit 1ab43fd

Please sign in to comment.