forked from sds/scss-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pseudo_element.rb
24 lines (22 loc) · 929 Bytes
/
pseudo_element.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module SCSSLint
# Checks for the use of double colons with pseudo elements.
class Linter::PseudoElement < Linter
include LinterRegistry
# https://msdn.microsoft.com/en-us/library/windows/apps/hh767361.aspx
# https://developer.mozilla.org/en-US/docs/Web/CSS/Mozilla_Extensions
# http://tjvantoll.com/2013/04/15/list-of-pseudo-elements-to-style-form-controls/
PSEUDO_ELEMENTS = File.open(File.join(SCSS_LINT_DATA, 'pseudo-elements.txt'))
.read
.split
.to_set
def visit_pseudo(pseudo)
if PSEUDO_ELEMENTS.include?(pseudo.name)
return if pseudo.syntactic_type == :element
add_lint(pseudo, 'Begin pseudo elements with double colons: `::`')
else
return if pseudo.syntactic_type != :element
add_lint(pseudo, 'Begin pseudo classes with a single colon: `:`')
end
end
end
end