diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 91907760..a6e32261 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -69,6 +69,9 @@ jobs: uses: actions/setup-node@v1 with: node-version: ${{ matrix.node }} + - name: Install @typescript-eslint/parser@3 + run: npm install -D @typescript-eslint/parser@3 + if: matrix.node == '8.10.0' - name: Install Packages run: npm install - name: Install ESLint v${{ matrix.eslint }} diff --git a/package.json b/package.json index 76e90d26..a5dbd835 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "npm-run-all": "^4.1.5", "nyc": "^14.0.0", "opener": "^1.5.1", - "prettier": "^2.2.1", + "prettier": "^2.3.1", "rimraf": "^2.6.3", "rollup": "^1.1.2", "rollup-plugin-node-resolve": "^4.0.0", diff --git a/src/parser-services.ts b/src/parser-services.ts index 0e086d85..d2af06b0 100644 --- a/src/parser-services.ts +++ b/src/parser-services.ts @@ -32,9 +32,7 @@ import { isSFCFile } from "./common/parser-options" // Helpers //------------------------------------------------------------------------------ -type CustomBlockVisitorFactory = ( - context: CustomBlockContext, -) => +type CustomBlockVisitorFactory = (context: CustomBlockContext) => | { [key: string]: (...args: any) => void } @@ -229,9 +227,10 @@ export function define( for (const customBlock of customBlocks) { const lang = getLang(customBlock) - const activeVisitorFactories = visitorFactories.filter( - (f) => f.test(lang, customBlock), - ) + const activeVisitorFactories = + visitorFactories.filter((f) => + f.test(lang, customBlock), + ) if (!activeVisitorFactories.length) { continue } diff --git a/src/script/index.ts b/src/script/index.ts index af250027..c1ce613b 100644 --- a/src/script/index.ts +++ b/src/script/index.ts @@ -54,16 +54,15 @@ const DUMMY_PARENT: any = {} // Like Vue, it judges whether it is a function expression or not. // https://github.com/vuejs/vue/blob/0948d999f2fddf9f90991956493f976273c5da1f/src/compiler/codegen/events.js#L3 const IS_FUNCTION_EXPRESSION = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/u -const IS_SIMPLE_PATH = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?'\]|\["[^"]*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/u +const IS_SIMPLE_PATH = + /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?'\]|\["[^"]*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/u /** * Parse the alias and iterator of 'v-for' directive values. * @param code The code to parse. * @returns The parsed result. */ -function processVForAliasAndIterator( - code: string, -): { +function processVForAliasAndIterator(code: string): { aliases: string hasParens: boolean delimiter: string @@ -555,9 +554,8 @@ export function parseScriptElement( ? text.range[0] : node.startTag.range[1] const code = text != null && text.type === "VText" ? text.value : "" - const locationCalculator = globalLocationCalculator.getSubCalculatorAfter( - offset, - ) + const locationCalculator = + globalLocationCalculator.getSubCalculatorAfter(offset) const result = parseScriptFragment(code, locationCalculator, parserOptions) // Needs the tokens of start/end tags for `lines-around-*` rules to work @@ -624,7 +622,8 @@ export function parseExpression( if (!retB.expression) { return retB } - const ret = (retB as unknown) as ExpressionParseResult + const ret = + retB as unknown as ExpressionParseResult ret.expression = { type: "VFilterSequenceExpression", @@ -1012,8 +1011,9 @@ function parseVOnExpressionBody( ).ast const references = analyzeExternalReferences(ast, parserOptions) const outermostStatement = ast.body[0] as ESLintExpressionStatement - const functionDecl = (outermostStatement.expression as ESLintUnaryExpression) - .argument as ESLintFunctionExpression + const functionDecl = ( + outermostStatement.expression as ESLintUnaryExpression + ).argument as ESLintFunctionExpression const block = functionDecl.body const body = block.body const firstStatement = first(body) diff --git a/src/template/index.ts b/src/template/index.ts index 19374d1a..183dcea8 100644 --- a/src/template/index.ts +++ b/src/template/index.ts @@ -768,9 +768,8 @@ export function processMustache( const document = getOwnerDocument(node) try { - const locationCalculator = globalLocationCalculator.getSubCalculatorAfter( - range[0], - ) + const locationCalculator = + globalLocationCalculator.getSubCalculatorAfter(range[0]) const ret = parseExpression( mustache.value, locationCalculator, diff --git a/test/define-custom-blocks-visitor.js b/test/define-custom-blocks-visitor.js index cbb88ce3..aef1ac4d 100644 --- a/test/define-custom-blocks-visitor.js +++ b/test/define-custom-blocks-visitor.js @@ -395,10 +395,11 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { create(ctx) { return { Program(node) { - const error = ctx.parserServices.parseCustomBlockElement( - jsonParser, - { jsonSyntax: "json" } - ).error + const error = + ctx.parserServices.parseCustomBlockElement( + jsonParser, + { jsonSyntax: "json" } + ).error ctx.report({ node, message: JSON.stringify({