scss_beautifier 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +32 -0
- data/LICENSE.txt +21 -0
- data/README.md +31 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/data/default_config.yml +49 -0
- data/data/pseudo_elements.txt +97 -0
- data/exe/scss-beautify +6 -0
- data/lib/scss_beautifier.rb +35 -0
- data/lib/scss_beautifier/cli.rb +20 -0
- data/lib/scss_beautifier/config.rb +21 -0
- data/lib/scss_beautifier/convert.rb +31 -0
- data/lib/scss_beautifier/formatters/bang_format.rb +21 -0
- data/lib/scss_beautifier/formatters/border_zero.rb +22 -0
- data/lib/scss_beautifier/formatters/color.rb +24 -0
- data/lib/scss_beautifier/formatters/comment.rb +17 -0
- data/lib/scss_beautifier/formatters/debug.rb +8 -0
- data/lib/scss_beautifier/formatters/declaration_order.rb +23 -0
- data/lib/scss_beautifier/formatters/empty_rule.rb +19 -0
- data/lib/scss_beautifier/formatters/leading_zero.rb +12 -0
- data/lib/scss_beautifier/formatters/name_format.rb +45 -0
- data/lib/scss_beautifier/formatters/property_sort_order.rb +23 -0
- data/lib/scss_beautifier/formatters/pseudo_element.rb +20 -0
- data/lib/scss_beautifier/formatters/qualifying_element.rb +14 -0
- data/lib/scss_beautifier/formatters/selector.rb +8 -0
- data/lib/scss_beautifier/formatters/shorthand.rb +112 -0
- data/lib/scss_beautifier/formatters/string_quotes.rb +33 -0
- data/lib/scss_beautifier/formatters/trailing_zero.rb +24 -0
- data/lib/scss_beautifier/options.rb +94 -0
- data/lib/scss_beautifier/version.rb +3 -0
- data/scss_beautifier.gemspec +28 -0
- data/tmp/bang.scss +3 -0
- data/tmp/border0.scss +3 -0
- data/tmp/colorkeyword.scss +3 -0
- data/tmp/colorshort.scss +3 -0
- data/tmp/comments.scss +5 -0
- data/tmp/debug.scss +4 -0
- data/tmp/declarationorder.scss +31 -0
- data/tmp/dump.mdown +63 -0
- data/tmp/elseplacement.scss +18 -0
- data/tmp/empty.scss +3 -0
- data/tmp/leadingzero.scss +17 -0
- data/tmp/nameformat.scss +30 -0
- data/tmp/pm.scss +228 -0
- data/tmp/pm2.scss +235 -0
- data/tmp/propertysortorder.scss +19 -0
- data/tmp/pseudoelement.scss +13 -0
- data/tmp/qualifyingelement.scss +23 -0
- data/tmp/selectors.scss +3 -0
- data/tmp/shorthand.scss +15 -0
- data/tmp/string_quotes.scss +12 -0
- data/tmp/test.scss +1 -0
- data/tmp/test2.scss +35 -0
- data/tmp/trailing_zero.scss +15 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2ce70dc26b3aba0b8f6c3d9ad761a86cadc3b424
|
4
|
+
data.tar.gz: 7a31fde608c0e532a9eb00f92d16014fc41aff8d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0cbf7a4fea907cf8a73c06bdec3eaf2bcf815cd95ad2b203811769410e29ec1ebfbd3371216cc95f1b17e62a4e4180cb46f28b7a885783cf2afe8ca0d91bb76f
|
7
|
+
data.tar.gz: 764cb602dee01882d61aacddaed12f7cca74afe2126f1e5e7fe33a0ff60479a8857faf0fb919e4bc2fef1683fc16fa77c2b43394c02ef80eb85464635daee724
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.DS_Store
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at ivan.tse1@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
scss_beautifier (0.1.0)
|
5
|
+
sass (~> 3.4)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coderay (1.1.1)
|
11
|
+
method_source (0.8.2)
|
12
|
+
minitest (5.9.0)
|
13
|
+
pry (0.10.4)
|
14
|
+
coderay (~> 1.1.0)
|
15
|
+
method_source (~> 0.8.1)
|
16
|
+
slop (~> 3.4)
|
17
|
+
rake (10.5.0)
|
18
|
+
sass (3.4.22)
|
19
|
+
slop (3.6.0)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
bundler (~> 1.12)
|
26
|
+
minitest (~> 5.0)
|
27
|
+
pry
|
28
|
+
rake (~> 10.0)
|
29
|
+
scss_beautifier!
|
30
|
+
|
31
|
+
BUNDLED WITH
|
32
|
+
1.12.5
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Ivan Tse
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# SCSSBeautifier
|
2
|
+
|
3
|
+
Beautify your SCSS code so that the formatting is consistent and adherent to your style guide.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install it as a gem:
|
8
|
+
|
9
|
+
$ gem install scss_beautifier
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
`scss-beautify the_scss_file.scss`
|
14
|
+
|
15
|
+
This will print out the formatted SCSS code.
|
16
|
+
|
17
|
+
## Development
|
18
|
+
|
19
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
20
|
+
|
21
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/paperlesspost/scss_beautifier. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
26
|
+
|
27
|
+
|
28
|
+
## License
|
29
|
+
|
30
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
31
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "scss_beautifier"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
formatters:
|
2
|
+
|
3
|
+
border_zero:
|
4
|
+
enabled: true
|
5
|
+
|
6
|
+
comment:
|
7
|
+
enabled: true
|
8
|
+
|
9
|
+
color:
|
10
|
+
enabled: true
|
11
|
+
|
12
|
+
debug:
|
13
|
+
enabled: true
|
14
|
+
|
15
|
+
empty_rule:
|
16
|
+
enabled: true
|
17
|
+
|
18
|
+
selector:
|
19
|
+
enabled: true
|
20
|
+
|
21
|
+
declaration_order:
|
22
|
+
enabled: true
|
23
|
+
|
24
|
+
# else_placement:
|
25
|
+
# enabled: true
|
26
|
+
|
27
|
+
leading_zero:
|
28
|
+
enabled: true
|
29
|
+
|
30
|
+
name_format:
|
31
|
+
enabled: true
|
32
|
+
|
33
|
+
property_sort_order:
|
34
|
+
enabled: true
|
35
|
+
|
36
|
+
pseudo_element:
|
37
|
+
enabled: true
|
38
|
+
|
39
|
+
qualifying_element:
|
40
|
+
enabled: true
|
41
|
+
|
42
|
+
shorthand:
|
43
|
+
enabled: true
|
44
|
+
|
45
|
+
string_quotes:
|
46
|
+
enabled: true
|
47
|
+
|
48
|
+
trailing_zero:
|
49
|
+
enabled: true
|
@@ -0,0 +1,97 @@
|
|
1
|
+
-moz-anonymous-block
|
2
|
+
-moz-anonymous-positioned-block
|
3
|
+
-moz-canvas
|
4
|
+
-moz-cell-content
|
5
|
+
-moz-focus-inner
|
6
|
+
-moz-focus-outer
|
7
|
+
-moz-inline-table
|
8
|
+
-moz-page
|
9
|
+
-moz-page-sequence
|
10
|
+
-moz-pagebreak
|
11
|
+
-moz-pagecontent
|
12
|
+
-moz-placeholder
|
13
|
+
-moz-progress-bar
|
14
|
+
-moz-progress-bar
|
15
|
+
-moz-range-thumb
|
16
|
+
-moz-range-track
|
17
|
+
-moz-scrolled-canvas
|
18
|
+
-moz-scrolled-content
|
19
|
+
-moz-scrolled-page-sequence
|
20
|
+
-moz-selection
|
21
|
+
-moz-svg-foreign-content
|
22
|
+
-moz-table
|
23
|
+
-moz-table-cell
|
24
|
+
-moz-table-column
|
25
|
+
-moz-table-column-group
|
26
|
+
-moz-table-outer
|
27
|
+
-moz-table-row
|
28
|
+
-moz-table-row-group
|
29
|
+
-moz-viewport
|
30
|
+
-moz-viewport-scroll
|
31
|
+
-moz-xul-anonymous-block
|
32
|
+
-ms-browse
|
33
|
+
-ms-check
|
34
|
+
-ms-clear
|
35
|
+
-ms-expand
|
36
|
+
-ms-expand
|
37
|
+
-ms-fill
|
38
|
+
-ms-fill-lower
|
39
|
+
-ms-fill-upper
|
40
|
+
-ms-reveal
|
41
|
+
-ms-thumb
|
42
|
+
-ms-ticks-after
|
43
|
+
-ms-ticks-before
|
44
|
+
-ms-tooltip
|
45
|
+
-ms-track
|
46
|
+
-ms-value
|
47
|
+
-webkit-calendar-picker-indicator
|
48
|
+
-webkit-color-swatch
|
49
|
+
-webkit-color-swatch-wrapper
|
50
|
+
-webkit-datetime-edit
|
51
|
+
-webkit-datetime-edit-day-field
|
52
|
+
-webkit-datetime-edit-fields-wrapper
|
53
|
+
-webkit-datetime-edit-month-field
|
54
|
+
-webkit-datetime-edit-text
|
55
|
+
-webkit-datetime-edit-year-field
|
56
|
+
-webkit-file-upload-button
|
57
|
+
-webkit-full-page-media
|
58
|
+
-webkit-inner-spin-button
|
59
|
+
-webkit-input-placeholder
|
60
|
+
-webkit-keygen-select
|
61
|
+
-webkit-meter-bar
|
62
|
+
-webkit-meter-even-less-good-value
|
63
|
+
-webkit-meter-optimum-value
|
64
|
+
-webkit-meter-suboptimum-value
|
65
|
+
-webkit-outer-spin-button
|
66
|
+
-webkit-progress-bar
|
67
|
+
-webkit-progress-inner-element
|
68
|
+
-webkit-progress-value
|
69
|
+
-webkit-resizer
|
70
|
+
-webkit-scrollbar
|
71
|
+
-webkit-scrollbar-button
|
72
|
+
-webkit-scrollbar-corner
|
73
|
+
-webkit-scrollbar-thumb
|
74
|
+
-webkit-scrollbar-track
|
75
|
+
-webkit-scrollbar-track-piece
|
76
|
+
-webkit-search-cancel-button
|
77
|
+
-webkit-search-decoration
|
78
|
+
-webkit-search-results-button
|
79
|
+
-webkit-search-results-decoration
|
80
|
+
-webkit-slider-runnable-track
|
81
|
+
-webkit-slider-thumb
|
82
|
+
-webkit-textfield-decoration-container
|
83
|
+
-webkit-validation-bubble
|
84
|
+
-webkit-validation-bubble-arrow
|
85
|
+
-webkit-validation-bubble-arrow-clipper
|
86
|
+
-webkit-validation-bubble-heading
|
87
|
+
-webkit-validation-bubble-message
|
88
|
+
-webkit-validation-bubble-text-block
|
89
|
+
after
|
90
|
+
backdrop
|
91
|
+
before
|
92
|
+
content
|
93
|
+
first-letter
|
94
|
+
first-line
|
95
|
+
placeholder
|
96
|
+
selection
|
97
|
+
shadow
|
data/exe/scss-beautify
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift "/Users/joenatalzia/Sites/tools/sass/lib"
|
4
|
+
|
5
|
+
module SCSSBeautifier
|
6
|
+
module Formatters
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
require "sass"
|
11
|
+
|
12
|
+
require "scss_beautifier/version"
|
13
|
+
require "scss_beautifier/cli"
|
14
|
+
require "scss_beautifier/config"
|
15
|
+
|
16
|
+
# Our custom SCSS to SCSS converter
|
17
|
+
require "scss_beautifier/convert"
|
18
|
+
|
19
|
+
# Formatters
|
20
|
+
require "scss_beautifier/formatters/bang_format"
|
21
|
+
require "scss_beautifier/formatters/border_zero"
|
22
|
+
require "scss_beautifier/formatters/color"
|
23
|
+
require "scss_beautifier/formatters/comment"
|
24
|
+
require "scss_beautifier/formatters/debug"
|
25
|
+
require "scss_beautifier/formatters/declaration_order"
|
26
|
+
require "scss_beautifier/formatters/empty_rule"
|
27
|
+
require "scss_beautifier/formatters/leading_zero"
|
28
|
+
require "scss_beautifier/formatters/name_format"
|
29
|
+
require "scss_beautifier/formatters/property_sort_order"
|
30
|
+
require "scss_beautifier/formatters/pseudo_element"
|
31
|
+
require "scss_beautifier/formatters/qualifying_element"
|
32
|
+
require "scss_beautifier/formatters/selector"
|
33
|
+
require "scss_beautifier/formatters/shorthand"
|
34
|
+
require "scss_beautifier/formatters/string_quotes"
|
35
|
+
require "scss_beautifier/formatters/trailing_zero"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SCSSBeautifier
|
2
|
+
class CLI
|
3
|
+
DEFAULT = File.realpath(File.join(File.dirname(__FILE__), "..", "..", "data", "default_config.yml")).freeze
|
4
|
+
# Takes an array of arguments
|
5
|
+
# Returns exit code
|
6
|
+
def run(args)
|
7
|
+
contents = File.read(ARGV.first)
|
8
|
+
engine = Sass::Engine.new(contents, cache: false, syntax: :scss)
|
9
|
+
|
10
|
+
tree = engine.to_tree
|
11
|
+
Config.new(DEFAULT).formatters.each do |formatter|
|
12
|
+
formatter.visit(tree)
|
13
|
+
end
|
14
|
+
|
15
|
+
puts SCSSBeautifier::Convert.visit(tree, {}, :scss)
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module SCSSBeautifier
|
4
|
+
class Config
|
5
|
+
|
6
|
+
def initialize(config_location)
|
7
|
+
@config = parse_config(config_location)
|
8
|
+
end
|
9
|
+
|
10
|
+
def parse_config(config_location)
|
11
|
+
YAML.load(File.read(config_location))
|
12
|
+
end
|
13
|
+
|
14
|
+
def formatters
|
15
|
+
enabled_formatters = @config["formatters"].select {|_, formatter| formatter["enabled"] }.keys
|
16
|
+
enabled_formatters.map do |formatter|
|
17
|
+
SCSSBeautifier::Formatters.const_get(formatter.split("_").map(&:capitalize).join)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class SCSSBeautifier::Convert < Sass::Tree::Visitors::Convert
|
2
|
+
def visit_if(node, &block)
|
3
|
+
if true
|
4
|
+
visit_if_no_newline(node, &block)
|
5
|
+
else
|
6
|
+
super(node)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
# ElsePlacement
|
10
|
+
def visit_if_no_newline(node)
|
11
|
+
name =
|
12
|
+
if !@is_else
|
13
|
+
"if"
|
14
|
+
elsif node.expr
|
15
|
+
"else if"
|
16
|
+
else
|
17
|
+
"else"
|
18
|
+
end
|
19
|
+
@is_else = false
|
20
|
+
str = "#{tab_str}@#{name}"
|
21
|
+
str << " #{node.expr.to_sass(@options)}" if node.expr
|
22
|
+
str << yield
|
23
|
+
str.rstrip! if node.else
|
24
|
+
@is_else = true
|
25
|
+
str << ' ' + visit(node.else).lstrip! if node.else
|
26
|
+
str
|
27
|
+
ensure
|
28
|
+
@is_else = false
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|