Skip to content

Commit 537cd34

Browse files
committed
feat: introduce library configs with instructions
1 parent 3f508b5 commit 537cd34

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

packages/lint-staged-config/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ Then, create a `lint-staged.config.js` file in each workspace:
3434
export { workspace as default } from '@apitree.cz/lint-staged-config';
3535
```
3636

37+
If the workspace contains a distributable package (aka library), use the following configuration instead:
38+
39+
```js
40+
export { library as default } from '@apitree.cz/lint-staged-config';
41+
```
42+
43+
> See the [WebStorm Settings in PNPM Monorepos](../ts-config/README.md#webstorm-settings-in-pnpm-monorepos) section in `@apitree.cz/ts-config` for further information.
44+
3745
### Single-package repos
3846

3947
Install the package and create a `lint-staged.config.js` file in the root of your project:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from './library.js';
12
export * from './root.js';
23
export * from './single-package.js';
34
export * from './workspace.js';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { Configuration } from 'lint-staged';
2+
3+
import { workspace } from './workspace.js';
4+
5+
/**
6+
* Lint-staged configuration for monorepo workspace containing distributable library.
7+
*/
8+
export const library = {
9+
...workspace,
10+
'./**/*.{ts,tsx}': [() => 'tsc --build tsconfig.lib.json'],
11+
} satisfies Configuration;

packages/ts-config/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,46 @@ Suitable for distributable `npm` packages (framework-agnostic).
6363
}
6464
```
6565

66+
#### WebStorm Settings in PNPM Monorepos
67+
68+
In order for WebStorm to correctly resolve paths for internal packages in PNPM monorepos, separate your configuration into:
69+
70+
`tsconfig.lib.json`
71+
72+
```json
73+
{
74+
"extends": "@apitree.cz/ts-config/library",
75+
"include": ["**/*.js", "**/*.ts", "**/*.tsx"],
76+
"exclude": ["dist", "node_modules"]
77+
}
78+
```
79+
80+
`tsconfig.json`
81+
82+
```json
83+
{
84+
"extends": "./tsconfig.lib.json",
85+
"compilerOptions": {
86+
"rootDir": "./src",
87+
"outDir": "./dist"
88+
},
89+
"include": ["./src"]
90+
}
91+
```
92+
93+
> 🧠 Do not forget to use the `tsconfig.lib.json` in your general type-check script.
94+
95+
If your package also contains other non-src files (e.g. `tests`, `scripts`, etc.), create a separate `tsconfig.json` in each of those folders:
96+
97+
```json
98+
{
99+
"extends": "../tsconfig.lib.json",
100+
"compilerOptions": {
101+
"rootDir": ".."
102+
}
103+
}
104+
```
105+
66106
### Node.js
67107

68108
Suitable for Node.js services and apps.

0 commit comments

Comments
 (0)