csscomb / csscomb.js

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

Cannot read property 'is' of null #525

Closed ghost closed 5 years ago

obenjiro commented 7 years ago

@kinkwilde can you provide css file that cause the issue?

ghost commented 7 years ago

I created a sample test file to test it on and it does fail on this. It seems to work on one of my header files just fine but others it raise this same error.

I use csscomb through atom-beautify which has just updated to use the latest version of csscomb and the newer gonzales-pe. I've even tried updating the 2 manually. The guys over at atom-beautify told me to come over her to ask as it seems to be a csscomb issue but I am unsure where the fault lies at the moment. I can provide a list of plugins used or a beautify debug file if needed.

/* TEST COMB */
.extend-comb {
    border: 1px solid $white;
}

.test-comb {
    $color: pink;

    @extend .extend-comb;

    @include font-size(22);
    @include clearfix;
    @include position(vertical, absolute);

    background-color: $color;
    color: red;
    display: block;
    height: 100%;
    width: 100%;

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    @include break-min($md-break) {
        color: blue;
    }

    @include break-max($md-break) {
        color: yellow;
    }

    @include break-between($lg-break, $xl-break) {
        color: black;
    }

    @media (min-width: $xx-break) {
        color: green;
    }
}
muuvmuuv commented 7 years ago

Got the same issue.

Cannot read property 'is' of null
Hide Stack Trace
TypeError: Cannot read property 'is' of null
    at Object.insertNewlines (/Users/marvinheilemann/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:237:20)
    at node.forEach (/Users/marvinheilemann/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:124:12)
    at Node.forEach (/Users/marvinheilemann/.atom/packages/atom-beautify/node_modules/gonzales-pe/lib/gonzales.js:175:83)
    at Object.processRuleSets (/Users/marvinheilemann/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:123:10)
    at Object.processBlock (/Users/marvinheilemann/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:98:12)
    at Object.process (/Users/marvinheilemann/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:89:10)
    at /Users/marvinheilemann/.atom/packages/atom-beautify/node_modules/csscomb/lib/core.js:380:14
    at Array.forEach (native)
    at Comb._processTree (/Users/marvinheilemann/.atom/packages/atom-beautify/node_modules/csscomb/lib/core.js:379:8)

SCSS

[module="book"]  .container content {
  padding: 7% 30px !important;

  background: rgba($color-dark, .5);

  @include media-breakpoint-up(md) {
    padding: 10% 50px !important;
  }

  p {
    margin: 0;
  }
}
obenjiro commented 7 years ago

@muuvmuuv @kinkwilde I can't reproduce the issue. What version of csscomb are you using? Try 4.1.0

ghost commented 7 years ago

As far as I am aware (last time I checked) it was updated to 4.1.0 - It is happening on all 3 of my machines that I have access to.

When you did your test did you use my .csscomb file? If yes, then do we think it's an issue with atom-beautify?

obenjiro commented 7 years ago

@kinkwilde Finally... the error was reproduced on Windows. It's actually happening of Windows machines -.- (MacOS, Linux - works fine). Working on issue

aljopro commented 6 years ago

I'm seeing a very similar issue But on my mac

TypeError: Cannot read property 'is' of null
    at Plugin.insertNewlines (/Users/jchappell/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:237:20)
    at node.forEach (/Users/jchappell/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:124:12)
    at Node.forEach (/Users/jchappell/.atom/packages/atom-beautify/node_modules/gonzales-pe/lib/gonzales.js:175:83)
    at Plugin.processRuleSets (/Users/jchappell/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:123:10)
    at Plugin.processBlock (/Users/jchappell/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:98:12)
    at Plugin.process (/Users/jchappell/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:89:10)
    at /Users/jchappell/.atom/packages/atom-beautify/node_modules/csscomb/lib/core.js:384:14
    at Array.forEach (native)
    at Comb._processTree (/Users/jchappell/.atom/packages/atom-beautify/node_modules/csscomb/lib/core.js:383:8)

