diff --git a/core/config/validation.js b/core/config/validation.js index 0440d003b628..f4bbf34caea8 100644 --- a/core/config/validation.js +++ b/core/config/validation.js @@ -47,25 +47,24 @@ function assertValidPluginName(config, pluginName) { /** * Throws an error if the provided object does not implement the required Fraggle Rock gatherer interface. - * @param {LH.Config.AnyFRGathererDefn} gathererDefn + * @param {LH.Config.AnyArtifactDefn} artifactDefn */ -function assertValidFRGatherer(gathererDefn) { - const gatherer = gathererDefn.instance; - const gathererName = gatherer.name; +function assertValidArtifact(artifactDefn) { + const gatherer = artifactDefn.gatherer.instance; if (typeof gatherer.meta !== 'object') { - throw new Error(`${gathererName} gatherer did not provide a meta object.`); + throw new Error(`Gatherer for ${artifactDefn.id} did not provide a meta object.`); } if (gatherer.meta.supportedModes.length === 0) { - throw new Error(`${gathererName} gatherer did not support any gather modes.`); + throw new Error(`Gatherer for ${artifactDefn.id} did not support any gather modes.`); } if ( typeof gatherer.getArtifact !== 'function' || gatherer.getArtifact === BaseFRGatherer.prototype.getArtifact ) { - throw new Error(`${gathererName} gatherer did not define a "getArtifact" method.`); + throw new Error(`Gatherer for ${artifactDefn.id} did not define a "getArtifact" method.`); } } @@ -258,7 +257,7 @@ function assertValidConfig(resolvedConfig) { throw new Error(`Config defined multiple artifacts with id '${artifactDefn.id}'`); } artifactIds.add(artifactDefn.id); - assertValidFRGatherer(artifactDefn.gatherer); + assertValidArtifact(artifactDefn); } for (const auditDefn of resolvedConfig.audits || []) { @@ -303,7 +302,7 @@ function throwInvalidArtifactDependency(artifactId, dependencyKey) { export { isValidArtifactDependency, assertValidPluginName, - assertValidFRGatherer, + assertValidArtifact, assertValidFRNavigations, assertValidAudit, assertValidCategories, diff --git a/core/gather/base-gatherer.js b/core/gather/base-gatherer.js index 8e5f06ebe14d..95651a75aa14 100644 --- a/core/gather/base-gatherer.js +++ b/core/gather/base-gatherer.js @@ -54,20 +54,6 @@ class FRGatherer { * @return {LH.Gatherer.PhaseResult} */ getArtifact(passContext) { } - - /** - * Legacy property used to define the artifact ID. In Fraggle Rock, the artifact ID lives on the config. - * @return {keyof LH.GathererArtifacts} - */ - get name() { - let name = this.constructor.name; - // Rollup will mangle class names in an known way–just trim until `$`. - if (name.includes('$')) { - name = name.substr(0, name.indexOf('$')); - } - // @ts-expect-error - assume that class name has been added to LH.GathererArtifacts. - return name; - } } export default FRGatherer; diff --git a/core/gather/gatherers/css-usage.js b/core/gather/gatherers/css-usage.js index c4e4cea3b89d..9e3adce3d725 100644 --- a/core/gather/gatherers/css-usage.js +++ b/core/gather/gatherers/css-usage.js @@ -51,7 +51,7 @@ class CSSUsage extends FRGatherer { ); Sentry.captureException(err, { tags: { - gatherer: this.name, + gatherer: 'CSSUsage', }, extra: { url: event.header.sourceURL, diff --git a/core/gather/gatherers/trace-elements.js b/core/gather/gatherers/trace-elements.js index 6ed24ffdc065..7179d977c785 100644 --- a/core/gather/gatherers/trace-elements.js +++ b/core/gather/gatherers/trace-elements.js @@ -296,7 +296,7 @@ class TraceElements extends FRGatherer { }); } catch (err) { Sentry.captureException(err, { - tags: {gatherer: this.name}, + tags: {gatherer: 'TraceElements'}, level: 'error', }); continue; diff --git a/core/test/config/validation-test.js b/core/test/config/validation-test.js index 0f500d45924b..835c4bff6557 100644 --- a/core/test/config/validation-test.js +++ b/core/test/config/validation-test.js @@ -84,20 +84,22 @@ describe('Fraggle Rock Config Validation', () => { }); }); - describe('.assertValidFRGatherer', () => { + describe('.assertValidArtifact', () => { it('should throw if gatherer does not have a meta object', () => { const gatherer = new BaseGatherer(); // @ts-expect-error - We are intentionally creating a malformed input. gatherer.meta = undefined; const gathererDefn = {instance: gatherer}; - const invocation = () => validation.assertValidFRGatherer(gathererDefn); + const artifactDefn = {id: 'NewArtifact', gatherer: gathererDefn}; + const invocation = () => validation.assertValidArtifact(artifactDefn); expect(invocation).toThrow(/did not provide a meta/); }); it('should throw if gatherer does not have a supported modes', () => { const gathererDefn = {instance: new BaseGatherer()}; - const invocation = () => validation.assertValidFRGatherer(gathererDefn); + const artifactDefn = {id: 'NewArtifact', gatherer: gathererDefn}; + const invocation = () => validation.assertValidArtifact(artifactDefn); expect(invocation).toThrow(/did not support any gather modes/); }); @@ -106,7 +108,8 @@ describe('Fraggle Rock Config Validation', () => { gatherer.meta = {supportedModes: ['navigation']}; const gathererDefn = {instance: gatherer}; - const invocation = () => validation.assertValidFRGatherer(gathererDefn); + const artifactDefn = {id: 'NewArtifact', gatherer: gathererDefn}; + const invocation = () => validation.assertValidArtifact(artifactDefn); expect(invocation).toThrow(/did not define.*getArtifact/); }); }); diff --git a/core/test/gather/mock-driver.js b/core/test/gather/mock-driver.js index db52b09f02be..0c4c4d16258f 100644 --- a/core/test/gather/mock-driver.js +++ b/core/test/gather/mock-driver.js @@ -97,7 +97,6 @@ function createMockGathererInstance(meta) { /** @return {LH.Gatherer.AnyFRGathererInstance} */ asGatherer() { - // @ts-expect-error - We'll rely on the tests passing to know this matches. return this; }, }; diff --git a/core/test/gather/navigation-runner-test.js b/core/test/gather/navigation-runner-test.js index a2197d0c3da6..91a54fb59eaf 100644 --- a/core/test/gather/navigation-runner-test.js +++ b/core/test/gather/navigation-runner-test.js @@ -58,7 +58,6 @@ describe('NavigationRunner', () => { function createGathererDefn() { return { instance: { - name: 'Accessibility', meta: {supportedModes: []}, startInstrumentation: fnAny(), stopInstrumentation: fnAny(), diff --git a/types/gatherer.d.ts b/types/gatherer.d.ts index f1bd31839ef5..7e513bf4215a 100644 --- a/types/gatherer.d.ts +++ b/types/gatherer.d.ts @@ -117,7 +117,6 @@ declare module Gatherer { type FRGatherPhase = keyof Omit interface FRGathererInstance { - name: keyof GathererArtifacts; // temporary COMPAT measure until artifact config support is available meta: GathererMeta; startInstrumentation(context: FRTransitionalContext): Promise|void; startSensitiveInstrumentation(context: FRTransitionalContext): Promise|void;