From 123ed325cd9b4d7f8570d62a00f7d54c250d363a Mon Sep 17 00:00:00 2001 From: Alexey Ryabov Date: Fri, 24 Nov 2023 11:15:52 +0300 Subject: [PATCH] feat(typescript): add base config --- README.md | 49 +++++++++++++++++++++++++++++++++++ package.json | 6 +++-- typescript/tsconfig.base.json | 13 ++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 typescript/tsconfig.base.json diff --git a/README.md b/README.md index fdf8d21..629fb70 100644 --- a/README.md +++ b/README.md @@ -320,6 +320,55 @@ To show final ESLint config: npx eslint --print-config ``` +## 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. diff --git a/package.json b/package.json index b1071f6..31193c2 100644 --- a/package.json +++ b/package.json @@ -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 .", diff --git a/typescript/tsconfig.base.json b/typescript/tsconfig.base.json new file mode 100644 index 0000000..5646dfb --- /dev/null +++ b/typescript/tsconfig.base.json @@ -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 + } +}