@d3lm/lint-preset 1.5.5 → 1.6.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.
@@ -10,8 +10,8 @@ interface WrapOptions {
10
10
  */
11
11
  readonly avoidSentenceOrphans: boolean;
12
12
  /**
13
- * Sets how many columns a line may exceed its limit before it counts as overflowing. A layout
14
- * also uses them when that saves a line.
13
+ * Sets how many columns a line may exceed its limit before it counts as overflowing.
14
+ * A layout also uses those columns when that saves a line.
15
15
  */
16
16
  readonly tolerance: number;
17
17
  /**
@@ -21,7 +21,13 @@ interface WrapOptions {
21
21
  }
22
22
  type LineIssueType = 'overflow' | 'underfill' | 'orphan' | 'widow' | 'unbalanced' | 'split-parenthetical';
23
23
  /**
24
- * JSDoc writes types and `{@link ...}` tags as `{...}` groups, so they stay intact like code spans.
24
+ * Splits text into words. JSDoc writes types and `{@link ...}` tags as `{...}` groups, so they stay
25
+ * intact like code spans.
26
+ *
27
+ * A Markdown link stays intact too, since a link that continues on the next line can't be followed
28
+ * in an editor. rust-analyzer, for one, only resolves an intra-doc link that sits on one line of
29
+ * a `///` comment. A link is one word, like a code span, but its own words keep one space between
30
+ * them, like the words around it.
25
31
  */
26
32
  declare function tokenize(text: string): string[];
27
33
  /**
@@ -30,7 +36,12 @@ declare function tokenize(text: string): string[];
30
36
  */
31
37
  declare function wrapTokens(tokens: readonly string[], firstLimit: number, restLimit: number, options: WrapOptions): string[][];
32
38
 
33
- type CommentKind = 'jsdoc' | 'block';
39
+ /**
40
+ * Describes the syntax of a comment. Rust has doc comments for the item after them (`outer`, like `///` and `/**`)
41
+ * and for the item that holds them (`inner`, like `//!` and `/*!`). A `line` comment is a run of plain line comments
42
+ * (`//`), which is never rewrapped.
43
+ */
44
+ type CommentKind = 'jsdoc' | 'block' | 'line' | 'outer-line-doc' | 'inner-line-doc' | 'outer-block-doc' | 'inner-block-doc';
34
45
  type ParagraphKind = 'prose' | 'list' | 'tag' | 'code' | 'other';
35
46
  interface AnalyzeOptions extends WrapOptions {
36
47
  /**
@@ -75,7 +86,8 @@ interface ParagraphReport {
75
86
  /**
76
87
  * Holds the exact source lines for `startLine` through `endLine` when the paragraph is
77
88
  * greedily wrapped to the width, or `null` when the paragraph isn't prose, e.g. code,
78
- * a table, a diagram, or `@example`.
89
+ * a table, a diagram, or `@example`. A paragraph that is accepted with the layout for a
90
+ * wider width within the tolerance keeps its lines.
79
91
  */
80
92
  readonly suggestion: readonly string[] | null;
81
93
  }
@@ -95,9 +107,12 @@ interface CommentReport {
95
107
  readonly paragraphs: readonly ParagraphReport[];
96
108
  }
97
109
  /**
98
- * Finds all own-line block and JSDoc comments in a JavaScript or TypeScript source file and reports
99
- * how each paragraph deviates from a greedy wrap at `options.width`. Line comments (`//`) are never
100
- * analyzed. A source with a syntax error that stops the parser has no reports.
110
+ * Finds all own-line block and JSDoc comments in a JavaScript or TypeScript source file, or block
111
+ * and doc comments in a Rust source file (`.rs`), and reports how each paragraph deviates from a
112
+ * greedy wrap at `options.width`. A run of Rust line doc comments (`///` or `//!`) counts as one
113
+ * comment. A run of other line comments (`//`) on their own lines is never rewrapped, and it is
114
+ * only reported when a line is longer than the maximum. A source with a syntax error that stops
115
+ * the parser has no reports.
101
116
  */
102
117
  declare function analyzeSource(source: string, filename: string, options: AnalyzeOptions): CommentReport[];
103
118
  /**
@@ -115,16 +130,17 @@ declare function hasVerdictIssues(report: CommentReport): boolean;
115
130
  */
116
131
  declare function rewrapComment(report: CommentReport): string;
117
132
  /**
118
- * Returns the syntax tree of the source as JSON, without positions or comments, used to verify
119
- * that only comments changed. Moving or rewording a comment keeps it the same, while any change
120
- * to a string, template, regex, JSX text, or where a statement ends changes it. A source that
121
- * doesn't parse has no tree to compare, so all of its text counts.
133
+ * Returns the syntax tree of the source as JSON, without positions or comments, used to verify that
134
+ * only comments changed. Moving or rewording a comment leaves the tree the same, while any change to
135
+ * a string, template, regex, JSX text, or where a statement ends changes it. A source that doesn't
136
+ * parse has no tree to compare, so all of its text counts. A Rust source is compared by its tokens
137
+ * instead, with each run of doc comments as one marker (see `rustFingerprint`).
122
138
  */
123
139
  declare function codeFingerprint(source: string, filename: string): string;
124
140
 
125
141
  type AgentRunner = 'claude' | 'codex' | 'cursor';
126
142
  type HookMode = 'agent' | 'report' | 'off';
127
- type AgentScope = 'suspicious' | 'all';
143
+ type AgentScope = 'suspicious' | 'failing' | 'all';
128
144
  interface AgentConfig {
129
145
  /**
130
146
  * Names the agent CLI to spawn. Defaults to the host that triggered the hook, or `claude`
@@ -179,8 +195,10 @@ interface AgentConfig {
179
195
  * Selects which comments the agent sees. `suspicious` (default) is a triage, not a full review.
180
196
  * It only sends comments with hints, like a possible semicolon or a line that may end with the
181
197
  * first word of a sentence, and comments with issues in parts the tool never rewraps, so most
182
- * runs never call the agent. The tool fixes the layout of prose itself. `all` sends every comment
183
- * in changed lines, so that the agent reviews the wording of each against its rules.
198
+ * runs never call the agent. The tool fixes the layout of prose itself. `failing` sends only
199
+ * the comments with verdicts, the ones that fail `comments check`, and no comment that only has
200
+ * hints. `all` sends every comment in changed lines, so that the agent reviews the wording of
201
+ * each against its rules.
184
202
  */
185
203
  readonly scope?: AgentScope;
186
204
  }
@@ -196,8 +214,9 @@ interface HookConfig {
196
214
  }
197
215
  interface CommentsConfig {
198
216
  /**
199
- * Sets the preferred line length for comments, including indentation and the comment prefix.
200
- * Defaults to prettier's `printWidth`, or 80.
217
+ * Sets the preferred line length for comments, including indentation and the comment
218
+ * prefix. Defaults to prettier's `printWidth`, or 80. In Rust files, it defaults to
219
+ * rustfmt's `comment_width` instead, which is 80 by default too.
201
220
  */
202
221
  readonly width?: number;
203
222
  /**
@@ -214,8 +233,9 @@ interface CommentsConfig {
214
233
  readonly singleLineWidth?: number;
215
234
  /**
216
235
  * Sets how many columns prose lines may go past `width` when that saves a line in a paragraph of
217
- * three or more lines. It never goes past `maxWidth`. When `maxWidth` is omitted, it also sets a
218
- * legacy hard limit of `width + tolerance`.
236
+ * three or more lines. A paragraph that already has the layout for a wider `width`, up to `width`
237
+ * plus this many columns, also passes as it is. It never goes past `maxWidth`. When `maxWidth` is
238
+ * omitted, it also sets a legacy hard limit of `width + tolerance`.
219
239
  */
220
240
  readonly tolerance?: number;
221
241
  /**
@@ -236,9 +256,15 @@ interface CommentsConfig {
236
256
  */
237
257
  readonly style?: boolean;
238
258
  /**
239
- * Lists the file extensions to process. Defaults to JavaScript and TypeScript extensions.
259
+ * Lists the file extensions to process. Defaults to JavaScript, TypeScript, and Rust extensions.
240
260
  */
241
261
  readonly extensions?: readonly string[];
262
+ /**
263
+ * Lists glob patterns, relative to the repository root, of the only files to process.
264
+ * Without patterns, every file with one of the `extensions` is processed. `ignore` still
265
+ * skips files that match both.
266
+ */
267
+ readonly include?: readonly string[];
242
268
  /**
243
269
  * Lists glob patterns, relative to the repository root, of files to skip.
244
270
  */
@@ -10,8 +10,8 @@ interface WrapOptions {
10
10
  */
11
11
  readonly avoidSentenceOrphans: boolean;
12
12
  /**
13
- * Sets how many columns a line may exceed its limit before it counts as overflowing. A layout
14
- * also uses them when that saves a line.
13
+ * Sets how many columns a line may exceed its limit before it counts as overflowing.
14
+ * A layout also uses those columns when that saves a line.
15
15
  */
16
16
  readonly tolerance: number;
17
17
  /**
@@ -21,7 +21,13 @@ interface WrapOptions {
21
21
  }
22
22
  type LineIssueType = 'overflow' | 'underfill' | 'orphan' | 'widow' | 'unbalanced' | 'split-parenthetical';
23
23
  /**
24
- * JSDoc writes types and `{@link ...}` tags as `{...}` groups, so they stay intact like code spans.
24
+ * Splits text into words. JSDoc writes types and `{@link ...}` tags as `{...}` groups, so they stay
25
+ * intact like code spans.
26
+ *
27
+ * A Markdown link stays intact too, since a link that continues on the next line can't be followed
28
+ * in an editor. rust-analyzer, for one, only resolves an intra-doc link that sits on one line of
29
+ * a `///` comment. A link is one word, like a code span, but its own words keep one space between
30
+ * them, like the words around it.
25
31
  */
26
32
  declare function tokenize(text: string): string[];
27
33
  /**
@@ -30,7 +36,12 @@ declare function tokenize(text: string): string[];
30
36
  */
31
37
  declare function wrapTokens(tokens: readonly string[], firstLimit: number, restLimit: number, options: WrapOptions): string[][];
32
38
 
33
- type CommentKind = 'jsdoc' | 'block';
39
+ /**
40
+ * Describes the syntax of a comment. Rust has doc comments for the item after them (`outer`, like `///` and `/**`)
41
+ * and for the item that holds them (`inner`, like `//!` and `/*!`). A `line` comment is a run of plain line comments
42
+ * (`//`), which is never rewrapped.
43
+ */
44
+ type CommentKind = 'jsdoc' | 'block' | 'line' | 'outer-line-doc' | 'inner-line-doc' | 'outer-block-doc' | 'inner-block-doc';
34
45
  type ParagraphKind = 'prose' | 'list' | 'tag' | 'code' | 'other';
35
46
  interface AnalyzeOptions extends WrapOptions {
36
47
  /**
@@ -75,7 +86,8 @@ interface ParagraphReport {
75
86
  /**
76
87
  * Holds the exact source lines for `startLine` through `endLine` when the paragraph is
77
88
  * greedily wrapped to the width, or `null` when the paragraph isn't prose, e.g. code,
78
- * a table, a diagram, or `@example`.
89
+ * a table, a diagram, or `@example`. A paragraph that is accepted with the layout for a
90
+ * wider width within the tolerance keeps its lines.
79
91
  */
80
92
  readonly suggestion: readonly string[] | null;
81
93
  }
@@ -95,9 +107,12 @@ interface CommentReport {
95
107
  readonly paragraphs: readonly ParagraphReport[];
96
108
  }
97
109
  /**
98
- * Finds all own-line block and JSDoc comments in a JavaScript or TypeScript source file and reports
99
- * how each paragraph deviates from a greedy wrap at `options.width`. Line comments (`//`) are never
100
- * analyzed. A source with a syntax error that stops the parser has no reports.
110
+ * Finds all own-line block and JSDoc comments in a JavaScript or TypeScript source file, or block
111
+ * and doc comments in a Rust source file (`.rs`), and reports how each paragraph deviates from a
112
+ * greedy wrap at `options.width`. A run of Rust line doc comments (`///` or `//!`) counts as one
113
+ * comment. A run of other line comments (`//`) on their own lines is never rewrapped, and it is
114
+ * only reported when a line is longer than the maximum. A source with a syntax error that stops
115
+ * the parser has no reports.
101
116
  */
102
117
  declare function analyzeSource(source: string, filename: string, options: AnalyzeOptions): CommentReport[];
103
118
  /**
@@ -115,16 +130,17 @@ declare function hasVerdictIssues(report: CommentReport): boolean;
115
130
  */
116
131
  declare function rewrapComment(report: CommentReport): string;
117
132
  /**
118
- * Returns the syntax tree of the source as JSON, without positions or comments, used to verify
119
- * that only comments changed. Moving or rewording a comment keeps it the same, while any change
120
- * to a string, template, regex, JSX text, or where a statement ends changes it. A source that
121
- * doesn't parse has no tree to compare, so all of its text counts.
133
+ * Returns the syntax tree of the source as JSON, without positions or comments, used to verify that
134
+ * only comments changed. Moving or rewording a comment leaves the tree the same, while any change to
135
+ * a string, template, regex, JSX text, or where a statement ends changes it. A source that doesn't
136
+ * parse has no tree to compare, so all of its text counts. A Rust source is compared by its tokens
137
+ * instead, with each run of doc comments as one marker (see `rustFingerprint`).
122
138
  */
123
139
  declare function codeFingerprint(source: string, filename: string): string;
124
140
 
125
141
  type AgentRunner = 'claude' | 'codex' | 'cursor';
126
142
  type HookMode = 'agent' | 'report' | 'off';
127
- type AgentScope = 'suspicious' | 'all';
143
+ type AgentScope = 'suspicious' | 'failing' | 'all';
128
144
  interface AgentConfig {
129
145
  /**
130
146
  * Names the agent CLI to spawn. Defaults to the host that triggered the hook, or `claude`
@@ -179,8 +195,10 @@ interface AgentConfig {
179
195
  * Selects which comments the agent sees. `suspicious` (default) is a triage, not a full review.
180
196
  * It only sends comments with hints, like a possible semicolon or a line that may end with the
181
197
  * first word of a sentence, and comments with issues in parts the tool never rewraps, so most
182
- * runs never call the agent. The tool fixes the layout of prose itself. `all` sends every comment
183
- * in changed lines, so that the agent reviews the wording of each against its rules.
198
+ * runs never call the agent. The tool fixes the layout of prose itself. `failing` sends only
199
+ * the comments with verdicts, the ones that fail `comments check`, and no comment that only has
200
+ * hints. `all` sends every comment in changed lines, so that the agent reviews the wording of
201
+ * each against its rules.
184
202
  */
185
203
  readonly scope?: AgentScope;
186
204
  }
@@ -196,8 +214,9 @@ interface HookConfig {
196
214
  }
197
215
  interface CommentsConfig {
198
216
  /**
199
- * Sets the preferred line length for comments, including indentation and the comment prefix.
200
- * Defaults to prettier's `printWidth`, or 80.
217
+ * Sets the preferred line length for comments, including indentation and the comment
218
+ * prefix. Defaults to prettier's `printWidth`, or 80. In Rust files, it defaults to
219
+ * rustfmt's `comment_width` instead, which is 80 by default too.
201
220
  */
202
221
  readonly width?: number;
203
222
  /**
@@ -214,8 +233,9 @@ interface CommentsConfig {
214
233
  readonly singleLineWidth?: number;
215
234
  /**
216
235
  * Sets how many columns prose lines may go past `width` when that saves a line in a paragraph of
217
- * three or more lines. It never goes past `maxWidth`. When `maxWidth` is omitted, it also sets a
218
- * legacy hard limit of `width + tolerance`.
236
+ * three or more lines. A paragraph that already has the layout for a wider `width`, up to `width`
237
+ * plus this many columns, also passes as it is. It never goes past `maxWidth`. When `maxWidth` is
238
+ * omitted, it also sets a legacy hard limit of `width + tolerance`.
219
239
  */
220
240
  readonly tolerance?: number;
221
241
  /**
@@ -236,9 +256,15 @@ interface CommentsConfig {
236
256
  */
237
257
  readonly style?: boolean;
238
258
  /**
239
- * Lists the file extensions to process. Defaults to JavaScript and TypeScript extensions.
259
+ * Lists the file extensions to process. Defaults to JavaScript, TypeScript, and Rust extensions.
240
260
  */
241
261
  readonly extensions?: readonly string[];
262
+ /**
263
+ * Lists glob patterns, relative to the repository root, of the only files to process.
264
+ * Without patterns, every file with one of the `extensions` is processed. `ignore` still
265
+ * skips files that match both.
266
+ */
267
+ readonly include?: readonly string[];
242
268
  /**
243
269
  * Lists glob patterns, relative to the repository root, of files to skip.
244
270
  */