diff --git a/src/warnings.js b/src/warnings.js index ba7f7ac..7faa619 100644 --- a/src/warnings.js +++ b/src/warnings.js @@ -54,16 +54,16 @@ export const warnings = Object.freeze({ }); export function generateWarning(kind, options) { - const { location, file = null, value = null } = options; + const { location, file = null, value = null, source = "JS-X-Ray" } = options; if (kind === "encoded-literal") { return Object.assign( - { kind, value, location: [utils.toArrayLocation(location)] }, + { kind, value, location: [utils.toArrayLocation(location)], source }, warnings[kind] ); } - const result = { kind, location: utils.toArrayLocation(location) }; + const result = { kind, location: utils.toArrayLocation(location), source }; if (utils.notNullOrUndefined(file)) { result.file = file; } diff --git a/test/warnings.spec.js b/test/warnings.spec.js index 4f1b8ce..2c26ed8 100644 --- a/test/warnings.spec.js +++ b/test/warnings.spec.js @@ -14,6 +14,7 @@ test("Given an encoded-literal kind it should generate a warning with deep locat assert.deepEqual(result, { kind: "encoded-literal", value: null, + source: "JS-X-Ray", location: [ [[0, 0], [0, 0]] ], @@ -33,6 +34,7 @@ test("Given a weak-crypto kind it should generate a warning with value, simple l kind: "weak-crypto", value: "md5", file: "hello.js", + source: "JS-X-Ray", location: [ [0, 0], [0, 0] ], diff --git a/types/warnings.d.ts b/types/warnings.d.ts index 5185a44..14f1752 100644 --- a/types/warnings.d.ts +++ b/types/warnings.d.ts @@ -25,6 +25,7 @@ interface WarningDefault { kind: WarningName; file?: string; value: string; + source: string; location: WarningLocation | WarningLocation[]; i18n: string; severity: "Information" | "Warning" | "Critical";