Skip to content

Commit 3a68261

Browse files
committed
lint?
1 parent b6d2f0f commit 3a68261

File tree

3 files changed

+39
-22
lines changed

3 files changed

+39
-22
lines changed

README.md

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ module.exports = {
145145
<!-- codegen:start {preset: markdownFromJsdoc, source: src/presets/custom.ts, export: custom} -->
146146
#### [custom](./src/presets/custom.ts#L62)
147147

148-
Define your own codegen function, which will receive all options specified. Import the `Preset` type from this library to define a strongly-typed preset function:
148+
Define your own codegen function, which will receive all options specified.
149+
150+
Import the `Preset` type from this library to define a strongly-typed preset function:
149151

150152
##### Example
151153

@@ -164,7 +166,12 @@ This can be used in other files by specifying the `source` option like:
164166

165167
`<!-- codegen:start {source: ./lib/my-custom-preset.js, export: jsonPrinter, myCustomProp: hello}`
166168

167-
<br /> Note that some helpers passed via `dependencies`, such as `glob`, `fs`, `path`, `child_process`, `lodash`, `jsYaml`, `dedent`, and `readPkgUp`, corresponding to those node modules respectively. These can be useful to allow access to those libraries without them being production dependencies. This also allows your lint process to use these node-only dependencies, even in a file that is not run in node - only the calls would be included in any bundled output, not the dependencies themselves.
169+
<br />
170+
171+
Note that some helpers passed via `dependencies`, such as `glob`, `fs`, `path`, `child_process`, `lodash`, `jsYaml`, `dedent`, and `readPkgUp`, corresponding to those
172+
node modules respectively. These can be useful to allow access to those libraries without them being production dependencies.
173+
This also allows your lint process to use these node-only dependencies, even in a file that is not run in node - only the calls would be included in any
174+
bundled output, not the dependencies themselves.
168175

169176
##### Params
170177

@@ -268,13 +275,17 @@ module.exports.myGenerator = ({dependencies}) => {
268275
![](./gifs/custom.gif)
269276

270277
<!-- codegen:start {preset: markdownFromJsdoc, source: src/presets/copy.ts, export: copy} -->
271-
#### [copy](./src/presets/copy.ts#L53)
278+
#### [copy](./src/presets/copy.ts#L49)
272279

273-
Copies a whole other file. Useful for "borrowing" an implementation of a simple utility from another project, without needing to publish it. Obviously this creates duplicated code, so use judiciously!
280+
Copies a whole other file. Useful for "borrowing" an implementation of a simple utility from another project, without needing to publish it.
281+
Obviously this creates duplicated code, so use judiciously!
274282

275283
##### basic usage
276284
```js
277-
// codegen:start {preset: copy, source: ../../another-project/src/some-file.ts} import {z} from 'zod' export const MyObject = z.object({ foo: z.string() })
285+
// codegen:start {preset: copy, source: ../../another-project/src/some-file.ts}
286+
import {z} from 'zod'
287+
288+
export const MyObject = z.object({foo: z.string()})
278289
// codegen:end
279290
```
280291

@@ -283,6 +294,7 @@ Copies a whole other file. Useful for "borrowing" an implementation of a simple
283294
```ts
284295
import {z} from 'zod/v4' // in this project we use zod v4, but we're copying from a project that uses zod v3
285296
// codegen:start {preset: copy, source: ../../another-project/src/some-file.ts, excludeLines: ['^import']}
297+
286298
export const MyObject = z.object({foo: z.string()})
287299
// codegen:end
288300
```
@@ -304,9 +316,9 @@ export const MyObject = z.object({foo: z.string()})
304316
// by default, the content will perform a "simplified" comparison with existing content, so differences from tools like prettier
305317
// are ignored. if you care about whitespace and similar differences, you can set the comparison option to `strict`.
306318
// codegen:start {preset: copy, source: ../../another-project/src/some-file.ts, comparison: strict}
307-
import {z} from 'zod'
319+
import {z} from "zod"
308320

309-
export const MyObject = z.object({foo: z.string()})
321+
export const MyObject = z.objectfoo: z.string()})
310322
// codegen:end
311323
```
312324
<!-- codegen:end -->
@@ -430,7 +442,12 @@ Generate a table of contents from the current markdown file, based on markdown h
430442
<!-- codegen:start {preset: markdownFromJsdoc, source: src/presets/markdown-from-tests.ts, export: markdownFromTests} -->
431443
#### [markdownFromTests](./src/presets/markdown-from-tests.ts#L25)
432444

433-
Use a test file to generate library usage documentation. Note: this has been tested with vitest and jest. It _might_ also work fine with mocha, and maybe ava, but those haven't been tested. JSDoc/inline comments above tests will be added as a "preamble", making this a decent way to quickly document API usage of a library, and to be sure that the usage is real and accurate.
445+
Use a test file to generate library usage documentation.
446+
447+
Note: this has been tested with vitest and jest. It _might_ also work fine with mocha, and maybe ava, but those haven't been tested.
448+
449+
JSDoc/inline comments above tests will be added as a "preamble", making this a decent way to quickly document API usage of a library,
450+
and to be sure that the usage is real and accurate.
434451

435452
##### Example
436453

@@ -454,7 +471,11 @@ Use a test file to generate library usage documentation. Note: this has been tes
454471
<!-- codegen:start {preset: markdownFromJsdoc, source: src/presets/labeler.ts, export: labeler} -->
455472
#### [labeler](./src/presets/labeler.ts#L26)
456473

457-
Generates a yaml config for the [GitHub Pull Request Labeler Action](https://github.com/actions/labeler). Creates a label per package name, which will be applied to any file modified under the leaf package path. When packages are added or removed from the repo, or renamed, the yaml config will stay in sync with them. Additional labels can be added outside of the generated code block. See https://github.com/mmkal/ts/tree/main/.github/labeler.yml for an example.
474+
Generates a yaml config for the [GitHub Pull Request Labeler Action](https://github.com/actions/labeler).
475+
Creates a label per package name, which will be applied to any file modified under the leaf package path.
476+
When packages are added or removed from the repo, or renamed, the yaml config will stay in sync with them.
477+
Additional labels can be added outside of the generated code block.
478+
See https://github.com/mmkal/ts/tree/main/.github/labeler.yml for an example.
458479

459480
##### Example
460481
```yaml

src/presets/copy.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ import {definePreset} from './util/standard-schema-preset'
88
* ```js
99
* // codegen:start {preset: copy, source: ../../another-project/src/some-file.ts}
1010
* import {z} from 'zod'
11-
* export const MyObject = z.object({ foo: z.string() })
11+
*
12+
* export const MyObject = z.object({foo: z.string()})
1213
* // codegen:end
1314
* ```
1415
*
1516
* #### excludeLines
1617
*
1718
* ```ts
18-
* ;
1919
* import {z} from 'zod/v4' // in this project we use zod v4, but we're copying from a project that uses zod v3
2020
* // codegen:start {preset: copy, source: ../../another-project/src/some-file.ts, excludeLines: ['^import']}
21-
* ;
22-
* export const MyObject = z.object({ foo: z.string() })
21+
*
22+
* export const MyObject = z.object({foo: z.string()})
2323
* // codegen:end
2424
* ```
2525
*
@@ -29,11 +29,9 @@ import {definePreset} from './util/standard-schema-preset'
2929
* // in this case this will effectively skip the copying step on machines that don't have the sibling project installed
3030
* // e.g. on CI runners.
3131
* // codegen:start {preset: copy, source: ../../another-project/src/some-file.ts, onlyIfExists: ../../another-project/package.json}
32-
* ;
3332
* import {z} from 'zod'
34-
* ;
35-
* export const MyObject = z.object({ foo: z.string() });
36-
* ;
33+
*
34+
* export const MyObject = z.object({foo: z.string()})
3735
* // codegen:end
3836
* ```
3937
*
@@ -42,11 +40,9 @@ import {definePreset} from './util/standard-schema-preset'
4240
* // by default, the content will perform a "simplified" comparison with existing content, so differences from tools like prettier
4341
* // are ignored. if you care about whitespace and similar differences, you can set the comparison option to `strict`.
4442
* // codegen:start {preset: copy, source: ../../another-project/src/some-file.ts, comparison: strict}
45-
* ;
4643
* import {z} from "zod"
47-
* ;
48-
* export const MyObject = z.object({ foo: z.string() })
49-
* ;
44+
*
45+
* export const MyObject = z.objectfoo: z.string()})
5046
* // codegen:end
5147
* ```
5248
*/

src/presets/markdown-from-jsdoc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export const markdownFromJsdoc: Preset<{source: string; export?: string; headerL
123123

124124
if (sec.type === 'description') {
125125
// line breaks that run into letters aren't respected by jsdoc, so shouldn't be in markdown either
126-
return sec.content.replaceAll(/\r?\n\s*([A-Za-z])/g, ' $1')
126+
return sec.content //.replaceAll(/\r?\n\s*([A-Za-z])/g, ' $1')
127127
}
128128

129129
if (sec.type === 'see') {

0 commit comments

Comments
 (0)