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

Support .less files #29

Open Arkkimaagi opened 8 years ago

Arkkimaagi commented 8 years ago

For some reason linter.py seems to be missing the .less file extension:

syntax = ('css', 'css3', 'sass', 'scss', 'postcss')

if I add it myself, stylelint seems to work as wanted on .less files too.

syntax = ('css', 'css3', 'sass', 'scss', 'postcss', 'less')
Arkkimaagi commented 8 years ago

In addition, the syntax should be set so that stylelint gets the file format properly. This is how I get it working better from command line:

$ stylelint --syntax=less sample.less

Sadly I have no idea how to pass the syntax information trough sublimelinter

Any suggestions on getting this working are really welcome, as this is stopping me from linting some .less files alltogether.

Arkkimaagi commented 8 years ago

I was able to get better support for LESS by hacking the stylelint_wrapper.js and linter.py like this:

linter.py:

    syntax = ('css', 'css3', 'sass', 'scss', 'postcss', 'less')

stylelint_wrapper.js:

    var syntax = "css";
    if(/\.less$/.test(process.argv[2])){
      syntax = "less"
    }else if(/\.scss$/.test(process.argv[2])){
      syntax = "scss"
    }else if(/\.sss$/.test(process.argv[2])){
      syntax = "sugarss"
    }

    var lint = child_process.spawnSync("node", [cliLocation, process.argv[2], "--syntax", syntax]);

It's an ugly fix, and as such does not warrant a pull request, but it shows that it can be done. Feel free to extrapolate from this ugly hack. :)