1.0.1 • Published 1 year ago

@em-and-ai/eslint-config-server v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Eslint configuration for ExpressJs

This package extends Airbnb's base JS .eslintrc (without React plugins) as an extensible shared configuration.

Installation

npm install --save-dev @em-and-ai/eslint-config-server

Usage

  • First of all, you need to install Eslint:
npm install --save-dev eslint
  • Next step, you need to install Airbnb-base and Import Plugin:
npm install --save-dev eslint-config-airbnb-base
npm install --save-dev eslint-plugin-import@latest
  • Create eslint configuration file (.eslintrc) by yourself or by the following command:
npm init @eslint/config
  • Because this package base on Airbnb-base, so you need to extend Airbnb-base first and then extend this package:
    "extends": [
        "airbnb-base",
        "@em-and-ai/server"
    ]
  • To check eslint, you need to add line in your package.json:
  "scripts": {
    "lint": "eslint --ext .js ."
  }
  • If you want to add more script to auto fix. You need to add --fix flag like this:
  "scripts": {
    "lint": "eslint --ext .js .",
    "lint:fix": "eslint --fix --ext .js ."
  }

Integration

You can integrate this ESLint configuration with Husky.

  • First of all, enable Git hooks:
npx husky install
  • Then, you can create a hook to check Eslint before commit:
npx husky add .husky/pre-commit "npm run lint"