Project

jscop

0.0
No release in over 3 years
Low commit activity in last 3 years
A linter for checking errors in javascript code
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1.0
~> 12.3
~> 3.0

Runtime

~> 0.8
~> 0.5
 Project Readme

Gem Version Build Status

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 command chmod a+x exe/jscop if permission is not granted
  • Ensure you have rspec installed, or ensure that gem rspec is listed among the gems in the Gemfile => then run bundle install
  • In the console, run rspec or rake 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

License

The gem is available as open source under the terms of the MIT License.