csscomb / csscomb.js

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

TypeError: ast.remove is not a function #501

Closed thenewvu closed 5 years ago

thenewvu commented 7 years ago

Sir, I've met this error with all CSS files and with both custom and default configure:

(node:25107) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: ast.remove is not a function
(node:25107) 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.

This error only occurs in v4.0.1, not with v3.1.7.

My environment:

node v7.7.1
arch linux 4.9.11
sublistic commented 7 years ago

I get the following similar error:

(node:2323) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'is' of null
(node:2323) 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.

node v7.10.0 OSX 10.11.6

1f47a commented 7 years ago

Same error here

node 7.10.0
OSX 10.10.5
gabriensymons commented 7 years ago

Similar error when running csscomb@4.0.1 as an exec command with ant. Like @thenewvu, no error with version 3.1.7:

csscomb:
     [exec] (node:66140) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: this._parseString(...).then is not a function

My env:

Apache Ant 1.9.7
node 6.10.2
macOS 10.12.4
janwerkhoven commented 7 years ago

Getting error in Atom Beautify 0.29.26 which uses CSS Comb. How to resolve?

TypeError: ast.remove is not a function
    at /Users/jw/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/block-indent.js:48:13
    at Node.eachFor (/Users/jw/.atom/packages/atom-beautify/node_modules/gonzales-pe/lib/gonzales.js:129:83)
    at Object.process (/Users/jw/.atom/packages/atom-beautify/node_modules/csscomb/lib/options/block-indent.js:44:9)
    at /Users/jw/.atom/packages/atom-beautify/node_modules/csscomb/lib/core.js:380:14
    at Array.forEach (native)
    at Comb._processTree (/Users/jw/.atom/packages/atom-beautify/node_modules/csscomb/lib/core.js:379:8)
janwerkhoven commented 7 years ago

Temporary workaround: Remove "block-indent": " ", from the .csscomb.json file and the error ceases to appear and ceases to block the rest of the formatting. That means no indenting of blocks until fixed, but still better than no formatting at all.

janwerkhoven commented 7 years ago

Is it this line of code that is failing? https://github.com/csscomb/csscomb.js/blob/dev/src/options/block-indent.js#L48

janwerkhoven commented 7 years ago

Is nobody maintaining this?

obenjiro commented 7 years ago

@janwerkhoven I do maintain this repository. I will look into this asap.

mfeckie commented 7 years ago

Should this

https://github.com/csscomb/csscomb.js/blob/dev/src/options/block-indent.js#L48

ast.remove(i);

not be

ast.removeChild(i); ?

ryanbowden commented 7 years ago

I am having the same issue and changing "eof-newline": false, to true fixes the fault. Hope that helps finding the issue.

ikeq commented 7 years ago

@ryanbowden It works! Thanks.

Spunkie commented 7 years ago

The fix from @mfeckie worked for me.

maxfenton commented 6 years ago

Still having this issue in the current version until I make the change @ryanbowden suggested.

tucq88 commented 6 years ago

Still having issue, @ryanbowden update does'nt work with me :(

tucq88 commented 6 years ago

Found the issues, cause my style has many lines commented out by // , Is this a known issue ?

janwerkhoven commented 6 years ago

I can confirm both the fix and work-around.

How to avoid the errors

In the .csscomb.json set "eof-newline": true,.

Thanks @ryanbowden

How to fix it

In node_modules/csscomb/lib/options/block-indent.js replace ast.remove(i); with ast.removeChild(i);.

Thanks @mfeckie !

seezee commented 6 years ago

Also getting similar error. Node v.8.9.1 & OS High Sierra with latest CSSComb. (node:22596) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): [object Object] (node:22596) [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.

harapeko commented 6 years ago

similar error

.hoge {
    $arr: (
        "s": 3,
        "m": 4,
        "l": 5,
    ) !default;

    @each $key, $value in $arr {
        "&--of3" { // ← this is bad
        }
    }
}
(node:110565) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): [object Object]
(node:110565) [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.

Node: v8.7.0 OS: Ubuntu 14.04.5 LTS

klavatron commented 6 years ago

Thanks, both fixes work!

xianshenglu commented 6 years ago

@ryanbowden ,It works for me too!

luisFebro commented 5 years ago
*{
  outline: none;
}*

My issue was this last asterisk which was preventing my code to run. Check if you don't have such syntax error because I have tried all the solutions above, but ended up to be that!

UPDATED: watch out for unset comments, if you don't wrap them like this:

color: navy;
  background-color: black;
  _TOP:  
  1st top-left; 2nd top-right;
  BOTTOM:
  3rd bottom-right; 4th bottom-left;_ /*this whole block should be a comment block. This produces this error, too*/
  text-shadow: -3px -3px 7px lightblue, 3px -3px 7px lightblue,
  3px 3px 7px lightblue, -3px 3px 7px lightblue;
tonyganch commented 5 years ago

Fixed by @janwerkhoven with #552.

janwerkhoven commented 5 years ago

🙌