diff --git a/packages/hint/src/lib/engine.ts b/packages/hint/src/lib/engine.ts index bd520d4e460..8712529c66a 100644 --- a/packages/hint/src/lib/engine.ts +++ b/packages/hint/src/lib/engine.ts @@ -25,7 +25,6 @@ import { Events, HintConfig, HintResources, - IConnector, IConnectorConstructor, IFetchOptions, @@ -35,14 +34,12 @@ import { NetworkData, Parser, Problem, - ProblemLocation, Severity, StringKeyOf } from './types'; import { HintContext } from './hint-context'; import { HintScope } from './enums/hint-scope'; import { Configuration } from './config'; -import { Category } from './enums/category'; const debug: debug.IDebugger = d(__filename); @@ -282,18 +279,7 @@ export class Engine extends EventEmitter { } /** Reports a message from one of the hints. */ - public report(hintId: string, category: Category, severity: Severity, sourceCode: string, location: ProblemLocation | null, message: string, resource: string, codeLanguage: string | undefined) { - const problem: Problem = { - category, - codeLanguage, - hintId, - location: location || { column: -1, line: -1 }, - message, - resource, - severity, - sourceCode - }; - + public report(problem: Problem) { this.messages.push(problem); } diff --git a/packages/hint/src/lib/hint-context.ts b/packages/hint/src/lib/hint-context.ts index 300dacaa380..ff4a5962017 100644 --- a/packages/hint/src/lib/hint-context.ts +++ b/packages/hint/src/lib/hint-context.ts @@ -133,16 +133,16 @@ export class HintContext { * So pass the `location` on as it is. */ - this.engine.report( - this.id, - (this.meta && this.meta.docs && this.meta.docs.category) ? this.meta.docs.category : Category.other, - severity || this.severity, - codeSnippet || sourceCode || '', - position, + this.engine.report({ + category: (this.meta && this.meta.docs && this.meta.docs.category) ? this.meta.docs.category : Category.other, + codeLanguage: options.codeLanguage, + hintId: this.id, + location: position || { column: -1, line: -1 }, message, resource, - options.codeLanguage - ); + severity: severity || this.severity, + sourceCode: codeSnippet || sourceCode || '' + }); } /** Subscribe an event in hint. */ diff --git a/packages/hint/tests/lib/engine.ts b/packages/hint/tests/lib/engine.ts index e181a662c26..846c9f4c39f 100644 --- a/packages/hint/tests/lib/engine.ts +++ b/packages/hint/tests/lib/engine.ts @@ -921,13 +921,21 @@ test('executeOn should forward content if provided', async (t) => { const Engine = loadScript(t.context); class FakeConnectorCollect implements IConnector { - private server: typeof Engine; - public constructor(server: typeof Engine) { + private server: import('../../src/lib/engine').Engine; + public constructor(server: import('../../src/lib/engine').Engine) { this.server = server; } public collect(target: url.URL, options?: IFetchOptions) { - this.server.report('1', Category.other, 1, 'node', { column: 1, line: 1 }, options && options.content || '', target.href); + this.server.report({ + category: Category.other, + hintId: '1', + location: { column: 1, line: 1 }, + message: options && options.content || '', + resource: target.href, + severity: 1, + sourceCode: 'node' + }); return Promise.resolve(target); }