Skip to content

Commit

Permalink
Fix: upgrade vue-eslint-parser (#34)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mysticatea committed Jun 18, 2017
1 parent 7fb94b9 commit 22aeca5
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.nyc_output
/coverage
/tests/integrations/*/node_modules
/node_modules
/test.*
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.tabSize": 2
}
4 changes: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "lib/index.js",
"scripts": {
"start": "npm run test:simple -- --watch --growl",
"test:base": "mocha tests --recursive",
"test:base": "mocha \"tests/lib/**/*.js\" \"tests/integrations/*.js\" --timeout 60000",
"test:simple": "npm run test:base -- --reporter nyan",
"test": "nyc npm run test:base",
"lint": "eslint .",
Expand Down Expand Up @@ -45,7 +45,7 @@
},
"dependencies": {
"requireindex": "^1.1.0",
"vue-eslint-parser": "mysticatea/vue-eslint-parser#v1.1.0-4"
"vue-eslint-parser": "^1.1.0-6"
},
"devDependencies": {
"@types/node": "^4.2.6",
Expand Down
5 changes: 5 additions & 0 deletions tests/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"env": {
"mocha": true
}
}
39 changes: 39 additions & 0 deletions tests/integrations/eslint-plugin-import.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* @copyright 2017 Toru Nagashima. All rights reserved.
* See LICENSE file in root directory for full license.
*/
'use strict'

// -----------------------------------------------------------------------------
// Requirements
// -----------------------------------------------------------------------------

const cp = require('child_process')
const path = require('path')

// -----------------------------------------------------------------------------
// Tests
// -----------------------------------------------------------------------------

const ESLINT = `.${path.sep}node_modules${path.sep}.bin${path.sep}eslint`

describe('Integration with eslint-plugin-import', () => {
let originalCwd

before(() => {
originalCwd = process.cwd()
process.chdir(path.join(__dirname, 'eslint-plugin-import'))
cp.execSync('npm i', { stdio: 'inherit', env: { npm_config_package_lock: 'false' }})
})
after(() => {
process.chdir(originalCwd)
})

// https://github.com/vuejs/eslint-plugin-vue/issues/21#issuecomment-308957697
// eslint-plugin-vue had been breaking eslint-plugin-import if people use both at the same time.
// This test is in order to prevent the regression.
it('should lint without errors', () => {
cp.execSync(`${ESLINT} a.vue`, { stdio: 'inherit' })
})
})
22 changes: 22 additions & 0 deletions tests/integrations/eslint-plugin-import/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"root": true,
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2015
},
"parser": "vue-eslint-parser",
"plugins": [
"import",
"vue"
],
"rules": {
"import/default": "warn",
"import/namespace": "warn"
},
"settings": {
"import/extensions": [
".js",
".vue"
]
}
}
10 changes: 10 additions & 0 deletions tests/integrations/eslint-plugin-import/a.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<template>
<b></b>
</template>

<script>
import B from "./b.vue"
export default {
components: {B}
}
</script>
7 changes: 7 additions & 0 deletions tests/integrations/eslint-plugin-import/b.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<div>Hello</div>
</template>

<script>
export default {}
</script>
15 changes: 15 additions & 0 deletions tests/integrations/eslint-plugin-import/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"private": true,
"name": "integration-test-for-eslint-plugin-import",
"version": "1.0.0",
"description": "Integration test for eslint-plugin-import",
"scripts": {},
"keywords": [],
"author": "Toru Nagashima (https://github.com/mysticatea)",
"license": "MIT",
"dependencies": {
"eslint": "~3.19.0",
"eslint-plugin-import": "~2.3.0",
"eslint-plugin-vue": "file:../../.."
}
}
4 changes: 4 additions & 0 deletions tests/lib/rules/no-invalid-template-root.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ tester.run('no-invalid-template-root', rule, {
{
filename: 'test.vue',
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>'
},
{
filename: 'test.vue',
code: `<template>\n <c1 v-if="1" />\n <c2 v-else-if="1" />\n <c3 v-else />\n</template>`
}
],
invalid: [
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/no-invalid-v-else-if.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ tester.run('no-invalid-v-else-if', rule, {
{
filename: 'test.vue',
code: '<template><div><div v-if="foo"></div><div v-else-if="foo"></div><div v-else-if="foo"></div></div></template>'
},
{
filename: 'test.vue',
code: `<template>\n <c1 v-if="1" />\n <c2 v-else-if="1" />\n <c3 v-else />\n</template>`
}
],
invalid: [
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/no-invalid-v-else.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ tester.run('no-invalid-v-else', rule, {
{
filename: 'test.vue',
code: '<template><div><div v-if="foo"></div><div v-else-if="foo"></div><div v-else></div></div></template>'
},
{
filename: 'test.vue',
code: `<template>\n <c1 v-if="1" />\n <c2 v-else-if="1" />\n <c3 v-else />\n</template>`
}
],
invalid: [
Expand Down

0 comments on commit 22aeca5

Please sign in to comment.