Skip to content

Format #109

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 2 commits into from
Jun 16, 2021
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
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 5 additions & 6 deletions src/parser-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ import { isSFCFile } from "./common/parser-options"
// Helpers
//------------------------------------------------------------------------------

type CustomBlockVisitorFactory = (
context: CustomBlockContext,
) =>
type CustomBlockVisitorFactory = (context: CustomBlockContext) =>
| {
[key: string]: (...args: any) => void
}
Expand Down Expand Up @@ -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
}
Expand Down
20 changes: 10 additions & 10 deletions src/script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -624,7 +622,8 @@ export function parseExpression(
if (!retB.expression) {
return retB
}
const ret = (retB as unknown) as ExpressionParseResult<VFilterSequenceExpression>
const ret =
retB as unknown as ExpressionParseResult<VFilterSequenceExpression>

ret.expression = {
type: "VFilterSequenceExpression",
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions src/template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions test/define-custom-blocks-visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down