csscomb.json

{
    "exclude": [
        ".git/**",
        "node_modules/**",
        "bower_components/**",
        "dist/**",
        "gulp/**"
    ],
    "always-semicolon": true,
    "block-indent": "\t",
    "color-case": "upper",
    "color-shorthand": false,
    "element-case": "lower",
    "leading-zero": true,
    "lines-between-rulesets": 1,
    "quotes": "single",
    "remove-empty-rulesets": true,
    "sort-order-fallback": "abc",
    "space-after-colon": " ",
    "space-after-combinator": " ",
    "space-after-opening-brace": "\n",
    "space-after-selector-delimiter": "\n",
    "space-before-closing-brace": "\n",
    "space-before-colon": "",
    "space-before-combinator": " ",
    "space-before-opening-brace": " ",
    "space-before-selector-delimiter": "",
    "space-between-declarations": "\n",
    "strip-spaces": true,
    "unitless-zero": true,
    "sort-order": []
}
yoh-m commented 6 years ago

Had the same issue, just removed the comments at the top of my file and it works!
Apparently if it's starting with any comment, be it line comment with // or block comment with /*, csscomb will give this UnhandledPromiseRejectionWarning error.

mariovalney commented 5 years ago

Same here for SCSS file with comment on top:

CSScomb error:
(node:23692) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'is' of null
    at Plugin.insertNewlines (/home/valney/.config/sublime-text-3/Packages/sublime-csscomb/node_modules/csscomb/lib/options/lines-between-rulesets.js:237:21)
    at node.forEach (/home/valney/.config/sublime-text-3/Packages/sublime-csscomb/node_modules/csscomb/lib/options/lines-between-rulesets.js:118:12)
    at Node.forEach (/home/valney/.config/sublime-text-3/Packages/sublime-csscomb/node_modules/csscomb/node_modules/gonzales-pe/lib/gonzales.js:175:83)
    at Plugin.processAtRules (/home/valney/.config/sublime-text-3/Packages/sublime-csscomb/node_modules/csscomb/lib/options/lines-between-rulesets.js:117:10)
    at Plugin.processBlock (/home/valney/.config/sublime-text-3/Packages/sublime-csscomb/node_modules/csscomb/lib/options/lines-between-rulesets.js:95:12)
    at Plugin.process (/home/valney/.config/sublime-text-3/Packages/sublime-csscomb/node_modules/csscomb/lib/options/lines-between-rulesets.js:89:10)
    at /home/valney/.config/sublime-text-3/Packages/sublime-csscomb/node_modules/csscomb/lib/core.js:384:14
    at Array.forEach (<anonymous>)
    at Comb._processTree (/home/valney/.config/sublime-text-3/Packages/sublime-csscomb/node_modules/csscomb/lib/core.js:383:8)
    at <anonymous>
(node:23692) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23692) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Removing comment (or adding a empty line at top) fixes it.

Using Sublime CSSComb and any non-empty .csscomb.json.

zreese commented 4 years ago

Is this fixed? Currently running into this issue with version 4.3.0 via atom-beautify on OSX.

Cannot read property 'is' of null
TypeError: Cannot read property 'is' of null
    at Plugin.insertNewlines (/Users/zreese/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:237:21)
    at node.forEach (/Users/zreese/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:124:12)
    at Node.forEach (/Users/zreese/.atom/packages/atom-beautify/node_modules/gonzales-pe/lib/gonzales.js:175:83)
    at Plugin.processRuleSets (/Users/zreese/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:123:10)
    at Plugin.processBlock (/Users/zreese/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:98:12)
    at Plugin.process (/Users/zreese/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/lines-between-rulesets.js:89:10)
    at /Users/zreese/.atom/packages/atom-beautify/node_modules/csscomb/lib/core.js:384:14
    at Array.forEach (<anonymous>)
    at Comb._processTree (/Users/zreese/.atom/packages/atom-beautify/node_modules/csscomb/lib/core.js:383:8)