weixin_39631445
weixin_39631445
2020-12-09 13:58

Scss syntax

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?

该提问来源于开源项目:kungfusheep/SublimeLinter-contrib-stylelint

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

12条回答

  • weixin_39905226 weixin_39905226 5月前

    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, hope you response them together. Cheers

    点赞 评论 复制链接分享
  • weixin_39631445 weixin_39631445 5月前

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

     javascript
    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 ! 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. , which file did you actually changed for that?

    点赞 评论 复制链接分享
  • weixin_39905226 weixin_39905226 5月前

    sorry, i forgot point the path ,it is:

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

    ------------------ 原始邮件 ------------------ 发件人: "Cédric Trigoso";notifications.com; 发送时间: 2015年12月19日(星期六) 晚上10:44 收件人: "kungfusheep/SublimeLinter-contrib-stylelint"SublimeLinter-contrib-stylelint.github.com; 抄送: "篱竹"835287890.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 ! 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. , which file did you actually changed for that?

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

    点赞 评论 复制链接分享
  • weixin_39631445 weixin_39631445 5月前

    thanks!

    点赞 评论 复制链接分享
  • weixin_39762666 weixin_39762666 5月前

    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.

    点赞 评论 复制链接分享
  • weixin_39972264 weixin_39972264 5月前

    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?

    点赞 评论 复制链接分享
  • weixin_39905226 weixin_39905226 5月前

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

    点赞 评论 复制链接分享
  • weixin_39631445 weixin_39631445 5月前

    No, not yet :(

    点赞 评论 复制链接分享
  • weixin_39762666 weixin_39762666 5月前

    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.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 .

    点赞 评论 复制链接分享
  • weixin_39905226 weixin_39905226 5月前

    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!!

    点赞 评论 复制链接分享
  • weixin_39631445 weixin_39631445 5月前

    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

    点赞 评论 复制链接分享
  • weixin_39905226 weixin_39905226 5月前

    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~~

    点赞 评论 复制链接分享

相关推荐