Shared ECMAScript Config (TS, Lint, Prettier)
-
Install
yarn add -D @nihalgonsalves/esconfig typescript typescript-eslint eslint prettier
-
tsconfig.json
{ "extends": "@nihalgonsalves/esconfig/tsconfig.shared.json", "compilerOptions": { "outDir": "./build", "rootDir": "./src" }, "include": ["./src"] }
-
eslint.config.mjs
import tseslint from "typescript-eslint"; import sharedConfig from "@nihalgonsalves/esconfig/eslint.config.shared"; export default tseslint.config( { ignores: [] }, ...sharedConfig, // ... others );
If you're using React:
import tseslint from "typescript-eslint"; import sharedConfig from "@nihalgonsalves/esconfig/eslint.config.react-shared"; export default tseslint.config( { ignores: [] }, ...sharedConfig, // ... others );
-
package.json
{ "scripts": { "build": "tsc", "lint": "eslint ./src/", "format": "prettier . --write", "format:check": "prettier . --check" } }
-
Done! Don't forget to run
build
,lint
andformat:check
in your CI workflow.