Skip to content

AleksandarIvezic/JavaScript-Linters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript Linters

The main goal of this project is to create a linters that can check JavaScript files and provide feedback about errors. The project was built completely by using Ruby.

In this project we are looking for the following errors:

  • Wrong indentation
  • Trailing spaces
  • New line errors
  • Missing tags - (), [], and {}
  • Multiple variable declaration

Built With

  • Ruby
  • RSpec for Ruby Testing

Getting Started

Prerequisites

  • Installed Ruby

Download the repo

To get a local copy of the repository please run the following commands on your terminal:

 cd <folder>

 git clone https://github.com/ShinobiWarior/JavaScript-Linters.git

To check for errors on a file:

 ruby ./bin/main js_test.js

Install RSpec

To instal RSpec for testing please run the following command on your terminal:

gem install rspec

Run tests

To test the code, run rspec from root of the folder using terminal.

  • Please keep in mind that modifying the js_test.js file will affect the test results.

Good and bad code examples

Wrong indentation

//Good Code

const person = {
  firstName: "john",
  lastName: "doe",
  age: 30,
  hobbies: ["music", "movies", "sports"],
  address: {
    street: "50 main st",
    city: "boston",
    state: "ma"
  }
}

//Bad code

const person = {
    firstName: "john",
    lastName: "doe",
    age: 30,
    hobbies: ["music", "movies", "sports"],
    address: {
        street: "50 main st",
        city: "boston",
        state: "ma"
    }
}

Trailing spaces (Pipe | stands instead of cursor)

//Good Code

const score = 10;|

//Bad code

const score = 10; |

New line errors

//Good Code

const score = 10;

const person = {
  firstName: "john",
  lastName: "doe",
  age: 30,
  hobbies: ["music", "movies", "sports"],
  address: {
    street: "50 main st",
    city: "boston",
    state: "ma"
  }
}

//Bad code

const score = 10;


const person = {
  firstName: "john",
  lastName: "doe",
  age: 30,
  hobbies: ["music", "movies", "sports"],
  address: {
      street: "50 main st",
      city: "boston",
      state: "ma"
  }
}

Missing tags - (), [], and {}

//Good Code

const person = {
  firstName: "john",
  lastName: "doe",
  age: 30,
  hobbies: ["music", "movies", "sports"],
  address: {
    street: "50 main st",
    city: "boston",
    state: "ma"
  }
}

//Bad code

const person = {
  firstName: "john",
  lastName: "doe",
  age: 30,
  hobbies: "music", "movies", "sports"],
  address: {
      street: "50 main st",
      city: "boston",
      state: "ma"
    
}

Multiple variable declaration

//Good Code

let age = 30;
const old = 31;
const score = 10; 

//Bad code

let age = 30;
const age = 31;
const score = 10; 

Author

👤 Aleksandar Ivezic

🤝 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

About

This repo contains JavaScript-Linters built with Ruby

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published