Skip to content

Bug: Cannot format expressions in Vue using TS types #365

Open
@jjlorenzo

Description

@jjlorenzo

Info

Tool Version
Plugin v1.20.0
Prettier v2.6.1
Framework vue
Node v17.7.1
OS mac

Prettier config

// @ts-check
/// <reference types="@prettier/plugin-pug/src/prettier" />

/**
 * @type {import("prettier").Options}
 */
module.exports = {
  plugins: [require.resolve("@prettier/plugin-pug")],
  printWidth: 120,
  pugClassNotation: "attribute",
  pugFramework: "vue",
  pugSortAttributes: "asc",
  pugSortAttributesEnd: ["^:", "^@"],
  quoteProps: "consistent",
  semi: false,
  trailingComma: "all",
}

Input

<template lang="pug">
n-modal(
  preset="card",
  transform-origin="center",
  v-model:show="show",
  :closable="false",
  :close-on-esc="false",
  :footer-style="{ textAlign: 'center' }",
  :header-style="{ textAlign: 'center' }",
  :mask-closable="false",
  :style="{ backgroundColor: theme.inputColorDisabled, width: '600px' }"
)
  template(#header) Enter the PIN code
  template(#default)
    n-space(justify="space-around", :wrap="false")
      n-input(
        readonly,
        size="large",
        v-for="(value, index) in pinChrs",
        v-model:value="pinChrs[index]",
        :key="index",
        :maxlength="1",
        :show-button="false",
        :style="{ textAlign: 'center', width: '60px' }",
        :theme-overrides="{ fontSizeLarge: '40px', heightLarge: '80px' }"
        :ref="(el:any) => pinRefs[index] = el",
      )
  template(#footer) You should have received by a phone call or by SMS
</template>

Output or Error

The `:ref="(el:any) => pinRefs[index] = el",` doesn't get ordered, in general no ordering occurs either in the parent component

Expected Output

In this case, is expected that `:ref="(el:any) => pinRefs[index] = el",` gets reordered to before `:maxlength="1",`

Additional Context

Metadata

Metadata

Assignees

Labels

framework: VueRelated to the framework Vuetype: bugFunctionality that does not work as intended/expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions