neoclide / coc-prettier

Prettier extension for coc.nvim.
MIT License
546 stars 48 forks source link

Error output when using prettier v3 #164

Closed yaegassy closed 1 year ago

yaegassy commented 1 year ago

Description

version 3 of prettier has been released.

When using prettier ver3 with coc-prettier, an error seems to be output when starting the extension. It seems that coc-prettier needs to be adjusted for prettier ver3.

Error

Screen shot:

coc-prettier-issue-use-prettier-v3

CocInfo:

...snip

2023-07-06T16:19:38.820 INFO (pid:2849) [services] - LanguageClient ESLint state change: stopped => starting
2023-07-06T16:19:38.822 ERROR (pid:2849) [server] - unhandledRejection  Promise {
  <rejected> TypeError: Cannot read properties of undefined (reading 'forEach')
      at PrettierEditService.getSelectors (/Users/yaegassy/.config/coc/extensions/node_modules/coc-prettier/lib/index.js:4439:18)
      at PrettierEditService.handleActiveTextEditorChanged (/Users/yaegassy/.config/coc/extensions/node_modules/coc-prettier/lib/index.js:4411:36)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
} TypeError: Cannot read properties of undefined (reading 'forEach')
    at PrettierEditService.getSelectors (/Users/yaegassy/.config/coc/extensions/node_modules/coc-prettier/lib/index.js:4439:18)
    at PrettierEditService.handleActiveTextEditorChanged (/Users/yaegassy/.config/coc/extensions/node_modules/coc-prettier/lib/index.js:4411:36)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

...snip

Repro

mkdir -p $HOME/check-prettier3
cd $HOME/check-prettier3
npm init -y
npm i prettier@^3.0.0
nvim check.ts
edilson258 commented 1 year ago

same error too