matype / stylefmt

stylefmt is a tool that automatically formats stylesheets.
Other
2.1k stars 89 forks source link

Is it possible to explicitly point to a stylelint config file? #144

Closed hejmartin closed 8 years ago

hejmartin commented 8 years ago

I have a project where new css code shares repo with legacy code. I have the need to specify two different grunt tasks with different .stylelintrc.json files for linting, as the new code has stricter lint rules than the old code.

This is possible in stylelint by using the configFile option, but as far as I can tell stylefmt has no option for this. Is it something that could be added in a future release?

This is how my gruntfile looks at the moment:

    postcss: {

        // Lint and (sometimes) fix styling and syntax errors
        // ----------------------------------------------------------------------
        lint_old: {
            files: [{
                dest: '',
                src: old_css_files
            }],
            options: {
                processors: [
                    // Format css according to some .stylelintrc rules
                    require('stylefmt')({
                        // I need a config option here
                    }),
                    // Lint css
                    require('stylelint')({
                        configFile: 'project/old/.stylelintrc.json'
                    })
                ]
            }
        },

        lint_new: {
            files: [{
                dest: '',
                src: new_css_files
            }],
            options: {
                processors: [
                    // Format css according to some .stylelintrc rules
                    require('stylefmt')({
                        // I need a config option here
                    }),
                    // Lint css
                    require('stylelint')({
                        configFile: 'project/new/.stylelintrc.json'
                    })
                ]
            }
        },
matype commented 8 years ago

@hejmartin Thank you for your report. If we can set option for the path of stylelint configuration file in the option of stylefmt, I think that it seems work well.

matype commented 8 years ago

@hejmartin Just released v3.5.0 that includes --config option to specify the path of stylelint configration file. Please update and confirm it :)

hejmartin commented 8 years ago

@morishitter Nice! Seems to be mostly working, but I noticed that if I have an "extends"-declaration in one file, and an indentation rule in the file I'm extending, the indendation rule will not be applied.

// This is the file I'm passing in via the config param
{
    "extends": "../../.stylelintrc.json",
    "rules": {
        "selector-pseudo-element-colon-notation": null,
        "declaration-colon-space-after": null
    }
}
// This is the extended file
{
    "rules": {
        "indendation": "tab" // This will not be applied
    }
}

Instead, stylefmt will use the default of two spaces for indentation.

hejmartin commented 8 years ago

@morishitter This seems to be true for other rules as well, such as string-quotes. I can work around it by copying rules from my base config file, but it would be nice if it worked.