Skip to content

singularit-de/eslint-config

Repository files navigation

singularIT Logo

Website | Blog | Team

@singularit/eslint-config

Configs

Config Version Description
@singularit/eslint-config npm extends @singularit/eslint-config-vue and @singularit/eslint-config-react
@singularit/eslint-config-basic npm
@singularit/eslint-config-typescript npm extends @singularit/eslint-config-basic
@singularit/eslint-config-vue npm extends @singularit/eslint-config-typescript
@singularit/eslint-config-react npm extends @singularit/eslint-config-typescript

Usage

Install

npm install eslint @singularit/eslint-config -D

Config .eslintrc.js

module.exports = {
  extends: "@singularit"
}

Add script for package.json

For example:

{
  "scripts": {
    "lint": "eslint .",
    "lint:fix": "eslint . --fix"
  }
}

Githooks with husky and lint-staged

  1. Install and setup husky
npx husky-init && npm install
  1. Add lint-staged to pre-commit hook
# .husky/pre-commit

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

- npm test
+ npx lint-staged
  1. Configure lint-staged
// package.json
{
  ...
+ "lint-staged": {
+   "*.{js,jsx,ts,tsx,vue,md,yml,yaml}": "eslint --fix --max-warnings 0"
+ }
  ...
}

Automatic fix-on-save in vscode

  1. Install the ESLint extension

  2. Add file .vscode/settings.json or add to file if it already exists

{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  }
}

License

MIT

Credits