From 1fe41275cdea2414ffad4063d96b35ed182c2fde Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Sat, 1 Dec 2018 17:48:25 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A5=20change=20the=20AST=20of=20filter?= =?UTF-8?q?s=20syntax=20(vuejs/eslint-plugin-vue#687)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/ast.md | 13 + src/ast/nodes.ts | 23 + src/ast/traverse.ts | 2 + src/common/location-calculator.ts | 4 +- src/script/index.ts | 389 +++++++- src/template/index.ts | 21 +- test/ast.js | 22 +- test/fixtures/ast/filter-empty/ast.json | 849 +++++++++++++++++ test/fixtures/ast/filter-empty/source.vue | 4 + .../ast/filter-empty/token-ranges.json | 32 + test/fixtures/ast/filter-empty/tree.json | 75 ++ test/fixtures/ast/filters-2/ast.json | 876 ++++++++++++++++++ test/fixtures/ast/filters-2/source.vue | 3 + test/fixtures/ast/filters-2/token-ranges.json | 27 + test/fixtures/ast/filters-2/tree.json | 99 ++ test/fixtures/ast/filters-error/ast.json | 659 +++++++++++++ test/fixtures/ast/filters-error/source.vue | 4 + .../ast/filters-error/token-ranges.json | 28 + test/fixtures/ast/filters-error/tree.json | 43 + test/fixtures/ast/filters/ast.json | 750 +++++++++++++++ test/fixtures/ast/filters/source.vue | 3 + test/fixtures/ast/filters/token-ranges.json | 23 + test/fixtures/ast/filters/tree.json | 88 ++ 23 files changed, 3989 insertions(+), 48 deletions(-) create mode 100644 test/fixtures/ast/filter-empty/ast.json create mode 100644 test/fixtures/ast/filter-empty/source.vue create mode 100644 test/fixtures/ast/filter-empty/token-ranges.json create mode 100644 test/fixtures/ast/filter-empty/tree.json create mode 100644 test/fixtures/ast/filters-2/ast.json create mode 100644 test/fixtures/ast/filters-2/source.vue create mode 100644 test/fixtures/ast/filters-2/token-ranges.json create mode 100644 test/fixtures/ast/filters-2/tree.json create mode 100644 test/fixtures/ast/filters-error/ast.json create mode 100644 test/fixtures/ast/filters-error/source.vue create mode 100644 test/fixtures/ast/filters-error/token-ranges.json create mode 100644 test/fixtures/ast/filters-error/tree.json create mode 100644 test/fixtures/ast/filters/ast.json create mode 100644 test/fixtures/ast/filters/source.vue create mode 100644 test/fixtures/ast/filters/token-ranges.json create mode 100644 test/fixtures/ast/filters/tree.json diff --git a/docs/ast.md b/docs/ast.md index 27bc63ad..11cd8b3f 100644 --- a/docs/ast.md +++ b/docs/ast.md @@ -109,6 +109,18 @@ interface VSlotScopeExpression <: Expression { type: "VSlotScopeExpression" id: Pattern } + +interface VFilterSequenceExpression <: Expression { + type: "VFilterSequenceExpression" + expression: Expression + filters: [ VFilter ] +} + +interface VFilter <: Node { + type: "VFilter" + callee: Identifier + arguments: [ Expression ] +} ``` - This is mustaches or directive values. @@ -119,6 +131,7 @@ interface VSlotScopeExpression <: Expression { - `VForExpression` is an expression node like [ForInStatement] but it has an array as `left` property and does not have `body` property. This is the value of [`v-for` directives]. - `VOnExpression` is an expression node like [BlockStatement] but it does not have braces. This is the value of [`v-on` directives] only if the `v-on` directive doesn't have that argument. - `VSlotScopeExpression` is an expression node like [VariableDeclarator]. This is the value of [`slot-scope` attribute] or the `scope` attribute of `