Skip to content

Commit

Permalink
core: fix NodeDetails type mismatch (#11752)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny authored Dec 2, 2020
1 parent ece5e8c commit 1a7ecd5
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 32 deletions.
6 changes: 3 additions & 3 deletions lighthouse-core/audits/accessibility/axe-audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ class AxeAudit extends Audit {
let items = [];
if (rule && rule.nodes) {
items = rule.nodes.map(node => ({
node: /** @type {LH.Audit.Details.NodeValue} */ ({
type: 'node',
node: {
type: /** @type {'node'} */ ('node'),
lhId: node.lhId,
selector: node.selector,
path: node.devtoolsNodePath,
snippet: node.snippet,
boundingRect: node.boundingRect,
explanation: node.failureSummary,
nodeLabel: node.nodeLabel,
}),
},
}));
}

Expand Down
6 changes: 3 additions & 3 deletions lighthouse-core/audits/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,11 @@ class AutocompleteAudit extends Audit {
continue;
}
failingFormsData.push({
node: /** @type {LH.Audit.Details.NodeValue} */ ({
type: 'node',
node: {
type: /** @type {'node'} */ ('node'),
snippet: input.snippet,
nodeLabel: input.nodeLabel,
}),
},
suggestion: suggestion,
current: input.autocomplete.attribute,
});
Expand Down
12 changes: 6 additions & 6 deletions lighthouse-core/audits/dobetterweb/dom-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,24 @@ class DOMSize extends Audit {
value: stats.totalBodyElements,
},
{
node: /** @type {LH.Audit.Details.NodeValue} */ ({
type: 'node',
node: {
type: /** @type {'node'} */ ('node'),
path: stats.depth.devtoolsNodePath,
snippet: stats.depth.snippet,
selector: stats.depth.selector,
nodeLabel: stats.depth.nodeLabel,
}),
},
statistic: str_(UIStrings.statisticDOMDepth),
value: stats.depth.max,
},
{
node: /** @type {LH.Audit.Details.NodeValue} */ ({
type: 'node',
node: {
type: /** @type {'node'} */ ('node'),
path: stats.width.devtoolsNodePath,
snippet: stats.width.snippet,
selector: stats.width.selector,
nodeLabel: stats.width.nodeLabel,
}),
},
statistic: str_(UIStrings.statisticDOMWidth),
value: stats.width.max,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ class ExternalAnchorsUseRelNoopenerAudit extends Audit {
})
.map(anchor => {
return {
node: /** @type {LH.Audit.Details.NodeValue} */ ({
type: 'node',
node: {
type: /** @type {'node'} */ ('node'),
path: anchor.devtoolsNodePath || '',
selector: anchor.selector || '',
nodeLabel: anchor.nodeLabel || '',
snippet: anchor.snippet || '',
}),
},
href: anchor.href || 'Unknown',
target: anchor.target || '',
rel: anchor.rel || '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ class PasswordInputsCanBePastedIntoAudit extends Audit {
const items = [];
passwordInputsWithPreventedPaste.forEach(input => {
items.push({
node: /** @type {LH.Audit.Details.NodeValue} */ ({
type: 'node',
node: {
type: /** @type {'node'} */ ('node'),
snippet: input.snippet,
path: input.devtoolsNodePath,
}),
},
});
});

Expand Down
6 changes: 3 additions & 3 deletions lighthouse-core/audits/largest-contentful-paint-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ class LargestContentfulPaintElement extends Audit {
const lcpElementDetails = [];
if (lcpElement) {
lcpElementDetails.push({
node: /** @type {LH.Audit.Details.NodeValue} */ ({
type: 'node',
node: {
type: /** @type {'node'} */ ('node'),
lhId: lcpElement.lhId,
path: lcpElement.devtoolsNodePath,
selector: lcpElement.selector,
nodeLabel: lcpElement.nodeLabel,
snippet: lcpElement.snippet,
boundingRect: lcpElement.boundingRect,
}),
},
});
}

Expand Down
6 changes: 3 additions & 3 deletions lighthouse-core/audits/layout-shift-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ class LayoutShiftElements extends Audit {

const clsElementData = clsElements.map(element => {
return {
node: /** @type {LH.Audit.Details.NodeValue} */ ({
type: 'node',
node: {
type: /** @type {'node'} */ ('node'),
lhId: element.lhId,
path: element.devtoolsNodePath,
selector: element.selector,
nodeLabel: element.nodeLabel,
snippet: element.snippet,
boundingRect: element.boundingRect,
}),
},
score: element.score,
};
});
Expand Down
6 changes: 3 additions & 3 deletions lighthouse-core/audits/unsized-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ class UnsizedImages extends Audit {
const url = URL.elideDataURI(image.src);
unsizedImages.push({
url,
node: /** @type {LH.Audit.Details.NodeValue} */ ({
type: 'node',
node: {
type: /** @type {'node'} */ ('node'),
path: image.devtoolsNodePath,
selector: image.selector,
nodeLabel: image.nodeLabel,
snippet: image.snippet,
}),
},
});
}

Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/gather/gatherers/link-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class LinkElements extends Gatherer {
devtoolsNodePath: '',
selector: '',
nodeLabel: '',
boundingRect: null,
snippet: '',
});
}
Expand Down
3 changes: 1 addition & 2 deletions lighthouse-core/gather/gatherers/script-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function collectAllScriptElements() {
id: script.id || null,
async: script.async,
defer: script.defer,
source: /** @type {'head'|'body'} */ (script.closest('head') ? 'head' : 'body'),
source: script.closest('head') ? 'head' : 'body',
// @ts-expect-error - getNodeDetails put into scope via stringification
...getNodeDetails(script),
content: script.src ? null : script.text,
Expand Down Expand Up @@ -112,7 +112,6 @@ class ScriptElements extends Gatherer {
snippet: '',
selector: '',
nodeLabel: '',
boundingRect: null,
type: null,
src: record.url,
id: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe('Link Elements gatherer', () => {
devtoolsNodePath: '',
nodeLabel: '',
snippet: '',
boundingRect: null,
selector: '',
...overrides,
};
Expand Down
2 changes: 1 addition & 1 deletion types/artifacts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ declare global {
lhId?: string,
devtoolsNodePath: string,
selector: string,
boundingRect: Rect | null,
boundingRect?: Rect,
snippet: string,
nodeLabel: string,
}
Expand Down

0 comments on commit 1a7ecd5

Please sign in to comment.