scss-lint 0.15.0 → 0.16.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1861dcef7f2f3be9166fd44664791979a1f1f7b
4
- data.tar.gz: 032466f84b7ad63144ebf038d86e5b7b26455dd6
3
+ metadata.gz: 62de0759332c7a6b7f6875564132d5a57d279ec7
4
+ data.tar.gz: 7ddb756b1a9f1fb8ce38dfa1809e78d64cade852
5
5
  SHA512:
6
- metadata.gz: 522188c952f6be108b512e9b606472227e91ccaa9766c223116592d52ba18f30b91ba201cf657ba77da35575914bf16b47c25af1ddf154f72bbe6ff7b3427353
7
- data.tar.gz: 4e13aa18990e381d7e8a7d5316975daac70dc2525d7ebdbe24d47bd64786a4f6a4d2151b1e84f2144492bb8a26850bd3318e45eeef4566d49301f0f313f12a73
6
+ metadata.gz: b432b1c02ea96468df966153142aee54cef52da51b184f1dab3dc019e54d6022a3e3f9ee184d70a36e2a4c928dcc41f78df7515f7d9b748b9fc1e09196aacfea
7
+ data.tar.gz: 2377c8e052114ac59e5b9b85d67a3e93d15b64a1bcbeb6109c694a6b81a9a0ffb31b3d341bcf640b70116aa8d5bcda9a2938de4e57c85b2c8d6405f20f92a67e
data/config/default.yml CHANGED
@@ -24,6 +24,9 @@ linters:
24
24
  DuplicateProperty:
25
25
  enabled: true
26
26
 
27
+ EmptyLineBetweenBlocks:
28
+ enabled: true
29
+
27
30
  EmptyRule:
28
31
  enabled: true
29
32
 
@@ -45,6 +48,7 @@ linters:
45
48
 
46
49
  PropertySpelling:
47
50
  enabled: true
51
+ extra_properties: []
48
52
 
49
53
  SelectorDepth:
50
54
  enabled: true
@@ -1,6 +1,7 @@
1
1
  # Global application constants.
2
2
  module SCSSLint
3
3
  SCSS_LINT_HOME = File.realpath(File.join(File.dirname(__FILE__), '..', '..'))
4
+ SCSS_LINT_DATA = File.join(SCSS_LINT_HOME, 'data')
4
5
 
5
6
  REPO_URL = 'https://github.com/causes/scss-lint'
6
7
  BUG_REPORT_URL = "#{REPO_URL}/issues"
@@ -0,0 +1,83 @@
1
+ module SCSSLint
2
+ # Reports the lack of empty lines between block defintions.
3
+ class Linter::EmptyLineBetweenBlocks < Linter
4
+ include LinterRegistry
5
+
6
+ def visit_function(node)
7
+ check(node, '@function')
8
+ yield
9
+ end
10
+
11
+ def visit_mixin(node)
12
+ # Ignore @includes which don't have any block content
13
+ check(node, '@include') if node.children
14
+ .any? { |child| child.is_a?(Sass::Tree::Node) }
15
+ yield
16
+ end
17
+
18
+ def visit_mixindef(node)
19
+ check(node, '@mixin')
20
+ yield
21
+ end
22
+
23
+ def visit_rule(node)
24
+ check(node, 'Rule')
25
+ yield
26
+ end
27
+
28
+ private
29
+
30
+ MESSAGE_FORMAT = '%s declaration should be %s by an empty line'
31
+
32
+ def check(node, type)
33
+ check_preceding_node(node, type)
34
+ check_following_node(node, type)
35
+ end
36
+
37
+ def check_following_node(node, type)
38
+ if (following_node = next_node(node)) && (next_start_line = following_node.line)
39
+ unless engine.lines[next_start_line - 2].strip.empty?
40
+ add_lint(next_start_line - 1, MESSAGE_FORMAT % [type, 'followed'])
41
+ end
42
+ end
43
+ end
44
+
45
+ # In cases where the previous node is not a block declaration, we won't
46
+ # have run any checks against it, so we need to check here if the previous
47
+ # line is an empty line
48
+ def check_preceding_node(node, type)
49
+ case prev_node(node)
50
+ when
51
+ nil,
52
+ Sass::Tree::FunctionNode,
53
+ Sass::Tree::MixinNode,
54
+ Sass::Tree::MixinDefNode,
55
+ Sass::Tree::RuleNode,
56
+ Sass::Tree::CommentNode
57
+ # Ignore
58
+ else
59
+ unless engine.lines[node.line - 2].strip.empty?
60
+ add_lint(node.line, MESSAGE_FORMAT % [type, 'preceded'])
61
+ end
62
+ end
63
+ end
64
+
65
+ def next_node(node)
66
+ return unless siblings = node_siblings(node)
67
+ siblings[siblings.index(node) + 1] if siblings.count > 1
68
+ end
69
+
70
+ def prev_node(node)
71
+ return unless siblings = node_siblings(node)
72
+ index = siblings.index(node)
73
+ siblings[index - 1] if index > 0 && siblings.count > 1
74
+ end
75
+
76
+ def node_siblings(node)
77
+ return unless node && node.node_parent
78
+ node.node_parent
79
+ .children
80
+ .select { |child| child.is_a?(Sass::Tree::Node) }
81
+ end
82
+ end
83
+ end
@@ -3,6 +3,11 @@ module SCSSLint
3
3
  class Linter::PropertySpelling < Linter
