6.0.0 • Published 5 months ago

@corva/eslint-config-node v6.0.0

Weekly downloads
38
License
UNLICENSED
Repository
-
Last release
5 months ago

@corva/eslint-config-node

Defines global linting rules for Corva.AI Node.js projects.

Usage

Setup

Generic

npm install husky standard-version -D
npm pkg set scripts.prepare="husky install"
npm pkg set scripts.release="git add -A && standard-version -a"
npm pkg set scripts.release-rc="git add -A && standard-version -a --prerelease rc --skip.changelog"
npm run prepare

Codestyle

# Install
npm i -D @corva/eslint-config-node
# OR
yarn add -D @corva/eslint-config-node

# Add eslint config
echo "module.exports = {'extends': '@corva/eslint-config-node'};" > .eslintrc.js

# Add prettier config
echo "\"@corva/eslint-config-node/prettier\"" > .prettierrc

or add a .eslintrc.js file in the root of your project and extended it with the default config:

module.exports = {
  extends: '@corva/eslint-config-node',
};

and .prettierrc:

"@corva/eslint-config-node/prettier"

Commitlint

Add dependencies:

npm i -D @commitlint/cli @commitlint/config-conventional

Add config:

echo "module.exports = {extends: ['@commitlint/config-conventional']};" > .commitlintrc.js

For husky <=v4 add following in your package.json:

{
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  }
}

For husky >= v5:

npx husky add .husky/commit-msg  'npx --no -- commitlint --edit ${1}'

lint-staged

Add dependencies:

npm i -D lint-staged

Add config to package.json:

{
  "scripts": {
    "lint": "eslint .",
    "lint:fix": "eslint . --fix"
  },
  "lint-staged": {
    "*.{js,ts}": "npm run lint:fix"
  }
}

For husky <=v4 add following in your package.json:

{
  "husky": {
    "hooks": {
      "pre-commit": "npx lint-staged"
    }
  }
}

For husky >= v5:

npx husky add .husky/pre-commit  'npx lint-staged'