Skip to content

Commit

Permalink
feat: update plugin audits
Browse files Browse the repository at this point in the history
  • Loading branch information
hrenaud committed Nov 24, 2023
1 parent 49f89a9 commit 984f0d2
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 322 deletions.
37 changes: 4 additions & 33 deletions lighthouse-plugin-ecoindex/audits/bp/print-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,21 @@
*/

import { Audit } from 'lighthouse'
import refCnumr from './ref-cnumr.js'
import refsURLS from './refs-urls.js'

class BPPrintCSS extends Audit {
static get meta() {
return {
id: 'bp-print-css',
title: 'Print CSS',
failureTitle: 'No print css implemented.',
description: `A print css must be implemented to hide useless elements when printing. [See CNUMR BP_027](${refCnumr.bp_027.en})`,
title: '#RWEB_027 - Print CSS',
failureTitle: '#RWEB_027 - No print css implemented.',
description: `A print css must be implemented to hide useless elements when printing. [See #RWEB_027](${refsURLS.rweb.bp_027.en})`,

// The name of the custom gatherer class that provides input to this audit.
requiredArtifacts: ['LinkElements', 'DOMStats', 'devtoolsLogs'],
}
}

// static get metrics() {
// return [
// {
// id: 'dom-size',
// title: 'DOM Size',
// description: 'The size of the DOM in bytes.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'request-count',
// title: 'Request Count',
// description: 'The number of network requests made by the page.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'total-compressed-size',
// title: 'Total Compressed Size',
// description: 'The total size of all compressed responses in bytes.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'print-css-audit',
// title: 'print-css-audit',
// description: 'print-css-audit.',
// scoreDisplayMode: 'numeric',
// },
// ]
// }

static audit(artifacts) {
const stylesheets = artifacts.LinkElements.filter(
link =>
Expand Down
30 changes: 0 additions & 30 deletions lighthouse-plugin-ecoindex/audits/bp/ref-cnumr.js

This file was deleted.

36 changes: 36 additions & 0 deletions lighthouse-plugin-ecoindex/audits/bp/refs-urls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export default {
greenwebfoundation: {
home: {
fr: 'https://www.thegreenwebfoundation.org/',
en: 'https://www.thegreenwebfoundation.org/',
},
api_doc: {
fr: 'https://developers.thegreenwebfoundation.org/api/greencheck/v3/check-single-domain/',
en: 'https://developers.thegreenwebfoundation.org/api/greencheck/v3/check-single-domain/',
},
},
ecoindex: {
method: {
fr: 'https://www.ecoindex.fr/comment-ca-marche/#m%C3%A9thodologie-danalyse',
en: 'https://www.ecoindex.fr/comment-ca-marche/#m%C3%A9thodologie-danalyse',
},
grade: {
fr: 'https://www.ecoindex.fr/comment-ca-marche/#le-calcul-de-la-note',
en: 'https://www.ecoindex.fr/comment-ca-marche/#le-calcul-de-la-note',
},
score: {
fr: 'https://www.ecoindex.fr/comment-ca-marche/#le-calcul-de-lecoindex',
en: 'https://www.ecoindex.fr/comment-ca-marche/#le-calcul-de-lecoindex',
},
footprint: {
fr: 'https://www.ecoindex.fr/comment-ca-marche/#lempreinte-environnementale',
en: 'https://www.ecoindex.fr/comment-ca-marche/#lempreinte-environnementale',
},
},
rweb: {
bp_027: {
fr: 'https://github.com/cnumr/best-practices/blob/main/chapters/BP_027_fr.md',
en: 'https://github.com/cnumr/best-practices/blob/main/chapters/BP_027_en.md',
},
},
}
8 changes: 4 additions & 4 deletions lighthouse-plugin-ecoindex/audits/bp/thegreenwebfoundation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Audit } from 'lighthouse'
import { createErrorResult } from '../../utils/index.js'
import refCnumr from './ref-cnumr.js'
import refsURLS from './refs-urls.js'

function makeTableDetails(domain, jsonResponse) {
const { hosted_by, hosted_by_website, modified, supporting_documents } =
Expand All @@ -26,7 +26,7 @@ function makeTableDetails(domain, jsonResponse) {
]
const moreInfo = {
label: `more info on The Green Web Foundation API v3`,
data: `see ${refCnumr.greenwebfoundation_API.en}`,
data: `see ${refsURLS.greenwebfoundation.api_doc.en}`,
}
switch (jsonResponse['data']) {
case false:
Expand Down Expand Up @@ -96,7 +96,7 @@ class TheGreenWebFoundation extends Audit {
id: 'bp-thegreenwebfoundation',
title: 'The Green Web Foundation',
failureTitle: 'Your website is not hosted on a green web host.',
description: `The Green Web Foundation is a non-profit organisation on a mission to make the web green by creating tools for a sustainable web. [See The Green Web Foundation](${refCnumr.greenwebfoundation.en})`,
description: `The Green Web Foundation is a non-profit organisation on a mission to make the web green by creating tools for a sustainable web. [See The Green Web Foundation](${refsURLS.greenwebfoundation.home.en})`,

// The name of the custom gatherer class that provides input to this audit.
requiredArtifacts: ['URL', 'devtoolsLogs'],
Expand All @@ -109,7 +109,7 @@ class TheGreenWebFoundation extends Audit {
id: 'bp-thegreenwebfoundation',
title: 'The Green Web Foundation',
description:
'The Green Web Foundation is a non-profit organisation on a mission to make the web green by creating tools for a sustainable web. [See The Green Web Foundation](${refCnumr.greenwebfoundation.en})',
'The Green Web Foundation is a non-profit organisation on a mission to make the web green by creating tools for a sustainable web. [See The Green Web Foundation](${refsURLS.greenwebfoundation.home.en})',
scoreDisplayMode: 'manual',
},
]
Expand Down
33 changes: 2 additions & 31 deletions lighthouse-plugin-ecoindex/audits/ecoindex-ghg.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '../utils/index.js'

import { Audit } from 'lighthouse'
import refCnumr from './bp/ref-cnumr.js'
import refsURLS from './bp/refs-urls.js'

class EcoindexGreenhouseGasEmissionAudit extends Audit {
static get meta() {
Expand All @@ -14,42 +14,13 @@ class EcoindexGreenhouseGasEmissionAudit extends Audit {
title: 'Greenhouse Gas Emission (eqCO2)',
failureTitle:
'Greenhouse Gas Emission (eqCO2), your page generates a lot of greenhouse gas',
description: `Greenhouse Gas Emission (eqCO2) of your page. [See Ecoindex, Environmental footprint](${refCnumr.ecoindex_footprint.en})`,
description: `Greenhouse Gas Emission (eqCO2) of your page. [See Ecoindex, Environmental footprint](${refsURLS.ecoindex.footprint.en})`,
requiredArtifacts: ['MainDocumentContent', 'DOMStats', 'devtoolsLogs'],
supportedModes: ['navigation', 'timespan', 'snapshot'],
scoreDisplayMode: 'numeric',
}
}

// static get metrics() {
// return [
// {
// id: 'dom-size',
// title: 'DOM Size',
// description: 'The size of the DOM in bytes.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'request-count',
// title: 'Request Count',
// description: 'The number of network requests made by the page.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'total-compressed-size',
// title: 'Total Compressed Size',
// description: 'The total size of all compressed responses in bytes.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'eco-index-ghg',
// title: 'Greenhouse Gas Emission',
// description: 'Greenhouse Gas Emission (eqCO2) of your page.',
// scoreDisplayMode: 'numeric',
// },
// ]
// }

static async audit(artifacts, context) {
try {
const ecoIndexScore = await getLoadingExperience(artifacts, context)
Expand Down
34 changes: 2 additions & 32 deletions lighthouse-plugin-ecoindex/audits/ecoindex-grade.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,21 @@ import {
} from '../utils/index.js'

import { Audit } from 'lighthouse'
import refCnumr from './bp/ref-cnumr.js'
import refsURLS from './bp/refs-urls.js'

class EcoindexGradeAudit extends Audit {
static get meta() {
return {
id: 'eco-index-grade',
title: 'Grade',
failureTitle: 'Grade, your page has a big impact',
description: `The EcoIndex score evaluating the environmental impact of the page. [See Ecoindex, Calculating the score](${refCnumr.ecoindex_grade.en})`,
description: `The EcoIndex score evaluating the environmental impact of the page. [See Ecoindex, Calculating the score](${refsURLS.ecoindex.grade.en})`,
requiredArtifacts: ['MainDocumentContent', 'DOMStats', 'devtoolsLogs'],
supportedModes: ['navigation', 'timespan', 'snapshot'],
scoreDisplayMode: 'numeric',
}
}

// static get metrics() {
// return [
// {
// id: 'dom-size',
// title: 'DOM Size',
// description: 'The size of the DOM in bytes.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'request-count',
// title: 'Request Count',
// description: 'The number of network requests made by the page.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'total-compressed-size',
// title: 'Total Compressed Size',
// description: 'The total size of all compressed responses in bytes.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'eco-index-grade',
// title: 'Ecoindex Grade',
// description:
// 'The EcoIndex score evaluating the environmental impact of the page.',
// scoreDisplayMode: 'manual',
// },
// ]
// }

static async audit(artifacts, context) {
try {
const ecoIndexScore = await getLoadingExperience(artifacts, context)
Expand Down
33 changes: 2 additions & 31 deletions lighthouse-plugin-ecoindex/audits/ecoindex-nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,21 @@ import {
} from '../utils/index.js'

import { Audit } from 'lighthouse'
import refCnumr from './bp/ref-cnumr.js'
import refsURLS from './bp/refs-urls.js'

class EcoindexNodesAudit extends Audit {
static get meta() {
return {
id: 'eco-index-nodes',
title: 'Ecoindex DOM elements (nodes)',
failureTitle: 'Ecoindex DOM elements (nodes), your page is too complex',
description: `Explication: Counting all the DOM nodes on the page, excluding the child nodes of \`svg\` elements, gives us the number of DOM elements on the page. This method encourages you not to replace a complex svg with an image, simply to obtain a better score. [See Ecoindex, Analysis methodology](${refCnumr.ecoindex_method.en})`,
description: `Explication: Counting all the DOM nodes on the page, excluding the child nodes of \`svg\` elements, gives us the number of DOM elements on the page. This method encourages you not to replace a complex svg with an image, simply to obtain a better score. [See Ecoindex, Analysis methodology](${refsURLS.ecoindex.method.en})`,
requiredArtifacts: ['MainDocumentContent', 'DOMStats', 'devtoolsLogs'],
supportedModes: ['navigation', 'timespan', 'snapshot'],
scoreDisplayMode: 'numeric',
}
}

// static get metrics() {
// return [
// {
// id: 'dom-size',
// title: 'DOM Size',
// description: 'The size of the DOM in bytes.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'request-count',
// title: 'Request Count',
// description: 'The number of network requests made by the page.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'total-compressed-size',
// title: 'Total Compressed Size',
// description: 'The total size of all compressed responses in bytes.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'eco-index-nodes',
// title: 'DOM elements',
// description: `Explication: Counting all the DOM nodes on the page, excluding the child nodes of \`svg\` elements, gives us the number of DOM elements on the page. This method encourages you not to replace a complex svg with an image, simply to obtain a better score. [See Ecoindex, Analysis methodology](${refCnumr.ecoindex_method.en})`,
// scoreDisplayMode: 'numeric',
// },
// ]
// }

static async audit(artifacts, context) {
try {
const ecoIndexScore = await getLoadingExperience(artifacts, context, true)
Expand Down
34 changes: 2 additions & 32 deletions lighthouse-plugin-ecoindex/audits/ecoindex-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '../utils/index.js'

import { Audit } from 'lighthouse'
import refCnumr from './bp/ref-cnumr.js'
import refsURLS from './bp/refs-urls.js'

class EcoindexRequestsAudit extends Audit {
static get meta() {
Expand All @@ -14,43 +14,13 @@ class EcoindexRequestsAudit extends Audit {
title: 'Number of requests',
failureTitle:
'Number of requests, your page calls too many external resources',
description: `The number of \`Network.loadingFinished\` logs indicates the number of requests made to external resources. [See Ecoindex, Analysis methodology](${refCnumr.ecoindex_method.en})`,
description: `The number of \`Network.loadingFinished\` logs indicates the number of requests made to external resources. [See Ecoindex, Analysis methodology](${refsURLS.ecoindex.method.en})`,
requiredArtifacts: ['MainDocumentContent', 'DOMStats', 'devtoolsLogs'],
supportedModes: ['navigation', 'timespan', 'snapshot'],
scoreDisplayMode: 'numeric',
}
}

// static get metrics() {
// return [
// {
// id: 'dom-size',
// title: 'DOM Size',
// description: 'The size of the DOM in bytes.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'request-count',
// title: 'Request Count',
// description: 'The number of network requests made by the page.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'total-compressed-size',
// title: 'Total Compressed Size',
// description: 'The total size of all compressed responses in bytes.',
// scoreDisplayMode: 'numeric',
// },
// {
// id: 'eco-index-requests',
// title: 'Number of requests',
// description:
// 'The EcoIndex score evaluating the environmental impact of the page.',
// scoreDisplayMode: 'numeric',
// },
// ]
// }

static async audit(artifacts, context) {
try {
const ecoIndexScore = await getLoadingExperience(artifacts, context, true)
Expand Down
Loading

0 comments on commit 984f0d2

Please sign in to comment.