scss-lint 0.12.0 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5efc8809d431b7de019112e2771839116d88df95
4
- data.tar.gz: d54b6ba942585c4fbdc969c389af86e0da47088c
3
+ metadata.gz: 1649ab811a945a99099b9d000b14059532b28365
4
+ data.tar.gz: fae32ee4b1704070dd7a84f3a4b2a1e353d0c0ad
5
5
  SHA512:
6
- metadata.gz: 406a4cd62baa39e5dc561c5cd84cedc7ef7b4d64a0b8813a693c22fb3192640f0382b3a839f317fdbe0f75738c6ed53b3f494bd5e9c32ed50f79833841e76f43
7
- data.tar.gz: e0c8b74d3cf6bb80f592cfacc9ed25fe642b397e36ca9e965ee31a4889a8291ea2b88334aba45aae0c4eaf5cf52c610150bf6bc0b2ecd5b6af92aa4547ea21b5
6
+ metadata.gz: cbb264e07bd5c093f54bcd5dad3ff02e990441a734684bee27dbdf1404ea71e7b14d0234bf551ad48bc2ba050478b5fc9ee1feed028a55e01e1d9a08970b8d28
7
+ data.tar.gz: 9334e0f4b9bedfcdcfb02edb653fbd0d3136986815647047ca19b1607f5f569398473feb7efead4d62d19efb942bfe0b161440a48d2b184f43c74c2b370a4bd2
@@ -1,52 +1,27 @@
1
- require 'find'
2
-
3
- module SCSSLint
4
- autoload :CLI, 'scss_lint/cli'
5
- autoload :Engine, 'scss_lint/engine'
6
- autoload :Lint, 'scss_lint/lint'
7
- autoload :LinterRegistry, 'scss_lint/linter_registry'
8
- autoload :Linter, 'scss_lint/linter'
9
- autoload :Reporter, 'scss_lint/reporter'
10
- autoload :Runner, 'scss_lint/runner'
11
- autoload :SelectorVisitor, 'scss_lint/selector_visitor'
12
- autoload :Utils, 'scss_lint/utils'
13
-
14
- require 'scss_lint/constants'
15
- require 'scss_lint/version'
16
-
17
- # Preload Sass so we can monkey patch it
18
- require 'sass'
19
- require File.expand_path('scss_lint/sass/script', File.dirname(__FILE__))
20
- require File.expand_path('scss_lint/sass/tree', File.dirname(__FILE__))
21
-
22
- # Load all linters
23
- Dir[File.expand_path('scss_lint/linter/*.rb', File.dirname(__FILE__))].each do |file|
24
- require file
25
- end
26
-
27
- # Load all reporters
28
- Dir[File.expand_path('scss_lint/reporter/*.rb', File.dirname(__FILE__))].each do |file|
29
- require file
30
- end
31
-
32
- class << self
33
- def extract_files_from(list)
34
- files = []
35
- list.each do |file|
36
- Find.find(file) do |f|
37
- files << f if scssish_file?(f)
38
- end
39
- end
40
- files.uniq
41
- end
42
-
43
- private
44
-
45
- VALID_EXTENSIONS = %w[.css .scss]
46
- def scssish_file?(file)
47
- return false unless FileTest.file?(file)
1
+ require 'scss_lint/constants'
2
+ require 'scss_lint/cli'
3
+ require 'scss_lint/engine'
4
+ require 'scss_lint/lint'
5
+ require 'scss_lint/linter_registry'
6
+ require 'scss_lint/runner'
7
+ require 'scss_lint/selector_visitor'
8
+ require 'scss_lint/version'
9
+ require 'scss_lint/utils'
10
+
11
+ # Preload Sass so we can monkey patch it
12
+ require 'sass'
13
+ require File.expand_path('scss_lint/sass/script', File.dirname(__FILE__))
14
+ require File.expand_path('scss_lint/sass/tree', File.dirname(__FILE__))
15
+
16
+ # Load all linters in sorted order, since ordering matters and some systems
17
+ # return the files in an order which loads a child class before the parent.
18
+ require 'scss_lint/linter'
19
+ Dir[File.expand_path('scss_lint/linter/**/*.rb', File.dirname(__FILE__))].sort.each do |file|
20
+ require file
21
+ end
48
22
 
49
- VALID_EXTENSIONS.include?(File.extname(file))
50
- end
51
- end
23
+ # Load all reporters
24
+ require 'scss_lint/reporter'
25
+ Dir[File.expand_path('scss_lint/reporter/*.rb', File.dirname(__FILE__))].sort.each do |file|
26
+ require file
52
27
  end
@@ -1,3 +1,4 @@
1
+ require 'find'
1
2
  require 'optparse'
2
3
 
3
4
  module SCSSLint
@@ -80,11 +81,28 @@ module SCSSLint
80
81
  def find_files
81
82
  excluded_files = options.fetch(:excluded_files, [])
82
83
 
