Skip to content

Commit a758bd9

Browse files
committed
chore: package-lock.json
1 parent 4c312d3 commit a758bd9

File tree

7 files changed

+99
-102
lines changed

7 files changed

+99
-102
lines changed

.husky/commit-msg

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
4-
npx --no-install commitlint --edit
1+
npx --no-install commitlint --edit $1

.husky/pre-commit

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
3-
4-
npm run prettier --silent
5-
npm run lint --silent
1+
npx lint-staged

AGENTS.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,32 +67,34 @@ react-native-typescript-library-starter/
6767

6868
All commands should be run from the repository root.
6969

70-
| Command | Description |
71-
|---|---|
72-
| `npm run setup` | Interactive wizard — configure name, author, repo URLs |
73-
| `npm install` | Install all dependencies |
74-
| `npm run build` | Build library to `lib/` via bob |
75-
| `npm run typecheck` | Type-check without emitting files |
76-
| `npm run lint` | Run ESLint with colored output |
77-
| `npm run lint:ci` | Run ESLint without spinner (for CI) |
78-
| `npm run prettier` | Format code with colored output |
79-
| `npm run prettier:ci` | Check formatting without spinner (for CI) |
80-
| `npm test` | Run Jest tests |
81-
| `npm run test:watch` | Run Jest in watch mode |
82-
| `npm run test:coverage` | Run Jest with coverage report |
83-
| `npm run semantic-release` | Manually trigger a release (usually done by CI) |
70+
| Command | Description |
71+
| -------------------------- | ---------------------------------------------------------- |
72+
| `npm run setup` | Interactive wizard — configure name, author, repo URLs |
73+
| `npm install` | Install all dependencies (also runs `husky` via `prepare`) |
74+
| `npm run build` | Build library to `lib/` via bob |
75+
| `npm run typecheck` | Type-check without emitting files |
76+
| `npm run lint` | Run ESLint with colored output |
77+
| `npm run lint:ci` | Run ESLint without spinner (for CI) |
78+
| `npm run prettier` | Format code with colored output |
79+
| `npm run prettier:ci` | Check formatting without spinner (for CI) |
80+
| `npm test` | Run Jest tests |
81+
| `npm run test:watch` | Run Jest in watch mode |
82+
| `npm run test:coverage` | Run Jest with coverage report |
83+
| `npm run semantic-release` | Manually trigger a release (usually done by CI) |
8484

8585
---
8686

8787
## Conventions
8888

8989
### TypeScript
90+
9091
- Strict mode is enabled (`"strict": true`). No `any`, no `ts-ignore` without a comment explaining why.
9192
- Use `type` for type aliases and `interface` for object shapes.
9293
- Always use `import type` for type-only imports.
9394
- Path alias `@/*` maps to `src/*`.
9495

9596
### Components
97+
9698
- One component per folder under `src/components/`.
9799
- File naming: `MyComponent.tsx` (implementation), `MyComponent.types.ts` (props), `index.ts` (barrel).
98100
- Props interface must be named `<ComponentName>Props` and exported from the barrel.
@@ -101,21 +103,25 @@ All commands should be run from the repository root.
101103
- Forward `testID` and derive child testIDs as `${testID}-<part>`.
102104

103105
### Hooks
106+
104107
- One hook per file under `src/hooks/`.
105108
- Export the hook as a named export (not default).
106109
- Export the options interface as `Use<HookName>Options`.
107110
- Export the return interface as `Use<HookName>Return`.
108111
- All hooks must have full TSDoc with `@param`, `@returns`, and `@example`.
109112

110113
### Public API
114+
111115
- Only add exports to `src/index.ts` — this is the package entry point.
112116
- Export both the value and its types from `src/index.ts`.
113117
- Never import from `lib/` — always from `src/`.
114118

115119
### Commits
120+
116121
Follow Conventional Commits. Allowed types: `feat`, `fix`, `perf`, `refactor`, `style`, `test`, `docs`, `ci`, `chore`, `revert`.
117122

118123
Examples:
124+
119125
```
120126
feat: add PressableCard component
121127
fix: correct button accessibility role
@@ -124,6 +130,7 @@ docs: update README with new API
124130
```
125131

