@febase/eslint-config-nextts
v1.6.0
Published
Shared eslint react typescript config
Downloads
8
Readme
Eslint Config Next TS
This package provides eslint
config for the nextjs
projects use the typescript.
Only support the new Eslint flat config.
Prettier and Linters
- Prettier Config:
Prettier
config for theFront-end
projects. - Prettier Config:
Prettier
config for theSvelte
projects. - Eslint Config Base:
Eslint
config for theJavascript
projects. - Eslint Config Typescript:
Eslint
config for theTypescript
projects. - Eslint Config React JS:
Eslint
config for theReact JS
projects. - Eslint Config React TS:
Eslint
config for theReact TS
projects. - Eslint Config Next JS:
Eslint
config for theNext JS
projects. - Eslint Config Next TS:
Eslint
config for theNext TS
projects. - Eslint Config Lit JS:
Eslint
config for theLit JS
projects. - Eslint Config Lit TS:
Eslint
config for theLit TS
projects. - Eslint Config Node ESM:
Eslint
config for theNode Esm
projects. - Eslint Config Svelte JS:
Eslint
config for theSvelte
projects. - Eslint Config Svelte TS:
Eslint
config for theSvelte TS
projects.
and more to come.
Usage
1. Install package
pnpm add -D @febase/eslint-config-nextts eslint
2. Add config to your eslint.config.js
. Please read more about Eslint Flat Config.
import { config } from '@febase/eslint-config-nextts';
export default [...config];
3. Add script to your package.json
.
{
"scripts": {
"lint": "eslint \"src/**/*.{ts,tsx}\"",
"lint:fix": "pnpm lint --fix"
}
}
4. tsconfig.eslint.json
and tsconfig.json
.
- Search for the
tsconfig.eslint.json
file from the folder containing theeslint.config.js
file up to the root folder. - if
tsconfig.eslint.json
file is not found. Thetsconfig.json
file in the current folder will be used. - If you have a
tsconfig.json
file and itsinclude
paths include all the files you'd like to lint, you can directly use that file without using thetsconfig.eslint.json
file.
5. Monorepo
- Should only create a
tsconfig.eslint.json
in root monorepo. parserOptions.project
supports['./tsconfig.eslint.json', './packages/*/tsconfig.json', './apps/*/tsconfig.json']
.
Configuration your VScode
.
In root your project's folder. Create .vscode
folder with structure:
.vscode
- settings.json
{
"eslint.experimental.useFlatConfig": true,
// if the `eslint.config.js` file is in mono-repo please remove comment of the below line.
// "eslint.workingDirectories": [{ "pattern": "./apps/*/" }, { "pattern": "./packages/*/" }],
"eslint.options": {
"overrideConfigFile": "eslint.config.js"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
Setup git hooks
- Install packages and global setup
husky
,lint-staged
.
pnpm add -D husky lint-staged
pnpm dlx husky install
pnpm pkg set scripts.prepare="husky install"
pnpm dlx husky add .husky/pre-commit "pnpm dlx lint-staged"
- Add the following to your
package.json
:
{
"lint-staged": {
"*.{js,jsx,ts,tsx}": ["pnpm format", "pnpm lint:fix"],
"*.{json,css,md,html}": ["pnpm format"]
}
}