csscomb / csscomb.js

CSS coding style formatter
http://csscomb.com/
MIT License
3.29k stars 457 forks source link

support for css vars #625

Closed ctf0 closed 1 year ago

ctf0 commented 4 years ago

atm if we have

:root {
   /* some vars */;
}

anywhere in file, you get an error

TypeError: Cannot read property 'first' of null
appbak3r commented 4 years ago

Is dev branch going to be merged to a new tag? Cause it has a fix for this issue

voskresla commented 4 years ago

It affect vscode.csscomb plugin too. Waiting for a merge )

Manyaka commented 4 years ago

Any news about this issue? I use csscomb and I like it, but it does not work with css vars :(

nanoo-k commented 4 years ago

For the time being I can use SCSS vars so it's no big deal, but +1 to getting that fix in.

alecdwm commented 4 years ago

While we wait for a new release, here's a workaround you can use if you invoke csscomb from the command line:

package.json

{
  "scripts": {
    "fmt": "node node_modules/csscomb/src/cli.js -c .csscombrc src",
  },
  "devDependencies": {
    "csscomb": "csscomb/csscomb.js#1f27f9e4e0f6a9f0849b6fc6e8325baf9371aeaf",
  }
}

The hash 1f27f9e4e0f6a9f0849b6fc6e8325baf9371aeaf refers to the commit containing the fix.

If you invoke csscomb directly you'll see an error like this:

Error: Cannot find module '../lib/cli'

So instead I am using node node_modules/csscomb/src/cli.js.

perlun commented 3 years ago

Hi,

Any timeframe for releasing a new version of csscomb? I was about to take it into usage for my own project, but since I rely heavily on CSS variables this bug is pretty much a showstopper for me right now.

I tried with npm install -g git+https://github.com/csscomb/csscomb.js#1f27f9e4e0f6a9f0849b6fc6e8325baf9371aeaf and while it installs, I get errors like this when trying to execute csscomb:

 $ csscomb darkerfx/styles/main.css 
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module '../lib/cli'
Require stack:
- /home/per/.nvm/versions/node/v14.15.5/lib/node_modules/csscomb/bin/csscomb
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/home/per/.nvm/versions/node/v14.15.5/lib/node_modules/csscomb/bin/csscomb:2:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/per/.nvm/versions/node/v14.15.5/lib/node_modules/csscomb/bin/csscomb'
  ]
}

I tried with find /home/per/.nvm/versions/node/v14.15.5/lib/node_modules/csscomb -name cli.js to try and use the approach suggested in https://github.com/csscomb/csscomb.js/issues/625#issuecomment-598365348, but the file doesn't exit there. My project is not Node.js-based so I' d prefer to not have to create a package.json just for the sake of executing csscomb. Any other workarounds?

bitst0rm commented 3 years ago

This bug seems to be already fixed with commit. If you cannot wait for the official release then you can do it by yourself:

$ git clone https://github.com/csscomb/csscomb.js.git
$ cd csscomb.js
$ npm install --save-dev
> Delete all unnecessary hidden files and folders exactly the official one from:
https://registry.npmjs.org/csscomb/-/csscomb-4.3.0.tgz
> Push it to your repo
> In your project package.json add:
    "devDependencies": {
        "csscomb": "git+https://github.com/your/csscomb.js.git",
    }

Here is what i did for my project. But dont use it directly, fork it instead since it is my Test-repo so it can be removed soon: https://github.com/bitst0rm-dev/csscomb.js