質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
ESLint

ESLintは、JavaScriptのための構文チェックツール。全検証ルールを自由に on/offでき、独自のプロジェクトに合わせたカスタムルールを容易に設定することが可能。公開されている様々なプラグインを組み込んで使用することもできます。

Q&A

解決済

1回答

3483閲覧

VSCode にて ESLintと Prettierの設定が競合します。。。

gano

総合スコア39

ESLint

ESLintは、JavaScriptのための構文チェックツール。全検証ルールを自由に on/offでき、独自のプロジェクトに合わせたカスタムルールを容易に設定することが可能。公開されている様々なプラグインを組み込んで使用することもできます。

0グッド

0クリップ

投稿2020/06/01 08:01

問題

ESLint,Prettierで1行80文字までという設定をしています。
以下のような行を追加したら、89文字だったので、ESLintから警告がでています。

Typescript

1import SignUpTemplate from '../../../components/templates/authentication/SignUpTemplate';

修正しようと思い、以下のように改行をしたのですが、

Typescript

1import SignUpTemplate 2 from '../../../components/templates/authentication/SignUpTemplate';

ファイルを保存すると、
元の89文字の行に自動で修正されてしまいます。
エラーがでて、永遠と保存ができない状態です。。。

設定

以下のような設定を行っています。

.eslintrc

... rules: { 'max-len': [2, { "code": 80 }], // eslint official 'newline-before-return': 'error', 'no-console': 'warn', 'no-continue': 'off', 'require-yield': 'error', // for react-app-env.d.ts (https://github.com/facebook/create-react-app/issues/6560) 'spaced-comment': [ 'error', 'always', { markers: ['/'], }, ], // @typescript-eslint '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/explicit-member-accessibility': 'off', indent: 'off', '@typescript-eslint/indent': 'off', '@typescript-eslint/no-unnecessary-type-assertion': 'error', // prefer-arrow 'prefer-arrow/prefer-arrow-functions': [ 'error', { disallowPrototype: true, singleReturnOnly: true, classPropertiesAllowed: false } ], // react 'react/jsx-filename-extension': [ 'error', { extensions: ['jsx', 'tsx'] } ], 'react/jsx-props-no-spreading': [ 'warn', { custom: 'ignore', }, ], 'react/prop-types': 'off', 'react/prefer-stateless-function': 'off', // react hooks 'react-hooks/rules-of-hooks': 'error', 'react-hooks/exhaustive-deps': 'error', // import 'import/extensions': [ 'error', 'always', { js: 'never', jsx: 'never', ts: 'never', tsx: 'never' } ], 'import/prefer-default-export': 'off', }, ...

.prettierrc

{ "printWidth": 80, "semi": true, "singleQuote": true, "trailingComma": "all", "arrowParens": "always" }

package.json

"devDependencies": { ... "@types/prettier": "^1.19.0", "@types/stylelint": "^9.10.1", "@typescript-eslint/eslint-plugin": "^3.0.2", "@typescript-eslint/parser": "^3.0.2", "eslint": "^6.6.0", "eslint-config-airbnb": "^18.1.0", "eslint-config-airbnb-base": "^14.1.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-jest": "^23.13.2", "eslint-plugin-prefer-arrow": "^1.2.1", "eslint-plugin-prettier": "^3.1.3", "prettier": "^2.0.5", ... "stylelint": "^12.0.0", "stylelint-config-prettier": "^8.0.0", "stylelint-config-standard": "^19.0.0", "stylelint-order": "^3.1.1" },

上記の状態なのですが、アドバイスいただけますでしょうか?
何回かこの状況で苦戦して、適当にいじったら解消されるというのを経験しているのですが、ちゃんと理解をして対処したいと考えています。。。よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

こちらの情報で解決できました。

Why do I keep getting Delete 'cr' prettier/prettier?

.eslintrcに以下の設定を追記しました。

'prettier/prettier': ["error", { "endOfLine": "off", }],

投稿2020/06/01 09:46

gano

総合スコア39

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問