Sha256: 033ad8d8e654819803fa92883e82a04f0b88fdf0b12e1414899379f542ae9c6e
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
require 'sass' module SCSSLint class Linter::ShorthandLinter < Linter include LinterRegistry def visit_prop(node) unless SHORTHANDABLE_PROPERTIES.include? node.name.first.to_s return end if node.value.to_sass.strip =~ /\A(\S+\s+\S+(\s+\S+){0,2})\Z/ add_lint(node) unless valid_shorthand?($1) end end def description 'Property values should use the shortest shorthand syntax allowed' end private SHORTHANDABLE_PROPERTIES = %w[border-color border-radius border-style border-width margin padding] def valid_shorthand?(shorthand) values = shorthand.split(/\s+/) top, right, bottom, left = values if top == right && right == bottom && bottom == left false elsif top == right && bottom.nil? && left.nil? false elsif top == bottom && right == left false elsif top == bottom && left.nil? false elsif right == left false else true end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
scss-lint-0.6.7 | lib/scss_lint/linter/shorthand_linter.rb |
scss-lint-0.6.6 | lib/scss_lint/linter/shorthand_linter.rb |
scss-lint-0.6.5 | lib/scss_lint/linter/shorthand_linter.rb |