Closed ryokryok closed 9 months ago
What version of eslint are you using? v8.56.0
eslint
What version of prettier are you using? 3.1.1
prettier
What version of eslint-plugin-prettier are you using? 7.33.2
eslint-plugin-prettier
Please paste any applicable config files that you're using (e.g. .prettierrc or .eslintrc files) .prettierrc eslint.config.js
.prettierrc
.eslintrc
eslint.config.js
What source code are you linting? N/A
What did you expect to happen? I was going to write eslint.config.js in ESM syntax, at "type": "module" projects. And import this plugin like this:
"type": "module"
import prettier from "eslint-plugin-prettier/recommended"; ... /** @type {import("eslint").Linter.FlatConfig[]} */ export default [ { // another config }, prettier, ];
What actually happened?
Error: Cannot find module 'eslint-config-prettier'
$ pnpm lint > screen-map@0.0.0 lint /Users/mrozin/Develop/react/screen-map > ESLINT_USE_FLAT_CONFIG=true eslint . Oops! Something went wrong! :( ESLint: 8.56.0 Error: Cannot find module 'eslint-config-prettier' Require stack: - /Users/mrozin/Develop/react/screen-map/node_modules/.pnpm/eslint-plugin-prettier@5.1.2_eslint@8.56.0_prettier@3.1.1/node_modules/eslint-plugin-prettier/recommended.js at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15) at Module._load (node:internal/modules/cjs/loader:985:27) at Module.require (node:internal/modules/cjs/loader:1235:19) at require (node:internal/modules/helpers:176:18) at Object.<anonymous> (/Users/mrozin/Develop/react/screen-map/node_modules/.pnpm/eslint-plugin-prettier@5.1.2_eslint@8.56.0_prettier@3.1.1/node_modules/eslint-plugin-prettier/recommended.js:1:30) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at cjsLoader (node:internal/modules/esm/translators:345:17) ELIFECYCLE Command failed with exit code 2.
This eslint.config.js works.
import prettier from "eslint-plugin-prettier"; /** @type {import("eslint").Linter.FlatConfig[]} */ export default [ { plugins: { // others prettier: prettier, }, rules: { // others ...prettier.configs.recommended.rules, }, }, ];
It's a peer dependency.
What version of
eslint
are you using? v8.56.0What version of
prettier
are you using? 3.1.1What version of
eslint-plugin-prettier
are you using? 7.33.2Please paste any applicable config files that you're using (e.g.
.prettierrc
or.eslintrc
files).prettierrc
eslint.config.js
What source code are you linting? N/A
What did you expect to happen? I was going to write
eslint.config.js
in ESM syntax, at"type": "module"
projects. And import this plugin like this:What actually happened?
Error: Cannot find module 'eslint-config-prettier'
note
This
eslint.config.js
works.