sds / scss-lint

Configurable tool for writing clean, consistent SCSS
MIT License
3.66k stars 465 forks source link

Feature request: Support specifying vendor prefixes with property sort order #511

Open kristerkari opened 9 years ago

kristerkari commented 9 years ago

I looks like scss-lint ignores vendor prefixes if they're specified in the order config for PropertySortOrder linter.

Here is a failing test that I wrote (I'm not sure if it is correct, I tried to write it the same way as the other tests):

  context 'when the order includes vendor prefixes' do
    let(:linter_config) { {
      'order' => %w["-ms-animation-delay" "-webkit-animation-delay" "-moz-animation-delay" "animation-delay"]
    } }

    context 'and the properties match the specified order' do
      let(:scss) { <<-SCSS }
        p {
          -ms-animation-delay: 1s;
          -webkit-animation-delay: 1s;
          -moz-animation-delay: 1s;
          animation-delay: 1s;
        }
      SCSS

      it { should_not report_lint }
    end

    context 'and the properties do not match the specified order' do
      let(:scss) { <<-SCSS }
        p {
          -ms-animation-delay: 1s;
          -moz-animation-delay: 1s;
          -webkit-animation-delay: 1s;
          animation-delay: 1s;
        }
      SCSS

      it { should report_lint line: 3 }
    end

  end
sds commented 9 years ago

Hey @kristerkari,

We explicitly ignore vendor prefixes because it seems like overkill to specify their exact order. Being able to just write animation-delay in your order list, and automatically ordering the -moz-*, -ms-*, and -webkit-*, prefixes to be in alphabetical order saves you a lot of typing in the order list.

Is there a strong reason you need to order the vendor prefixes a certain way?

kristerkari commented 9 years ago

Is there a strong reason you need to order the vendor prefixes a certain way?

I was converting existing configuration from csscomb -> scss-lint, and it includes prefixes. The problem is that csscomb will order the prefixes in the specified order, but then scss-lint will give linting errors if the order is not what it expects (it ignores the prefix ordering that coverted csscomb config has).

So, having this feature would make scss-lint work correctly when existing csscomb configuration is used.

sds commented 9 years ago

Thanks for clarifying, @kristerkari. Happy to accept a pull request that implements this feature.