Skip to content

Commit

Permalink
feat: update package.json include tsconfig.base.json
Browse files Browse the repository at this point in the history
  • Loading branch information
tianyingchun committed May 28, 2024
1 parent e3d3855 commit 55d37a9
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-moons-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperse/eslint-config-hyperse": patch
---

update `package.json` include `tsconfig.base.json`
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
"editor.formatOnSave": false
},
"eslint.experimental.useFlatConfig": true,
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
}
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<img alt="stable version" src="https://img.shields.io/npm/v/%40hyperse%2Feslint-config-hyperse?branch=main&label=version&logo=npm&style=flat-quare&labelColor=000000" />
</a>
<a>
<img alt="LoC" src="https://img.shields.io/bundlephobia/min/%40hyperse%2Feslint-config-hyperse?style=flat-quare&labelColor=000000" />
<img alt="LoC" src="https://img.shields.io/bundlephobia/min/%40hyperse%2Feslint-config-hyperse" />
</a>
<a aria-label="Top language" href="https://github.com/hyperse-io/eslint-config-hyperse/search?l=typescript">
<img alt="GitHub top language" src="https://img.shields.io/github/languages/top/hyperse-io/eslint-config-hyperse?style=flat-square&labelColor=000&color=blue">
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 8 additions & 4 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -24,5 +23,10 @@
"rootDir": ".",
"outDir": "dist"
},
"exclude": ["**/node_modules", "**/.*/"]
}
"exclude": [
"**/node_modules",
"**/.*/",
"dist",
"build"
]
}
7 changes: 4 additions & 3 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
11 changes: 7 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}

0 comments on commit 55d37a9

Please sign in to comment.