scss-lint 0.4 → 0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'sass'
|
2
|
+
require 'set'
|
3
|
+
|
4
|
+
module SCSSLint
|
5
|
+
class Linter::DuplicateSelectorLinter < Linter
|
6
|
+
include LinterRegistry
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def run(engine)
|
10
|
+
lints = []
|
11
|
+
engine.tree.each do |node|
|
12
|
+
if node.is_a?(Sass::Tree::RuleNode)
|
13
|
+
lints << check_selector_already_used(node)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
lints.compact
|
17
|
+
end
|
18
|
+
|
19
|
+
def description
|
20
|
+
'Rule was declared with same selector as another--you should merge them'
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def check_selector_already_used(rule_node)
|
26
|
+
#selectors_seen = Set.new
|
27
|
+
|
28
|
+
puts rule_node.rule.inspect
|
29
|
+
puts rule_node.resolved_rules
|
30
|
+
|
31
|
+
#rule_node.children.each do |child|
|
32
|
+
#selectors = child.rule.first.to_s.gsub(/\s/, '')
|
33
|
+
|
34
|
+
#if selectors_seen.member?(selectors)
|
35
|
+
#return create_lint(child)
|
36
|
+
#else
|
37
|
+
#selectors_seen.add selectors
|
38
|
+
#end
|
39
|
+
#end
|
40
|
+
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -23,23 +23,24 @@ module SCSSLint
|
|
23
23
|
|
24
24
|
def check_valid_shorthand_value(prop_node)
|
25
25
|
if prop_node.value.is_a?(Sass::Script::String) &&
|
26
|
-
prop_node.value.to_s.strip =~ /\A(\S+\s+\S
|
26
|
+
prop_node.value.to_s.strip =~ /\A(\S+\s+\S+(\s+\S+){0,2})\Z/
|
27
27
|
return create_lint(prop_node) unless valid_shorthand?($1)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
def valid_shorthand?(shorthand)
|
32
32
|
values = shorthand.split(/\s+/)
|
33
|
+
top, right, bottom, left = values
|
33
34
|
|
34
|
-
if
|
35
|
-
values[1] == values[2] &&
|
36
|
-
values[2] == values[3]
|
35
|
+
if top == right && right == bottom && bottom == left
|
37
36
|
false
|
38
|
-
elsif
|
37
|
+
elsif top == right && bottom.nil? && left.nil?
|
39
38
|
false
|
40
|
-
elsif
|
39
|
+
elsif top == bottom && right == left
|
41
40
|
false
|
42
|
-
elsif
|
41
|
+
elsif top == bottom && left.nil?
|
42
|
+
false
|
43
|
+
elsif right == left
|
43
44
|
false
|
44
45
|
else
|
45
46
|
true
|
data/lib/scss_lint/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scss-lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colorize
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/scss_lint/lint.rb
|
74
74
|
- lib/scss_lint/linter.rb
|
75
75
|
- lib/scss_lint/linter/declaration_order_linter.rb
|
76
|
+
- lib/scss_lint/linter/duplicate_selector_linter.rb
|
76
77
|
- lib/scss_lint/linter/empty_rule_linter.rb
|
77
78
|
- lib/scss_lint/linter/debug_linter.rb
|
78
79
|
- lib/scss_lint/linter/single_line_per_selector_linter.rb
|