最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Eslint or prettier is adding 2 semi colons to the end of a line in vscode - Stack Overflow

programmeradmin1浏览0评论

In VScode when I accidentally leave off a semi colon at the end of a javascript line and save the file, vscode (prettier or eslint or both) fixes this by adding 2 semi colons to the end of the line. Example

Original line

const x = 1

Fixed line

const x = 1;;

I want it to add only 1 ;

Where would I look to fix this? facepalm

In VScode when I accidentally leave off a semi colon at the end of a javascript line and save the file, vscode (prettier or eslint or both) fixes this by adding 2 semi colons to the end of the line. Example

Original line

const x = 1

Fixed line

const x = 1;;

I want it to add only 1 ;

Where would I look to fix this? facepalm

Share Improve this question asked Apr 12, 2019 at 0:42 graburygrabury 5,61917 gold badges81 silver badges136 bronze badges 1
  • Did you manage to find what was causing this? I am hitting the same issue. – Lee Commented Apr 26, 2019 at 22:37
Add a ment  | 

1 Answer 1

Reset to default 4

TL;DR: Check your ESLint rules, make sure you don't have a redundant one that is already being taken care of by your plugins.

I was having this issue. I solved it in my .eslintrc.json file, which I had mis-configured.

I have both the plugin installed for prettier

    "plugins": ["babel", "react", "prettier"],

as well a rule set for eslint to add semi colons

    "rules": {
        "semi": ["error", "always"],

When I take either that rule out or the prettier plugin out, it would go to only adding one semicolon.

However, when I would take out the prettier plugin, it would also give the error: Definition for rule 'prettier/prettier' was not foundeslint(prettier/prettier)

So the rule setting seemed to be redundant with the plugin, and removing the rule fixed this issue.

发布评论

评论列表(0)

  1. 暂无评论