unplugin / unplugin-turbo-console

🚀 Improve the Developer Experience of console
https://utc.yuy1n.io
MIT License
526 stars 12 forks source link

Wrong insertion position since last update #16

Closed arnriu closed 10 months ago

arnriu commented 10 months ago

Describe the bug

I'm updating from 1.0.9 to 1.1.0. I'm using vite + react

Here is an exemple of what is going on. In my code, I have this line:

.catch(e => console.log('Missing Icon: ', _type, ' ', _name, ' ', e))

And what gets generated is:

.catch((e)=>console.group("%c🚀 index.jsx:74%c🔦 http://localhost:3070/client#c3JjL2NvbXBvbmVudHMvdXRpbHMvSWNvbi9pbmRleC5qc3g6NzQ6MjE=","padding:2px 5px; border-radius:3px 0 0 3px;margin-bottom:5px;color: #111827; background: #F7DF1E","background: #00DC8250;padding:2px 5px;border-radius:0 3px 3px 0;margin-bottom:5px")
console.log('Missing Icon: ', _type, ' ', _name, ' ', e)
console.groupEnd());

Problem here is that my catch function does not have brackets, and now the insertion of console.group is messing up the catch function.

This is one of many examples all over the app with function without brackets.

Tested with 1.0.9 and there is no issue.

Reproduction

https://codesandbox.io/p/devbox/vite-react-forked-txyl29

System Info

System:
    OS: macOS 14.2.1
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 698.39 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.2.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.14.1 - /usr/local/bin/pnpm
    bun: 1.0.18 - ~/Library/pnpm/bun
    Watchman: 2023.04.10.00 - /usr/local/bin/watchman
  Browsers:
    Brave Browser: 109.1.47.171
    Chrome: 122.0.6238.2
    Edge: 120.0.2210.133
    Safari: 17.2.1
    Safari Technology Preview: 17.4

(firefox is missing from this list: Firefox: 122.0b7)

Used Package Manager

pnpm

Validations

yuyinws commented 10 months ago

Fixed on https://github.com/unplugin/unplugin-turbo-console/releases/tag/v1.1.1