Skip to content

Breaking: support ESLint 5 and drop the supports of old stuffs #532

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

Merged
merged 8 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

> Official ESLint plugin for Vue.js

## :exclamation: Attention - this is documentation for version `5.x` :exclamation:

This branch contains `eslint-plugin-vue@next` which is a pre-released `5.0`, but it's not the default version that you get with `npm install eslint-plugin-vue`. In order to install this you need to specify either `"eslint-plugin-vue": "next"` in `package.json` or do `npm install eslint-plugin-vue@next`.

Please try it and report any issues that you might have encountered.

If you want to check previous releases [go here](https://github.com/vuejs/eslint-plugin-vue/releases).

## :art: Playground on the Web

You can try this plugin on the Web.
Expand All @@ -14,15 +22,13 @@ You can try this plugin on the Web.

## :grey_exclamation: Requirements

- [ESLint](http://eslint.org/) `>=3.18.0`.
- `>=4.7.0` to use `eslint --fix`.
- `>=4.14.0` to use with `babel-eslint`.
- Node.js `>=4.0.0`
- [ESLint](http://eslint.org/) `^5.0.0`.
- Node.js `>=6.5.0`

## :cd: Installation

```bash
npm install --save-dev eslint eslint-plugin-vue
npm install --save-dev eslint eslint-plugin-vue@next
```

## :rocket: Usage
Expand Down
8 changes: 4 additions & 4 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
machine:
node:
version: 8
version: 10

dependencies:
pre:
- nvm install 6
- nvm install 4
- nvm install 8

test:
override:
- nvm use 4 && npm test
- nvm use 6 && npm test
- nvm use 8 && npm test
- nvm use 10 && npm test
# Test for the minimum version we are supporting.
- nvm use 8 && npm i eslint@3.18.0 --no-save && $(npm bin)/mocha tests/lib/rules/*.js --reporter dot
- nvm use 10 && npm i eslint@5.0.0 --no-save && $(npm bin)/mocha tests/lib/rules/*.js --reporter dot
4 changes: 2 additions & 2 deletions lib/utils/indent-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const assert = require('assert')
// Helpers
// ------------------------------------------------------------------------------

const KNOWN_NODES = new Set(['ArrayExpression', 'ArrayPattern', 'ArrowFunctionExpression', 'AssignmentExpression', 'AssignmentPattern', 'AwaitExpression', 'BinaryExpression', 'BlockStatement', 'BreakStatement', 'CallExpression', 'CatchClause', 'ClassBody', 'ClassDeclaration', 'ClassExpression', 'ConditionalExpression', 'ContinueStatement', 'DebuggerStatement', 'DoWhileStatement', 'EmptyStatement', 'ExperimentalRestProperty', 'ExperimentalSpreadProperty', 'ExportAllDeclaration', 'ExportDefaultDeclaration', 'ExportNamedDeclaration', 'ExportSpecifier', 'ExpressionStatement', 'ForInStatement', 'ForOfStatement', 'ForStatement', 'FunctionDeclaration', 'FunctionExpression', 'Identifier', 'IfStatement', 'ImportDeclaration', 'ImportDefaultSpecifier', 'ImportNamespaceSpecifier', 'ImportSpecifier', 'LabeledStatement', 'Literal', 'LogicalExpression', 'MemberExpression', 'MetaProperty', 'MethodDefinition', 'NewExpression', 'ObjectExpression', 'ObjectPattern', 'Program', 'Property', 'RestElement', 'ReturnStatement', 'SequenceExpression', 'SpreadElement', 'Super', 'SwitchCase', 'SwitchStatement', 'TaggedTemplateExpression', 'TemplateElement', 'TemplateLiteral', 'ThisExpression', 'ThrowStatement', 'TryStatement', 'UnaryExpression', 'UpdateExpression', 'VariableDeclaration', 'VariableDeclarator', 'WhileStatement', 'WithStatement', 'YieldExpression', 'VAttribute', 'VDirectiveKey', 'VDocumentFragment', 'VElement', 'VEndTag', 'VExpressionContainer', 'VForExpression', 'VIdentifier', 'VLiteral', 'VOnExpression', 'VStartTag', 'VText'])
const KNOWN_NODES = new Set(['ArrayExpression', 'ArrayPattern', 'ArrowFunctionExpression', 'AssignmentExpression', 'AssignmentPattern', 'AwaitExpression', 'BinaryExpression', 'BlockStatement', 'BreakStatement', 'CallExpression', 'CatchClause', 'ClassBody', 'ClassDeclaration', 'ClassExpression', 'ConditionalExpression', 'ContinueStatement', 'DebuggerStatement', 'DoWhileStatement', 'EmptyStatement', 'ExperimentalRestProperty', 'ExperimentalSpreadProperty', 'ExportAllDeclaration', 'ExportDefaultDeclaration', 'ExportNamedDeclaration', 'ExportSpecifier', 'ExpressionStatement', 'ForInStatement', 'ForOfStatement', 'ForStatement', 'FunctionDeclaration', 'FunctionExpression', 'Identifier', 'IfStatement', 'ImportDeclaration', 'ImportDefaultSpecifier', 'ImportNamespaceSpecifier', 'ImportSpecifier', 'LabeledStatement', 'Literal', 'LogicalExpression', 'MemberExpression', 'MetaProperty', 'MethodDefinition', 'NewExpression', 'ObjectExpression', 'ObjectPattern', 'Program', 'Property', 'RestElement', 'ReturnStatement', 'SequenceExpression', 'SpreadElement', 'Super', 'SwitchCase', 'SwitchStatement', 'TaggedTemplateExpression', 'TemplateElement', 'TemplateLiteral', 'ThisExpression', 'ThrowStatement', 'TryStatement', 'UnaryExpression', 'UpdateExpression', 'VariableDeclaration', 'VariableDeclarator', 'WhileStatement', 'WithStatement', 'YieldExpression', 'VAttribute', 'VDirectiveKey', 'VDocumentFragment', 'VElement', 'VEndTag', 'VExpressionContainer', 'VForExpression', 'VIdentifier', 'VLiteral', 'VOnExpression', 'VSlotScopeExpression', 'VStartTag', 'VText'])
const LT_CHAR = /[\r\n\u2028\u2029]/
const LINES = /[^\r\n\u2028\u2029]+(?:$|\r\n|[\r\n\u2028\u2029])/g
const BLOCK_COMMENT_PREFIX = /^\s*\*/
Expand Down Expand Up @@ -845,7 +845,7 @@ module.exports.defineVisitor = function create (context, tokenStore, defaultOpti
if (node.expression != null && node.range[0] !== node.expression.range[0]) {
const startQuoteToken = tokenStore.getFirstToken(node)
const endQuoteToken = tokenStore.getLastToken(node)
const childToken = tokenStore.getFirstToken(node.expression)
const childToken = tokenStore.getTokenAfter(startQuoteToken)

setOffset(childToken, 1, startQuoteToken)
setOffset(endQuoteToken, 0, startQuoteToken)
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@
"url": "https://github.com/vuejs/eslint-plugin-vue/issues"
},
"engines": {
"node": ">=4"
"node": ">=6.5"
},
"peerDependencies": {
"eslint": "^3.18.0 || ^4.0.0"
"eslint": "^5.0.0"
},
"dependencies": {
"vue-eslint-parser": "^2.0.3"
"vue-eslint-parser": "^3.2.1"
},
"devDependencies": {
"@types/node": "^4.2.16",
"babel-eslint": "^8.2.2",
"chai": "^4.1.0",
"eslint": "^4.14.0",
"eslint-plugin-eslint-plugin": "^0.8.0",
"eslint": "^5.2.0",
"eslint-plugin-eslint-plugin": "^1.4.0",
"eslint-plugin-html": "^4.0.1",
"eslint-plugin-vue-libs": "^2.0.0",
"eslint-plugin-vue-libs": "^3.0.0",
"lodash": "^4.17.4",
"mocha": "^3.2.0",
"nyc": "^11.1.0"
"mocha": "^5.2.0",
"nyc": "^12.0.2"
}
}
4 changes: 2 additions & 2 deletions tests/fixtures/html-indent/binary-expression-10.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!--{}-->
<template>
<div
:class="
:class="(
a
+
b,
c
+
d
"
)"
/>
</template>
4 changes: 2 additions & 2 deletions tests/fixtures/html-indent/sequence-expression-01.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!--{}-->
<template>
<div
v-bind:a="
v-bind:a="(
1
,
2
,
3
"
)"
></div>
</template>
4 changes: 2 additions & 2 deletions tests/fixtures/html-indent/sequence-expression-02.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!--{}-->
<template>
<div
v-bind:b="
v-bind:b="(
1,
2,
3
"
)"
></div>
</template>
4 changes: 2 additions & 2 deletions tests/fixtures/html-indent/sequence-expression-03.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!--{}-->
<template>
<div
v-bind:c="
v-bind:c="(
a +
b,
2
"
)"
></div>
</template>
6 changes: 3 additions & 3 deletions tests/fixtures/html-indent/sequence-expression-04.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!--{}-->
<template>
{{
{{(
a,
b,
c
}}
</template>
)}}
</template>
17 changes: 17 additions & 0 deletions tests/fixtures/html-indent/slot-scope-01.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--{}-->
<template>
<div slot-scope="
{
a
,
b:
temp1
,
c: {
ca: temp2
},
d: { da,
db: temp3 }
}
"></div>
</template>
5 changes: 2 additions & 3 deletions tests/lib/rules/name-property-casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ const RuleTester = require('eslint').RuleTester
// ------------------------------------------------------------------------------

