@alint-js/plugin-js 0.1.3 → 0.1.5
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/LICENSE +21 -0
- package/dist/index.d.mts +103 -19
- package/dist/index.mjs +94 -19
- package/package.json +4 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alint contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
//#region ../plugin/dist/index.d.mts
|
|
2
|
-
//#region ../core/dist/types-
|
|
2
|
+
//#region ../core/dist/types-DM4idR4w.d.mts
|
|
3
3
|
//#region src/core/source/types.d.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
interface BaseSourceFile {
|
|
5
|
+
contentHash: string;
|
|
6
|
+
language: string;
|
|
7
|
+
path: string;
|
|
8
|
+
}
|
|
9
|
+
type ClassTarget = PlannedSourceTargetOfKind<'class'>;
|
|
10
|
+
type FileTarget = PlannedSourceTargetOfKind<'file'>;
|
|
11
|
+
type FunctionTarget = PlannedSourceTargetOfKind<'function'>;
|
|
7
12
|
interface LanguageContext {
|
|
8
13
|
cwd: string;
|
|
9
14
|
languageOptions: Record<string, unknown>;
|
|
@@ -13,6 +18,20 @@ interface LineRange {
|
|
|
13
18
|
endLine: number;
|
|
14
19
|
startLine: number;
|
|
15
20
|
}
|
|
21
|
+
interface PlannedSourceTarget {
|
|
22
|
+
file: BaseSourceFile;
|
|
23
|
+
identity: string;
|
|
24
|
+
kind: SourceTargetKind;
|
|
25
|
+
language: string;
|
|
26
|
+
loc?: SourceLocation;
|
|
27
|
+
metadata?: SourceTargetMetadata;
|
|
28
|
+
name?: string;
|
|
29
|
+
origin?: SourceTargetOrigin;
|
|
30
|
+
range?: SourceRange;
|
|
31
|
+
}
|
|
32
|
+
type PlannedSourceTargetOfKind<Kind extends SourceTargetKind> = Omit<PlannedSourceTarget, 'kind'> & {
|
|
33
|
+
kind: Kind;
|
|
34
|
+
};
|
|
16
35
|
interface ProcessedSource {
|
|
17
36
|
identity: string;
|
|
18
37
|
language?: string;
|
|
@@ -34,16 +53,26 @@ interface ProcessorPostprocessContext extends ProcessorContext {
|
|
|
34
53
|
file: SourceFile;
|
|
35
54
|
processedSources: ProcessedSource[];
|
|
36
55
|
}
|
|
37
|
-
interface
|
|
38
|
-
|
|
56
|
+
interface SourceExtractOptions {
|
|
57
|
+
/**
|
|
58
|
+
* Overrides the file's configured `language:` pin.
|
|
59
|
+
*
|
|
60
|
+
* For a caller walking a mixed tree, where the file's own config cannot know what each file is.
|
|
61
|
+
*/
|
|
62
|
+
language?: string;
|
|
63
|
+
}
|
|
64
|
+
interface SourceFile extends BaseSourceFile {
|
|
39
65
|
lines: string[];
|
|
40
|
-
path: string;
|
|
41
66
|
text: string;
|
|
42
67
|
}
|
|
43
68
|
interface SourceLocation {
|
|
44
69
|
end: SourcePosition;
|
|
45
70
|
start: SourcePosition;
|
|
46
71
|
}
|
|
72
|
+
interface SourceMetadataObject {
|
|
73
|
+
readonly [key: string]: SourceMetadataValue;
|
|
74
|
+
}
|
|
75
|
+
type SourceMetadataValue = boolean | null | number | readonly SourceMetadataValue[] | SourceMetadataObject | SourceRange | string;
|
|
47
76
|
interface SourcePosition {
|
|
48
77
|
column: number;
|
|
49
78
|
line: number;
|
|
@@ -53,8 +82,22 @@ interface SourceRange {
|
|
|
53
82
|
start: number;
|
|
54
83
|
}
|
|
55
84
|
interface SourceRuntime {
|
|
56
|
-
|
|
57
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Targets for any file, linted or not.
|
|
87
|
+
*
|
|
88
|
+
* Resolves the file's own config the way linting does, resolves its language from that config,
|
|
89
|
+
* and runs that language's extract. A rule handed `ProjectTarget.files`, or an index builder
|
|
90
|
+
* sweeping files outside the lint set, has no other way to parse them.
|
|
91
|
+
*
|
|
92
|
+
* An ignored file extracts to `[]` rather than throwing: sweeping broadly and skipping what the
|
|
93
|
+
* config excluded is the normal case, not an error.
|
|
94
|
+
*
|
|
95
|
+
* Only wired inside a run. A runtime built by `createSourceRuntime()` with no extractor throws,
|
|
96
|
+
* because there is no config to resolve the file against.
|
|
97
|
+
*/
|
|
98
|
+
extract: (filePath: string, options?: SourceExtractOptions) => Promise<SourceTarget[]>;
|
|
99
|
+
getText: (file: SourceFile) => string;
|
|
100
|
+
readFile: (file: BaseSourceFile | string) => Promise<SourceFile>;
|
|
58
101
|
sliceLines: (file: SourceFile, range: LineRange) => SourceText;
|
|
59
102
|
sliceRange: (file: SourceFile, range: SourceRange) => SourceText;
|
|
60
103
|
}
|
|
@@ -64,16 +107,14 @@ interface SourceTarget {
|
|
|
64
107
|
kind: SourceTargetKind;
|
|
65
108
|
language: string;
|
|
66
109
|
loc?: SourceLocation;
|
|
67
|
-
metadata?:
|
|
110
|
+
metadata?: SourceTargetMetadata;
|
|
68
111
|
name?: string;
|
|
69
112
|
origin?: SourceTargetOrigin;
|
|
70
113
|
range?: SourceRange;
|
|
71
114
|
text: string;
|
|
72
115
|
}
|
|
73
116
|
type SourceTargetKind = 'class' | 'file' | 'fragment' | 'function' | 'symbol' | (string & {});
|
|
74
|
-
type
|
|
75
|
-
kind: Kind;
|
|
76
|
-
};
|
|
117
|
+
type SourceTargetMetadata = Readonly<Record<string, SourceMetadataValue>>;
|
|
77
118
|
interface SourceTargetOrigin {
|
|
78
119
|
physicalPath: string;
|
|
79
120
|
range?: SourceRange;
|
|
@@ -705,7 +746,7 @@ interface Config$1<TIssue extends BaseIssue$1<unknown>> {
|
|
|
705
746
|
readonly abortPipeEarly?: boolean | undefined;
|
|
706
747
|
}
|
|
707
748
|
//#endregion
|
|
708
|
-
//#region ../core/dist/types-
|
|
749
|
+
//#region ../core/dist/types-deBCDA4_.d.mts
|
|
709
750
|
//#region src/config/types.d.ts
|
|
710
751
|
type ModelSize = 'large' | 'medium' | 'small';
|
|
711
752
|
interface RunnerCacheConfig {
|
|
@@ -797,6 +838,12 @@ interface AlintConfigItem {
|
|
|
797
838
|
}
|
|
798
839
|
interface AlintLinterOptions {
|
|
799
840
|
noInlineConfig?: boolean;
|
|
841
|
+
/**
|
|
842
|
+
* How the run reports files it lints that no language claimed, so they were handled as plain
|
|
843
|
+
* text. Defaults to `'warn'`. An explicit `language: 'plaintext'` pin means plain text was the
|
|
844
|
+
* intent, so pinned files are never reported.
|
|
845
|
+
*/
|
|
846
|
+
reportUnregisteredLanguages?: RuleSeverity;
|
|
800
847
|
reportUnusedDisableDirectives?: RuleSeverity;
|
|
801
848
|
}
|
|
802
849
|
type Awaitable<T> = Promise<T> | T;
|
|
@@ -826,6 +873,20 @@ interface IgnoreConfig {
|
|
|
826
873
|
interface LanguageDefinition {
|
|
827
874
|
extensions?: readonly string[];
|
|
828
875
|
extract: (file: SourceFile, context: LanguageContext) => Awaitable<SourceTarget[]>;
|
|
876
|
+
/**
|
|
877
|
+
* The language's id: what a config pins through `language:`, what a rule's `languages` lists, and
|
|
878
|
+
* what every target it extracts reports. The registry is keyed by it, so two packs cannot claim
|
|
879
|
+
* the same one.
|
|
880
|
+
*
|
|
881
|
+
* Use the identifier editors already use — `go`, `python`, `rust`, `typescript`, `plaintext` —
|
|
882
|
+
* rather than inventing a spelling. Anyone can register a language, so the set is open by
|
|
883
|
+
* definition and only a shared convention keeps one language from arriving under three names.
|
|
884
|
+
*
|
|
885
|
+
* NOTICE: the list is VS Code's. The Language Server Protocol shares it for the languages it
|
|
886
|
+
* covers, but its table has no entry for plain text, so `plaintext` comes from VS Code alone.
|
|
887
|
+
* https://code.visualstudio.com/docs/languages/identifiers
|
|
888
|
+
* https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentItem
|
|
889
|
+
*/
|
|
829
890
|
name: string;
|
|
830
891
|
}
|
|
831
892
|
interface PluginDefinition<Rules extends Record<string, RuleDefinition<any>> = Record<string, RuleDefinition<any>>> {
|
|
@@ -838,10 +899,7 @@ interface ProcessorDefinition {
|
|
|
838
899
|
postprocess?: (diagnostics: DiagnosticDescriptor[], context: ProcessorPostprocessContext) => Awaitable<DiagnosticDescriptor[]>;
|
|
839
900
|
preprocess: (file: SourceFile, context: ProcessorContext) => Awaitable<ProcessedSource[]>;
|
|
840
901
|
}
|
|
841
|
-
interface ProjectFileEntry {
|
|
842
|
-
contentHash: string;
|
|
843
|
-
language: string;
|
|
844
|
-
path: string;
|
|
902
|
+
interface ProjectFileEntry extends BaseSourceFile {
|
|
845
903
|
targetCount: number;
|
|
846
904
|
}
|
|
847
905
|
interface ProjectTarget {
|
|
@@ -891,6 +949,15 @@ interface RuleDefinition<OptionsSchema extends RuleOptionsSchema = []> {
|
|
|
891
949
|
/** Additional stable rule inputs, such as imported prompts, that invalidate cached results when changed. */
|
|
892
950
|
cacheKey?: unknown;
|
|
893
951
|
create: (context: RuleContext<RuleOptionsOutput<OptionsSchema>>) => RuleHandlers;
|
|
952
|
+
/**
|
|
953
|
+
* Which languages this rule reads. Omitting it opts out of extraction: the rule still receives
|
|
954
|
+
* file targets, but never the function and class targets a language produces.
|
|
955
|
+
*
|
|
956
|
+
* It does not choose how a file is parsed. A config's `language:` pin, or the extension, settles
|
|
957
|
+
* that before any rule is consulted. Directory and project targets ignore it too: they index a
|
|
958
|
+
* tree rather than come from a language.
|
|
959
|
+
*/
|
|
960
|
+
languages?: RuleLanguages;
|
|
894
961
|
model?: ModelRequirement;
|
|
895
962
|
options?: OptionsSchema;
|
|
896
963
|
}
|
|
@@ -905,6 +972,23 @@ interface RuleInferenceUsageRecord {
|
|
|
905
972
|
ruleId?: string;
|
|
906
973
|
totalTokens?: number;
|
|
907
974
|
}
|
|
975
|
+
/**
|
|
976
|
+
* - `'any'` — every registered language, and never a failure. A rule that works from `FunctionInfo`
|
|
977
|
+
* alone wants this: a language pack the user installs later is covered without a new release.
|
|
978
|
+
* - A list of language ids — `LanguageDefinition.name` values such as `go` or `typescript`, never
|
|
979
|
+
* file extensions. The rule handles exactly these. Files of other languages are skipped
|
|
980
|
+
* rather than failed, so one plugin can carry rules for several languages behind one `files:`
|
|
981
|
+
* glob. If a listed language is not registered at all the run fails, because a rule scoped to a
|
|
982
|
+
* language nothing provides would otherwise skip every file in silence.
|
|
983
|
+
* - `{ ids: string[], skipMissing?: boolean }` — the same scoping, but an unregistered id can be
|
|
984
|
+
* skipped instead of failing. For a plugin whose rules span languages a given user may not have installed.
|
|
985
|
+
*/
|
|
986
|
+
type RuleLanguages = 'any' | readonly string[] | {
|
|
987
|
+
/** Language ids this rule applies to. */
|
|
988
|
+
ids: readonly string[];
|
|
989
|
+
/** Whether to skip unregistered languages instead of failing. */
|
|
990
|
+
skipMissing?: boolean;
|
|
991
|
+
};
|
|
908
992
|
type RuleOptionsOutput<OptionsSchema extends RuleOptionsSchema> = { readonly [Index in keyof OptionsSchema]: InferOutput$1<OptionsSchema[Index]>; };
|
|
909
993
|
type RuleOptionsSchema = readonly GenericSchema[];
|
|
910
994
|
type RuleSeverity = 'error' | 'off' | 'warn';
|
|
@@ -924,7 +1008,7 @@ interface RuleWithHandler {
|
|
|
924
1008
|
onTargetProject?: never;
|
|
925
1009
|
onTargetWith: (target: Target) => Awaitable<void>;
|
|
926
1010
|
}
|
|
927
|
-
type Target = DirectoryTarget |
|
|
1011
|
+
type Target = DirectoryTarget | PlannedSourceTarget | ProjectTarget;
|
|
928
1012
|
//#endregion
|
|
929
1013
|
//#region ../../node_modules/.pnpm/valibot@1.4.2_typescript@6.0.3/node_modules/valibot/dist/index.d.mts
|
|
930
1014
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -1983,8 +1983,26 @@ async function judgeSource(options) {
|
|
|
1983
1983
|
//#region src/rules/inline-miniature-normalizer/rule.ts
|
|
1984
1984
|
const inlineMiniatureNormalizerRule = defineRule({
|
|
1985
1985
|
cacheKey: inlineMiniatureNormalizerPrompt,
|
|
1986
|
-
create: (ctx) => ({
|
|
1986
|
+
create: (ctx) => ({
|
|
1987
|
+
/**
|
|
1988
|
+
* Reviews one planned file for inline miniature normalizers.
|
|
1989
|
+
*
|
|
1990
|
+
* Triggering workflow:
|
|
1991
|
+
*
|
|
1992
|
+
* {@link inlineMiniatureNormalizerRule}
|
|
1993
|
+
* -> `RuleHandlers.onTargetFile`
|
|
1994
|
+
* -> {@link judgeSource}
|
|
1995
|
+
*
|
|
1996
|
+
* Upstream:
|
|
1997
|
+
* - {@link inlineMiniatureNormalizerRule}
|
|
1998
|
+
*
|
|
1999
|
+
* Downstream:
|
|
2000
|
+
* - {@link judgeSource}
|
|
2001
|
+
* - `RuleContext.report`
|
|
2002
|
+
*/
|
|
2003
|
+
async onTargetFile(target) {
|
|
1987
2004
|
const model = await ctx.model();
|
|
2005
|
+
const file = await ctx.src.readFile(target.file);
|
|
1988
2006
|
const findings = await judgeSource({
|
|
1989
2007
|
logger: ctx.logger,
|
|
1990
2008
|
metering: ctx.metering,
|
|
@@ -1993,7 +2011,7 @@ const inlineMiniatureNormalizerRule = defineRule({
|
|
|
1993
2011
|
outputLanguage: ctx.outputLanguage,
|
|
1994
2012
|
prompt: inlineMiniatureNormalizerPrompt,
|
|
1995
2013
|
signal: ctx.signal,
|
|
1996
|
-
source:
|
|
2014
|
+
source: file.text
|
|
1997
2015
|
});
|
|
1998
2016
|
for (const finding of findings) ctx.report({
|
|
1999
2017
|
evidence: {
|
|
@@ -4959,9 +4977,10 @@ var RepositoryReviewProtocolError = class extends Error {
|
|
|
4959
4977
|
async function reviewRepository(ctx, target, options) {
|
|
4960
4978
|
const agent = requireAgent(ctx);
|
|
4961
4979
|
const model = await ctx.model();
|
|
4980
|
+
const file = await ctx.src.readFile(target.file);
|
|
4962
4981
|
const submission = createSubmitReviewTool({
|
|
4963
4982
|
allowedCategories: options.allowedCategories,
|
|
4964
|
-
lineCount:
|
|
4983
|
+
lineCount: file.lines.length,
|
|
4965
4984
|
requireFutureFailure: options.requireFutureFailure ?? false,
|
|
4966
4985
|
requireRelatedLocations: options.requireRelatedLocations ?? false
|
|
4967
4986
|
});
|
|
@@ -4974,7 +4993,7 @@ async function reviewRepository(ctx, target, options) {
|
|
|
4974
4993
|
model,
|
|
4975
4994
|
prompt: [options.prompt, JSON.stringify({
|
|
4976
4995
|
path: repositoryRelativePath(ctx.cwd, target.file.path),
|
|
4977
|
-
source: formatSourceWithLineNumbers(
|
|
4996
|
+
source: formatSourceWithLineNumbers(file.text)
|
|
4978
4997
|
})].join("\n\n"),
|
|
4979
4998
|
tools: [...withNumberedReads(createTools(ctx.cwd)), submission.tool]
|
|
4980
4999
|
});
|
|
@@ -5207,7 +5226,7 @@ function createMixedLayersWithoutAbstractionRule(dependencies = defaultMixedLaye
|
|
|
5207
5226
|
*
|
|
5208
5227
|
* Triggering workflow:
|
|
5209
5228
|
*
|
|
5210
|
-
* `
|
|
5229
|
+
* `planSource`
|
|
5211
5230
|
* -> `sourceExecution`
|
|
5212
5231
|
* -> `RuleHandlers.onTargetFile`
|
|
5213
5232
|
* -> {@link onTargetFile}
|
|
@@ -5218,8 +5237,8 @@ function createMixedLayersWithoutAbstractionRule(dependencies = defaultMixedLaye
|
|
|
5218
5237
|
* -> {@link reportMixedLayerFindings}
|
|
5219
5238
|
*
|
|
5220
5239
|
* Upstream:
|
|
5221
|
-
* - `
|
|
5222
|
-
*
|
|
5240
|
+
* - `planSource` owns source extraction and compact job admission, with handler selection
|
|
5241
|
+
* through `sourceExecution` in `packages/core/src/core/source/planner.ts`
|
|
5223
5242
|
*
|
|
5224
5243
|
* Downstream:
|
|
5225
5244
|
* - {@link generateStructured} -> coverage and data-flow draft
|
|
@@ -5230,7 +5249,7 @@ function createMixedLayersWithoutAbstractionRule(dependencies = defaultMixedLaye
|
|
|
5230
5249
|
*/
|
|
5231
5250
|
async function onTargetFile(target) {
|
|
5232
5251
|
const model = await ctx.model();
|
|
5233
|
-
const source = ctx.src.
|
|
5252
|
+
const source = (await ctx.src.readFile(target.file)).text;
|
|
5234
5253
|
const firstDraft = await dependencies.generateDraft({
|
|
5235
5254
|
createMessages: (retryFeedback) => createMixedLayerMessages(source, mixedLayersWithoutAbstractionCoveragePerspective, retryFeedback, ctx.outputLanguage),
|
|
5236
5255
|
logger: ctx.logger,
|
|
@@ -5513,8 +5532,26 @@ Return warnings only. If uncertain, use medium or low confidence instead of forc
|
|
|
5513
5532
|
//#region src/rules/no-private-schema-toolkit/rule.ts
|
|
5514
5533
|
const privateSchemaToolkitRule = defineRule({
|
|
5515
5534
|
cacheKey: privateSchemaToolkitPrompt,
|
|
5516
|
-
create: (ctx) => ({
|
|
5535
|
+
create: (ctx) => ({
|
|
5536
|
+
/**
|
|
5537
|
+
* Reviews one planned file for private schema toolkits.
|
|
5538
|
+
*
|
|
5539
|
+
* Triggering workflow:
|
|
5540
|
+
*
|
|
5541
|
+
* {@link privateSchemaToolkitRule}
|
|
5542
|
+
* -> `RuleHandlers.onTargetFile`
|
|
5543
|
+
* -> {@link judgeSource}
|
|
5544
|
+
*
|
|
5545
|
+
* Upstream:
|
|
5546
|
+
* - {@link privateSchemaToolkitRule}
|
|
5547
|
+
*
|
|
5548
|
+
* Downstream:
|
|
5549
|
+
* - {@link judgeSource}
|
|
5550
|
+
* - `RuleContext.report`
|
|
5551
|
+
*/
|
|
5552
|
+
async onTargetFile(target) {
|
|
5517
5553
|
const model = await ctx.model();
|
|
5554
|
+
const file = await ctx.src.readFile(target.file);
|
|
5518
5555
|
const findings = await judgeSource({
|
|
5519
5556
|
logger: ctx.logger,
|
|
5520
5557
|
metering: ctx.metering,
|
|
@@ -5523,7 +5560,7 @@ const privateSchemaToolkitRule = defineRule({
|
|
|
5523
5560
|
outputLanguage: ctx.outputLanguage,
|
|
5524
5561
|
prompt: privateSchemaToolkitPrompt,
|
|
5525
5562
|
signal: ctx.signal,
|
|
5526
|
-
source:
|
|
5563
|
+
source: file.text
|
|
5527
5564
|
});
|
|
5528
5565
|
for (const finding of findings) ctx.report({
|
|
5529
5566
|
evidence: {
|
|
@@ -5703,7 +5740,7 @@ const redundantBindingRule = defineRule({
|
|
|
5703
5740
|
* Triggering workflow:
|
|
5704
5741
|
*
|
|
5705
5742
|
* {@link defineRule}
|
|
5706
|
-
* -> `
|
|
5743
|
+
* -> `PlannedSourceTarget.kind === "file"`
|
|
5707
5744
|
* -> `onTargetFile`
|
|
5708
5745
|
* -> {@link judgeSource} / {@link verifyRedundantBindings}
|
|
5709
5746
|
*
|
|
@@ -5717,6 +5754,7 @@ const redundantBindingRule = defineRule({
|
|
|
5717
5754
|
*/
|
|
5718
5755
|
async onTargetFile(target) {
|
|
5719
5756
|
const model = await ctx.model();
|
|
5757
|
+
const source = (await ctx.src.readFile(target.file)).text;
|
|
5720
5758
|
const candidates = await judgeSource({
|
|
5721
5759
|
logger: ctx.logger,
|
|
5722
5760
|
metering: ctx.metering,
|
|
@@ -5725,7 +5763,7 @@ async onTargetFile(target) {
|
|
|
5725
5763
|
outputLanguage: ctx.outputLanguage,
|
|
5726
5764
|
prompt: redundantBindingPrompt,
|
|
5727
5765
|
signal: ctx.signal,
|
|
5728
|
-
source
|
|
5766
|
+
source
|
|
5729
5767
|
});
|
|
5730
5768
|
if (candidates.length === 0) return;
|
|
5731
5769
|
const candidateLines = new Set(candidates.map((candidate) => candidate.line));
|
|
@@ -5736,7 +5774,7 @@ async onTargetFile(target) {
|
|
|
5736
5774
|
model,
|
|
5737
5775
|
outputLanguage: ctx.outputLanguage,
|
|
5738
5776
|
signal: ctx.signal,
|
|
5739
|
-
source
|
|
5777
|
+
source
|
|
5740
5778
|
});
|
|
5741
5779
|
const reportedLines = /* @__PURE__ */ new Set();
|
|
5742
5780
|
for (const finding of verifiedFindings) {
|
|
@@ -5835,8 +5873,26 @@ Return warnings only. If uncertain, use medium or low confidence instead of forc
|
|
|
5835
5873
|
//#region src/rules/no-redundant-jsdoc/rule.ts
|
|
5836
5874
|
const redundantJsdocRule = defineRule({
|
|
5837
5875
|
cacheKey: redundantJsdocPrompt,
|
|
5838
|
-
create: (ctx) => ({
|
|
5876
|
+
create: (ctx) => ({
|
|
5877
|
+
/**
|
|
5878
|
+
* Reviews one planned file for redundant JSDoc.
|
|
5879
|
+
*
|
|
5880
|
+
* Triggering workflow:
|
|
5881
|
+
*
|
|
5882
|
+
* {@link redundantJsdocRule}
|
|
5883
|
+
* -> `RuleHandlers.onTargetFile`
|
|
5884
|
+
* -> {@link judgeSource}
|
|
5885
|
+
*
|
|
5886
|
+
* Upstream:
|
|
5887
|
+
* - {@link redundantJsdocRule}
|
|
5888
|
+
*
|
|
5889
|
+
* Downstream:
|
|
5890
|
+
* - {@link judgeSource}
|
|
5891
|
+
* - `RuleContext.report`
|
|
5892
|
+
*/
|
|
5893
|
+
async onTargetFile(target) {
|
|
5839
5894
|
const model = await ctx.model();
|
|
5895
|
+
const file = await ctx.src.readFile(target.file);
|
|
5840
5896
|
const findings = await judgeSource({
|
|
5841
5897
|
logger: ctx.logger,
|
|
5842
5898
|
metering: ctx.metering,
|
|
@@ -5845,7 +5901,7 @@ const redundantJsdocRule = defineRule({
|
|
|
5845
5901
|
outputLanguage: ctx.outputLanguage,
|
|
5846
5902
|
prompt: redundantJsdocPrompt,
|
|
5847
5903
|
signal: ctx.signal,
|
|
5848
|
-
source:
|
|
5904
|
+
source: file.text
|
|
5849
5905
|
});
|
|
5850
5906
|
for (const finding of findings) ctx.report({
|
|
5851
5907
|
evidence: {
|
|
@@ -6012,8 +6068,26 @@ Return warnings only. If uncertain, use medium or low confidence instead of forc
|
|
|
6012
6068
|
//#region src/rules/no-trivial-wrapper-stack/rule.ts
|
|
6013
6069
|
const trivialWrapperStackRule = defineRule({
|
|
6014
6070
|
cacheKey: trivialWrapperStackPrompt,
|
|
6015
|
-
create: (ctx) => ({
|
|
6071
|
+
create: (ctx) => ({
|
|
6072
|
+
/**
|
|
6073
|
+
* Reviews one planned file for trivial wrapper stacks.
|
|
6074
|
+
*
|
|
6075
|
+
* Triggering workflow:
|
|
6076
|
+
*
|
|
6077
|
+
* {@link trivialWrapperStackRule}
|
|
6078
|
+
* -> `RuleHandlers.onTargetFile`
|
|
6079
|
+
* -> {@link judgeSource}
|
|
6080
|
+
*
|
|
6081
|
+
* Upstream:
|
|
6082
|
+
* - {@link trivialWrapperStackRule}
|
|
6083
|
+
*
|
|
6084
|
+
* Downstream:
|
|
6085
|
+
* - {@link judgeSource}
|
|
6086
|
+
* - `RuleContext.report`
|
|
6087
|
+
*/
|
|
6088
|
+
async onTargetFile(target) {
|
|
6016
6089
|
const model = await ctx.model();
|
|
6090
|
+
const file = await ctx.src.readFile(target.file);
|
|
6017
6091
|
const findings = await judgeSource({
|
|
6018
6092
|
logger: ctx.logger,
|
|
6019
6093
|
metering: ctx.metering,
|
|
@@ -6022,7 +6096,7 @@ const trivialWrapperStackRule = defineRule({
|
|
|
6022
6096
|
outputLanguage: ctx.outputLanguage,
|
|
6023
6097
|
prompt: trivialWrapperStackPrompt,
|
|
6024
6098
|
signal: ctx.signal,
|
|
6025
|
-
source:
|
|
6099
|
+
source: file.text
|
|
6026
6100
|
});
|
|
6027
6101
|
for (const finding of findings) ctx.report({
|
|
6028
6102
|
evidence: {
|
|
@@ -6094,7 +6168,7 @@ const vacuousFunctionRule = defineRule({
|
|
|
6094
6168
|
* Triggering workflow:
|
|
6095
6169
|
*
|
|
6096
6170
|
* {@link defineRule}
|
|
6097
|
-
* -> `
|
|
6171
|
+
* -> `PlannedSourceTarget.kind === "file"`
|
|
6098
6172
|
* -> `onTargetFile`
|
|
6099
6173
|
* -> {@link judgeSource}
|
|
6100
6174
|
*
|
|
@@ -6107,6 +6181,7 @@ const vacuousFunctionRule = defineRule({
|
|
|
6107
6181
|
*/
|
|
6108
6182
|
async onTargetFile(target) {
|
|
6109
6183
|
const model = await ctx.model();
|
|
6184
|
+
const file = await ctx.src.readFile(target.file);
|
|
6110
6185
|
const findings = await judgeSource({
|
|
6111
6186
|
logger: ctx.logger,
|
|
6112
6187
|
metering: ctx.metering,
|
|
@@ -6115,7 +6190,7 @@ async onTargetFile(target) {
|
|
|
6115
6190
|
outputLanguage: ctx.outputLanguage,
|
|
6116
6191
|
prompt: vacuousFunctionPrompt,
|
|
6117
6192
|
signal: ctx.signal,
|
|
6118
|
-
source:
|
|
6193
|
+
source: file.text
|
|
6119
6194
|
});
|
|
6120
6195
|
for (const finding of findings) ctx.report({
|
|
6121
6196
|
evidence: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alint-js/plugin-js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.mts",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"@valibot/to-json-schema": "^1.7.1",
|
|
17
17
|
"apeira": "^0.0.7",
|
|
18
18
|
"valibot": "^1.4.2",
|
|
19
|
-
"@alint-js/
|
|
20
|
-
"@alint-js/tools-fs": "0.1.
|
|
21
|
-
"@alint-js/
|
|
19
|
+
"@alint-js/core": "0.1.5",
|
|
20
|
+
"@alint-js/tools-fs": "0.1.5",
|
|
21
|
+
"@alint-js/plugin": "0.1.5"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "tsdown",
|