Skip to content

Commit

Permalink
feat(typescript): add base config
Browse files Browse the repository at this point in the history
  • Loading branch information
lesha1201 committed Nov 24, 2023
1 parent efde22e commit 123ed32
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,55 @@ To show final ESLint config:
npx eslint --print-config <some-file>
```

## TypeScript

We provide a base config for TypeScript which contains some defaults we usually
use.

To use it, just extend it in your `tsconfig.json`:

```json
{
"extends": "@datarockets/style-guide/typescript"
}
```

The base config isn't intented to be used as a complete one so you might need
to add more settings in your `tsconfig.json`. For example:

```json
{
"extends": "@datarockets/style-guide/typescript",
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"noEmit": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".storybook/**/*"
],
"exclude": ["node_modules"]
}
```

## Acknowledge

Inspired by https://github.com/vercel/style-guide.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
"license": "MIT",
"exports": {
"./eslint/*": "./eslint/configs/*.js",
"./prettier": "./prettier/index.js"
"./prettier": "./prettier/index.js",
"./typescript": "./typescript/tsconfig.base.json"
},
"main": "index.js",
"files": [
"eslint",
"prettier"
"prettier",
"typescript"
],
"scripts": {
"format": "prettier --write .",
Expand Down
13 changes: 13 additions & 0 deletions typescript/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"docs": "https://github.com/datarockets/style-guide",
"compilerOptions": {
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"strict": true,
"incremental": true
}
}

0 comments on commit 123ed32

Please sign in to comment.