@d3lm/lint-preset 1.5.6 → 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
  /**
@@ -96,9 +107,12 @@ interface CommentReport {
96
107
  readonly paragraphs: readonly ParagraphReport[];
97
108
  }
98
109
  /**
99
- * Finds all own-line block and JSDoc comments in a JavaScript or TypeScript source file and reports
100
- * how each paragraph deviates from a greedy wrap at `options.width`. Line comments (`//`) are never
101
- * 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.
102
116
  */
103
117
  declare function analyzeSource(source: string, filename: string, options: AnalyzeOptions): CommentReport[];
104
118
  /**
@@ -116,16 +130,17 @@ declare function hasVerdictIssues(report: CommentReport): boolean;
116
130
  */
117
131
  declare function rewrapComment(report: CommentReport): string;
118
132
  /**
119
- * Returns the syntax tree of the source as JSON, without positions or comments, used to verify
120
- * that only comments changed. Moving or rewording a comment keeps it the same, while any change
121
- * to a string, template, regex, JSX text, or where a statement ends changes it. A source that
122
- * 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`).
123
138
  */
124
139
  declare function codeFingerprint(source: string, filename: string): string;
125
140
 
126
141
  type AgentRunner = 'claude' | 'codex' | 'cursor';
127
142
  type HookMode = 'agent' | 'report' | 'off';
128
- type AgentScope = 'suspicious' | 'all';
143
+ type AgentScope = 'suspicious' | 'failing' | 'all';
129
144
  interface AgentConfig {
130
145
  /**
131
146
  * Names the agent CLI to spawn. Defaults to the host that triggered the hook, or `claude`
@@ -180,8 +195,10 @@ interface AgentConfig {
180
195
  * Selects which comments the agent sees. `suspicious` (default) is a triage, not a full review.
181
196
  * It only sends comments with hints, like a possible semicolon or a line that may end with the
182
197
  * first word of a sentence, and comments with issues in parts the tool never rewraps, so most
183
- * runs never call the agent. The tool fixes the layout of prose itself. `all` sends every comment
184
- * 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.
185
202
  */
186
203
  readonly scope?: AgentScope;
187
204
  }
@@ -197,8 +214,9 @@ interface HookConfig {
197
214
  }
198
215
  interface CommentsConfig {
199
216
  /**
200
- * Sets the preferred line length for comments, including indentation and the comment prefix.
201
- * 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.
202
220
  */
203
221
  readonly width?: number;
204
222
  /**
@@ -238,9 +256,15 @@ interface CommentsConfig {
238
256
  */
239
257
  readonly style?: boolean;
240
258
  /**
241
- * 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.
242
260
  */
243
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[];
244
268
  /**
245
269
  * Lists glob patterns, relative to the repository root, of files to skip.
246
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
  /**
@@ -96,9 +107,12 @@ interface CommentReport {
96
107
  readonly paragraphs: readonly ParagraphReport[];
97
108
  }
98
109
  /**
99
- * Finds all own-line block and JSDoc comments in a JavaScript or TypeScript source file and reports
100
- * how each paragraph deviates from a greedy wrap at `options.width`. Line comments (`//`) are never
101
- * 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.
102
116
  */
103
117
  declare function analyzeSource(source: string, filename: string, options: AnalyzeOptions): CommentReport[];
104
118
  /**
@@ -116,16 +130,17 @@ declare function hasVerdictIssues(report: CommentReport): boolean;
116
130
  */
117
131
  declare function rewrapComment(report: CommentReport): string;
118
132
  /**
119
- * Returns the syntax tree of the source as JSON, without positions or comments, used to verify
120
- * that only comments changed. Moving or rewording a comment keeps it the same, while any change
121
- * to a string, template, regex, JSX text, or where a statement ends changes it. A source that
122
- * 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`).
123
138
  */
124
139
  declare function codeFingerprint(source: string, filename: string): string;
125
140
 
126
141
  type AgentRunner = 'claude' | 'codex' | 'cursor';
127
142
  type HookMode = 'agent' | 'report' | 'off';
128
- type AgentScope = 'suspicious' | 'all';
143
+ type AgentScope = 'suspicious' | 'failing' | 'all';
129
144
  interface AgentConfig {
130
145
  /**
131
146
  * Names the agent CLI to spawn. Defaults to the host that triggered the hook, or `claude`
@@ -180,8 +195,10 @@ interface AgentConfig {
180
195
  * Selects which comments the agent sees. `suspicious` (default) is a triage, not a full review.
181
196
  * It only sends comments with hints, like a possible semicolon or a line that may end with the
182
197
  * first word of a sentence, and comments with issues in parts the tool never rewraps, so most
183
- * runs never call the agent. The tool fixes the layout of prose itself. `all` sends every comment
184
- * 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.
185
202
  */
186
203
  readonly scope?: AgentScope;
187
204
  }
@@ -197,8 +214,9 @@ interface HookConfig {
197
214
  }
198
215
  interface CommentsConfig {
199
216
  /**
200
- * Sets the preferred line length for comments, including indentation and the comment prefix.
201
- * 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.
202
220
  */
203
221
  readonly width?: number;
204
222
  /**
@@ -238,9 +256,15 @@ interface CommentsConfig {
238
256
  */
239
257
  readonly style?: boolean;
240
258
  /**
241
- * 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.
242
260
  */
243
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[];
244
268
  /**
245
269
  * Lists glob patterns, relative to the repository root, of files to skip.
246
270
  */