From 55d37a990c911af66ab12f12069d90997977134c Mon Sep 17 00:00:00 2001 From: tianyingchun Date: Tue, 28 May 2024 13:48:54 +0800 Subject: [PATCH] feat: update `package.json` include `tsconfig.base.json` --- .changeset/honest-moons-look.md | 5 +++++ .vscode/settings.json | 3 +++ README.md | 38 ++++++++++++++++++++++++++++++++- package.json | 1 + tsconfig.base.json | 12 +++++++---- tsconfig.build.json | 7 +++--- tsconfig.json | 11 ++++++---- 7 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 .changeset/honest-moons-look.md diff --git a/.changeset/honest-moons-look.md b/.changeset/honest-moons-look.md new file mode 100644 index 0000000..595b02b --- /dev/null +++ b/.changeset/honest-moons-look.md @@ -0,0 +1,5 @@ +--- +"@hyperse/eslint-config-hyperse": patch +--- + +update `package.json` include `tsconfig.base.json` diff --git a/.vscode/settings.json b/.vscode/settings.json index 602b802..8d81300 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,4 +17,7 @@ "editor.formatOnSave": false }, "eslint.experimental.useFlatConfig": true, + "[jsonc]": { + "editor.defaultFormatter": "vscode.json-language-features" + }, } diff --git a/README.md b/README.md index cc34b17..9427a7e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ stable version - LoC + LoC GitHub top language @@ -29,6 +29,7 @@ These are the ESLint and Prettier settings for a Next.js project ⚡️ - [What it does](#what-it-does) - [Local / Per Project Install](#local--per-project-install) - [Scripts](#scripts) + - [Extends tsconfig.json](#extends-tsconfigjson) - [If you use Next.js](#if-you-use-nextjs) - [If you use React.js](#if-you-use-reactjs) - [If you use VS Code](#if-you-use-vs-code) @@ -69,6 +70,41 @@ export default defineConfig([ ]); ``` +### Extends tsconfig.json + +you can write you `tsconfig.json` via extends `@hyperse/eslint-config-hyperse/tsconfig.base.json` + +```json +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "@hyperse/eslint-config-hyperse/tsconfig.base.json", + "compilerOptions": { + "baseUrl": "./", + "rootDir": ".", + "outDir": "dist", + "types": ["vitest/globals"], + "paths": {} + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"] +} +``` + +write you `tsconfig.build.json` as below + +```json +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src", + "baseUrl": "./", + "incremental": false, + "paths": {} + }, + "exclude": ["**/*.stories.tsx", "**/*.stories.mdx", ".storybook/**", "dist"] +} +``` + ### Scripts You can add two scripts to your package.json to lint and/or fix your code: diff --git a/package.json b/package.json index 57977d3..b6954f6 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "import": "./dist/main/nextjs.js", "types": "./dist/main/nextjs.d.ts" }, + "./tsconfig.base.json": "./tsconfig.base.json", "./package.json": "./package.json" }, "types": "./dist/index.d.ts", diff --git a/tsconfig.base.json b/tsconfig.base.json index 74d60c8..731900e 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,11 +1,10 @@ { + "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { "strict": true, "useUnknownInCatchVariables": true, "allowJs": true, "skipLibCheck": true, - "experimentalDecorators": true, - "emitDecoratorMetadata": true, "forceConsistentCasingInFileNames": true, "noEmit": true, "jsx": "react-jsx", @@ -24,5 +23,10 @@ "rootDir": ".", "outDir": "dist" }, - "exclude": ["**/node_modules", "**/.*/"] -} + "exclude": [ + "**/node_modules", + "**/.*/", + "dist", + "build" + ] +} \ No newline at end of file diff --git a/tsconfig.build.json b/tsconfig.build.json index 20fe699..5541e28 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -2,12 +2,13 @@ "extends": "./tsconfig.json", "compilerOptions": { "incremental": false, - "moduleResolution": "nodenext", "declaration": true, "sourceMap": false, "outDir": "./dist", "rootDir": "./src", "baseUrl": "./" }, - "include": ["./src/*.ts"] -} + "include": [ + "./src/*.ts" + ] +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 0b89a9a..1ff2fb7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,13 +1,16 @@ { - "$schema": "https://json.schemastore.org/tsconfig", "extends": "./tsconfig.base.json", "compilerOptions": { + "rootDir": ".", "baseUrl": "./", + "outDir": "dist", "allowJs": false, "noEmit": false, "incremental": true, "paths": {}, - "types": ["@types/node", "vitest/globals"] + "types": [ + "@types/node", + "vitest/globals" + ] }, - "exclude": ["**/node_modules", "**/.*/", "dist", "build"] -} +} \ No newline at end of file