Skip to content

Commit 22aeca5

Browse files
authored
Fix: upgrade vue-eslint-parser (#34)
* Fix: upgrade vue-eslint-parser - Make correct ASTs about self-closing elements (fixes #29) - Improve the integration with eslint-plugin-import (refs #21) * add comments to integration test
1 parent 7fb94b9 commit 22aeca5

13 files changed

+119
-3
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.nyc_output
22
/coverage
3+
/tests/integrations/*/node_modules
34
/node_modules
45
/test.*

Diff for: .vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.tabSize": 2
3+
}

Diff for: package-lock.json

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "lib/index.js",
66
"scripts": {
77
"start": "npm run test:simple -- --watch --growl",
8-
"test:base": "mocha tests --recursive",
8+
"test:base": "mocha \"tests/lib/**/*.js\" \"tests/integrations/*.js\" --timeout 60000",
99
"test:simple": "npm run test:base -- --reporter nyan",
1010
"test": "nyc npm run test:base",
1111
"lint": "eslint .",
@@ -45,7 +45,7 @@
4545
},
4646
"dependencies": {
4747
"requireindex": "^1.1.0",
48-
"vue-eslint-parser": "mysticatea/vue-eslint-parser#v1.1.0-4"
48+
"vue-eslint-parser": "^1.1.0-6"
4949
},
5050
"devDependencies": {
5151
"@types/node": "^4.2.6",

Diff for: tests/.eslintrc.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"env": {
3+
"mocha": true
4+
}
5+
}

Diff for: tests/integrations/eslint-plugin-import.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* @author Toru Nagashima <https://github.com/mysticatea>
3+
* @copyright 2017 Toru Nagashima. All rights reserved.
4+
* See LICENSE file in root directory for full license.
5+
*/
6+
'use strict'
7+
8+
// -----------------------------------------------------------------------------
9+
// Requirements
10+
// -----------------------------------------------------------------------------
11+
12+
const cp = require('child_process')
13+
const path = require('path')
14+
15+
// -----------------------------------------------------------------------------
16+
// Tests
17+
// -----------------------------------------------------------------------------
18+
19+
const ESLINT = `.${path.sep}node_modules${path.sep}.bin${path.sep}eslint`
20+
21+
describe('Integration with eslint-plugin-import', () => {
22+
let originalCwd
23+
24+
before(() => {
25+
originalCwd = process.cwd()
26+
process.chdir(path.join(__dirname, 'eslint-plugin-import'))
27+
cp.execSync('npm i', { stdio: 'inherit', env: { npm_config_package_lock: 'false' }})
28+
})
29+
after(() => {
30+
process.chdir(originalCwd)
31+
})
32+
33+
// https://github.com/vuejs/eslint-plugin-vue/issues/21#issuecomment-308957697
34+
// eslint-plugin-vue had been breaking eslint-plugin-import if people use both at the same time.
35+
// This test is in order to prevent the regression.
36+
it('should lint without errors', () => {
37+
cp.execSync(`${ESLINT} a.vue`, { stdio: 'inherit' })
38+
})
39+
})
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"root": true,
3+
"parserOptions": {
4+
"sourceType": "module",
5+
"ecmaVersion": 2015
6+
},
7+
"parser": "vue-eslint-parser",
8+
"plugins": [
9+
"import",
10+
"vue"
11+
],
12+
"rules": {
13+
"import/default": "warn",
14+
"import/namespace": "warn"
15+
},
16+
"settings": {
17+
"import/extensions": [
18+
".js",
19+
".vue"
20+
]
21+
}
22+
}

Diff for: tests/integrations/eslint-plugin-import/a.vue

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<template>
2+
<b></b>
3+
</template>
4+
5+
<script>
6+
import B from "./b.vue"
7+
export default {
8+
components: {B}
9+
}
10+
</script>

Diff for: tests/integrations/eslint-plugin-import/b.vue

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<template>
2+
<div>Hello</div>
3+
</template>
4+
5+
<script>
6+
export default {}
7+
</script>

Diff for: tests/integrations/eslint-plugin-import/package.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"private": true,
3+
"name": "integration-test-for-eslint-plugin-import",
4+
"version": "1.0.0",
5+
"description": "Integration test for eslint-plugin-import",
6+
"scripts": {},
7+
"keywords": [],
8+
"author": "Toru Nagashima (https://github.com/mysticatea)",
9+
"license": "MIT",
10+
"dependencies": {
11+
"eslint": "~3.19.0",
12+
"eslint-plugin-import": "~2.3.0",
13+
"eslint-plugin-vue": "file:../../.."
14+
}
15+
}

Diff for: tests/lib/rules/no-invalid-template-root.js

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ tester.run('no-invalid-template-root', rule, {
4646
{
4747
filename: 'test.vue',
4848
code: '<template>\n <!-- comment -->\n <div v-if="foo">abc</div>\n <div v-else-if="bar">abc</div>\n <div v-else>abc</div>\n</template>'
49+
},
50+
{
51+
filename: 'test.vue',
52+
code: `<template>\n <c1 v-if="1" />\n <c2 v-else-if="1" />\n <c3 v-else />\n</template>`
4953
}
5054
],
5155
invalid: [

Diff for: tests/lib/rules/no-invalid-v-else-if.js

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ tester.run('no-invalid-v-else-if', rule, {
3434
{
3535
filename: 'test.vue',
3636
code: '<template><div><div v-if="foo"></div><div v-else-if="foo"></div><div v-else-if="foo"></div></div></template>'
37+
},
38+
{
39+
filename: 'test.vue',
40+
code: `<template>\n <c1 v-if="1" />\n <c2 v-else-if="1" />\n <c3 v-else />\n</template>`
3741
}
3842
],
3943
invalid: [

Diff for: tests/lib/rules/no-invalid-v-else.js

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ tester.run('no-invalid-v-else', rule, {
3434
{
3535
filename: 'test.vue',
3636
code: '<template><div><div v-if="foo"></div><div v-else-if="foo"></div><div v-else></div></div></template>'
37+
},
38+
{
39+
filename: 'test.vue',
40+
code: `<template>\n <c1 v-if="1" />\n <c2 v-else-if="1" />\n <c3 v-else />\n</template>`
3741
}
3842
],
3943
invalid: [

0 commit comments

Comments
 (0)