126132
### Testing
133+
127134
- Test files live in `src/__tests__/`.
128135
- File names match the source: `MyComponent.test.tsx`, `useMyHook.test.ts`.
129136
- Use `@testing-library/react-native` for component tests (`render`, `fireEvent`, `getByTestId`).

CONTRIBUTING.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ cd react-native-typescript-library-starter
1414
# 2. Install dependencies
1515
npm install
1616

17-
# 3. Set up git hooks
17+
# 3. Set up git hooks (runs automatically via the prepare script above)
1818
npm run husky:setup
1919
```
2020

2121
---
2222

2323
## Available Scripts
2424

25-
| Script | Description |
26-
|---|---|
27-
| `npm run build` | Build library to `lib/` |
28-
| `npm run typecheck` | Type-check without emitting |
29-
| `npm run lint` | Run ESLint with fix |
30-
| `npm run prettier` | Format code |
31-
| `npm test` | Run all tests |
32-
| `npm run test:watch` | Run tests in watch mode |
33-
| `npm run test:coverage` | Run tests with coverage |
25+
| Script | Description |
26+
| ----------------------- | --------------------------- |
27+
| `npm run build` | Build library to `lib/` |
28+
| `npm run typecheck` | Type-check without emitting |
29+
| `npm run lint` | Run ESLint with fix |
30+
| `npm run prettier` | Format code |
31+
| `npm test` | Run all tests |
32+
| `npm run test:watch` | Run tests in watch mode |
33+
| `npm run test:coverage` | Run tests with coverage |
3434

3535
---
3636

@@ -50,18 +50,18 @@ This project uses [Conventional Commits](https://www.conventionalcommits.org/).
5050

5151
### Allowed types
5252

53-
| Type | When to use |
54-
|---|---|
55-
| `feat` | A new feature |
56-
| `fix` | A bug fix |
57-
| `perf` | A performance improvement |
53+
| Type | When to use |
54+
| ---------- | --------------------------------------------------- |
55+
| `feat` | A new feature |
56+
| `fix` | A bug fix |
57+
| `perf` | A performance improvement |
5858
| `refactor` | Code change that is neither a bug fix nor a feature |
59-
| `style` | Formatting, whitespace, missing semicolons |
60-
| `test` | Adding or fixing tests |
61-
| `docs` | Documentation changes |
62-
| `ci` | CI/CD configuration changes |
63-
| `chore` | Build process or tooling changes |
64-
| `revert` | Reverts a previous commit |
59+
| `style` | Formatting, whitespace, missing semicolons |
60+
| `test` | Adding or fixing tests |
61+
| `docs` | Documentation changes |
62+
| `ci` | CI/CD configuration changes |
63+
| `chore` | Build process or tooling changes |
64+
| `revert` | Reverts a previous commit |
6565

6666
### Examples
6767

@@ -119,10 +119,10 @@ The commit message header is limited to **150 characters**.
119119

120120
Versioning is handled automatically by [semantic-release](https://github.com/semantic-release/semantic-release) based on commit messages. You do not need to manually bump versions.
121121

122-
| Commit type | Version bump |
123-
|---|---|
124-
| `fix` | Patch (0.0.x) |
125-
| `feat` | Minor (0.x.0) |
122+
| Commit type | Version bump |
123+
| ------------------------------------ | ------------- |
124+
| `fix` | Patch (0.0.x) |
125+
| `feat` | Minor (0.x.0) |
126126
| `feat` with `BREAKING CHANGE` footer | Major (x.0.0) |
127127

128128
---

README.md

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ npm install
3737

3838
### 2. Set up git hooks
3939

40-
```bash
41-
npm run husky:setup
42-
```
40+
Git hooks are installed automatically when you run `npm install` (via the `prepare` script). No extra step needed.
4341

4442
### 3. Configure the library
4543

@@ -50,6 +48,7 @@ npm run setup
5048
```
5149

5250
The wizard will ask for:
51+
5352
- **Package name** — your npm name (e.g. `react-native-my-library`)
5453
- **Description** — one sentence
5554
- **GitHub username / org** — used to build repo URLs automatically
@@ -116,29 +115,29 @@ react-native-typescript-library-starter/
116115

