A basic linter for CSS files developed using ruby.
This project was developed as a capstone project for the Microverse Ruby Module. The objective is to create a linter using the ruby language and test it using Rspec.
- Ruby,
- Rspec
To get a local copy up and running follow these simple example steps.
To run the linter you need to install RUBY on your computer. For windows, you can go to Ruby installer, for MAC and LINUX you can go to Ruby official site for instructions on how to install it.
To run it can be done by simply typing in the console ./bin/mm_css_lint.rb
This linter was created to work with CSS files inside the project folder and look for specific styling errors and will help your code to be more readable.
The linter will take either one parameter that should be the file name for a specific file you want to inspect or no parameters which means the linter will check all the .css files that are inside the project folder.
There are several types of checks performed by this linter, these are represented as individual linters internally. The internal linters implemented for the project are:
- Trailing white space: Checks for any spaces that are at the end of the line.
- Empty line: Checks for any extra empty lines inside the blocks and between blocks.
- Space for property and value: Checks for space after the colon at the value assignment for a property.
- Colors: Checks for all the color declarations to be in lower case.
- Semicolon: Checks for any semicolon missing inside the blocks.
- Comments: Checks for a space after a comment starts and a space before a comment ends.
- Block declaration space: Checks for a space before the opening bracket of a block and checks for no spaces in the closing bracket.
- Indentation: Checks for a two-space indentation inside blocks.
The lint class has logic built in that helps it work. It has a flag to detect whether a line is inside or outside a block, it also has a method that helps determine which type of line is it and has a counter for empty lines as well.
The results are presented to the user in the console with a line of text that indicates the files where the error was found along with the line number and the description of the error. The file name and the line number have a different color to help the user see better where the problem is.
If there are no error the linter will let the user know by giving a message as well.
The linter also generates a hidden file (.results.mm) to store the log of errors found.
To run the linter the user has to be inside the project root folder and then in the console type the following command:
ruby ./bin/mm_css_lint.rb {Filename}
Where the {Filename} represents the optional parameter for for checking a single file. The files to be checked can be anywhere inside the project folder, the linter will look for them automatically.
The linter will let you know what is going on and it has several errors that it can give.
When there are no files to check in the project.
When the file specified doesn't exists.
And finally when too many arguments are passed
👤 Mateo Mojica
- Github: @mateomh
- Twitter: @mateo_m_h
- Linkedin: Mateo Mojica
Contributions, issues and feature requests are welcome!
Feel free to check the issues page.
Give a ⭐️ if you like this project!
- Hat tip to anyone whose code was used
- Inspiration
- etc
This project is MIT licensed.