kungfusheep / SublimeLinter-contrib-stylelint

this repo is no longer maintained - please see https://github.com/SublimeLinter/SublimeLinter-stylelint
MIT License
116 stars 19 forks source link

TypeError: 'in <string>' requires string as left operand, not tuple #56

Open cixtor opened 6 years ago

cixtor commented 6 years ago

This issue is probably related to #47 and #50 but mine can be consistently reproduced.

Steps to Reproduce the Exception

Code Snippet To Reproduce The Bug

html,body,div,span,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,code,em,img,strong,tt,b,u,i,dl,dt,dd,ol,ul,li,table,tbody,tfoot,thead,tr,th,td {
    margin:0;
    padding:0;
    border:0
    font-size: 100%;
    font: inherit;
}

Errors Generated By The Linter

file.css:
1:1  error  stylelint: Error  Stylelint crashed: No configuration provided for /file.css

Full Copy of the Exception

SublimeLinter: #51468 stylelint github.css ERROR:

 Linter crashed.

Traceback (most recent call last):
  File "/SublimeLinter/lint/backend.py", line 97, in execute_lint_task
    errors = linter.lint(code, view_has_changed, settings) or []
  File "/SublimeLinter/lint/linter.py", line 797, in lint
    output = self.run(cmd, code)
  File "/SublimeLinter/lint/linter.py", line 1139, in run
    return self.communicate(cmd, code)
  File "/SublimeLinter-stylelint/linter.py", line 111, in communicate
    if fileext and not fileext[1:] in self.syntax:
TypeError: 'in <string>' requires string as left operand, not tuple
rfearing commented 6 years ago

@cixtor I had the EXACT same problem. I went back to the README and noticed that my package.json did not include postcss allthough the readme said to inlcude.

After installing in my project npm install postcss or yarn add postcss It worked again. I really hope this helps for you too!

cixtor commented 6 years ago

Thank you @rfearing I don't do JavaScript development but your solution will surely help other people.

I wanted to report this issue more as a way to warn the maintainer that there is an edge case in the code that is not being taken care of, and instead is forcing the linter to miserably crash without any hint to the user. These non-handled exceptions should be gracefully handled to offer recovery during the analysis of the code.