@d3lm/lint-preset 1.5.6 → 1.6.1
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.
- package/README.md +37 -10
- package/dist/bin/comments.js +542 -114
- package/dist/bin/comments.js.map +1 -1
- package/dist/comments.cjs +447 -69
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.d.cts +51 -25
- package/dist/comments.d.ts +51 -25
- package/dist/comments.js +449 -73
- package/dist/comments.js.map +1 -1
- package/native/comments.darwin-arm64.node +0 -0
- package/native/comments.darwin-x64.node +0 -0
- package/native/comments.linux-arm64-gnu.node +0 -0
- package/native/comments.linux-x64-gnu.node +0 -0
- package/package.json +9 -6
package/dist/comments.d.cts
CHANGED
|
@@ -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.
|
|
14
|
-
* also uses
|
|
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
|
|
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
|
-
|
|
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
|
/**
|
|
@@ -73,10 +84,10 @@ interface ParagraphReport {
|
|
|
73
84
|
readonly reason?: string;
|
|
74
85
|
readonly issues: readonly IssueReport[];
|
|
75
86
|
/**
|
|
76
|
-
* Holds the exact source lines for `startLine` through `endLine` when the paragraph is
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
87
|
+
* Holds the exact source lines for `startLine` through `endLine` when the paragraph is greedily
|
|
88
|
+
* wrapped to the width, or `null` when the paragraph isn't prose, e.g. code, a table, a diagram,
|
|
89
|
+
* or `@example`. A paragraph that the tolerance accepts as it is, with the layout for a wider
|
|
90
|
+
* width or with lines close to this one, keeps its lines.
|
|
80
91
|
*/
|
|
81
92
|
readonly suggestion: readonly string[] | null;
|
|
82
93
|
}
|
|
@@ -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
|
|
100
|
-
*
|
|
101
|
-
*
|
|
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
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
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. `
|
|
184
|
-
*
|
|
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
|
|
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
|
/**
|
|
@@ -214,10 +232,12 @@ interface CommentsConfig {
|
|
|
214
232
|
*/
|
|
215
233
|
readonly singleLineWidth?: number;
|
|
216
234
|
/**
|
|
217
|
-
* Sets how many columns prose lines may go past `width` when that saves a line in a paragraph
|
|
218
|
-
* three or more lines. A paragraph that already has the layout for a wider `width`, up to
|
|
219
|
-
* plus this many columns, also passes as it is.
|
|
220
|
-
*
|
|
235
|
+
* Sets how many columns prose lines may go past `width` when that saves a line in a paragraph
|
|
236
|
+
* of three or more lines. A paragraph that already has the layout for a wider `width`, up to
|
|
237
|
+
* `width` plus this many columns, also passes as it is. So does a paragraph with as many lines
|
|
238
|
+
* as the rewrap whose lines are each at most this many columns shorter or longer than in the
|
|
239
|
+
* rewrap. It never goes past `maxWidth`. When `maxWidth` is omitted, it also sets a legacy hard
|
|
240
|
+
* limit of `width + tolerance`.
|
|
221
241
|
*/
|
|
222
242
|
readonly tolerance?: number;
|
|
223
243
|
/**
|
|
@@ -238,9 +258,15 @@ interface CommentsConfig {
|
|
|
238
258
|
*/
|
|
239
259
|
readonly style?: boolean;
|
|
240
260
|
/**
|
|
241
|
-
* Lists the file extensions to process. Defaults to JavaScript and
|
|
261
|
+
* Lists the file extensions to process. Defaults to JavaScript, TypeScript, and Rust extensions.
|
|
242
262
|
*/
|
|
243
263
|
readonly extensions?: readonly string[];
|
|
264
|
+
/**
|
|
265
|
+
* Lists glob patterns, relative to the repository root, of the only files to process.
|
|
266
|
+
* Without patterns, every file with one of the `extensions` is processed. `ignore` still
|
|
267
|
+
* skips files that match both.
|
|
268
|
+
*/
|
|
269
|
+
readonly include?: readonly string[];
|
|
244
270
|
/**
|
|
245
271
|
* Lists glob patterns, relative to the repository root, of files to skip.
|
|
246
272
|
*/
|
package/dist/comments.d.ts
CHANGED
|
@@ -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.
|
|
14
|
-
* also uses
|
|
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
|
|
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
|
-
|
|
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
|
/**
|
|
@@ -73,10 +84,10 @@ interface ParagraphReport {
|
|
|
73
84
|
readonly reason?: string;
|
|
74
85
|
readonly issues: readonly IssueReport[];
|
|
75
86
|
/**
|
|
76
|
-
* Holds the exact source lines for `startLine` through `endLine` when the paragraph is
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
87
|
+
* Holds the exact source lines for `startLine` through `endLine` when the paragraph is greedily
|
|
88
|
+
* wrapped to the width, or `null` when the paragraph isn't prose, e.g. code, a table, a diagram,
|
|
89
|
+
* or `@example`. A paragraph that the tolerance accepts as it is, with the layout for a wider
|
|
90
|
+
* width or with lines close to this one, keeps its lines.
|
|
80
91
|
*/
|
|
81
92
|
readonly suggestion: readonly string[] | null;
|
|
82
93
|
}
|
|
@@ -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
|
|
100
|
-
*
|
|
101
|
-
*
|
|
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
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
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. `
|
|
184
|
-
*
|
|
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
|
|
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
|
/**
|
|
@@ -214,10 +232,12 @@ interface CommentsConfig {
|
|
|
214
232
|
*/
|
|
215
233
|
readonly singleLineWidth?: number;
|
|
216
234
|
/**
|
|
217
|
-
* Sets how many columns prose lines may go past `width` when that saves a line in a paragraph
|
|
218
|
-
* three or more lines. A paragraph that already has the layout for a wider `width`, up to
|
|
219
|
-
* plus this many columns, also passes as it is.
|
|
220
|
-
*
|
|
235
|
+
* Sets how many columns prose lines may go past `width` when that saves a line in a paragraph
|
|
236
|
+
* of three or more lines. A paragraph that already has the layout for a wider `width`, up to
|
|
237
|
+
* `width` plus this many columns, also passes as it is. So does a paragraph with as many lines
|
|
238
|
+
* as the rewrap whose lines are each at most this many columns shorter or longer than in the
|
|
239
|
+
* rewrap. It never goes past `maxWidth`. When `maxWidth` is omitted, it also sets a legacy hard
|
|
240
|
+
* limit of `width + tolerance`.
|
|
221
241
|
*/
|
|
222
242
|
readonly tolerance?: number;
|
|
223
243
|
/**
|
|
@@ -238,9 +258,15 @@ interface CommentsConfig {
|
|
|
238
258
|
*/
|
|
239
259
|
readonly style?: boolean;
|
|
240
260
|
/**
|
|
241
|
-
* Lists the file extensions to process. Defaults to JavaScript and
|
|
261
|
+
* Lists the file extensions to process. Defaults to JavaScript, TypeScript, and Rust extensions.
|
|
242
262
|
*/
|
|
243
263
|
readonly extensions?: readonly string[];
|
|
264
|
+
/**
|
|
265
|
+
* Lists glob patterns, relative to the repository root, of the only files to process.
|
|
266
|
+
* Without patterns, every file with one of the `extensions` is processed. `ignore` still
|
|
267
|
+
* skips files that match both.
|
|
268
|
+
*/
|
|
269
|
+
readonly include?: readonly string[];
|
|
244
270
|
/**
|
|
245
271
|
* Lists glob patterns, relative to the repository root, of files to skip.
|
|
246
272
|
*/
|