Nuxt.js エラー「error Delete `␍` prettier/prettier」が発生した場合の対処法

Nuxt.js エラー「error  Delete `␍`  prettier/prettier」が発生した場合の対処法

nuxt.js作成時にlinting toolsにprettierを選択し、原因がよくわからないエラーが発生したので、その対処法を記載

環境

  • OS  ubuntu19.10
  • node v12.13.0
  • npm 6.12.1
  • Nuxt.js v2.10.2

エラーメッセージ

下記のなんでもないコードでvueファイルを作成した際に発生

<template>
  <div>
    <h1>test page</h1>
  </div>
</template>

<script>
export default {}
</script>

エラーメッセージ

 1:11  error  Delete `␍`  prettier/prettier
 2:8   error  Delete `␍`  prettier/prettier
 3:24  error  Delete `␍`  prettier/prettier
 4:9   error  Delete `␍`  prettier/prettier
 5:12  error  Delete `␍`  prettier/prettier
 6:1   error  Delete `␍`  prettier/prettier
 7:9   error  Delete `␍`  prettier/prettier
 8:18  error  Delete `␍`  prettier/prettier
 9:10  error  Insert `⏎`  prettier/prettier

✖ 9 problems (9 errors, 0 warnings)
  9 errors and 0 warnings potentially fixable with the `--fix` option.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

対処法

yarn run lint –fixコマンドを実行すると、とりあえず修正してくれるので実行

## 実行
yarn run lint --fix

## 修正確認
yarn run lint

<出力結果>
yarn run v1.19.1
$ eslint --ext .js,.vue --ignore-path .gitignore .
Done in 0.92s.

yarn run lintでエラーがでなければ、修正されていることが確認できます

原因

原因調査してみると改行コードの問題っぽいため、プロジェクト配下にある.prettierrcを設定を変更することにしました。

{
  "semi": false,
  "arrowParens": "always",
  "endOfLine":"auto", → 追加
  "singleQuote": true
}