Code Monkey home page Code Monkey logo

css_linter's Introduction

CSS Linter

this a ruby based linter for CSS files. it provides feedback about syntax errors in CSS files. I would like to mention that I was inspired by Stylelint, that's why you will find that the output is a bit similar and maybe the choice of colors to.

Preview

invalid css errors

How it works

This version of the CSS Beginner Linter reads a css file provided in the command line like so:

ruby bin/main.rb tests/invalid.css

This CSS linter will catch and display the following syntax errors in the console if there is any:

  • Unknown word
  • Unexpected whitespace before '}'
  • Unexpected whitespace after '}'
  • Invalid selector go learn some CSS bro O.o
  • Unexpected whitespace before '{' only one space is allowed
  • Unexpected whitespace at end of line
  • Expected newline after '{'
  • Expected one space before '{'
  • Unexpected whitespace in pseudo-class after the colon
  • Missing space after the colon in the declaration
  • Unexpected whitespace after the colon in the declaration, expected only one space
  • Missing simi-colon at the end of the declaration
  • Unexpected whitespace at end of the line of the declaration
  • Unexpected empty line, expected only one empty line
  • Unexpected whitespace before selector

so as I mentioned earlier the CSS file you can put it where ever you want but with one condition which you want to target by the command line as I showed you, here is a couple of examples how the linter works:

For an invalid css file

File:

invalid css file

Output:

invalid css output

For a valid CSS file

File:

valid css file

output:

valid css output

How To run the Linter

First of all, you need to have the linter files on your computer. You can get them either cloning this repository or downloading its contents directly

  • To clone the repo, go on the project's Github page, click on "Clone or download", copy the contents of the text box, and then run git clone "repo" on the command line, where "repo" is the text you just copied.
  • If you want to download it directly instead, go on the project's Github page, click on "Clone or download", and then on "Download ZIP". After this, you need to extract the contents of the zip file on your computer.

Once you have the files on your computer, go on the command line and navigate to the linter directory. Once there :

  • create you own CSS file inside the project and fell it with whatever content but please be gentile don't write complex CSS selectors otherwise the program will fail.
  • open the terminal window and then type in bundle install to install a ruby colorize lib that gives a good looking output.
  • Run the linter directly from the root of the project directory, using the following command ruby ./bin/main.rb .test/invalid.css keep in mind that you can change .test/invalid.css to the location of the file that you have created.

How To run the tests

Any contribution is welcomed in this project, you need only to take on consideration one thing which is to write your own test cases if you added new functionality to the program. so all the test cases were written with RSpec inside spec/parser_spec.rb file if you created a new class add another file inside the same folder. and finally, to run the tests you will need to open the terminal and cd into the directory of that project and run the following command: rspec

Requirements

  • Ruby
  • Colorize
  • Rubocop

Built with

  • Ruby

Authors

๐Ÿ‘ค Zakariae El Mejdki

๐Ÿค Contributing

Contributions, issues and feature requests are welcome!

Feel free to check the issues page.

Show your support

Give a โญ๏ธ if you like this project!

Acknowledgments

โ€‹ Hat tip to anyone whose code was used

๐Ÿ“ License

This project is MIT licensed.

css_linter's People

Contributors

elmejdki avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

css_linter's Issues

Peer to peer code review - Hummingbird

  • Really understandable code
  • Create a file class to modularize it
  • Pretty good project
  • Group the tests by state.
  • Make a larger use of not_to eql.
  • Organize the images inside an assets folder.
  • Really good project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.