const parserOptions = {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: { experimentalObjectRestSpread: true }
ecmaVersion: 2018,
sourceType: 'module'
}

const ruleTester = new RuleTester()
Expand Down
17 changes: 5 additions & 12 deletions tests/lib/rules/no-async-in-computed-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@ const rule = require('../../../lib/rules/no-async-in-computed-properties')
const RuleTester = require('eslint').RuleTester

const parserOptions = {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: { experimentalObjectRestSpread: true }
}

const parserOptions8 = {
ecmaVersion: 8,
sourceType: 'module',
ecmaFeatures: { experimentalObjectRestSpread: true }
ecmaVersion: 2018,
sourceType: 'module'
}

// ------------------------------------------------------------------------------
Expand Down Expand Up @@ -77,7 +70,7 @@ ruleTester.run('no-async-in-computed-properties', rule, {
}));
}
`,
parserOptions: parserOptions8
parserOptions
}
],

Expand All @@ -93,7 +86,7 @@ ruleTester.run('no-async-in-computed-properties', rule, {
}
}
`,
parserOptions: parserOptions8,
parserOptions,
errors: [{
message: 'Unexpected async function declaration in "foo" computed property.',
line: 4
Expand All @@ -113,7 +106,7 @@ ruleTester.run('no-async-in-computed-properties', rule, {
}
}
`,
parserOptions: parserOptions8,
parserOptions,
errors: [{
message: 'Unexpected async function declaration in "foo" computed property.',
line: 4
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rules/no-dupe-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ruleTester.run('no-dupe-keys', rule, {
},
}
`,
parserOptions: { ecmaVersion: 8, sourceType: 'module', ecmaFeatures: { experimentalObjectRestSpread: true }}
parserOptions: { ecmaVersion: 2018, sourceType: 'module' }
},

{
Expand Down
10 changes: 2 additions & 8 deletions tests/lib/rules/no-parsing-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ tester.run('no-parsing-error', rule, {
options: [{ 'x-invalid-namespace': false }]
},
'<template><div/></template>',
'<template><div v-show="">hello</div></template>'
'<template><div v-show="">hello</div></template>',
'<template><div>{{ }}</div></template>'
],
invalid: [
{
Expand All @@ -230,13 +231,6 @@ tester.run('no-parsing-error', rule, {
code: '<template><div v-show="a;b;">hello</div></template>',
errors: ['Parsing error: Unexpected token ;.']
},
{
filename: 'test.vue',
code: '<template><div>{{ }}</div></template>',
errors: [
{ message: 'Parsing error: Expected to be an expression, but got empty.', column: 18 }
]
},
{
filename: 'test.vue',
code: '<template><div v-show=" ">hello</div></template>',
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/rules/no-reserved-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ const rule = require('../../../lib/rules/no-reserved-keys')
const RuleTester = require('eslint').RuleTester

const parserOptions = {
ecmaVersion: 7,
sourceType: 'module',
ecmaFeatures: { experimentalObjectRestSpread: true }
ecmaVersion: 2018,
sourceType: 'module'
}

// ------------------------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/rules/no-shared-component-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ const rule = require('../../../lib/rules/no-shared-component-data')
const RuleTester = require('eslint').RuleTester

const parserOptions = {
ecmaVersion: 7,
sourceType: 'module',
ecmaFeatures: { experimentalObjectRestSpread: true }
ecmaVersion: 2018,
sourceType: 'module'
}

// ------------------------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/rules/no-side-effects-in-computed-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ const rule = require('../../../lib/rules/no-side-effects-in-computed-properties'
const RuleTester = require('eslint').RuleTester

const parserOptions = {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: { experimentalObjectRestSpread: true }
ecmaVersion: 2018,
sourceType: 'module'
}

// ------------------------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/rules/order-in-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ const RuleTester = require('eslint').RuleTester
const ruleTester = new RuleTester()

const parserOptions = {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: { experimentalObjectRestSpread: true }
ecmaVersion: 2018,
sourceType: 'module'
}

ruleTester.run('order-in-components', rule, {
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/rules/prop-name-casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ const RuleTester = require('eslint').RuleTester
// ------------------------------------------------------------------------------

const parserOptions = {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: { experimentalObjectRestSpread: true }
ecmaVersion: 2018,
sourceType: 'module'
}

const ruleTester = new RuleTester()
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/rules/require-default-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
const rule = require('../../../lib/rules/require-default-prop')
const RuleTester = require('eslint').RuleTester
const parserOptions = {
ecmaVersion: 6,
ecmaFeatures: { experimentalObjectRestSpread: true },
ecmaVersion: 2018,
sourceType: 'module'
}

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rules/require-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ruleTester.run('require-prop-types', rule, {
}
}
`,
parserOptions: { ecmaVersion: 6, sourceType: 'module', ecmaFeatures: { experimentalObjectRestSpread: true }}
parserOptions: { ecmaVersion: 2018, sourceType: 'module' }
},
{
filename: 'test.vue',
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/rules/require-render-return.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const rule = require('../../../lib/rules/require-render-return')
const RuleTester = require('eslint').RuleTester

const parserOptions = {
ecmaVersion: 6,
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: { experimentalObjectRestSpread: true, jsx: true }
ecmaFeatures: { jsx: true }
}

// ------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/rules/require-valid-default-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const rule = require('../../../lib/rules/require-valid-default-prop')
const RuleTester = require('eslint').RuleTester

const parserOptions = {
ecmaVersion: 6,
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: { experimentalObjectRestSpread: true, jsx: true }
ecmaFeatures: { jsx: true }
}

function errorMessage (type) {
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/valid-v-on.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ tester.run('valid-v-on', rule, {
{
filename: 'test.vue',
code: '<template><div v-on="$listeners"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div v-on="{a, b, c: d}"></div></template>'
}
],
invalid: [
Expand Down