Skip to content

A CSS linter to help you find good manners to write your code.

License

Notifications You must be signed in to change notification settings

AlfredoElizarraras/css-linter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSS Linter

Table of Contents

About the project

This is a css linter built with ruby, it allows the programmer avoid some bad writing programming style.

Built With

  • Ruby 2.6.5

Prerequisites

  • Ruby 2.6.5

Install

git clone https://github.com/AlfredoElizarraras/css-linter.git

On command line: bundler install

Use

  1. Before running the linter, it needs a yaml file in the root directory, named checks.yml with the property 'Enabled: true' in the checks we want to perform.
  • Example of checks:
 --- 
 Checks:
 - spaces_before_first_brace:
   - Enabled: true
 - spaces_after_first_brace:
   - Enabled: true
 - rules_indentation:
   - Enabled: true
 - space_after_colon:
   - Enabled: false
 - no_uppcase_selectors:
   - Enabled: false
  1. Then we call the linter adding the path of the file we want to check.
  • For example:
ruby bin/main.rb examples/styles.css
  1. We will get the feedback from the linter with the total and details of errors and/or warnings we want to change.
  • Example of output:
  Number of errors: 8

  Messages from spaces_before_first_brace:
    - There's a missing space at line:  1
    - There's a missing space at line:  6

  Messages from spaces_after_first_brace:
    - There's an extra space at line:  6

  Messages from rules_indentation:
    - Theres's missing indentation of 1 space at line:  2
    - Theres's missing indentation of 1 space at line:  3
    - Theres's missing indentation of 2 spaces at line:  7

  Messages from space_after_colon:
    - There's missing a space after colon at line:  7

  Messages from no_uppcase_selectors:
    - Detected uses of upper-case in selector at line:  6

  1. Examples of good and bad code for each check.
  • spaces_before_first_brace:
  Good code:
  .nav {
    margin: 0;
    padding: 0;
  }

  Bad code:
  .nav{
    margin: 0;
    padding: 0;
  }
  • spaces_after_first_brace
  Good code:
  .nav {
    margin: 0;
    padding: 0;
  }

  Bad code: (it is a space after the openning brace)
  .nav { 
    margin: 0;
    padding: 0;
  }
  • rules_indentation
  Good code:
  .nav {
    margin: 0;
    padding: 0;
  }

  Bad code: (it is a space after the openning brace)
  .nav { 
  margin: 0; /* left 2 spaces of indentation */
   padding: 0; /* left 1 spaces of indentation */
  }
  • space_after_colon
  Good code:
  .nav {
    margin: 0;
    padding: 0;
  }

  Bad code: (it is a space after the openning brace)
  .nav { 
    margin:0; 
    padding:0; 
  }
  • no_uppcase_selectors
  Good code:
  .nav {
    margin: 0;
    padding: 0;
  }

  Bad code: (it is a space after the openning brace)
  .Nav { 
    margin: 0; 
    padding: 0; 
  }

Authors

This project is completed by Oscar Alfredo Gómez Elizarrarás, in partial requirements of the Microverse cirriculum.

👤 Oscar Alfredo Gómez Elizarrarás


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


License

This project is MIT licensed.

Copyright 2019 Oscar Alfredo Gómez Elizarrarás

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


About

A CSS linter to help you find good manners to write your code.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages