prettier / prettier

Prettier is an opinionated code formatter.
https://prettier.io
MIT License
49.44k stars 4.37k forks source link

can not format when code contains chinese function name. #16707

Closed yangyile1990 closed 1 month ago

yangyile1990 commented 1 month ago

Before use prettier my code is this:

<template>
  <div
    class="welcome-message"
    v-on:click="go即刻跳转到网站首页"
    v-on:mouseenter="set设置显示版本号"
    v-on:mouseleave="set设置隐藏版本号"
  >
    欢迎来到首页
  </div>
</template>

while after use "format": "prettier --write src" my code is:

<template>
  <div
    class="welcome-message"
    v-on:click="go即刻跳转到网站首页;"
    v-on:mouseenter="set设置显示版本号;"
    v-on:mouseleave="set设置隐藏版本号;"
  >
    欢迎来到首页
  </div>
</template>

so it is wrong to add ";" at the end of the function name. this make my produre can not work. so please help me to fix it.

now my code is this and it can avoid this problem when use format:

<div
    class="welcome-message"
    v-on:click="() => Go即刻跳转到网站首页()"
    v-on:mouseenter="() => Set设置显示版本号()"
    v-on:mouseleave="() => Set设置隐藏版本号()"
>
yangyile1990 commented 1 month ago

I know it is better to program not use chinese. while as you see, my english is very not good. so I have to write chinese function name in my code. maybe I can use pinyin but it is not easy to read. so could you please help me to fix this problem.

even I set "semi": false while not work.

{
  "$schema": "https://json.schemastore.org/prettierrc",
  "semi": false,
  "tabWidth": 4,
  "singleQuote": true,
  "printWidth": 120,
  "bracketSameLine": false,
  "trailingComma": "all"
}

please help me. thank you.

fisker commented 1 month ago

Duplicate of #13647

yangyile1990 commented 1 month ago

ok. thankyou.