@dloizides/frontend-devtools 2.1.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +185 -170
- package/README.md +9 -0
- package/dist/eslint/index.d.mts +4 -1
- package/dist/eslint/index.d.ts +4 -1
- package/dist/eslint/index.js +161 -25
- package/dist/eslint/index.js.map +1 -1
- package/dist/eslint/index.mjs +160 -26
- package/dist/eslint/index.mjs.map +1 -1
- package/dist/lighthouse/index.d.mts +41 -0
- package/dist/lighthouse/index.d.ts +41 -0
- package/dist/lighthouse/index.js +39 -0
- package/dist/lighthouse/index.js.map +1 -0
- package/dist/lighthouse/index.mjs +34 -0
- package/dist/lighthouse/index.mjs.map +1 -0
- package/package.json +12 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** D-OBS-15 front-end budgets (OBS-1): Core Web Vitals on a mid-range phone, warn only. */
|
|
2
|
+
declare const LIGHTHOUSE_BUDGETS: {
|
|
3
|
+
readonly lcpMs: 2500;
|
|
4
|
+
readonly tbtMs: 200;
|
|
5
|
+
readonly cls: 0.1;
|
|
6
|
+
readonly scriptBytes: number;
|
|
7
|
+
};
|
|
8
|
+
type Assertion = ['warn' | 'error', Record<string, number>];
|
|
9
|
+
/** Lighthouse CI assertions for the D-OBS-15 budgets; every entry is `warn`, never `error`. */
|
|
10
|
+
declare const budgetAssertions: Record<string, Assertion>;
|
|
11
|
+
/** Lighthouse's own mid-range phone profile (Moto G Power, simulated slow 4G, 4x CPU slowdown). */
|
|
12
|
+
declare const mobileSettings: {
|
|
13
|
+
readonly formFactor: "mobile";
|
|
14
|
+
readonly screenEmulation: {
|
|
15
|
+
readonly mobile: true;
|
|
16
|
+
readonly width: 412;
|
|
17
|
+
readonly height: 823;
|
|
18
|
+
readonly deviceScaleFactor: 1.75;
|
|
19
|
+
readonly disabled: false;
|
|
20
|
+
};
|
|
21
|
+
readonly throttlingMethod: "simulate";
|
|
22
|
+
readonly throttling: {
|
|
23
|
+
readonly rttMs: 150;
|
|
24
|
+
readonly throughputKbps: 1638.4;
|
|
25
|
+
readonly cpuSlowdownMultiplier: 4;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
interface LhciConfig {
|
|
29
|
+
ci: {
|
|
30
|
+
collect?: {
|
|
31
|
+
settings?: Record<string, unknown>;
|
|
32
|
+
} & Record<string, unknown>;
|
|
33
|
+
assert?: {
|
|
34
|
+
assertions?: Record<string, unknown>;
|
|
35
|
+
} & Record<string, unknown>;
|
|
36
|
+
} & Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
/** Adds the mobile settings and budget assertions to an app's lighthouserc; app-set keys win. */
|
|
39
|
+
declare function withBudgets<T extends LhciConfig>(config: T): T;
|
|
40
|
+
|
|
41
|
+
export { LIGHTHOUSE_BUDGETS, budgetAssertions, mobileSettings, withBudgets };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** D-OBS-15 front-end budgets (OBS-1): Core Web Vitals on a mid-range phone, warn only. */
|
|
2
|
+
declare const LIGHTHOUSE_BUDGETS: {
|
|
3
|
+
readonly lcpMs: 2500;
|
|
4
|
+
readonly tbtMs: 200;
|
|
5
|
+
readonly cls: 0.1;
|
|
6
|
+
readonly scriptBytes: number;
|
|
7
|
+
};
|
|
8
|
+
type Assertion = ['warn' | 'error', Record<string, number>];
|
|
9
|
+
/** Lighthouse CI assertions for the D-OBS-15 budgets; every entry is `warn`, never `error`. */
|
|
10
|
+
declare const budgetAssertions: Record<string, Assertion>;
|
|
11
|
+
/** Lighthouse's own mid-range phone profile (Moto G Power, simulated slow 4G, 4x CPU slowdown). */
|
|
12
|
+
declare const mobileSettings: {
|
|
13
|
+
readonly formFactor: "mobile";
|
|
14
|
+
readonly screenEmulation: {
|
|
15
|
+
readonly mobile: true;
|
|
16
|
+
readonly width: 412;
|
|
17
|
+
readonly height: 823;
|
|
18
|
+
readonly deviceScaleFactor: 1.75;
|
|
19
|
+
readonly disabled: false;
|
|
20
|
+
};
|
|
21
|
+
readonly throttlingMethod: "simulate";
|
|
22
|
+
readonly throttling: {
|
|
23
|
+
readonly rttMs: 150;
|
|
24
|
+
readonly throughputKbps: 1638.4;
|
|
25
|
+
readonly cpuSlowdownMultiplier: 4;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
interface LhciConfig {
|
|
29
|
+
ci: {
|
|
30
|
+
collect?: {
|
|
31
|
+
settings?: Record<string, unknown>;
|
|
32
|
+
} & Record<string, unknown>;
|
|
33
|
+
assert?: {
|
|
34
|
+
assertions?: Record<string, unknown>;
|
|
35
|
+
} & Record<string, unknown>;
|
|
36
|
+
} & Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
/** Adds the mobile settings and budget assertions to an app's lighthouserc; app-set keys win. */
|
|
39
|
+
declare function withBudgets<T extends LhciConfig>(config: T): T;
|
|
40
|
+
|
|
41
|
+
export { LIGHTHOUSE_BUDGETS, budgetAssertions, mobileSettings, withBudgets };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/lighthouse/index.ts
|
|
4
|
+
var LIGHTHOUSE_BUDGETS = {
|
|
5
|
+
lcpMs: 2500,
|
|
6
|
+
tbtMs: 200,
|
|
7
|
+
cls: 0.1,
|
|
8
|
+
scriptBytes: 300 * 1024
|
|
9
|
+
};
|
|
10
|
+
var budgetAssertions = {
|
|
11
|
+
"largest-contentful-paint": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.lcpMs }],
|
|
12
|
+
"total-blocking-time": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.tbtMs }],
|
|
13
|
+
"cumulative-layout-shift": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.cls }],
|
|
14
|
+
"resource-summary:script:size": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.scriptBytes }]
|
|
15
|
+
};
|
|
16
|
+
var mobileSettings = {
|
|
17
|
+
formFactor: "mobile",
|
|
18
|
+
screenEmulation: { mobile: true, width: 412, height: 823, deviceScaleFactor: 1.75, disabled: false },
|
|
19
|
+
throttlingMethod: "simulate",
|
|
20
|
+
throttling: { rttMs: 150, throughputKbps: 1638.4, cpuSlowdownMultiplier: 4 }
|
|
21
|
+
};
|
|
22
|
+
function withBudgets(config) {
|
|
23
|
+
const { collect = {}, assert = {} } = config.ci;
|
|
24
|
+
return {
|
|
25
|
+
...config,
|
|
26
|
+
ci: {
|
|
27
|
+
...config.ci,
|
|
28
|
+
collect: { ...collect, settings: { ...mobileSettings, ...collect.settings } },
|
|
29
|
+
assert: { ...assert, assertions: { ...budgetAssertions, ...assert.assertions } }
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.LIGHTHOUSE_BUDGETS = LIGHTHOUSE_BUDGETS;
|
|
35
|
+
exports.budgetAssertions = budgetAssertions;
|
|
36
|
+
exports.mobileSettings = mobileSettings;
|
|
37
|
+
exports.withBudgets = withBudgets;
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lighthouse/index.ts"],"names":[],"mappings":";;;AACO,IAAM,kBAAA,GAAqB;AAAA,EAChC,KAAA,EAAO,IAAA;AAAA,EACP,KAAA,EAAO,GAAA;AAAA,EACP,GAAA,EAAK,GAAA;AAAA,EACL,aAAa,GAAA,GAAM;AACrB;AAKO,IAAM,gBAAA,GAA8C;AAAA,EACzD,4BAA4B,CAAC,MAAA,EAAQ,EAAE,eAAA,EAAiB,kBAAA,CAAmB,OAAO,CAAA;AAAA,EAClF,uBAAuB,CAAC,MAAA,EAAQ,EAAE,eAAA,EAAiB,kBAAA,CAAmB,OAAO,CAAA;AAAA,EAC7E,2BAA2B,CAAC,MAAA,EAAQ,EAAE,eAAA,EAAiB,kBAAA,CAAmB,KAAK,CAAA;AAAA,EAC/E,gCAAgC,CAAC,MAAA,EAAQ,EAAE,eAAA,EAAiB,kBAAA,CAAmB,aAAa;AAC9F;AAGO,IAAM,cAAA,GAAiB;AAAA,EAC5B,UAAA,EAAY,QAAA;AAAA,EACZ,eAAA,EAAiB,EAAE,MAAA,EAAQ,IAAA,EAAM,KAAA,EAAO,GAAA,EAAK,MAAA,EAAQ,GAAA,EAAK,iBAAA,EAAmB,IAAA,EAAM,QAAA,EAAU,KAAA,EAAM;AAAA,EACnG,gBAAA,EAAkB,UAAA;AAAA,EAClB,YAAY,EAAE,KAAA,EAAO,KAAK,cAAA,EAAgB,MAAA,EAAQ,uBAAuB,CAAA;AAC3E;AAUO,SAAS,YAAkC,MAAA,EAAc;AAC9D,EAAA,MAAM,EAAE,UAAU,EAAC,EAAG,SAAS,EAAC,KAAM,MAAA,CAAO,EAAA;AAC7C,EAAA,OAAO;AAAA,IACL,GAAG,MAAA;AAAA,IACH,EAAA,EAAI;AAAA,MACF,GAAG,MAAA,CAAO,EAAA;AAAA,MACV,OAAA,EAAS,EAAE,GAAG,OAAA,EAAS,QAAA,EAAU,EAAE,GAAG,cAAA,EAAgB,GAAG,OAAA,CAAQ,QAAA,EAAS,EAAE;AAAA,MAC5E,MAAA,EAAQ,EAAE,GAAG,MAAA,EAAQ,UAAA,EAAY,EAAE,GAAG,gBAAA,EAAkB,GAAG,MAAA,CAAO,UAAA,EAAW;AAAE;AACjF,GACF;AACF","file":"index.js","sourcesContent":["/** D-OBS-15 front-end budgets (OBS-1): Core Web Vitals on a mid-range phone, warn only. */\nexport const LIGHTHOUSE_BUDGETS = {\n lcpMs: 2500,\n tbtMs: 200,\n cls: 0.1,\n scriptBytes: 300 * 1024,\n} as const;\n\ntype Assertion = ['warn' | 'error', Record<string, number>];\n\n/** Lighthouse CI assertions for the D-OBS-15 budgets; every entry is `warn`, never `error`. */\nexport const budgetAssertions: Record<string, Assertion> = {\n 'largest-contentful-paint': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.lcpMs }],\n 'total-blocking-time': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.tbtMs }],\n 'cumulative-layout-shift': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.cls }],\n 'resource-summary:script:size': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.scriptBytes }],\n};\n\n/** Lighthouse's own mid-range phone profile (Moto G Power, simulated slow 4G, 4x CPU slowdown). */\nexport const mobileSettings = {\n formFactor: 'mobile',\n screenEmulation: { mobile: true, width: 412, height: 823, deviceScaleFactor: 1.75, disabled: false },\n throttlingMethod: 'simulate',\n throttling: { rttMs: 150, throughputKbps: 1638.4, cpuSlowdownMultiplier: 4 },\n} as const;\n\ninterface LhciConfig {\n ci: {\n collect?: { settings?: Record<string, unknown> } & Record<string, unknown>;\n assert?: { assertions?: Record<string, unknown> } & Record<string, unknown>;\n } & Record<string, unknown>;\n}\n\n/** Adds the mobile settings and budget assertions to an app's lighthouserc; app-set keys win. */\nexport function withBudgets<T extends LhciConfig>(config: T): T {\n const { collect = {}, assert = {} } = config.ci;\n return {\n ...config,\n ci: {\n ...config.ci,\n collect: { ...collect, settings: { ...mobileSettings, ...collect.settings } },\n assert: { ...assert, assertions: { ...budgetAssertions, ...assert.assertions } },\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/lighthouse/index.ts
|
|
2
|
+
var LIGHTHOUSE_BUDGETS = {
|
|
3
|
+
lcpMs: 2500,
|
|
4
|
+
tbtMs: 200,
|
|
5
|
+
cls: 0.1,
|
|
6
|
+
scriptBytes: 300 * 1024
|
|
7
|
+
};
|
|
8
|
+
var budgetAssertions = {
|
|
9
|
+
"largest-contentful-paint": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.lcpMs }],
|
|
10
|
+
"total-blocking-time": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.tbtMs }],
|
|
11
|
+
"cumulative-layout-shift": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.cls }],
|
|
12
|
+
"resource-summary:script:size": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.scriptBytes }]
|
|
13
|
+
};
|
|
14
|
+
var mobileSettings = {
|
|
15
|
+
formFactor: "mobile",
|
|
16
|
+
screenEmulation: { mobile: true, width: 412, height: 823, deviceScaleFactor: 1.75, disabled: false },
|
|
17
|
+
throttlingMethod: "simulate",
|
|
18
|
+
throttling: { rttMs: 150, throughputKbps: 1638.4, cpuSlowdownMultiplier: 4 }
|
|
19
|
+
};
|
|
20
|
+
function withBudgets(config) {
|
|
21
|
+
const { collect = {}, assert = {} } = config.ci;
|
|
22
|
+
return {
|
|
23
|
+
...config,
|
|
24
|
+
ci: {
|
|
25
|
+
...config.ci,
|
|
26
|
+
collect: { ...collect, settings: { ...mobileSettings, ...collect.settings } },
|
|
27
|
+
assert: { ...assert, assertions: { ...budgetAssertions, ...assert.assertions } }
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { LIGHTHOUSE_BUDGETS, budgetAssertions, mobileSettings, withBudgets };
|
|
33
|
+
//# sourceMappingURL=index.mjs.map
|
|
34
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lighthouse/index.ts"],"names":[],"mappings":";AACO,IAAM,kBAAA,GAAqB;AAAA,EAChC,KAAA,EAAO,IAAA;AAAA,EACP,KAAA,EAAO,GAAA;AAAA,EACP,GAAA,EAAK,GAAA;AAAA,EACL,aAAa,GAAA,GAAM;AACrB;AAKO,IAAM,gBAAA,GAA8C;AAAA,EACzD,4BAA4B,CAAC,MAAA,EAAQ,EAAE,eAAA,EAAiB,kBAAA,CAAmB,OAAO,CAAA;AAAA,EAClF,uBAAuB,CAAC,MAAA,EAAQ,EAAE,eAAA,EAAiB,kBAAA,CAAmB,OAAO,CAAA;AAAA,EAC7E,2BAA2B,CAAC,MAAA,EAAQ,EAAE,eAAA,EAAiB,kBAAA,CAAmB,KAAK,CAAA;AAAA,EAC/E,gCAAgC,CAAC,MAAA,EAAQ,EAAE,eAAA,EAAiB,kBAAA,CAAmB,aAAa;AAC9F;AAGO,IAAM,cAAA,GAAiB;AAAA,EAC5B,UAAA,EAAY,QAAA;AAAA,EACZ,eAAA,EAAiB,EAAE,MAAA,EAAQ,IAAA,EAAM,KAAA,EAAO,GAAA,EAAK,MAAA,EAAQ,GAAA,EAAK,iBAAA,EAAmB,IAAA,EAAM,QAAA,EAAU,KAAA,EAAM;AAAA,EACnG,gBAAA,EAAkB,UAAA;AAAA,EAClB,YAAY,EAAE,KAAA,EAAO,KAAK,cAAA,EAAgB,MAAA,EAAQ,uBAAuB,CAAA;AAC3E;AAUO,SAAS,YAAkC,MAAA,EAAc;AAC9D,EAAA,MAAM,EAAE,UAAU,EAAC,EAAG,SAAS,EAAC,KAAM,MAAA,CAAO,EAAA;AAC7C,EAAA,OAAO;AAAA,IACL,GAAG,MAAA;AAAA,IACH,EAAA,EAAI;AAAA,MACF,GAAG,MAAA,CAAO,EAAA;AAAA,MACV,OAAA,EAAS,EAAE,GAAG,OAAA,EAAS,QAAA,EAAU,EAAE,GAAG,cAAA,EAAgB,GAAG,OAAA,CAAQ,QAAA,EAAS,EAAE;AAAA,MAC5E,MAAA,EAAQ,EAAE,GAAG,MAAA,EAAQ,UAAA,EAAY,EAAE,GAAG,gBAAA,EAAkB,GAAG,MAAA,CAAO,UAAA,EAAW;AAAE;AACjF,GACF;AACF","file":"index.mjs","sourcesContent":["/** D-OBS-15 front-end budgets (OBS-1): Core Web Vitals on a mid-range phone, warn only. */\nexport const LIGHTHOUSE_BUDGETS = {\n lcpMs: 2500,\n tbtMs: 200,\n cls: 0.1,\n scriptBytes: 300 * 1024,\n} as const;\n\ntype Assertion = ['warn' | 'error', Record<string, number>];\n\n/** Lighthouse CI assertions for the D-OBS-15 budgets; every entry is `warn`, never `error`. */\nexport const budgetAssertions: Record<string, Assertion> = {\n 'largest-contentful-paint': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.lcpMs }],\n 'total-blocking-time': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.tbtMs }],\n 'cumulative-layout-shift': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.cls }],\n 'resource-summary:script:size': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.scriptBytes }],\n};\n\n/** Lighthouse's own mid-range phone profile (Moto G Power, simulated slow 4G, 4x CPU slowdown). */\nexport const mobileSettings = {\n formFactor: 'mobile',\n screenEmulation: { mobile: true, width: 412, height: 823, deviceScaleFactor: 1.75, disabled: false },\n throttlingMethod: 'simulate',\n throttling: { rttMs: 150, throughputKbps: 1638.4, cpuSlowdownMultiplier: 4 },\n} as const;\n\ninterface LhciConfig {\n ci: {\n collect?: { settings?: Record<string, unknown> } & Record<string, unknown>;\n assert?: { assertions?: Record<string, unknown> } & Record<string, unknown>;\n } & Record<string, unknown>;\n}\n\n/** Adds the mobile settings and budget assertions to an app's lighthouserc; app-set keys win. */\nexport function withBudgets<T extends LhciConfig>(config: T): T {\n const { collect = {}, assert = {} } = config.ci;\n return {\n ...config,\n ci: {\n ...config.ci,\n collect: { ...collect, settings: { ...mobileSettings, ...collect.settings } },\n assert: { ...assert, assertions: { ...budgetAssertions, ...assert.assertions } },\n },\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dloizides/frontend-devtools",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Shared RN-web dev tooling (dev-only) for the dloizides.com SaaS frontends: the custom ESLint plugin pack and rule packs (/eslint)
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "Shared RN-web dev tooling (dev-only) for the dloizides.com SaaS frontends: the custom ESLint plugin pack and rule packs (/eslint) the test-results reporters (/test-results) and the Lighthouse CI budget preset (/lighthouse). initI18n moved to @dloizides/i18n in 2.0.0. Never imports a product.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
7
7
|
"eslint-plugin",
|
|
@@ -35,6 +35,16 @@
|
|
|
35
35
|
"default": "./dist/eslint/index.mjs"
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
|
+
"./lighthouse": {
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./dist/lighthouse/index.d.ts",
|
|
41
|
+
"default": "./dist/lighthouse/index.js"
|
|
42
|
+
},
|
|
43
|
+
"import": {
|
|
44
|
+
"types": "./dist/lighthouse/index.d.mts",
|
|
45
|
+
"default": "./dist/lighthouse/index.mjs"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
38
48
|
"./test-results": {
|
|
39
49
|
"require": {
|
|
40
50
|
"types": "./dist/test-results/index.d.ts",
|