A set of prettify eslint configs with prettier and Airbnb rules include. Support for React/TypeScript/ES2019/Node.
This repo container 4 npm packages.
eslint-config-prettify-base
for ES2019 or Node projecteslint-config-prettify-react
for React JavaScript projecteslint-config-prettify-ts-base
for vanilla TypeScript projecteslint-config-prettify-ts-react
for React TypeScript project
Chose proper config 👆, and install dependencies. For example, eslint-config-prettify-base
:
# Just those two dependencies, no need for extra parser, plugins or configs
yarn add --dev eslint eslint-config-prettify-base prettier
# Or using npm if you prefer
npm install --save-dev eslint eslint-config-prettify-base prettier
Upgrade your ESLint config
// .eslintrc
{
"root": true,
"extends": ["eslint-config-prettify-base"]
}
eslint-config-prettify-ts-react
and eslint-config-prettify-ts-base
using command executing directory to detect tsconfig.json
(for TypeScript path alias), try below configuration if you meet Unable to resolve path to module ‘xxx’
error.
{
"extends": ["eslint-config-prettify-base"],
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
// use <root>/tsconfig.json
"typescript": {
// always try to resolve types under `<root/>@types` directory even it doesn't contain any source code, like `@types/unist`
"alwaysTryTypes": true,
// use <root>/path/to/folder/tsconfig.json
"directory": "./path/to/folder"
},
// Multiple tsconfigs (Useful for monorepos)
// use a glob pattern
"typescript": {
"directory": "./packages/*/tsconfig.json"
},
// use an array
"typescript": {
"directory": [
"./packages/module-a/tsconfig.json",
"./packages/module-b/tsconfig.json"
]
},
}
}
This monorepo managed by lerna with yarn workspace.
# Trigger 'lerna bootstrap'
yarn
Unit tests write with jest
yarn test
Commit message lint by commitlint with config @commitlint/config-conventional
, scope must be package's names.For example, fix(base): import module unsolved
.
# Create package CHANGELOG.md, increase package.json version and git commit and tag
yarn run release
# Publish release version
yarn run publish