lib/scss_lint/linter/shorthand.rb in scss-lint-0.23.1 vs lib/scss_lint/linter/shorthand.rb in scss-lint-0.24.0
- old
+ new
@@ -35,29 +35,27 @@
value = literal.value
# HACK: node_parent may not be initialized at this point, so we need to
# set it ourselves
value.node_parent = literal
+ return unless value.is_a?(Sass::Script::Value::String)
- if value.is_a?(Sass::Script::Value::String)
- check_script_string(prop, value)
- end
+ check_script_string(prop, value)
end
- LIST_LITERAL_REGEX = %r{
+ LIST_LITERAL_REGEX = /
\A
(\S+\s+\S+(\s+\S+){0,2}) # Two to four values separated by spaces
(\s+!\w+)? # Ignore `!important` priority overrides
\z
- }x
+ /x
def check_script_string(prop, script_string)
return unless script_string.type == :identifier
+ return unless values = script_string.value.strip[LIST_LITERAL_REGEX, 1]
- if values = script_string.value.strip[LIST_LITERAL_REGEX, 1]
- check_shorthand(prop, script_string, values.split)
- end
+ check_shorthand(prop, script_string, values.split)
end
def check_shorthand(prop, node, values)
return unless (2..4).member?(values.count)
@@ -80,13 +78,13 @@
[top, right, bottom, left].compact
end
end
def can_condense_to_one_value(top, right, bottom, left)
- if top == right
- top == bottom && (bottom == left || left.nil?) ||
- bottom.nil? && left.nil?
- end
+ return unless top == right
+
+ top == bottom && (bottom == left || left.nil?) ||
+ bottom.nil? && left.nil?
end
def can_condense_to_two_values(top, right, bottom, left)
top == bottom && right == left ||
top == bottom && left.nil? && top != right