117116
## Scripts
118117

119-
| Command | Description |
120-
|---|---|
121-
| `npm run build` | Build library to `lib/` via bob |
122-
| `npm run typecheck` | Type-check without emitting |
123-
| `npm run lint` | Run ESLint with colored output and auto-fix |
124-
| `npm run lint:ci` | ESLint without spinner (for CI) |
125-
| `npm run prettier` | Format source files |
126-
| `npm run prettier:ci` | Check formatting (for CI) |
127-
| `npm test` | Run Jest tests |
128-
| `npm run test:watch` | Jest in watch mode |
129-
| `npm run test:coverage` | Jest with coverage report |
118+
| Command | Description |
119+
| ----------------------- | ------------------------------------------- |
120+
| `npm run build` | Build library to `lib/` via bob |
121+
| `npm run typecheck` | Type-check without emitting |
122+
| `npm run lint` | Run ESLint with colored output and auto-fix |
123+
| `npm run lint:ci` | ESLint without spinner (for CI) |
124+
| `npm run prettier` | Format source files |
125+
| `npm run prettier:ci` | Check formatting (for CI) |
126+
| `npm test` | Run Jest tests |
127+
| `npm run test:watch` | Jest in watch mode |
128+
| `npm run test:coverage` | Jest with coverage report |
130129

131130
---
132131

133132
## Build Output
134133

135134
`react-native-builder-bob` produces three output targets inside `lib/`:
136135

137-
| Output | Path | Used by |
138-
|---|---|---|
139-
| CommonJS | `lib/commonjs/` | Node.js, bundlers with `require()` |
140-
| ESM | `lib/module/` | Modern bundlers, tree-shaking |
141-
| TypeScript | `lib/typescript/` | Type declarations for consumers |
136+
| Output | Path | Used by |
137+
| ---------- | ----------------- | ---------------------------------- |
138+
| CommonJS | `lib/commonjs/` | Node.js, bundlers with `require()` |
139+
| ESM | `lib/module/` | Modern bundlers, tree-shaking |
140+
| TypeScript | `lib/typescript/` | Type declarations for consumers |
142141

143142
The `package.json` `exports` field routes consumers to the correct output automatically.
144143

