lib/scss_lint/linter/shorthand_linter.rb in scss-lint-0.4 vs lib/scss_lint/linter/shorthand_linter.rb in scss-lint-0.5
- old
+ new
@@ -21,26 +21,27 @@
private
def check_valid_shorthand_value(prop_node)
if prop_node.value.is_a?(Sass::Script::String) &&
- prop_node.value.to_s.strip =~ /\A(\S+\s+\S+\s+\S+(\s+\S+)?)\Z/
+ prop_node.value.to_s.strip =~ /\A(\S+\s+\S+(\s+\S+){0,2})\Z/
return create_lint(prop_node) unless valid_shorthand?($1)
end
end
def valid_shorthand?(shorthand)
values = shorthand.split(/\s+/)
+ top, right, bottom, left = values
- if values[0] == values[1] &&
- values[1] == values[2] &&
- values[2] == values[3]
+ if top == right && right == bottom && bottom == left
false
- elsif values[0] == values[2] && values[1] == values[3]
+ elsif top == right && bottom.nil? && left.nil?
false
- elsif values[0] == values[2] && values[3].nil?
+ elsif top == bottom && right == left
false
- elsif values[1] == values[3]
+ elsif top == bottom && left.nil?
+ false
+ elsif right == left
false
else
true
end
end