Jak poprawnie skonfigurować eslint?

0

Witam, mam taki problem ze próbuje odpalic next.js z rozszerzenie (extension) prettier-eslint dla vscode. Ale dostaje taki bład jak poniżej. W aplikacji frontendowej wszystko działa poprawnie.
Ale tutaj nie. Ze zwykym (extension) prettier wszystko działa. Tylko że to rozszerzenie nie poprawia błędów z eslinta, czyli jak z flagą --fix. Albo da się ustawić aby zwykłe rozszerzenie prettier uruchamiało się ale z flagą --fix?.

Error: Expected `input` to be a `string`, got `object` 
TypeError: Expected `input` to be a `string`, got `object`
	at fb.exports (c:\Users\bartl\.vscode\extensions\rvest.vs-code-prettier-eslint-5.1.0\dist\extension.js:7:7296)
	at c:\Users\bartl\.vscode\extensions\rvest.vs-code-prettier-eslint-5.1.0\dist\extension.js:192:25
	at zme (c:\Users\bartl\.vscode\extensions\rvest.vs-code-prettier-eslint-5.1.0\dist\extension.js:185:1460)

.eslintrc.json

{
  "extends": [
    "next/core-web-vitals", 
    "plugin:@typescript-eslint/recommended",
    "plugin:import/errors",
    "plugin:import/warnings",
    "plugin:import/typescript",
    "plugin:jsx-a11y/recommended",
    "plugin:eslint-comments/recommended",
    "plugin:prettier/recommended"
  ]
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/*": ["./*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}
{
  "name": "next",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@types/node": "20.5.7",
    "@types/react": "18.2.21",
    "@types/react-dom": "18.2.7",
    "next": "13.4.19",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "typescript": "5.2.2",
    "prettier": "^3.0.3",
    "eslint": "8.48.0",
    "eslint-config-next": "13.4.19",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-eslint-comments": "^3.2.0",
    "eslint-plugin-import": "^2.28.1",
    "eslint-plugin-jsx-a11y": "^6.7.1",
    "eslint-plugin-prettier": "^5.0.0",
    "eslint-plugin-react": "^7.33.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "@typescript-eslint/eslint-plugin": "^6.5.0",
    "@typescript-eslint/parser": "^6.5.0"
  }
}

0

Krótkie googlowanie mówi mi, że to prawdopodobnie jest związane z niekompatybilnością między nową wersją Prettiera, gdzie nastąpił pewien breaking change, a resztą softu.

https://github.com/idahogurl/vs-code-prettier-eslint/issues/171
https://github.com/prettier/prettier-eslint/pull/901

0

Jak żeś to znalazł mi nic nie wszukało

0

wrzuciłem w Google ten błąd:
Error: Expected input to be a string, got object
plus nazwy technologii typu prettier, vs-code-prettier-eslint itp.
i na GH jeszcze w issues tej wtyczki

0

Jeśli chcesz ustawić automatyczne formatowanie podczas zapisu to VSCode ma osobne wtyczki do eslinta i prettiera

https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint

.vscode/settings.json

{
  "editor.formatOnSave": false,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  }
}

1 użytkowników online, w tym zalogowanych: 0, gości: 1