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

Scss syntax #3

Closed drixsonic closed 8 years ago

drixsonic commented 8 years ago

I couldn't find a way to make the plugin work with scss files. Passing --syntax scss to the stylelint args in the user settings didn't work. Am I missing something or is it not yet supported?

fengnana commented 8 years ago

I have the same problem, have you find any solution?

drixsonic commented 8 years ago

No, not yet :(

kungfusheep commented 8 years ago

Hi - sorry for the delayed response I've been quite busy. I'll try to look at this over the next couple of days. Cheers. On Wed, 16 Dec 2015 at 16:53, Cédric Trigoso notifications@github.com wrote:

No, not yet :(

— Reply to this email directly or view it on GitHub https://github.com/kungfusheep/SublimeLinter-contrib-stylelint/issues/3#issuecomment-165172858 .

fengnana commented 8 years ago

oh,may be i know how to resove it.... try it, set sublime text 'View'->'Syntax'->'css', then it works on mine scss files, good luck!!

drixsonic commented 8 years ago

Right, that works also for me except for files using interpolations #{}... Then I get such an error in the Sublime console: toolbar.css:111:21: Unknown word. Unfortunately all my scss files use interpolations now... Running stylelint from the CLI works fine: stylelint stylesheets/**/*.scss --syntax scss

fengnana commented 8 years ago

may be you can try this: set sublime text 'View'->'Syntax'->'sass'(if don't find the 'sass' tag , install it by https://packagecontrol.io/packages/Sass), and then, you should make a change in linter.py(Sublime Text 3/Packages/SublimeLinter-contrib-stylelint/linter.py),add 'sass' as "syntax = ('css', 'css3', 'sass')",then restart sublime. try it, good luck~~

fengnana commented 8 years ago

by the way , there is a bug about the error lines that Sublime console. in some case , it always show" :[1, 1]:",but actually is not the reall error lines. so i try to do this: image change to image can be right, but i am not sure it's a right way to fix it or not. so, @kungfusheep hope you response them together. Cheers

drixsonic commented 8 years ago

I've found a way to make it work. I had to change stylelint_wrapper.js, the postcss part now looks like:

var postcss = require("postcss");
var syntax = require("postcss-scss");
var stylelint = require("stylelint");
var reporter = postcss.plugin("reporter", require("./reporter/lib/reporter"));

/// css to be processed
var fileName = process.argv[2];
var css = fs.readFileSync(fileName, "utf8");

/// start the linting process.
postcss([
        stylelint( config )
        ,reporter()
    ])
    .process(css, {
        from: fileName,
        syntax: syntax
    })
    .then()
    .catch(function(err) {
        console.error(err.stack)
    })

I needed to install postcss-scss globally also (npm install postcss-scss -g).

Now everything works fine even with the sass syntax highlighting thanks to @fengnana! Seems to work also work for plain css but didn't had time to check that deeply. One thing though, the error lines are not always pointing to the right line. @fengnana, which file did you actually changed for that?

fengnana commented 8 years ago

sorry, i forgot point the path ,it is:

Sublime Text 3/Packages/SublimeLinter-contrib-stylelint/reporter/lib/formatter.js

------------------ 原始邮件 ------------------ 发件人: "Cédric Trigoso";notifications@github.com; 发送时间: 2015年12月19日(星期六) 晚上10:44 收件人: "kungfusheep/SublimeLinter-contrib-stylelint"SublimeLinter-contrib-stylelint@noreply.github.com; 抄送: "篱竹"835287890@qq.com; 主题: Re: [SublimeLinter-contrib-stylelint] Scss syntax (#3)

I've found a way to make it work. I had to change stylelint_wrapper.js, the postcss part now look like: var postcss = require("postcss"); var syntax = require("postcss-scss"); var stylelint = require("stylelint"); var reporter = postcss.plugin("reporter", require("./reporter/lib/reporter")); /// css to be processed var fileName = process.argv[2]; var css = fs.readFileSync(fileName, "utf8"); /// start the linting process. postcss([ stylelint( config ) ,reporter() ]) .process(css, { from: fileName, syntax: syntax }) .then() .catch(function(err) { console.error(err.stack) })

I needed to install postcss-scss globally also (npm install postcss-scss -g).

Now everything works fine even with the sass syntax highlighting thanks to @fengnana! Seems to work also work for plain css but didn't had time to check that deeply. One thing though, the error lines are not always pointing to the right line. @fengnana, which file did you actually changed for that?

— Reply to this email directly or view it on GitHub.

drixsonic commented 8 years ago

@fengnana thanks!

kungfusheep commented 8 years ago

Hi - I've updated the plugin wrapper to use the stylelint CLI, so you should now be able to get sass/scss support just as you'd expect from stylelint out of the box. Thanks for reporting.

marcoms commented 7 years ago

@kungfusheep Could you detail the steps to work with scss files please? I've set --syntax scss in the user args, but is anything else required?