csscomb / csscomb.js

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

Get "Cannot read property 'first' of null" error with :root selector #647

Open maliyshock opened 2 years ago

maliyshock commented 2 years ago

I tried to use 4.2.0 version of CSS comb, and I got this error

"comb": "node node_modules/csscomb/src/cli.js -c .csscomb.json src/scss",

csscomb/lib/options/sort-order.js:163
let property = node.first('property').first();
                                    ^
TypeError: Cannot read property 'first' of null

I believe the problem occurs when you are trying to use :root selector.

The same thing happens here https://gitmemory.com/issue/csscomb/csscomb.js/625/820750672 The workaround is to use

"devDependencies": {
    "csscomb": "csscomb/csscomb.js#1f27f9e4e0f6a9f0849b6fc6e8325baf9371aeaf"
}

and

"scripts": {
    "comb": "node node_modules/csscomb/src/cli.js -c .csscomb.json src/scss",
}

I would be happy to use CSS comb without that kind of patches. Thanks!