gems.scss_lint-0.57.0.lib.scss_lint.linter.chained_classes.rb Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sass-maven-plugin Show documentation
Show all versions of sass-maven-plugin Show documentation
A Maven Plugin that compiles Sass files.
module SCSSLint
# Checks for uses of chained classes (e.g. .foo.bar).
class Linter::ChainedClasses < Linter
include LinterRegistry
def visit_sequence(sequence)
line_offset = 0
sequence.members.each do |member|
line_offset += 1 if member =~ /\n/
next unless chained_class?(member)
add_lint(member.line + line_offset,
'Prefer using a distinct class over chained classes ' \
'(e.g. .new-class over .foo.bar')
end
end
private
def chained_class?(simple_sequence)
return unless simple_sequence.is_a?(Sass::Selector::SimpleSequence)
simple_sequence.members.count { |member| member.is_a?(Sass::Selector::Class) } >= 2
end
end
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy