@mrmartineau/kit 0.1.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +325 -40
  2. package/package.json +46 -17
  3. package/src/biome/biome.json +37 -7
  4. package/src/biome/strict.json +108 -0
  5. package/src/eslint/index.ts +49 -13
  6. package/src/index.ts +2 -1
  7. package/src/oxfmt/.oxfmtrc.json +5 -1
  8. package/src/oxlint/.oxlintrc.json +12 -3
  9. package/src/oxlint/strict.json +61 -0
  10. package/src/prettier/astro.js +31 -0
  11. package/src/prettier/astro.test.ts +48 -0
  12. package/src/sounds/index.ts +156 -156
  13. package/src/utils/checks/checks.test.ts +162 -0
  14. package/src/utils/checks/collections.ts +63 -0
  15. package/src/utils/checks/index.ts +17 -0
  16. package/src/utils/checks/isEmpty.ts +15 -0
  17. package/src/utils/checks/nullish.ts +26 -0
  18. package/src/utils/checks/numbers.ts +31 -0
  19. package/src/utils/checks/objects.ts +38 -0
  20. package/src/utils/checks/primitives.ts +41 -0
  21. package/src/utils/formatters/constants.ts +1 -0
  22. package/src/utils/formatters/index.ts +24 -0
  23. package/src/utils/formatters/numbers/__tests__/formatNumberBase.test.ts +55 -0
  24. package/src/utils/formatters/numbers/__tests__/formatNumberCurrency.test.ts +55 -0
  25. package/src/utils/formatters/numbers/__tests__/formatNumberDecimal.test.ts +63 -0
  26. package/src/utils/formatters/numbers/__tests__/formatNumberDecimalForceDecimalPlaces.test.ts +29 -0
  27. package/src/utils/formatters/numbers/formatNumberAccounting.ts +27 -0
  28. package/src/utils/formatters/numbers/formatNumberBase.ts +21 -0
  29. package/src/utils/formatters/numbers/formatNumberBytes.ts +29 -0
  30. package/src/utils/formatters/numbers/formatNumberCompact.ts +19 -0
  31. package/src/utils/formatters/numbers/formatNumberCurrency.ts +25 -0
  32. package/src/utils/formatters/numbers/formatNumberDecimal.ts +21 -0
  33. package/src/utils/formatters/numbers/formatNumberDecimalForceDecimalPlaces.ts +23 -0
  34. package/src/utils/formatters/numbers/formatNumberOrdinal.ts +22 -0
  35. package/src/utils/formatters/numbers/formatNumberPercent.ts +21 -0
  36. package/src/utils/formatters/numbers/formatNumberRange.ts +22 -0
  37. package/src/utils/formatters/numbers/formatNumberSignDisplay.ts +24 -0
  38. package/src/utils/formatters/strings/formatInitials.ts +17 -0
  39. package/src/utils/formatters/strings/formatList.test.ts +48 -0
  40. package/src/utils/formatters/strings/formatList.ts +10 -0
  41. package/src/utils/formatters/strings/maskString.ts +27 -0
  42. package/src/utils/formatters/strings/normalizeWhitespace.ts +8 -0
  43. package/src/utils/formatters/strings/pluralize.ts +11 -0
  44. package/src/utils/formatters/strings/slugify.ts +12 -0
  45. package/src/utils/formatters/strings/splitWords.ts +12 -0
  46. package/src/utils/formatters/strings/stripDiacritics.ts +7 -0
  47. package/src/utils/formatters/strings/toCamelCase.ts +17 -0
  48. package/src/utils/formatters/strings/toKebabCase.ts +11 -0
  49. package/src/utils/formatters/strings/toPascalCase.ts +14 -0
  50. package/src/utils/formatters/strings/toSnakeCase.ts +11 -0
  51. package/src/utils/formatters/strings/toStartCase.test.ts +40 -0
  52. package/src/utils/formatters/strings/toStartCase.ts +21 -0
  53. package/src/utils/formatters/strings/truncate.ts +25 -0
  54. package/src/utils/index.ts +2 -0
package/README.md CHANGED
@@ -8,17 +8,22 @@ A personal collection of sounds, utilities, components, and hooks for use across
8
8
  bun add @mrmartineau/kit
9
9
  ```
10
10
 
11
- This package provides **configuration files and static assets only** — it does not install the underlying tools. Install whichever tools you actually need in your project:
11
+ This package provides **configuration files and static assets only**, with no runtime dependencies — it does not install the underlying tools. Install whichever tools you actually need in your project:
12
12
 
13
13
  ```bash
14
- # Biome (linter + formatter)
15
- bun add -d @biomejs/biome
16
-
17
- # oxc (linter + formatter)
14
+ # oxc (linter + formatter) — the default for new projects
18
15
  bun add -d oxlint oxfmt
16
+ # …plus, in an Astro project, so oxfmt can format .astro files
17
+ bun add -d @astrojs/compiler-rs
18
+
19
+ # Biome (linter + formatter) — older projects
20
+ bun add -d @biomejs/biome
19
21
 
20
22
  # ESLint + Prettier
21
- bun add -d eslint prettier
23
+ bun add -d eslint @eslint/js prettier
24
+
25
+ # Prettier with .astro support
26
+ bun add -d prettier prettier-plugin-astro
22
27
  ```
23
28
 
24
29
  You don't need all of them — just pick the tools you want to use and reference the matching config from this package.
@@ -59,12 +64,7 @@ audio.play()
59
64
  **Use the metadata module for programmatic access:**
60
65
 
61
66
  ```ts
62
- import {
63
- sounds,
64
- soundCategories,
65
- getSoundsByCategory,
66
- getSoundPath,
67
- } from '@mrmartineau/kit/sounds'
67
+ import { sounds, soundCategories, getSoundsByCategory, getSoundPath } from '@mrmartineau/kit/sounds'
68
68
 
69
69
  // List all sound names
70
70
  console.log(sounds)
@@ -78,18 +78,35 @@ const clickSounds = getSoundsByCategory('click')
78
78
 
79
79
  ### Biome
80
80
 
81
- Shared [Biome](https://biomejs.dev) config for linting and formatting. Biome natively supports extending from packages via its `extends` field.
81
+ Shared [Biome](https://biomejs.dev) config for linting and formatting. New projects
82
+ use oxlint and oxfmt instead; this config stays for projects that still use Biome. Biome natively supports extending from packages via its `extends` field.
82
83
 
83
84
  In your project's `biome.json`:
84
85
 
85
86
  ```json
86
87
  {
87
- "$schema": "https://biomejs.dev/schemas/2.1.3/schema.json",
88
- "extends": ["@mrmartineau/kit/biome"]
88
+ "$schema": "https://biomejs.dev/schemas/2.5.7/schema.json",
89
+ "extends": ["./node_modules/@mrmartineau/kit/src/biome/biome.json"]
89
90
  }
90
91
  ```
91
92
 
92
- **Included settings:** space indentation, single quotes, no semicolons, import sorting, sorted keys, recommended lint rules, React domain rules.
93
+ **Included settings:** space indentation (2), single quotes, no semicolons, trailing commas, 100 line width, import sorting, recommended lint rules, React domain rules.
94
+
95
+ The config is marked `"root": false` so Biome doesn't mistake it for a second root
96
+ configuration when it sits inside a project. `root` is not inherited through
97
+ `extends`, so your own `biome.json` stays the root.
98
+
99
+ It also turns off the unused-import, unused-variable, `useConst` and
100
+ `useImportType` rules in `.astro`, `.svelte` and `.vue` files. Biome cannot see
101
+ what the template uses, so it reports false errors, and `biome check --write`
102
+ deletes imports the template needs.
103
+
104
+ > Biome **replaces** the `overrides` list you extend; it does not add to it. If
105
+ > your `biome.json` has its own `overrides`, copy the kit ones you still need.
106
+
107
+ > Object-key sorting (`assist.actions.source.useSortedKeys`) is deliberately
108
+ > **not** enabled — it rewrites object literals in your source on save, which is
109
+ > surprising and occasionally meaningful. Turn it on per-project if you want it.
93
110
 
94
111
  ### oxlint
95
112
 
@@ -97,42 +114,133 @@ Shared [oxlint](https://oxc.rs/docs/guide/usage/linter/config) config. Reference
97
114
 
98
115
  ```json
99
116
  {
100
- "$schema": "./node_modules/oxlint/configuration_schema.json",
117
+ "$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json",
101
118
  "extends": ["./node_modules/@mrmartineau/kit/src/oxlint/.oxlintrc.json"]
102
119
  }
103
120
  ```
104
121
 
105
- **Included settings:** correctness (error), suspicious + perf (warn), typescript/unicorn/import/react/jsx-a11y plugins, no-console warn, no-debugger error.
122
+ **Included settings:** correctness (error), suspicious + perf (warn), browser + node + es2024 envs, typescript/unicorn/import/react/jsx-a11y plugins, no-console warn, no-debugger error, `typescript/consistent-type-imports` error, `no-unused-vars` that allows `const { a, ...rest } = x`, `react/react-in-jsx-scope` off (React 17+ needs no `React` import).
123
+
124
+ `consistent-type-imports` pairs with the `verbatimModuleSyntax` TypeScript
125
+ setting this kit also uses: without it, a type-only import that's missing the
126
+ `type` keyword survives into the emitted JavaScript as a real runtime import.
106
127
 
107
128
  ### oxfmt
108
129
 
109
- Shared [oxfmt](https://oxc.rs/docs/guide/usage/formatter) config. Reference it when running oxfmt:
130
+ Shared [oxfmt](https://oxc.rs/docs/guide/usage/formatter) config. oxfmt has no
131
+ `extends`, but it reads an `oxfmt.config.ts`, so import the kit settings and add
132
+ your own:
133
+
134
+ ```ts
135
+ // oxfmt.config.ts
136
+ import kit from '@mrmartineau/kit/oxfmt' with { type: 'json' }
137
+
138
+ export default { ...kit, ignorePatterns: ['src/routeTree.gen.ts'] }
139
+ ```
140
+
141
+ The settings match the Biome config: single quotes, no semicolons, 2-space
142
+ indentation, 100 print width, import sorting with no blank lines between groups.
143
+ `astro: true` formats `.astro` files, templates included, when the project has
144
+ `@astrojs/compiler-rs` installed. Projects without Astro files do not need it.
145
+
146
+ ### Strict configs
147
+
148
+ `src/biome/strict.json` and `src/oxlint/strict.json` extend the base configs
149
+ and turn the [coding standards](https://github.com/mrmartineau/agent-skills/tree/main/skills/coding-standards)
150
+ into errors. An agent cannot hand-wave a lint error, so it has one way left to
151
+ write the code: the standard one. Use them in new projects. In an older project,
152
+ turn on rules one at a time.
110
153
 
111
- ```sh
112
- oxfmt -c ./node_modules/@mrmartineau/kit/src/oxfmt/.oxfmtrc.json
154
+ ```json
155
+ { "extends": ["./node_modules/@mrmartineau/kit/src/biome/strict.json"] }
156
+ ```
157
+
158
+ ```json
159
+ { "extends": ["./node_modules/@mrmartineau/kit/src/oxlint/strict.json"] }
160
+ ```
161
+
162
+ Some files must break a rule: a package's entry `index.ts` re-exports, and
163
+ Storybook stories or Next.js pages need a default export. Turn the rule off for
164
+ those files only. In oxlint, your `overrides` add to the strict ones:
165
+
166
+ ```json
167
+ {
168
+ "extends": ["./node_modules/@mrmartineau/kit/src/oxlint/strict.json"],
169
+ "overrides": [
170
+ { "files": ["src/index.ts"], "rules": { "oxc/no-barrel-file": "off" } },
171
+ { "files": ["**/*.stories.tsx"], "rules": { "import/no-default-export": "off" } }
172
+ ]
173
+ }
113
174
  ```
114
175
 
115
- Or copy the settings into your own `.oxfmtrc.json`. The settings are kept consistent with the Biome config: single quotes, no semicolons, 2-space indentation, 100 print width.
176
+ In Biome, your `overrides` replace the strict ones, so copy those first
177
+ (see [Biome](#biome)).
178
+
179
+ | Standard | Biome | oxlint |
180
+ | :------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------- |
181
+ | kebab-case file names | `useFilenamingConvention` | `unicorn/filename-case` |
182
+ | No barrel files | `noBarrelFile`, `noReExportAll` | `oxc/no-barrel-file` |
183
+ | Named exports (config files excepted) | `noDefaultExport` | `import/no-default-export` |
184
+ | No `import * as` | `noNamespaceImport` | `import/no-namespace` |
185
+ | ES modules only | `noCommonJs` | `typescript/no-require-imports` |
186
+ | `interface` for object shapes | `useConsistentTypeDefinitions` | `typescript/consistent-type-definitions` |
187
+ | Unions, not enums | `noEnum` | — (use `erasableSyntaxOnly` in `tsconfig.json`) |
188
+ | No `any`, no `!`, no `@ts-ignore` | `noExplicitAny`, `noNonNullAssertion`, `noTsIgnore` | `typescript/no-explicit-any`, `typescript/no-non-null-assertion`, `typescript/ban-ts-comment` |
189
+ | `import type` for types | `useImportType` | `typescript/consistent-type-imports` (base) |
190
+ | At most 3 parameters | `useMaxParams` | `max-params` |
191
+ | No nested ternaries, no `==` | `noNestedTernary`, `noDoubleEquals` | `no-nested-ternary`, `eqeqeq` |
192
+ | Only `console.warn` and `console.error` | `noConsole` | `no-console` |
193
+ | No silent empty `catch` (a comment is fine) | `noEmptyBlockStatements` | `no-empty` |
194
+ | Sorting: Biome wants a compare function; oxlint wants `toSorted()` and `toReversed()` when the result is used | `useArraySortCompare` | `unicorn/no-array-sort`, `unicorn/no-array-reverse` |
195
+ | React: no `key={index}`, no components in components, hooks at top level | `noArrayIndexKey`, `noNestedComponentDefinitions`, `useHookAtTopLevel` | `react/no-array-index-key`, `react/no-unstable-nested-components`, `react/rules-of-hooks` |
196
+ | No `dangerouslySetInnerHTML`; for sanitised HTML, turn the rule off on that line with a reason | `noDangerouslySetInnerHtml` (base) | `react/no-danger` |
197
+
198
+ When an agent breaks a standard that has no rule here, add one. GritQL
199
+ plugins (Biome) and JS plugins (oxlint) cover what the built-in rules cannot.
116
200
 
117
201
  ### ESLint
118
202
 
119
- Shared [ESLint](https://eslint.org) flat config with sensible base rules (no formatting rules — use Prettier/Biome/oxfmt for that).
203
+ Shared [ESLint](https://eslint.org) flat config with a small set of base rules.
204
+ It carries no formatting rules — use Prettier, Biome or oxfmt for that.
120
205
 
121
- In your project's `eslint.config.ts` (or `.js`):
206
+ This config **layers on top of a recommended base rather than replacing it**, so
207
+ that this package stays dependency-free. Compose it with `@eslint/js` yourself —
208
+ on its own it will not give you `no-unused-vars`, `no-undef` and friends:
122
209
 
123
210
  ```ts
124
- import packConfig from '@mrmartineau/kit/eslint'
211
+ import js from '@eslint/js'
212
+ import kit from '@mrmartineau/kit/eslint'
125
213
  import { defineConfig } from 'eslint/config'
126
214
 
127
215
  export default defineConfig([
216
+ js.configs.recommended,
128
217
  {
129
218
  files: ['**/*.{ts,tsx,js,jsx}'],
130
- extends: [packConfig],
219
+ extends: [...kit],
131
220
  },
132
221
  ])
133
222
  ```
134
223
 
135
- **Included rules:** prefer-const, no-var, no-console (warn), no-debugger (error), eqeqeq, object-shorthand, prefer-template, prefer-arrow-callback, curly (multi-line). Add your own TypeScript/React plugins on top.
224
+ **Included rules:** prefer-const, no-var, no-console (warn), no-debugger
225
+ (error), no-alert (warn), eqeqeq, object-shorthand, prefer-template,
226
+ prefer-arrow-callback and curly (multi-line). Add your own TypeScript/React
227
+ plugins on top.
228
+
229
+ `curly` is the one stylistic-looking rule here, and it's deliberate: it guards
230
+ against a statement being accidentally added outside an unbraced block, which no
231
+ formatter will catch for you.
232
+
233
+ #### Opt-in: ban `../` imports
234
+
235
+ `no-restricted-imports` is exported separately rather than being on by default —
236
+ it only makes sense once a project has path aliases configured, and colocated
237
+ tests or sibling-directory imports in a library layout can't satisfy it at all.
238
+
239
+ ```ts
240
+ import kit, { noRelativeParentImports } from '@mrmartineau/kit/eslint'
241
+
242
+ export default defineConfig([...kit, noRelativeParentImports])
243
+ ```
136
244
 
137
245
  ### Prettier
138
246
 
@@ -152,6 +260,51 @@ Or create a `.prettierrc.json`:
152
260
 
153
261
  **Included settings:** single quotes, no semicolons, 2-space indentation, trailing commas, 100 print width.
154
262
 
263
+ #### Astro
264
+
265
+ Prettier can't parse `.astro` files on its own, so there's a separate config that
266
+ layers [`prettier-plugin-astro`](https://github.com/withastro/prettier-plugin-astro)
267
+ on top of the base one. It's kept separate because Prettier hard-errors when a
268
+ plugin listed in `plugins` can't be resolved — putting the plugin in the base
269
+ config would break every non-Astro consumer.
270
+
271
+ ```bash
272
+ bun add -d prettier prettier-plugin-astro
273
+ ```
274
+
275
+ In your `package.json`:
276
+
277
+ ```json
278
+ {
279
+ "prettier": "@mrmartineau/kit/prettier/astro"
280
+ }
281
+ ```
282
+
283
+ Or in a `prettier.config.mjs`:
284
+
285
+ ```js
286
+ export { default } from '@mrmartineau/kit/prettier/astro'
287
+ ```
288
+
289
+ Everything from the base config still applies — the `.astro` frontmatter and
290
+ expressions are formatted with the same single quotes, no semicolons, 2-space
291
+ indentation and 100 print width.
292
+
293
+ If you also use `prettier-plugin-tailwindcss`, it must come **last** in
294
+ `plugins`, so extend the config rather than referencing it directly:
295
+
296
+ ```js
297
+ import astro from '@mrmartineau/kit/prettier/astro'
298
+
299
+ export default {
300
+ ...astro,
301
+ plugins: [...astro.plugins, 'prettier-plugin-tailwindcss'],
302
+ }
303
+ ```
304
+
305
+ > oxfmt also formats `.astro` files (see [oxfmt](#oxfmt)). Biome does not format
306
+ > Astro templates.
307
+
155
308
  ### Utils, Components, Hooks
156
309
 
157
310
  ```ts
@@ -160,21 +313,153 @@ import { ... } from "@mrmartineau/kit/components";
160
313
  import { ... } from "@mrmartineau/kit/hooks";
161
314
  ```
162
315
 
316
+ #### Formatters
317
+
318
+ A collection of number and string formatters. All number formatters wrap
319
+ `Intl.NumberFormat` and default to the `en-GB` locale.
320
+
321
+ ```ts
322
+ import {
323
+ formatNumberAccounting,
324
+ formatNumberBase,
325
+ formatNumberBytes,
326
+ formatNumberCompact,
327
+ formatNumberCurrency,
328
+ formatNumberDecimal,
329
+ formatNumberDecimalForceDecimalPlaces,
330
+ formatNumberOrdinal,
331
+ formatNumberPercent,
332
+ formatNumberRange,
333
+ formatNumberSignDisplay,
334
+ formatInitials,
335
+ formatList,
336
+ maskString,
337
+ normalizeWhitespace,
338
+ pluralize,
339
+ slugify,
340
+ stripDiacritics,
341
+ toCamelCase,
342
+ toKebabCase,
343
+ toPascalCase,
344
+ toSnakeCase,
345
+ toStartCase,
346
+ truncate,
347
+ } from '@mrmartineau/kit/utils'
348
+ ```
349
+
350
+ ##### Number formatters
351
+
352
+ | Function | Signature | Example |
353
+ | --------------------------------------- | -------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
354
+ | `formatNumberBase` | `(value, options?)` | `formatNumberBase(1234)` → `"1,234"` |
355
+ | `formatNumberDecimal` | `(value, decimalCount = 2, options?)` | `formatNumberDecimal(1234.567, 2)` → `"1,234.57"` |
356
+ | `formatNumberDecimalForceDecimalPlaces` | `(value, decimalCount = 2, options?)` | `formatNumberDecimalForceDecimalPlaces(10, 2)` → `"10.00"` |
357
+ | `formatNumberCurrency` | `(value, currency, decimalCount = 2, options?)` | `formatNumberCurrency(1234, "GBP")` → `"£1,234.00"` |
358
+ | `formatNumberAccounting` | `(value, currency, decimalCount = 2, options?)` — negatives wrapped in parens | `formatNumberAccounting(-100, "USD")` → `"($100.00)"` |
359
+ | `formatNumberPercent` | `(value, decimalCount = 2, options?)` — value already in decimal form (`0.42` → `42%`) | `formatNumberPercent(0.421)` → `"42.1%"` |
360
+ | `formatNumberCompact` | `(value, display = "short", options?)` | `formatNumberCompact(1200)` → `"1.2K"` |
361
+ | `formatNumberOrdinal` | `(value, locale = "en-GB")` | `formatNumberOrdinal(3)` → `"3rd"` |
362
+ | `formatNumberBytes` | `(bytes, binary = false, decimalCount = 2)` | `formatNumberBytes(1536, true)` → `"1.5 KiB"` |
363
+ | `formatNumberRange` | `(min, max, options?, locale = "en-GB")` | `formatNumberRange(1, 5)` → `"1–5"` |
364
+ | `formatNumberSignDisplay` | `(value, decimalCount = 2, signDisplay = "exceptZero", options?)` | `formatNumberSignDisplay(5)` → `"+5"` |
365
+
366
+ ##### String formatters
367
+
368
+ | Function | Signature | Example |
369
+ | --------------------- | -------------------------------------------------------------- | ------------------------------------------------------- |
370
+ | `formatList` | `(array, options?)` — wraps `Intl.ListFormat` | `formatList(["a","b","c"])` → `"a, b, and c"` |
371
+ | `toStartCase` | `(str)` | `toStartCase("hello_world")` → `"Hello World"` |
372
+ | `toCamelCase` | `(str)` | `toCamelCase("hello_world")` → `"helloWorld"` |
373
+ | `toPascalCase` | `(str)` | `toPascalCase("hello_world")` → `"HelloWorld"` |
374
+ | `toKebabCase` | `(str)` | `toKebabCase("helloWorld")` → `"hello-world"` |
375
+ | `toSnakeCase` | `(str)` | `toSnakeCase("helloWorld")` → `"hello_world"` |
376
+ | `truncate` | `(str, maxLength, { ellipsis = "…", wordBoundary = false }?)` | `truncate("Hello world", 8)` → `"Hello w…"` |
377
+ | `slugify` | `(str)` | `slugify("Hello, World!")` → `"hello-world"` |
378
+ | `pluralize` | `(count, singular, plural?)` | `pluralize(2, "child", "children")` → `"children"` |
379
+ | `stripDiacritics` | `(str)` | `stripDiacritics("café")` → `"cafe"` |
380
+ | `normalizeWhitespace` | `(str)` | `normalizeWhitespace(" a\n\tb ")` → `"a b"` |
381
+ | `maskString` | `(str, { visibleStart = 0, visibleEnd = 4, maskChar = "•" }?)` | `maskString("4242424242424242")` → `"••••••••••••4242"` |
382
+ | `formatInitials` | `(name, maxLength = 2)` | `formatInitials("John Smith")` → `"JS"` |
383
+
384
+ #### Type checks
385
+
386
+ Runtime "is this a…?" checks. Each one is a TypeScript type guard, so the
387
+ value's type narrows after the check. Use them on data you don't control:
388
+ API responses, `JSON.parse`, `localStorage`, `catch` errors.
389
+
390
+ ```ts
391
+ import { isDefined, isPlainObject, isString } from '@mrmartineau/kit/utils'
392
+
393
+ const ids = [1, null, 2].filter(isDefined) // number[]
394
+ ```
395
+
396
+ | Function | `true` for |
397
+ | ----------------- | -------------------------------------------------------------------- |
398
+ | `isString` | strings |
399
+ | `isBoolean` | booleans |
400
+ | `isBigInt` | bigints |
401
+ | `isSymbol` | symbols |
402
+ | `isFunction` | functions, including classes |
403
+ | `isPrimitive` | anything that isn't an object or function, including `null` |
404
+ | `isNumber` | any number, including `NaN` and `Infinity` |
405
+ | `isFiniteNumber` | numbers that aren't `NaN` or `Infinity` |
406
+ | `isInteger` | whole numbers |
407
+ | `isNumericString` | strings that hold a finite number: `'42'` yes, `''` and `'12px'` no |
408
+ | `isNull` | `null` |
409
+ | `isUndefined` | `undefined` |
410
+ | `isNil` | `null` or `undefined` |
411
+ | `isDefined` | anything but `null` or `undefined`; works as a `filter` callback |
412
+ | `isObjectLike` | any non-null object, arrays included |
413
+ | `isObject` | non-null objects that aren't arrays |
414
+ | `isPlainObject` | `{}` literals and `Object.create(null)` only |
415
+ | `hasKey` | objects with that key as their own property: `hasKey(data, 'id')` |
416
+ | `isArray` | arrays |
417
+ | `isArrayOf` | arrays where every item passes a check: `isArrayOf(value, isString)` |
418
+ | `isValidDate` | `Date`s that hold a real date, not `new Date('nonsense')` |
419
+ | `isRegExp` | regular expressions |
420
+ | `isMap` | `Map`s |
421
+ | `isSet` | `Set`s |
422
+ | `isError` | `Error`s and subclasses |
423
+ | `isPromiseLike` | promises and anything else with a `.then` method |
424
+ | `isIterable` | anything `for...of` can loop over, strings included |
425
+ | `isEmpty` | `null`, `undefined`, `''`, `[]`, `{}` and empty `Map`s and `Set`s |
426
+
427
+ More detail and the reasoning behind each one: [Type check helpers](https://zander.wtf/notes/type-check-helpers/).
428
+
163
429
  ## Exports map
164
430
 
165
- | Specifier | Resolves to |
166
- | ------------------------------- | -------------------------------- |
167
- | `@mrmartineau/kit` | `src/index.ts` |
168
- | `@mrmartineau/kit/biome` | `src/biome/biome.json` |
169
- | `@mrmartineau/kit/eslint` | `src/eslint/index.ts` |
170
- | `@mrmartineau/kit/oxlint` | `src/oxlint/.oxlintrc.json` |
171
- | `@mrmartineau/kit/oxfmt` | `src/oxfmt/.oxfmtrc.json` |
172
- | `@mrmartineau/kit/prettier` | `src/prettier/.prettierrc.json` |
173
- | `@mrmartineau/kit/sounds` | `src/sounds/index.ts` (metadata) |
174
- | `@mrmartineau/kit/sounds/*.mp3` | `src/sounds/*.mp3` (raw files) |
175
- | `@mrmartineau/kit/utils` | `src/utils/index.ts` |
176
- | `@mrmartineau/kit/components` | `src/components/index.ts` |
177
- | `@mrmartineau/kit/hooks` | `src/hooks/index.ts` |
431
+ | Specifier | Resolves to |
432
+ | --------------------------------- | -------------------------------- |
433
+ | `@mrmartineau/kit` | `src/index.ts` |
434
+ | `@mrmartineau/kit/biome` | `src/biome/biome.json` |
435
+ | `@mrmartineau/kit/biome/strict` | `src/biome/strict.json` |
436
+ | `@mrmartineau/kit/eslint` | `src/eslint/index.ts` |
437
+ | `@mrmartineau/kit/oxlint` | `src/oxlint/.oxlintrc.json` |
438
+ | `@mrmartineau/kit/oxlint/strict` | `src/oxlint/strict.json` |
439
+ | `@mrmartineau/kit/oxfmt` | `src/oxfmt/.oxfmtrc.json` |
440
+ | `@mrmartineau/kit/prettier` | `src/prettier/.prettierrc.json` |
441
+ | `@mrmartineau/kit/prettier/astro` | `src/prettier/astro.js` |
442
+ | `@mrmartineau/kit/sounds` | `src/sounds/index.ts` (metadata) |
443
+ | `@mrmartineau/kit/sounds/*.mp3` | `src/sounds/*.mp3` (raw files) |
444
+ | `@mrmartineau/kit/utils` | `src/utils/index.ts` |
445
+ | `@mrmartineau/kit/components` | `src/components/index.ts` |
446
+ | `@mrmartineau/kit/hooks` | `src/hooks/index.ts` |
447
+
448
+ ## Development
449
+
450
+ This repo dogfoods its own oxlint and oxfmt configs — the root `.oxlintrc.json`
451
+ and `oxfmt.config.ts` use the shared configs in `src/`, so a change to them shows
452
+ up here first.
453
+
454
+ ```bash
455
+ bun run lint # check
456
+ bun run lint:fix # check and apply fixes
457
+ bun run format # format with oxfmt
458
+ bun test
459
+ bun run typecheck
460
+ ```
461
+
462
+ CI runs `oxlint --deny-warnings` and `oxfmt --check` alongside typecheck and tests on every pull request.
178
463
 
179
464
  ## Attribution
180
465
 
package/package.json CHANGED
@@ -1,43 +1,72 @@
1
1
  {
2
2
  "name": "@mrmartineau/kit",
3
- "version": "0.1.0",
4
- "type": "module",
5
- "publishConfig": {
6
- "access": "public"
3
+ "version": "1.1.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/mrmartineau/kit.git"
7
7
  },
8
+ "files": [
9
+ "src"
10
+ ],
11
+ "type": "module",
8
12
  "exports": {
9
13
  ".": "./src/index.ts",
10
14
  "./biome": "./src/biome/biome.json",
15
+ "./biome/strict": "./src/biome/strict.json",
11
16
  "./components": "./src/components/index.ts",
12
17
  "./eslint": "./src/eslint/index.ts",
13
18
  "./hooks": "./src/hooks/index.ts",
14
19
  "./oxfmt": "./src/oxfmt/.oxfmtrc.json",
15
20
  "./oxlint": "./src/oxlint/.oxlintrc.json",
21
+ "./oxlint/strict": "./src/oxlint/strict.json",
16
22
  "./prettier": "./src/prettier/.prettierrc.json",
23
+ "./prettier/astro": "./src/prettier/astro.js",
17
24
  "./sounds": "./src/sounds/index.ts",
18
25
  "./sounds/*": "./src/sounds/*",
19
26
  "./utils": "./src/utils/index.ts"
20
27
  },
21
- "files": [
22
- "src"
23
- ],
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "scripts": {
32
+ "test": "bun test",
33
+ "typecheck": "tsc --noEmit",
34
+ "lint": "oxlint",
35
+ "lint:fix": "oxlint --fix",
36
+ "format": "oxfmt",
37
+ "ci:lint": "oxlint --deny-warnings && oxfmt --check",
38
+ "release": "semantic-release"
39
+ },
24
40
  "devDependencies": {
25
- "@types/bun": "latest",
26
- "@types/eslint": "^9.6.1"
41
+ "@semantic-release/changelog": "^7.0.0",
42
+ "@semantic-release/commit-analyzer": "^13.0.1",
43
+ "@semantic-release/git": "^11.0.1",
44
+ "@semantic-release/github": "^12.0.9",
45
+ "@semantic-release/npm": "^13.1.5",
46
+ "@semantic-release/release-notes-generator": "^14.1.1",
47
+ "@types/bun": "1.3.14",
48
+ "@types/eslint": "^9.6.1",
49
+ "oxfmt": "^0.79.0",
50
+ "oxlint": "^1.94.0",
51
+ "prettier": "^3.9.6",
52
+ "prettier-plugin-astro": "^0.14.1",
53
+ "semantic-release": "^25.0.9"
27
54
  },
28
55
  "peerDependencies": {
29
- "eslint": "",
30
- "typescript": "^5"
56
+ "eslint": "*",
57
+ "prettier": "^3.0.0",
58
+ "prettier-plugin-astro": "^0.14.0",
59
+ "typescript": "^6.0.3"
31
60
  },
32
61
  "peerDependenciesMeta": {
33
62
  "eslint": {
34
63
  "optional": true
64
+ },
65
+ "prettier": {
66
+ "optional": true
67
+ },
68
+ "prettier-plugin-astro": {
69
+ "optional": true
35
70
  }
36
- },
37
- "dependencies": {
38
- "release-it": "^19.2.4"
39
- },
40
- "scripts": {
41
- "release": "release-it"
42
71
  }
43
72
  }
@@ -1,10 +1,10 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.1.3/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.5.7/schema.json",
3
+ "root": false,
3
4
  "assist": {
4
5
  "actions": {
5
6
  "source": {
6
- "organizeImports": "on",
7
- "useSortedKeys": "on"
7
+ "organizeImports": "on"
8
8
  }
9
9
  },
10
10
  "enabled": true
@@ -12,12 +12,15 @@
12
12
  "formatter": {
13
13
  "enabled": true,
14
14
  "formatWithErrors": true,
15
- "indentStyle": "space"
15
+ "indentStyle": "space",
16
+ "indentWidth": 2,
17
+ "lineWidth": 100
16
18
  },
17
19
  "javascript": {
18
20
  "formatter": {
19
21
  "quoteStyle": "single",
20
- "semicolons": "asNeeded"
22
+ "semicolons": "asNeeded",
23
+ "trailingCommas": "all"
21
24
  }
22
25
  },
23
26
  "linter": {
@@ -26,12 +29,39 @@
26
29
  },
27
30
  "enabled": true,
28
31
  "rules": {
29
- "recommended": true
32
+ "preset": "recommended"
30
33
  }
31
34
  },
32
35
  "vcs": {
33
36
  "clientKind": "git",
34
37
  "enabled": true,
35
38
  "useIgnoreFile": true
36
- }
39
+ },
40
+ "overrides": [
41
+ {
42
+ "includes": ["**/*.astro", "**/*.svelte", "**/*.vue"],
43
+ "linter": {
44
+ "rules": {
45
+ "correctness": {
46
+ "noUnusedImports": "off",
47
+ "noUnusedVariables": "off"
48
+ },
49
+ "style": {
50
+ "useConst": "off",
51
+ "useImportType": "off"
52
+ }
53
+ }
54
+ }
55
+ },
56
+ {
57
+ "includes": ["**/release.config.*"],
58
+ "linter": {
59
+ "rules": {
60
+ "suspicious": {
61
+ "noTemplateCurlyInString": "off"
62
+ }
63
+ }
64
+ }
65
+ }
66
+ ]
37
67
  }