4
4
  include LinterRegistry
5
5
 
6
+ def visit_root(node)
7
+ @extra_properties = config['extra_properties'].to_set
8
+ yield # Continue linting children
9
+ end
10
+
6
11
  def visit_prop(node)
7
12
  # Ignore properties with interpolation
8
13
  return if node.name.count > 1 || !node.name.first.is_a?(String)
@@ -12,269 +17,16 @@ module SCSSLint
12
17
  # Ignore vendor-prefixed properties
13
18
  return if name.start_with?('-')
14
19
 
15
- unless KNOWN_PROPERTIES.include?(name)
20
+ unless KNOWN_PROPERTIES.include?(name) || @extra_properties.include?(name)
16
21
  add_lint(node, "Unknown property #{name}")
17
22
  end
18
23
  end
19
24
 
20
25
  private
21
26
 
22
- KNOWN_PROPERTIES = %w[
23
- @keyframes
24
- alignment-adjust
25
- alignment-baseline
26
- animation
27
- animation-delay
28
- animation-direction
29
- animation-duration
30
- animation-fill-mode
31
- animation-iteration-count
32
- animation-name
33
- animation-play-state
34
- animation-timing-function
35
- appearance
36
- backface-visibility
37
- background
38
- background-attachment
39
- background-clip
40
- background-color
41
- background-image
42
- background-origin
43
- background-position
44
- background-repeat
45
- background-size
46
- baseline-shift
47
- bookmark-label
48
- bookmark-level
49
- bookmark-target
50
- border
51
- border-bottom
52
- border-bottom-color
53
- border-bottom-left-radius
54
- border-bottom-right-radius
55
- border-bottom-style
56
- border-bottom-width
57
- border-collapse
58
- border-color
59
- border-image
60
- border-image-outset
61
- border-image-repeat
62
- border-image-slice
63
- border-image-source
64
- border-image-width
65
- border-left
66
- border-left-color
67
- border-left-style
68
- border-left-width
69
- border-radius
70
- border-right
71
- border-right-color
72
- border-right-style
73
- border-right-width
74
- border-spacing
75
- border-style
76
- border-top
77
- border-top-color
78
- border-top-left-radius
79
- border-top-right-radius
80
- border-top-style
81
- border-top-width
82
- border-width
83
- bottom
84
- box-align
85
- box-decoration-break
86
- box-direction
87
- box-flex
88
- box-flex-group
89
- box-lines
90
- box-ordinal-group
91
- box-orient
92
- box-pack
93
- box-shadow
94
- box-sizing
95
- caption-side
96
- clear
97
- clip
98
- color
99
- color-profile
100
- column-count
101
- column-fill
102
- column-gap
103
- column-rule
104
- column-rule-color
105
- column-rule-style
106
- column-rule-width
107
- column-span
108
- column-width
109
- columns
110
- content
111
- counter-increment
112
- counter-reset
113
- crop
114
- cursor
115
- direction
116
- display
117
- dominant-baseline
118
- drop-initial-after-adjust
119
- drop-initial-after-align
120
- drop-initial-before-adjust
121
- drop-initial-before-align
122
- drop-initial-size
123
- drop-initial-value
124
- empty-cells
125
- fill
126
- filter
127
- fit
128
- fit-position
129
- float
130
- float-offset
131
- font
132
- font-family
133
- font-size
134
- font-size-adjust
135
- font-stretch
136
- font-style
137
- font-variant
138
- font-weight
139
- grid-columns
140
- grid-rows
141
- hanging-punctuation
142
- height
143
- hyphenate-after
144
- hyphenate-before
145
- hyphenate-character
146
- hyphenate-lines
147
- hyphenate-resource
148
- hyphens
149
- icon
150
- image-orientation
151
- image-resolution
152
- inline-box-align
153
- left
154
- letter-spacing
155
- line-height
156
- line-stacking
157
- line-stacking-ruby
158
- line-stacking-shift
159
- line-stacking-strategy
160
- list-style
161
- list-style-image
162
- list-style-position
163
- list-style-type
164
- margin
165
- margin-bottom
166
- margin-left
167
- margin-right
168
- margin-top
169
- mark
170
- mark-after
171
- mark-before
172
- marks
173
- marquee-direction
174
- marquee-play-count
175
- marquee-speed
176
- marquee-style
177
- max-height
178
- max-width
179
- min-height
180
- min-width
181
- move-to
182
- nav-down
183
- nav-index
184
- nav-left
185
- nav-right
186
- nav-up
187
- opacity
188
- orphans
189
- outline
190
- outline-color
191
- outline-offset
192
- outline-style
193
- outline-width
194
- overflow
195
- overflow-style
196
- overflow-x
197
- overflow-y
198
- padding
199
- padding-bottom
200
- padding-left
201
- padding-right
202
- padding-top
203
- page
204
- page-break-after
205
- page-break-before
206
- page-break-inside
207
- page-policy
208
- perspective
209
- perspective-origin
210
- phonemes
211
- pointer-events
212
- position
213
- punctuation-trim
214
- quotes
215
- rendering-intent
216
- resize
217
- rest
218
- rest-after
219
- rest-before
220
- right
221
- rotation
222
- rotation-point
223
- ruby-align
224
- ruby-overhang
225
- ruby-position
226
- ruby-span
227
- shape-rendering
228
- size
229
- speak
230
- src
231
- stroke
232
- stroke-width
233
- string-set
234
- table-layout
235
- target
236
- target-name
237
- target-new
238
- target-position
239
- text-align
240
- text-align-last
241
- text-decoration
242
- text-height
243
- text-indent
244
- text-justify
245
- text-outline
246
- text-overflow
247
- text-rendering
248
- text-shadow
249
- text-transform
250
- text-wrap
251
- top
252
- transform
253
- transform-origin
254
- transform-style
255
- transition
256
- transition-delay
257
- transition-duration
258
- transition-property
259
- transition-timing-function
260
- unicode-bidi
261
- vertical-align
262
- visibility
263
- voice-balance
264
- voice-duration
265
- voice-pitch
266
- voice-pitch-range
267
- voice-rate
268
- voice-stress
269
- voice-volume
270
- white-space
271
- widows
272
- width
273
- word-break
274
- word-spacing
275
- word-wrap
276
- z-index
277
- zoom
278
- ]
27
+ KNOWN_PROPERTIES = File.open(File.join(SCSS_LINT_DATA, 'properties.txt'))
28
+ .read
29
+ .split
30
+ .to_set
279
31
  end
