Create a linter for best practices on SCSS files. I did this project to push me in a real-life situation creating a program with requirements and deadlines to output a functional product at the end.
- Ruby
- RSpec gem
- Colorize gem
- Strscan gem
- VS Code
- Latest Ruby version.
To get a local copy up and running follow these simple example steps.
- Open a terminal or command prompt interface on your PC.
- Clone the repo with: git clone https://github.com/kenderb/RCP_basic_SCSS_linter.git
- On the terminal navigate to the project directory using cd RCP_basic_SCSS_linter/
- run bundle install
To check for errors in your SCSS file run the code ruby bin/main.rb + absolute path to SCSS file you want to check.
- You can check the Code running
bin/main.rb ./scss_test_file/sass_file.scss
in the project folder - If you have bad practices on the file will be displayed on the console like this.
- If you don't have bad practices on your file will be displayed on the console like this.
The linter scans the SCSS file and shows you the errors:
-
Use of @mixin that generates duplicates code after compiling it use %placeholders to reduce it.
Good practice%title-small { font-size: 15px; font-family: Roboto; color: #F2F2F2; } .blog-title { @extend %title-small; } .page-title { @extend %title-small; }
Bad practice
@mixin primary-title ($fontSize) { font-family: Quicksand; font-weight: 600; font-size: $fontSize; } .blog-title { @include primary-title(15px); } .page-title { @include primary-title(19px); }
-
Missed semicolon ERROR.
Good practice.bg_color { background: red; }
Bad practice
.bg_color { background: red }
-
Unclosed block ERROR.
Good practice.bg_color { background: red; }
Bad practice
.bg_color { background: red;
-
Found CamelCase, snake, lowerCamelCase ERROR.
Good practice.fh-selector { font-size: 21rem; } .htag-selector { font-size: 15rem; }
Bad practice
.FhSelector { font-size: 21rem; } .htagSelector { font-size: 15rem; }
- Open the console
- Navigate to the RCP_basic_scss_file_linter project
- Run rspec
- The spec folder contains the test file with a Helper.
👤 Kender Bolívar
- GitHub: @kenderb
- Twitter: @KBTarts
- LinkedIn: KenderBolivar
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
- SCSS file linter.
- Code.tutsplus.com
Give a ⭐️ if you like this project!