Skip to content

Commit

Permalink
Fix configuration list defining to override instead of merge
Browse files Browse the repository at this point in the history
When setting a list value in a custom configuration, `scss-lint` would
merge the value instead of overriding it.

This makes it impossible to remove unwanted values from lists in the
default configuration.

Admittedly, it's pretty surprising we haven't gotten a bug report about
this until now, given this behavior has existed since the configuration
system was added to `scss-lint`.
  • Loading branch information
sds committed Apr 15, 2015
1 parent 28b3b1e commit d59353c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# SCSS-Lint Changelog

## master (unreleased)

* Change configuration loading behavior so that defining lists in a custom
configuration will completely override the old list instead of adding to it

## 0.37.0

* Rename `BEM` option on `SelectorFormat` to `strict_BEM` to emphasize that
Expand Down
2 changes: 0 additions & 2 deletions lib/scss_lint/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ def load_file_contents(file)
def smart_merge(parent, child)
parent.merge(child) do |_key, old, new|
case old
when Array
old + new
when Hash
smart_merge(old, new)
else
Expand Down
13 changes: 13 additions & 0 deletions spec/scss_lint/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class FakeLinter2 < SCSSLint::Linter; end
linters:
FakeConfigLinter:
enabled: true
list: [1, 2, 3]
OtherFakeConfigLinter:
enabled: false
FILE
Expand Down Expand Up @@ -104,6 +105,18 @@ class FakeLinter2 < SCSSLint::Linter; end
end
end

context 'with a config file setting a list value different from the default' do
let(:config_file) { <<-FILE }
linters:
FakeConfigLinter:
list: [4, 5, 6]
FILE

it 'overrides the default value with the new value' do
subject.options['linters']['FakeConfigLinter']['list'].should == [4, 5, 6]
end
end

context 'when a wildcard is used for a namespaced linter' do
let(:default_file) { <<-FILE }
linters:
Expand Down

0 comments on commit d59353c

Please sign in to comment.