stylefmt icon indicating copy to clipboard operation
stylefmt copied to clipboard

Option to follow only rules described in .stylelintrc

Open cbrwizard opened this issue 8 years ago • 9 comments

Hey, it's great that you added support for .stylelintrc! I started using it in my project and I have noticed that, apparently, stylefmt uses a merging strategy when choosing rules: it follows .stylelintrc rules and also applies stylefmt's standard ones for the rules it didn't find/recognize in .stylelintrc. For instance, I follow stylelint-config-standard rules, where a block like

.selector-x { width: 10%; }

is allowed. Having a .stylelintrc with these simple contents

{
  "extends": "stylelint-config-standard"
}

does not raise an error or a warning when running stylelint for a block like the one ^. However, it gets auto formatted into

.selector-x { 
  width: 10%;
}

when I run stylefmt.

I think it would be great if there was a CLI option --only-stylelint or something like that which when passed would force stylefmt to format only the rules found/recognized in .stylelintrc file and do not do anything extra.

cbrwizard avatar Apr 06 '16 19:04 cbrwizard

@cbrwizard nice idea, I'd be interested in this as well.

s10wen avatar Jun 22 '16 07:06 s10wen

This tool is a strong candidate at my organization, but the enforcement of default rules is a current point of contention. Stylelint does explicitly state that rules are off by default, where as stylefmt will have default values applied for rules even if they are omitted. This seems to be a design difference between stylefmt and the project it is based off of.

Are there plans to realign this difference and allow rules to be off unless they are turned on, such as how stylelint works?

And maybe a better question, would you even want PRs that try to add this behavior? :smile:

gjjones avatar Jul 14 '16 12:07 gjjones

Now, stylefmt can handle many stylelint rules, so I decided to implement --onlyStylelint option. :)

matype avatar Jul 29 '16 02:07 matype

Same issue here. It makes Stylefmt format all places, which are acceptable by Stylelint config file.

It would be great to see --onlyStylelint, but I'd say it would be more appropriate to make external config file mandatory and instead add --defaultRules which will apply default rules, because so far Stylefmt goings against Stylelint paradigm, where config isn't default, but completely declarative.

ArmorDarks avatar Aug 09 '16 14:08 ArmorDarks

I'd like to see stylefmt have no rules set by default, then you can choose to enable the rules in the .stylelintrc / stylefmt as required.

s10wen avatar Aug 10 '16 08:08 s10wen

Is this fixed ? I have the same issue. Thanks

mparpaillon avatar Nov 24 '16 17:11 mparpaillon

I'm also confused about the state of this issue, and I think it's a vital one to address. Stylefmt making opinionated changes to code that on occasion directly counter what is set in .stylelintrc seems wrong.

Take, for example, this Stylelint setting: "value-list-comma-newline-after": "always" This enforces that any declaration with multiple values be formatted on multiple lines. However, Stylefmt automatically reformats value lists to be on one line. So in this case, Stylefmt actually creates a linting error.

I think it's essential that Stylefmt becomes a no-defaults tool so that it is in sync with the tool it uses for configuration.

evanwarner avatar Dec 09 '16 21:12 evanwarner

@morishitter can you confirm, is --onlyStylelint in the current version (just checking as nothing in the readme regarding it). Thanks for this great tool 👍

benfrain avatar Mar 03 '17 16:03 benfrain

@benfrain; I'm afraid not... I can't seem to find it anywhere in the repository: https://github.com/morishitter/stylefmt/search?utf8=%E2%9C%93&q=onlyStylelint.

@morishitter, an update on this would be greatly appreciated.

cascornelissen avatar Mar 21 '17 10:03 cascornelissen