Skip to content

Commit e5941e4

Browse files
committed
docs: update APIs
1 parent e3a19e3 commit e5941e4

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

workspaces/js-x-ray/docs/AstAnalyser.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface AstAnalyserOptions {
3131
/**
3232
* @default false
3333
*/
34-
optionalWarnings?: boolean | Iterable<string>;
34+
optionalWarnings?: boolean | Iterable<OptionalWarningName>;
3535
}
3636
```
3737

@@ -47,13 +47,14 @@ class AstAnalyser {
4747
options?: RuntimeOptions
4848
) => Report;
4949
analyseFile(
50-
pathToFile: string,
50+
pathToFile: string | URL,
5151
options?: RuntimeFileOptions
5252
): Promise<ReportOnFile>;
5353
analyseFileSync(
54-
pathToFile: string,
54+
pathToFile: string | URL,
5555
options?: RuntimeFileOptions
5656
): ReportOnFile;
57+
prepareSource(source: string, options?: PrepareSourceOptions): string
5758
}
5859
```
5960

@@ -148,7 +149,14 @@ export const customProbes = [
148149
main: (node, options) => {
149150
const { sourceFile, data: calleeName } = options;
150151
if (node.declarations[0].init.value === "danger") {
151-
sourceFile.addWarning("unsafe-danger", calleeName, node.loc);
152+
sourceFile.warnings.push({
153+
kind: "unsafe-danger",
154+
value: calleeName,
155+
location: node.loc,
156+
source: "JS-X-Ray Custom Probe",
157+
i18n: "sast_warnings.unsafe-danger",
158+
severity: "Warning"
159+
});
152160

153161
return ProbeSignals.Skip;
154162
}

0 commit comments

Comments
 (0)