windicss / windicss-intellisense

Intelligent WindiCSS tooling for VS Code
https://marketplace.visualstudio.com/items?itemName=voorjaar.windicss-intellisense
MIT License
194 stars 16 forks source link

Error loading config with `Auto Rename Tag` installed #132

Closed DaPotatoMan closed 6 months ago

DaPotatoMan commented 3 years ago

Problem: extension cant load the config file and thus doesn't work at all. If I use version 0.11.7 this error doesn't occur. Only happens if I upgrade.

Extension version: 0.15.1 Extension initial output:

⚠ WARN: SyntaxError: Unexpected token � in JSON at position 0
Windi CSS Intellisense is now active!
Output after I modify the config file (windi.config.ts)
``` ⚠ WARN: SyntaxError: Unexpected token � in JSON at position 0 Windi CSS Intellisense is now active! ⚠ WARN: TypeError: Cannot read property 'visitors' of undefined ⚠ WARN: SyntaxError: Unexpected token � in JSON at position 0 ⚠ WARN: Error: undefined: Must export a default export when using ES6 modules. e:\Projects\Collaborations\vocal-web-app\windi.config.ts:0:0 ```
Config file: (windi.config.ts)
```typescript import { defineConfig } from 'windicss/helpers'; export default defineConfig({ darkMode: false, theme: { fontFamily: { sans: ['Inter', 'Roboto', 'sans-serif'] }, extend: { colors: { accent: '#6366f1' }, textColor: { default: '#202020', 'default-light': '#454545', inverse: '#fff' }, backgroundColor: { default: '#f8f6f5', 'default-elevated': '#fff', inverse: '#000' } } }, }); ```
alexanderniebuhr commented 3 years ago

I can't reproduce it. Using your attached config file, gives no errors for me.

eggsy commented 3 years ago

I can reproduce it on my eggsy/website repository. My config is below, I don't think there are any problems with it because it works, I just don't get autocompletion and all (I get class sorting though).

import { defineConfig } from "windicss/helpers"
import defaultTheme from "windicss/defaultTheme"

import lineClamp from "windicss/plugin/line-clamp"

export default defineConfig({
  darkMode: "class",
  theme: {
    fontFamily: {
      sans: ["Inter", ...defaultTheme.fontFamily.sans],
    },
  },
  plugins: [lineClamp],
})

Here are the errors I get when I save this exact same config file.

image

My extension's version is 0.16.2.

alexanderniebuhr commented 3 years ago

@eggsy I use latest VS Code Insider. I just copied the config in windi.config.ts. And it works for me. Can you please open an simple html project folder and paste the windi.config.ts file in there. I want to make sure it is happening there too.

eggsy commented 3 years ago

@eggsy I use latest VS Code Insider. I just copied the config in windi.config.ts. And it works for me. Can you please open an simple html project folder and paste the windi.config.ts file in there. I want to make sure it is happening there too.

Yep, it's still the same, I tried upgrading my dependencies, upgrading typescript and re-installing the VSC Extension, nothing seems to work.

image

alexanderniebuhr commented 3 years ago

/cc @voorjaar can you reproduce it? I can not reproduce it

DaPotatoMan commented 3 years ago

Extension works (autocomplete, etc.) if I remove the config file.

alexanderniebuhr commented 3 years ago

Hmm yeah. So somehow there is a bug, don't know the cause yet

voorjaar commented 3 years ago

/cc @voorjaar can you reproduce it? I can not reproduce it

I can't either, not sure what happened here.

eggsy commented 3 years ago

Huh? This is weird but it just started working. I don't know if it started working after the last release but I think I've tried it, didn't work. Somehow it works now. I didn't change anything in the config, I also didn't do anything to fix it. I just tried to clone and console.log the JSON.parse then saw there were no errors 😅. It's working now!

image

alexanderniebuhr commented 3 years ago

Let's keep an eye on this for a while

DaPotatoMan commented 3 years ago

I think I may have found the cause (for me at least). It was the extension Auto Rename Tag by Jun Han. I found lines in prettier output that said it couldn't load and parse a JSON in that extension's folder. I disabled it and the WindiCSS extension started to work. @eggsy do you also use this extension (Auto Rename Tag)?

voorjaar commented 3 years ago

Huh? This is weird but it just started working. I don't know if it started working after the last release but I think I've tried it, didn't work. Somehow it works now. I didn't change anything in the config, I also didn't do anything to fix it. I just tried to clone and console.log the JSON.parse then saw there were no errors 😅. It's working now!

image

It's weird, I didn't fix this either...

bux commented 3 years ago

Can confirm, once I deactivated the Auto Rename Tag by Jun Han it worked for me again.

alexanderniebuhr commented 3 years ago

https://github.com/windicss/windicss-intellisense/issues/113 has also an issue with Auto Rename Tag.. I am not sure what's going on. But it seems that Extension does change the behavior of our extension a lot ..

amythos commented 3 years ago

it not works for me when i add a windi.config.ts file at root dir of my project, it works when i remove the windi.config.ts file.

vscode version: 1.56.2 Extension version: 0.17.1

// windi.config.ts
import { defineConfig } from 'windicss/helpers'

export default defineConfig({
  darkMode: 'class', // or 'media'
})
DaPotatoMan commented 3 years ago

@amythos If you have the extension Auto Rename Tag by Jun Han installed, disable it.

amythos commented 3 years ago

@DaPotatoMan i don't have the Auto Rename Tag extension

king-11 commented 3 years ago

I can confirm that the intellisense stops working when I enabled auto rename tag

alexanderniebuhr commented 3 years ago

@DaPotatoMan i don't have the Auto Rename Tag extension

can you provide reproduction steps in an separate issue please

alexanderniebuhr commented 3 years ago

/cc @windicss/windicss tagging this as need guidance & upstream since it seems that the 3rd party extension Auto Rename Tag, hooks into something. I truly have no idea how to fix this, or what caused this issue, as far as I can tell, we use native VS Code API, the way it is documented.