@@ -164,20 +163,20 @@ export default function App() {
164163

165164
### MyComponent Props
166165

167-
| Prop | Type | Default | Description |
168-
|---|---|---|---|
169-
| `title` | `string` || Primary title text (required) |
170-
| `description` | `string` || Optional description below title |
171-
| `enableButton` | `boolean` | `false` | Renders an action button |
172-
| `buttonText` | `string` | `"Press me"` | Button label |
173-
| `onPress` | `() => void` || Button press callback |
174-
| `style` | `StyleProp<ViewStyle>` || Root container style override |
175-
| `titleStyle` | `StyleProp<TextStyle>` || Title text style override |
176-
| `descriptionStyle` | `StyleProp<TextStyle>` || Description text style override |
177-
| `buttonStyle` | `StyleProp<ViewStyle>` || Button container style override |
178-
| `buttonTextStyle` | `StyleProp<TextStyle>` || Button label style override |
179-
| `accessibilityLabel` | `string` | `title` | Accessibility label for the container |
180-
| `testID` | `string` | `"my-component"` | Test ID for querying in tests |
166+
| Prop | Type | Default | Description |
167+
| -------------------- | ---------------------- | ---------------- | ------------------------------------- |
168+
| `title` | `string` | | Primary title text (required) |
169+
| `description` | `string` | | Optional description below title |
170+
| `enableButton` | `boolean` | `false` | Renders an action button |
171+
| `buttonText` | `string` | `"Press me"` | Button label |
172+
| `onPress` | `() => void` | | Button press callback |
173+
| `style` | `StyleProp<ViewStyle>` | | Root container style override |
174+
| `titleStyle` | `StyleProp<TextStyle>` | | Title text style override |
175+
| `descriptionStyle` | `StyleProp<TextStyle>` | | Description text style override |
176+
| `buttonStyle` | `StyleProp<ViewStyle>` | | Button container style override |
177+
| `buttonTextStyle` | `StyleProp<TextStyle>` | | Button label style override |
178+
| `accessibilityLabel` | `string` | `title` | Accessibility label for the container |
179+
| `testID` | `string` | `"my-component"` | Test ID for querying in tests |
181180

182181
---
183182

@@ -207,23 +206,23 @@ function Counter() {
207206

208207
### useMyHook Options
209208

210-
| Option | Type | Default | Description |
211-
|---|---|---|---|
212-
| `initialValue` | `number` | `0` | Starting counter value |
213-
| `max` | `number` || Upper bound (no limit if omitted) |
214-
| `min` | `number` | `0` | Lower bound |
215-
| `step` | `number` | `1` | Increment/decrement amount |
209+
| Option | Type | Default | Description |
210+
| -------------- | -------- | ------- | --------------------------------- |
211+
| `initialValue` | `number` | `0` | Starting counter value |
212+
| `max` | `number` | | Upper bound (no limit if omitted) |
213+
| `min` | `number` | `0` | Lower bound |
214+
| `step` | `number` | `1` | Increment/decrement amount |
216215

217216
### useMyHook Return
218217

219-
| Key | Type | Description |
220-
|---|---|---|
221-
| `count` | `number` | Current counter value |
222-
| `increment` | `() => void` | Increment by `step` |
223-
| `decrement` | `() => void` | Decrement by `step` |
224-
| `reset` | `() => void` | Reset to `initialValue` |
225-
| `isAtMax` | `boolean` | `true` when `count >= max` |
226-
| `isAtMin` | `boolean` | `true` when `count <= min` |
218+
| Key | Type | Description |
219+
| ----------- | ------------ | -------------------------- |
220+
| `count` | `number` | Current counter value |
221+
| `increment` | `() => void` | Increment by `step` |
222+
| `decrement` | `() => void` | Decrement by `step` |
223+
| `reset` | `() => void` | Reset to `initialValue` |
224+
| `isAtMax` | `boolean` | `true` when `count >= max` |
225+
| `isAtMin` | `boolean` | `true` when `count <= min` |
227226

228227
---
229228

@@ -237,6 +236,7 @@ npm run test:coverage # with coverage report
237236
```
238237

239238
Coverage thresholds are enforced in `package.json`:
239+
240240
- Branches: 70%
241241
- Functions / Lines / Statements: 80%
242242

@@ -255,6 +255,7 @@ chore: upgrade dependencies
255255
```
256256

257257
Commits trigger automatic versioning via semantic-release:
258+
258259
- `fix` → patch release
259260
- `feat` → minor release
260261
- `feat` with `BREAKING CHANGE` footer → major release

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"scripts": {
4343
"setup": "node scripts/setup.mjs",
4444
"build": "bob build",
45-
"prepare": "husky install",
45+
"prepare": "husky",
4646
"typecheck": "tsc --noEmit",
4747
"lint": "node scripts/terminal/lint.mjs",
4848
"lint:ci": "eslint \"src/**/*.{ts,tsx}\"",
@@ -52,9 +52,7 @@
5252
"test:watch": "jest --watch",
5353
"test:coverage": "jest --coverage",
5454
"semantic-release": "semantic-release",
55-
"husky:setup": "npx husky-init && npm run husky:commitlint && npm run husky:lint",
56-
"husky:commitlint": "npx husky add .husky/commit-msg 'npx --no-install commitlint --edit'",
57-
"husky:lint": "npx husky add .husky/pre-commit 'npx lint-staged'"
55+
"husky:setup": "husky"
5856
},
5957
"peerDependencies": {
6058
"react": ">=17.0.0",

src/__tests__/MyComponent.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ describe("MyComponent", () => {
4545
});
4646

4747
it("uses default button text when buttonText is omitted", () => {
48-
const { getByText } = render(
49-
<MyComponent title="Hello" enableButton />,
50-
);
48+
const { getByText } = render(<MyComponent title="Hello" enableButton />);
5149
expect(getByText("Press me")).toBeTruthy();
5250
});
5351
});

0 commit comments

Comments
 (0)