GithubHelp home page GithubHelp logo

vjeux / eslint-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bernardstanislas/eslint-bot

0.0 3.0 0.0 234 KB

A bot listening to github webhooks, running ESLint and sending inline comments on every commits.

JavaScript 100.00%

eslint-bot's Introduction

ESLint bot

ESLint bot is a tool that will help your improve your Javascript code quality by linting it automatically with the excellent ESLint whenever a change is pushed to your Github repository, and sending back comments directly on Github.

Once plugged on your repo's webhooks, any pushed code will be linted, then commented directly on the commit page on Github.

Example

You can see it in action on this sample commit.

Installation

Clone the repo, then do a

npm install

Optional : create a new Github account for your bot, which will be used to author the comments.

Configuration

You need to provide credentials to the Github account you want to use for the post-linting comments, as well as a file filter regex to determine whether a changed file should be linted or not.

This configuration is held by the config.js file, as follows :

export const GITHUB_USERNAME = 'username'; // Your bot's Github username
export const GITHUB_PASSWORD = 'password'; // Your bot's Github password

export const REPOSITORY_OWNER = 'owner/organisation';   // The owner of the repository you want to run the bot on.
export const REPOSITORY_NAME = 'name';                  // The name of the repository you want to run the bot on.

export const FILE_FILTER = /.*(.js|.jsx)$/; // By default, lint every single .js or .jsx file

You also need to configure ESLint through the .eslintrc. That's where all your linting rules go.

Eventually, you'll need to register your bot as a webhook for the repo you want to lint. Simply go the the settings page of your repo and add a new webhook pointing at your server's URL. Leave all the other options at their default value.

Note : you might be working on a npm-based project, in that case don't forget to modify the FILE_FILTER value to fit your needs and ignore the node_modules directory, otherwise you will end up with a slightly overshooting bot linting all your dependencies...

Running

To start the bot simply run

npm run start

Moving on

You might have noticed the Procfile in the repository. It enables you to run the bot on a Heroku VM.

I find it very convenient for this tool since you don't need many resources to run this small server. Moreover, you will be provided a fixed DNS, which is very convenient to register the webhook from Github.

eslint-bot's People

Contributors

bernardstanislas avatar

Watchers

 avatar  avatar  avatar

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.