83
- SCSSLint.extract_files_from(options[:files]).reject do |file|
84
+ extract_files_from(options[:files]).reject do |file|
84
85
  excluded_files.include?(file)
85
86
  end
86
87
  end
87
88
 
89
+ def extract_files_from(list)
90
+ files = []
91
+ list.each do |file|
92
+ Find.find(file) do |f|
93
+ files << f if scssish_file?(f)
94
+ end
95
+ end
96
+ files.uniq
97
+ end
98
+
99
+ VALID_EXTENSIONS = %w[.css .scss]
100
+ def scssish_file?(file)
101
+ return false unless FileTest.file?(file)
102
+
103
+ VALID_EXTENSIONS.include?(File.extname(file))
104
+ end
105
+
88
106
  def report_lints(lints)
89
107
  sorted_lints = lints.sort_by { |l| [l.filename, l.line] }
90
108
  reporter = options.fetch(:reporter, Reporter::DefaultReporter).new(sorted_lints)
@@ -0,0 +1,7 @@
1
+ module SCSSLint
2
+ # Superclass for linters that apply to codebases using the Compass framework.
3
+ #
4
+ # Any shared code/constants amongst Compass linters should be stored here.
5
+ class Linter::Compass < Linter
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ module SCSSLint
2
+ # Checks for uses of properties where a Compass mixin would be preferred.
3
+ class Linter::Compass::PropertyWithMixin < Linter::Compass
4
+ include LinterRegistry
5
+
6
+ def visit_prop(node)
7
+ prop_name = node.name.join
8
+
9
+ if PROPERTIES_WITH_MIXINS.include?(prop_name)
10
+ add_lint node, "Use the Compass `#{prop_name}` mixin instead of the property"
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ # Set of properties where the Compass mixin version is preferred
17
+ PROPERTIES_WITH_MIXINS = %w[
18
+ background-clip
19
+ background-origin
20
+ border-radius
21
+ box-shadow
22
+ box-sizing
23
+ opacity
24
+ text-shadow
25
+ transform
26
+ ].to_set
27
+ end
28
+ end
@@ -10,10 +10,7 @@ module SCSSLint
10
10
 
11
11
  case node.value
12
12
  when Sass::Script::Tree::Literal
13
- # HACK: node_parent may not be initialized at this point, so we need to
14
- # set it ourselves
15
- node.value.value.node_parent = node.value
16
- check_script_string(property_name, node.value.value)
13
+ check_script_literal(property_name, node.value)
17
14
  when Sass::Script::Tree::ListLiteral
18
15
  check_script_list(property_name, node.value)
19
16
  end
@@ -34,6 +31,18 @@ module SCSSLint
34
31
  check_shorthand(prop, list, list.children.map(&:to_sass))
35
32
  end
36
33
 
34
+ def check_script_literal(prop, literal)
35
+ value = literal.value
36
+
37
+ # HACK: node_parent may not be initialized at this point, so we need to
38
+ # set it ourselves
39
+ value.node_parent = literal
40
+
41
+ if value.is_a?(Sass::Script::Value::String)
42
+ check_script_string(prop, value)
43
+ end
44
+ end
45
+
37
46
  def check_script_string(prop, script_string)
38
47
  return unless script_string.type == :identifier
39
48
 
@@ -49,7 +49,8 @@ module SCSSLint
49
49
  linter.run(engine)
50
50
  rescue => error
51
51
  raise LinterError,
52
- "#{linter.class} raised unexpected error: '#{error.message}'",
52
+ "#{linter.class} raised unexpected error linting file #{file}: " <<
53
+ "'#{error.message}'",
53
54
  error.backtrace
54
55
  end
55
56
  end
@@ -1,3 +1,3 @@
1
1
  module SCSSLint
2
- VERSION = '0.12.0'
2
+ VERSION = '0.12.1'
3
3
  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.12.0
4
+ version: 0.12.1
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: 2013-11-04 00:00:00.000000000 Z
12
+ date: 2013-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
@@ -88,6 +88,7 @@ files:
88
88
  - lib/scss_lint/selector_visitor.rb
89
89
  - lib/scss_lint/sass/tree.rb
90
90
  - lib/scss_lint/sass/script.rb
91
+ - lib/scss_lint/linter/compass.rb
91
92
  - lib/scss_lint/linter/space_after_comma.rb
92
93
  - lib/scss_lint/linter/space_before_brace.rb
93
94
  - lib/scss_lint/linter/capitalization_in_selector.rb
@@ -100,6 +101,7 @@ files:
100
101
  - lib/scss_lint/linter/declaration_order.rb
101
102
  - lib/scss_lint/linter/zero_unit.rb
102
103
  - lib/scss_lint/linter/placeholder_in_extend.rb
104
+ - lib/scss_lint/linter/compass/property_with_mixin.rb
103
105
  - lib/scss_lint/linter/space_after_property_name.rb
104
106
  - lib/scss_lint/linter/usage_name.rb
105
107
  - lib/scss_lint/linter/border_zero.rb