MiiZZo
@MiiZZo
JavaScript, React, NodeJS, Student

Как использовать совместно eslint и prettier?

Текст ошибки:
Error: Cannot find module '��{ " s e m i " : t r u e , " t r a i l i n g C o m m a " : "
a l l " , " s i n g l e Q u o t e " : t r u e , " p r i n t W i d t h " : 1 2 0 ,
" t a b W i d t h " : 4 }
Npm script:
eslint \"src/client/**/*.tsx\" --quiet --fix
.prettierrc
{
    "semi": true,
    "trailingComma": "all",
    "singleQuote": true,
    "printWidth": 120,
    "tabWidth": 4
}

.eslintrc
{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2020,
    "ecmaFeatures": {
      "jsx": true 
    },
    "project": "./tsconfig.eslint.json"
  },
  "settings": {
    "react": {
      "version": "detect"
    }
  },
  "extends": [
    "plugin:react/recommended", 
    "plugin:@typescript-eslint/recommended",
    "prettier/@typescript-eslint",
    "plugin:prettier/recommended"
  ],
  "plugins": [
    "react-hooks" 
  ],
  "rules": {
    "react-hooks/rules-of-hooks": "error",
    "react-hooks/exhaustive-deps": "warn"
  }
}

Зависимости:
"prettier": "^2.0.5"
"eslint": "^7.3.1"
"eslint-config-prettier": "^6.11.0"
"eslint-plugin-import": "^2.22.0"
"eslint-plugin-prettier": "^3.1.4"
"eslint-plugin-react": "^7.20.3"
"eslint-plugin-react-hooks": "^4.0.5"
"@typescript-eslint/eslint-plugin": "^3.5.0"
"@typescript-eslint/parser": "^3.5.0"
Примечание: если убрать строку "plugin:prettier/recommended" из массива extends в файле .eslintrc, ошибка исчезает.
  • Вопрос задан
  • 78 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы