Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Latest commit

 

History

History
101 lines (76 loc) · 3.32 KB

README.md

File metadata and controls

101 lines (76 loc) · 3.32 KB

🚚 moved to https://github.com/NordicSemiconductor/asset-tracker-cloud-code-style-js
ℹ️ more info

Bifravst Code Style npm version

GitHub Actions Known Vulnerabilities semantic-release Renovate Mergify Status Commitizen friendly code style: prettier ESLint: TypeScript

Code style definitions for all Bifravst projects.

Installation

npm i --save-dev @bifravst/code-style

Usage

Update your package.json:

{
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.{ts,tsx}": ["prettier --write", "eslint --ext .js,.ts", "git add"],
    "*.{md,json,yaml,yml,js}": ["prettier --write", "git add"]
  }
}

Then:

npm i --save-dev @bifravst/code-style
cp node_modules/@bifravst/code-style/templates/* ./
cp node_modules/@bifravst/code-style/templates/.* ./

Use with React

npm install eslint-plugin-react --save-dev

Use this .eslintrc

{
  "extends": ["@bifravst/eslint-config-typescript", "plugin:react/recommended"],
  "settings": {
    "react": {
      "version": "latest"
    }
  }
}

tsconfig.json:

{
  "extends": "@bifravst/code-style/tsconfig.json",
  "include": ["src/*.tsx", "src/*.ts"],
  "exclude": ["src/*.spec.ts"],
  "compilerOptions": {
    "outDir": "dist/",
    "jsx": "react",
    "lib": ["DOM", "ES5"],
    "target": "es2018",
    "esModuleInterop": true
  }
}

Use with Creat React App

Use this .eslintrc

{
  "extends": ["@bifravst/eslint-config-typescript", "react-app"]
}

Do not use tsconfig.json from code-style.

Migrating to @bifravst/code-style

For converting projects to use code-style:

npm uninstall --save --save-dev @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier lint-staged prettier semantic-release @bifravst/code-style tslint lint-staged prettier typescript