280
32
  end
@@ -6,8 +6,15 @@ module SCSSLint
6
6
  def visit_root(node)
7
7
  @spaces = config['spaces']
8
8
  engine.lines.each_with_index do |line, index|
9
- line.scan /(\( *[^ ]|[^\s] *\))/ do |match|
10
- match.each { |str| check(str, index, engine) }
9
+ line.scan(/
10
+ (^(\t|\s)*\))? # Capture leading spaces and tabs followed by a `)`
11
+ (
12
+ \([ ]*(?!$) # Find `( ` as long as its not EOL )
13
+ |
14
+ [ ]*\)
15
+ )?
16
+ /x) do |match|
17
+ check(match[2], index, engine) if match[2]
11
18
  end
12
19
  end
13
20
  end
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module SCSSLint
3
- VERSION = '0.15.0'
3
+ VERSION = '0.16.0'
4
4
  end
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.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Causes Engineering
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-01 00:00:00.000000000 Z
12
+ date: 2014-01-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
@@ -100,6 +100,7 @@ files:
100
100
  - lib/scss_lint/linter/trailing_semicolon_after_property_value.rb
101
101
  - lib/scss_lint/linter/shorthand.rb
102
102
  - lib/scss_lint/linter/id_with_extraneous_selector.rb
103
+ - lib/scss_lint/linter/empty_line_between_blocks.rb
103
104
  - lib/scss_lint/linter/declaration_order.rb
104
105
  - lib/scss_lint/linter/zero_unit.rb
105
106
  - lib/scss_lint/linter/placeholder_in_extend.rb