scss_beautifier 0.1.8 → 0.1.10
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 +4 -4
- data/Gemfile.lock +1 -1
- data/data/default_config.yml +1 -0
- data/lib/scss_beautifier/cli.rb +13 -5
- data/lib/scss_beautifier/config.rb +4 -0
- data/lib/scss_beautifier/formatters/pseudo_element.rb +1 -0
- data/lib/scss_beautifier/formatters/selector.rb +1 -1
- data/lib/scss_beautifier/options.rb +9 -51
- data/lib/scss_beautifier/version.rb +1 -1
- data/lib/scss_beautifier.rb +1 -0
- data/tmp/dump.txt +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a3d388c808d3e8d767fa538e2383c6f18aa385f
|
4
|
+
data.tar.gz: 30e41286c9a23ffb74c3f55faf32c17270af9b4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7617a95f4d89c08655812ea0d770f0ca319d5d8e4fd438c474b31dd8441f57e2b1102dee18d18e77190836b7f75056324898e8f799ea835dc24fc07f81be3bd
|
7
|
+
data.tar.gz: b1492970c8027594c1f2d42b00c94dc0d72fedaf522358631b960fc8ca0e4a3f3f3b24c1b197598d32b8997bc6ebd0778fb0f6077b5639e124d9fec568bf258a
|
data/Gemfile.lock
CHANGED
data/data/default_config.yml
CHANGED
data/lib/scss_beautifier/cli.rb
CHANGED
@@ -4,17 +4,25 @@ module SCSSBeautifier
|
|
4
4
|
# Takes an array of arguments
|
5
5
|
# Returns exit code
|
6
6
|
def run(args)
|
7
|
-
|
7
|
+
options = Options.new.parse(args)
|
8
|
+
|
9
|
+
contents = File.read(args.first)
|
8
10
|
engine = Sass::Engine.new(contents, cache: false, syntax: :scss)
|
9
11
|
|
10
12
|
tree = engine.to_tree
|
11
|
-
Config.new(DEFAULT)
|
13
|
+
config = Config.new(options[:config] || DEFAULT)
|
14
|
+
|
15
|
+
config.formatters.each do |formatter|
|
12
16
|
formatter.visit(tree)
|
13
17
|
end
|
14
18
|
|
15
|
-
|
16
|
-
|
19
|
+
output = SCSSBeautifier::Convert.visit(tree, {indent: config.tab_style}, :scss)
|
20
|
+
if options[:in_place]
|
21
|
+
File.write(args.first, output)
|
22
|
+
else
|
23
|
+
puts output
|
24
|
+
end
|
17
25
|
end
|
18
26
|
|
19
27
|
end
|
20
|
-
end
|
28
|
+
end
|
@@ -8,6 +8,7 @@ class SCSSBeautifier::Formatters::PseudoElement < Sass::Tree::Visitors::Base
|
|
8
8
|
|
9
9
|
def check_pseudo(node)
|
10
10
|
node.rule = Sass::Util.strip_string_array(node.rule.map { |r|
|
11
|
+
return r unless r.is_a?(String)
|
11
12
|
require_double_colon = PSEUDO_ELEMENTS.index(r.split(":").last)
|
12
13
|
|
13
14
|
colon_type = require_double_colon ? '::' : ':'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class SCSSBeautifier::Formatters::Selector < Sass::Tree::Visitors::Base
|
2
2
|
def visit_rule(node)
|
3
3
|
node.rule = node.rule.each do |rule|
|
4
|
-
rule.gsub!(/,/, ",\n")
|
4
|
+
rule.gsub!(/,/, ",\n") if rule.is_a?(String)
|
5
5
|
end
|
6
6
|
node.send(:try_to_parse_non_interpolated_rules)
|
7
7
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "optparse"
|
2
2
|
|
3
|
-
module
|
3
|
+
module SCSSBeautifier
|
4
4
|
class Options
|
5
5
|
|
6
6
|
attr_reader :options
|
@@ -8,81 +8,39 @@ module Lintrunner
|
|
8
8
|
def initialize
|
9
9
|
@options = {}
|
10
10
|
@option_parser = OptionParser.new do |opts|
|
11
|
+
opts.version = SCSSBeautifier::VERSION
|
11
12
|
add_banner(opts)
|
12
13
|
add_config_option(opts)
|
13
|
-
|
14
|
-
add_include_path_option(opts)
|
15
|
-
add_reporter_option(opts)
|
16
|
-
add_ignore_option(opts)
|
17
|
-
add_colorize_option(opts)
|
14
|
+
add_in_place_option(opts)
|
18
15
|
end
|
19
16
|
end
|
20
17
|
|
21
18
|
def parse(args)
|
22
19
|
@option_parser.parse!(args)
|
23
|
-
add_defaults
|
24
20
|
options[:path] = args.first if args.first
|
25
21
|
options
|
26
22
|
end
|
27
23
|
|
28
24
|
private
|
29
25
|
|
30
|
-
def add_defaults
|
31
|
-
options[:config] ||= ".lintrunner_config"
|
32
|
-
options[:context] ||= Dir.pwd
|
33
|
-
options[:include_paths] = Array(options[:include_paths]) << options[:context]
|
34
|
-
options[:include_paths].uniq!
|
35
|
-
options[:reporter] ||= "text"
|
36
|
-
options[:path] = Dir.pwd
|
37
|
-
options[:ignore] ||= []
|
38
|
-
end
|
39
|
-
|
40
26
|
def add_banner(opts)
|
41
27
|
opts.banner = unindent(<<-BANNER)
|
42
|
-
|
28
|
+
Beautify your SCSS code
|
43
29
|
Usage: #{opts.program_name} [options] [path]
|
44
30
|
BANNER
|
45
31
|
end
|
46
32
|
|
47
33
|
def add_config_option(opts)
|
48
|
-
message = "the configuration file
|
34
|
+
message = "the configuration file"
|
49
35
|
opts.on("-c", "--config config", message, String) do |config|
|
50
36
|
self.options[:config] = config
|
51
37
|
end
|
52
38
|
end
|
53
39
|
|
54
|
-
def
|
55
|
-
message = "
|
56
|
-
opts.on("-
|
57
|
-
self.options[:
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def add_include_path_option(opts)
|
62
|
-
message = "the paths to add to load paths (the context is in the load path)"
|
63
|
-
opts.on("--include_path path1,...", message, Array) do |paths|
|
64
|
-
self.options[:include_paths] = paths
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def add_reporter_option(opts)
|
69
|
-
message = "the reporter that lintrunner uses to report results"
|
70
|
-
opts.on("--reporter reporter", message, String) do |reporter|
|
71
|
-
self.options[:reporter] = reporter
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def add_ignore_option(opts)
|
76
|
-
message = "the messages to ignore for this lintrunner execution"
|
77
|
-
opts.on("--ignore messages", message, Array) do |messages|
|
78
|
-
self.options[:ignore] = messages
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def add_colorize_option(opts)
|
83
|
-
message = "force colorized setting for output"
|
84
|
-
opts.on("--colorize", "--[no-]colorize", message) do |bool|
|
85
|
-
Rainbow.enabled = bool
|
40
|
+
def add_in_place_option(opts)
|
41
|
+
message = "whether to overwrite the file or not"
|
42
|
+
opts.on("-i", "--in-place", message) do |bool|
|
43
|
+
self.options[:in_place] = bool
|
86
44
|
end
|
87
45
|
end
|
88
46
|
|
data/lib/scss_beautifier.rb
CHANGED
data/tmp/dump.txt
CHANGED
@@ -35,6 +35,8 @@ https://github.com/sasstools/sass-lint/blob/master/docs/rules/brace-style.md - i
|
|
35
35
|
https://github.com/sasstools/sass-lint/blob/master/docs/rules/class-name-format.md
|
36
36
|
https://github.com/sasstools/sass-lint/blob/master/docs/rules/empty-args.md
|
37
37
|
|
38
|
+
Use interpolation over + when you want a string in the end (#{$degree}deg vs $degree + deg)
|
39
|
+
|
38
40
|
whoa never seen these rules
|
39
41
|
https://github.com/sasstools/sass-lint/blob/master/docs/rules/force-attribute-nesting.md
|
40
42
|
https://github.com/sasstools/sass-lint/blob/master/docs/rules/force-element-nesting.md
|
@@ -46,6 +48,7 @@ https://github.com/sasstools/sass-lint/blob/master/docs/rules/id-name-format.md
|
|
46
48
|
https://github.com/sasstools/sass-lint/blob/master/docs/rules/mixin-name-format.md
|
47
49
|
|
48
50
|
https://github.com/sasstools/sass-lint/blob/master/docs/rules/no-warn.md
|
51
|
+
how do maps look like? newlines separation?
|
49
52
|
|
50
53
|
|
51
54
|
These are spacing rules that come out of the box:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scss_beautifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Tse
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-08-
|
12
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sass
|