Jscop
This is a Linter for checking errors in Javascript code, built with Ruby.
Outline
- Installation
- Usage
- Errors currently detectable by jscop
- Variable naming errors
- Class naming errors
- Extra or redundant spacing errors
- Multiple declaration of classes in a file (class count) errors
- Unused variables are detected
- More about usage
- Testing this repo
- Built With
- Contributing
- Code of conduct
- Licence
Installation
Add this line to your application's Gemfile:
gem 'jscop'
And then execute:
$ bundle
Or install it yourself as:
$ gem install jscop
Usage
- once in desired path in the terminal/console, RUN
a. jscop # To lint all *.js files in the current $Path.
b. jscop ./**/path_to_file.js # To lint JUST a specific file.
c. jscop foldername # To lint all *.js files in a specific folder.
ERRORS
The following erros are currently detectable by Jscop:
VARIABLE NAMING ERRORS
- if capital letters or numbers are used to start a variable name, e.g
*Bad practice* let 8owngoal = 4 or const Capvar = 9
*Good practice* let owngoal = 4 or const capVar = 9
CLASS NAME ERRORS
- if class names begin with small letters and/or
- if class names are snake-cased or both e.g
*Bad practice* class badclass {} or class Bad-class {}
*Good practice* class GoodClass {} or class Good_Class {}
- Or if underscores and hyphen are mixed
*Bad practice* class Bad_class-Name {}
SPACING ERRORS
- if spaces are found at beginning of lines
- if extra spaces are found around variables e.g
*Bad practice* let| | vacuum = 4 or var hollow| | = 9
*Good practice* let vacuum = 4 or const hollow = 9
CLASS COUNT ERROR
- if more than one class is defined in a module,
UNUSED VARIABLE ERROR
- if a variable (var, let, const) is defined and never used.
- A lot of edge cases are covered here.
More About Usage
Arguments Supported By jscop to Check Javascript Code
- You can pass in file(s) or a folder in any of the following cases in your terminal
You can pass in a specific file $Path to test just the file
You can pass in a folder and all javascript files in it will be checked and finally
Everything Js can be linted all at once (both files and folders)
Testing this Repo
- Once in the $Path you intend to keep this project in the terminal of your machine
- Clone with this command
git clone [repo](https://github.com/codecell/jscop.git)
- Change directory into the folder
cd jscop
- Install project dependencies with the command
bundle install
- You can make the
exe/jscop
file executable with the commandchmod a+x exe/jscop
if permission is not granted - Ensure you have
rspec
installed, or ensure thatgem rspec
is listed among the gems in theGemfile
=> then runbundle install
- In the console, run
rspec
orrake
to run all the unit tests written for this project
Built With
- Ruby
- Rubular was used to craft and test the regular expressions
- Rubocop linter
- Stickler CI
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/codecell/jscop. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
Code of Conduct
Everyone interacting in the Jscop project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Author
👤 Alfred Ezaka
- Github: @codecell
- Twitter: @the_codecell
- Linkedin: ezaka alfred
License
The gem is available as open source under the terms of the MIT License.