Skip to content

Commit 3a3443f

Browse files
committed
refactor: disable no-magic-numbers (rule moved to typescript-eslint)
1 parent 2368557 commit 3a3443f

File tree

11 files changed

+26
-5
lines changed

11 files changed

+26
-5
lines changed

eslint.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export default tseslint.config(
2323
{
2424
enforceBuildableLibDependency: true,
2525
allow: [
26-
'^.*/eslint(\\.base)?\\.config\\.[cm]?js$',
27-
'^.*/code-pushup\\.(config|preset)(\\.m?[jt]s)?$',
26+
String.raw`^.*/eslint(\.base)?\.config\.[cm]?js$`,
27+
String.raw`^.*/code-pushup\.(config|preset)(\.m?[jt]s)?$`,
2828
'^[./]+/tools/.*$',
2929
],
3030
depConstraints: [
@@ -87,7 +87,7 @@ export default tseslint.config(
8787
rules: {
8888
'vitest/consistent-test-filename': [
8989
'warn',
90-
{ pattern: '.*\\.(unit|integration|e2e)\\.test\\.[tj]sx?$' },
90+
{ pattern: String.raw`.*\.(unit|integration|e2e)\.test\.[tj]sx?$` },
9191
],
9292
},
9393
},
@@ -98,7 +98,7 @@ export default tseslint.config(
9898
{
9999
files: ['**/perf/**/*.ts'],
100100
rules: {
101-
'no-magic-numbers': 'off',
101+
'@typescript-eslint/no-magic-numbers': 'off',
102102
'sonarjs/no-duplicate-string': 'off',
103103
},
104104
},

examples/plugins/src/lighthouse/src/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export const categoryCorePerfGroup: Group = {
7676
slug: LIGHTHOUSE_PERFORMANCE_CORE_GROUP_SLUG,
7777
title: 'performance-core',
7878
refs: [
79+
/* eslint-disable @typescript-eslint/no-magic-numbers */
7980
// web vitals
8081
{
8182
slug: fcpSlug,
@@ -110,6 +111,7 @@ export const categoryCorePerfGroup: Group = {
110111
slug: 'user-timings',
111112
weight: 0,
112113
},
114+
/* eslint-enable @typescript-eslint/no-magic-numbers */
113115
],
114116
};
115117

@@ -118,6 +120,7 @@ export const categoryCorePerfGroup2: Group = {
118120
title: 'performance-core-2',
119121
refs: [
120122
// web vitals
123+
/* eslint-disable @typescript-eslint/no-magic-numbers */
121124
{
122125
slug: 'first-contentful-paint',
123126
weight: 10,
@@ -138,5 +141,6 @@ export const categoryCorePerfGroup2: Group = {
138141
slug: 'speed-index',
139142
weight: 10,
140143
},
144+
/* eslint-enable @typescript-eslint/no-magic-numbers */
141145
],
142146
};

packages/cli/src/lib/history/history.options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function yargsHistoryOptionsDefinition(): Record<
3030
// https://git-scm.com/docs/git-log#Documentation/git-log.txt---max-countltnumbergt
3131
describe: 'Number of steps in history',
3232
type: 'number',
33-
33+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
3434
default: 5,
3535
},
3636
from: {

packages/plugin-coverage/src/lib/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export function applyMaxScoreAboveThreshold(
2424
}
2525

2626
export const coverageTypeWeightMapper: Record<CoverageType, number> = {
27+
/* eslint-disable @typescript-eslint/no-magic-numbers */
2728
function: 6,
2829
branch: 3,
2930
line: 1,
31+
/* eslint-enable @typescript-eslint/no-magic-numbers */
3032
};

packages/plugin-js-packages/src/lib/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ export const dependencyGroupToLong: Record<
2323
};
2424

2525
export const dependencyGroupWeights: Record<DependencyGroup, number> = {
26+
/* eslint-disable @typescript-eslint/no-magic-numbers */
2627
prod: 80,
2728
dev: 15,
2829
optional: 5,
30+
/* eslint-enable @typescript-eslint/no-magic-numbers */
2931
};
3032

3133
export const dependencyDocs: Record<DependencyGroup, string> = {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import type { PackageAuditLevel } from '../../config.js';
22

33
export const auditScoreModifiers: Record<PackageAuditLevel, number> = {
4+
/* eslint-disable @typescript-eslint/no-magic-numbers */
45
critical: 1,
56
high: 0.1,
67
moderate: 0.05,
78
low: 0.02,
89
info: 0.01,
10+
/* eslint-enable @typescript-eslint/no-magic-numbers */
911
};

packages/plugin-lighthouse/src/lib/runner/details/item-value.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export function formatTableItemPropertyValue(
5858

5959
const parsedItemValue = parseTableItemPropertyValue(itemValue);
6060

61+
/* eslint-disable @typescript-eslint/no-magic-numbers */
6162
switch (itemValueFormat) {
6263
case 'bytes':
6364
return formatBytes(Number(parsedItemValue));
@@ -93,6 +94,7 @@ export function formatTableItemPropertyValue(
9394
ui().logger.info(`Format type ${bold('thumbnail')} is not implemented`);
9495
return '';
9596
}
97+
/* eslint-enable @typescript-eslint/no-magic-numbers */
9698

9799
return itemValue;
98100
}

packages/utils/src/lib/reports/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
export const TERMINAL_WIDTH = 80;
33

44
export const SCORE_COLOR_RANGE = {
5+
/* eslint-disable @typescript-eslint/no-magic-numbers */
56
GREEN_MIN: 0.9,
67
YELLOW_MIN: 0.5,
8+
/* eslint-enable @typescript-eslint/no-magic-numbers */
79
};
810

911
export const FOOTER_PREFIX = 'Made with ❤ by'; // replace ❤️ with ❤, because ❤️ has output issues in terminal

packages/utils/src/lib/reports/log-stdout-summary.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,14 @@ function logRow(score: number, title: string, value?: string): void {
8181
},
8282
{
8383
text: title,
84+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
8485
padding: [0, 3, 0, 0],
8586
},
8687
...(value
8788
? [
8889
{
8990
text: cyanBright(value),
91+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
9092
width: 20,
9193
padding: [0, 0, 0, 0],
9294
},
@@ -107,6 +109,7 @@ export function logCategories({
107109
countCategoryAudits(refs, plugins),
108110
]);
109111
const table = ui().table();
112+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
110113
table.columnWidths([TERMINAL_WIDTH - 9 - 10 - 4, 9, 10]);
111114
table.head(
112115
REPORT_RAW_OVERVIEW_TABLE_HEADERS.map((heading, idx) => ({

packages/utils/src/lib/text-formats/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ export const TAB = ' ';
33
export const SPACE = ' ';
44

55
export const HIERARCHY = {
6+
/* eslint-disable @typescript-eslint/no-magic-numbers */
67
level_1: 1,
78
level_2: 2,
89
level_3: 3,
910
level_4: 4,
1011
level_5: 5,
1112
level_6: 6,
13+
/* eslint-enable @typescript-eslint/no-magic-numbers */
1214
} as const;

0 commit comments

Comments
 (0)