lib/scss_lint/linter/name_format.rb in scss-lint-0.30.0 vs lib/scss_lint/linter/name_format.rb in scss-lint-0.31.0
- old
+ new
@@ -44,13 +44,24 @@
skewX skewY
translateX translateY translateZ
].to_set
def check_name(node, node_type, node_text = node.name)
+ node_text = trim_underscore_prefix(node_text)
return unless violation = violated_convention(node_text)
add_lint(node, "Name of #{node_type} `#{node_text}` should be " \
"written #{violation[:explanation]}")
+ end
+
+ # Removes underscore prefix from name if leading underscores are allowed.
+ def trim_underscore_prefix(name)
+ if config['allow_leading_underscore']
+ # Remove if there is a single leading underscore
+ name = name.gsub(/^_(?!_)/, '')
+ end
+
+ name
end
def check_placeholder(node)
extract_string_selectors(node.selector).any? do |selector_str|
check_name(node, 'placeholder', selector_str.gsub('%', ''))