@ovh-ux/manager-static-analysis-kit 0.11.2 → 0.13.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 +22 -0
- package/README.md +2 -2
- package/bin/cli-path-config.js +9 -8
- package/bin/code-duplication-tests-cli.js +9 -9
- package/bin/lint-cli.js +26 -10
- package/bin/perf-budgets-tests-cli.js +9 -9
- package/bin/tests-coverage-cli-tests.js +9 -9
- package/bin/types-coverage-cli.js +7 -0
- package/bin/types-coverage-tests-cli.js +9 -9
- package/bin/utils/args-parse-utils.js +3 -2
- package/dist/adapters/code-duplication/helpers/code-duplication-analysis-helper.d.ts +1 -1
- package/dist/adapters/code-duplication/helpers/code-duplication-analysis-helper.d.ts.map +1 -1
- package/dist/adapters/code-duplication/helpers/code-duplication-analysis-helper.js +16 -146
- package/dist/adapters/code-duplication/helpers/code-duplication-reports-render.d.ts +4 -0
- package/dist/adapters/code-duplication/helpers/code-duplication-reports-render.d.ts.map +1 -0
- package/dist/adapters/code-duplication/helpers/code-duplication-reports-render.js +141 -0
- package/dist/adapters/eslint/rules/eslint-prettier.d.ts.map +1 -1
- package/dist/adapters/eslint/rules/eslint-prettier.js +3 -2
- package/dist/adapters/html-w3c-validation/helpers/html-w3c-tests-setup.d.ts +2 -2
- package/dist/configs/code-formatter-config.d.ts +0 -1
- package/dist/configs/code-formatter-config.d.ts.map +1 -1
- package/dist/configs/code-formatter-config.js +0 -10
- package/dist/configs/shared-exclusion-patterns.d.ts +2 -0
- package/dist/configs/shared-exclusion-patterns.d.ts.map +1 -1
- package/dist/configs/shared-exclusion-patterns.js +40 -27
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -28
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { codeDuplicationConfig } from '../../../configs/code-duplication-config.js';
|
|
2
|
+
function buildDisplayedFilePath(filePath) {
|
|
3
|
+
const norm = filePath.replace(/\\/g, '/');
|
|
4
|
+
const appsIdx = norm.indexOf('/apps/');
|
|
5
|
+
if (appsIdx >= 0)
|
|
6
|
+
return norm.slice(appsIdx + 1);
|
|
7
|
+
const parts = norm.split('/');
|
|
8
|
+
return parts.slice(Math.max(0, parts.length - 5)).join('/');
|
|
9
|
+
}
|
|
10
|
+
const buildDuplicationColorStatus = (pct) => {
|
|
11
|
+
const green = codeDuplicationConfig.thresholds?.green ?? 10;
|
|
12
|
+
const orange = codeDuplicationConfig.thresholds?.orange ?? 20;
|
|
13
|
+
return pct < green ? 'green' : pct < orange ? 'orange' : 'red';
|
|
14
|
+
};
|
|
15
|
+
function buildDuplicationWorstFiles(app, worstFiles = []) {
|
|
16
|
+
const threshold = codeDuplicationConfig.worstFiles.threshold;
|
|
17
|
+
if (!worstFiles.length) {
|
|
18
|
+
return `
|
|
19
|
+
<details class="coverage-details">
|
|
20
|
+
<summary>📊 Duplication Overview for <strong>${app}</strong></summary>
|
|
21
|
+
<p class="coverage-empty">No files above threshold 🎉</p>
|
|
22
|
+
</details>`;
|
|
23
|
+
}
|
|
24
|
+
const rows = worstFiles
|
|
25
|
+
.map(([file, f]) => {
|
|
26
|
+
const short = buildDisplayedFilePath(file);
|
|
27
|
+
const color = buildDuplicationColorStatus(f.percentage);
|
|
28
|
+
return `
|
|
29
|
+
<tr>
|
|
30
|
+
<td colspan="2" title="${file}">${short}</td>
|
|
31
|
+
<td>${f.duplicatedLines}/${f.totalLines}</td>
|
|
32
|
+
<td style="color:${color}">${f.percentage.toFixed(2)}%</td>
|
|
33
|
+
</tr>`;
|
|
34
|
+
})
|
|
35
|
+
.join('');
|
|
36
|
+
return `
|
|
37
|
+
<details class="coverage-details">
|
|
38
|
+
<summary>📊 Duplication Overview for <strong>${app}</strong> (≥ ${threshold}%)</summary>
|
|
39
|
+
<table class="coverage-subtable">
|
|
40
|
+
<tbody>${rows}</tbody>
|
|
41
|
+
</table>
|
|
42
|
+
</details>`;
|
|
43
|
+
}
|
|
44
|
+
function buildDuplicationCell(stats) {
|
|
45
|
+
const min = stats.minPercentage ?? stats.percentage;
|
|
46
|
+
const max = stats.maxPercentage ?? stats.percentage;
|
|
47
|
+
if (stats.duplicateLines === 0) {
|
|
48
|
+
return `<span style="color:${buildDuplicationColorStatus(0)}">0.00%</span>`;
|
|
49
|
+
}
|
|
50
|
+
if (min.toFixed(2) === max.toFixed(2)) {
|
|
51
|
+
return `
|
|
52
|
+
${stats.percentage.toFixed(2)}% (${stats.filesWithDuplication} files cluster at
|
|
53
|
+
<span style="color:${buildDuplicationColorStatus(min)}">${min.toFixed(2)}%</span>)
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
56
|
+
return `
|
|
57
|
+
${stats.percentage.toFixed(2)}% (range:
|
|
58
|
+
<span style="color:${buildDuplicationColorStatus(min)}">${min.toFixed(2)}%</span> –
|
|
59
|
+
<span style="color:${buildDuplicationColorStatus(max)}">${max.toFixed(2)}%</span>)
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
function buildAppRow(app, stats) {
|
|
63
|
+
if (stats.error) {
|
|
64
|
+
return `<tr style="background:#ffe0e0">
|
|
65
|
+
<td>${app}</td>
|
|
66
|
+
<td colspan="5" style="color:red">${stats.error}</td>
|
|
67
|
+
</tr>`;
|
|
68
|
+
}
|
|
69
|
+
const max = stats.maxPercentage ?? stats.percentage;
|
|
70
|
+
const rowColor = buildDuplicationColorStatus(max);
|
|
71
|
+
const bg = rowColor === 'green' ? '#e6ffed' : rowColor === 'orange' ? '#fff8e1' : '#ffe6e6';
|
|
72
|
+
return `
|
|
73
|
+
<tr style="background:${bg}">
|
|
74
|
+
<td>${app}</td>
|
|
75
|
+
<td>${stats.totalLines}</td>
|
|
76
|
+
<td>${stats.duplicateLines}</td>
|
|
77
|
+
<td>${stats.clonesCount}</td>
|
|
78
|
+
<td style="font-weight:bold;">${buildDuplicationCell(stats)}</td>
|
|
79
|
+
</tr>
|
|
80
|
+
<tr><td colspan="5">${buildDuplicationWorstFiles(app, stats.worstFiles)}</td></tr>`;
|
|
81
|
+
}
|
|
82
|
+
export function buildDuplicationReportHead() {
|
|
83
|
+
return `
|
|
84
|
+
<head>
|
|
85
|
+
<meta charset="UTF-8"/>
|
|
86
|
+
<title>Code Duplication Report</title>
|
|
87
|
+
<style>
|
|
88
|
+
body { font-family: Arial, sans-serif; margin: 2rem; }
|
|
89
|
+
table { border-collapse: collapse; width: 100%; }
|
|
90
|
+
th, td { border: 1px solid #ccc; padding: 0.5rem; text-align: left; }
|
|
91
|
+
th { background: #f0f0f0; }
|
|
92
|
+
.coverage-details {
|
|
93
|
+
margin: 0.3rem 0 0.8rem 1.5rem;
|
|
94
|
+
padding: 0.5rem;
|
|
95
|
+
border-left: 3px solid #ccc;
|
|
96
|
+
background: #fafafa;
|
|
97
|
+
border-radius: 4px;
|
|
98
|
+
}
|
|
99
|
+
.coverage-details summary { font-weight: bold; cursor: pointer; }
|
|
100
|
+
.coverage-subtable {
|
|
101
|
+
margin-top: 0.5rem;
|
|
102
|
+
border: 1px solid #ddd;
|
|
103
|
+
width: 95%;
|
|
104
|
+
font-size: 0.9em;
|
|
105
|
+
}
|
|
106
|
+
.coverage-empty {
|
|
107
|
+
margin: 0.5rem 0;
|
|
108
|
+
color: #888;
|
|
109
|
+
font-style: italic;
|
|
110
|
+
}
|
|
111
|
+
</style>
|
|
112
|
+
</head>
|
|
113
|
+
`.trim();
|
|
114
|
+
}
|
|
115
|
+
export function buildDuplicationReportBody(summary) {
|
|
116
|
+
const rows = Object.entries(summary.apps)
|
|
117
|
+
.map(([app, stats]) => buildAppRow(app, stats))
|
|
118
|
+
.join('');
|
|
119
|
+
return `
|
|
120
|
+
<body>
|
|
121
|
+
<h1>Code Duplication Report</h1>
|
|
122
|
+
<p>
|
|
123
|
+
Total lines: ${summary.totalLines},
|
|
124
|
+
Duplicate lines: ${summary.totalDuplicateLines},
|
|
125
|
+
Percentage: ${summary.percentage.toFixed(2)}%
|
|
126
|
+
</p>
|
|
127
|
+
<table>
|
|
128
|
+
<thead>
|
|
129
|
+
<tr>
|
|
130
|
+
<th>App</th>
|
|
131
|
+
<th>Total lines</th>
|
|
132
|
+
<th>Duplicate lines</th>
|
|
133
|
+
<th>Clones</th>
|
|
134
|
+
<th>Duplication %</th>
|
|
135
|
+
</tr>
|
|
136
|
+
</thead>
|
|
137
|
+
<tbody>${rows}</tbody>
|
|
138
|
+
</table>
|
|
139
|
+
</body>
|
|
140
|
+
`.trim();
|
|
141
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint-prettier.d.ts","sourceRoot":"","sources":["../../../../src/adapters/eslint/rules/eslint-prettier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"eslint-prettier.d.ts","sourceRoot":"","sources":["../../../../src/adapters/eslint/rules/eslint-prettier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAmBhC,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,UAUzC,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import prettier from 'eslint-plugin-prettier';
|
|
2
|
-
import { prettierConfig
|
|
2
|
+
import { prettierConfig } from '../../../configs/code-formatter-config.js';
|
|
3
3
|
import { commonTextFiles } from '../../../configs/file-globs-config.js';
|
|
4
|
+
import { sharedCodeFormatterIgnorePatterns } from '../../../configs/shared-exclusion-patterns.js';
|
|
4
5
|
export const prettierEslintConfig = {
|
|
5
6
|
files: [commonTextFiles],
|
|
6
|
-
ignores:
|
|
7
|
+
ignores: sharedCodeFormatterIgnorePatterns,
|
|
7
8
|
plugins: {
|
|
8
9
|
prettier,
|
|
9
10
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-formatter-config.d.ts","sourceRoot":"","sources":["../../src/configs/code-formatter-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code-formatter-config.d.ts","sourceRoot":"","sources":["../../src/configs/code-formatter-config.ts"],"names":[],"mappings":"AA8DA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;CAqB1B,CAAC"}
|
|
@@ -6,16 +6,6 @@ const require = createRequire(import.meta.url);
|
|
|
6
6
|
const tailwindPluginPath = require.resolve('prettier-plugin-tailwindcss');
|
|
7
7
|
const sortImportsPluginPath = require.resolve('@trivago/prettier-plugin-sort-imports');
|
|
8
8
|
const tailwindConfigPath = resolve(cwd(), 'tailwind.config.js');
|
|
9
|
-
export const prettierIgnorePatterns = [
|
|
10
|
-
'**/dist/**',
|
|
11
|
-
'**/custom-elements*/**',
|
|
12
|
-
'**/loader/**',
|
|
13
|
-
'**/react/**',
|
|
14
|
-
'**/vue/**',
|
|
15
|
-
'**/apps/container/**',
|
|
16
|
-
'**/apps/pci-databases-analytics/src/components/ui/**',
|
|
17
|
-
'**/apps/pci-databases-analytics/src/lib/utils.ts',
|
|
18
|
-
];
|
|
19
9
|
export const prettierConfig = {
|
|
20
10
|
semi: true,
|
|
21
11
|
singleQuote: true,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const sharedExclusionPatterns: string[];
|
|
2
|
+
export declare const sharedLintExclusionPatterns: string[];
|
|
2
3
|
export declare const sharedTypesExclusionPatterns: string[];
|
|
4
|
+
export declare const sharedCodeFormatterIgnorePatterns: string[];
|
|
3
5
|
//# sourceMappingURL=shared-exclusion-patterns.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-exclusion-patterns.d.ts","sourceRoot":"","sources":["../../src/configs/shared-exclusion-patterns.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared-exclusion-patterns.d.ts","sourceRoot":"","sources":["../../src/configs/shared-exclusion-patterns.ts"],"names":[],"mappings":"AA6EA,eAAO,MAAM,uBAAuB,UAOnC,CAAC;AAQF,eAAO,MAAM,2BAA2B,UAOvC,CAAC;AAaF,eAAO,MAAM,4BAA4B,UAKxC,CAAC;AAWF,eAAO,MAAM,iCAAiC,UAY7C,CAAC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
const baseExclusionPatterns = [
|
|
2
2
|
'**/node_modules/**',
|
|
3
|
-
'**/target/**',
|
|
4
3
|
'**/dist/**',
|
|
5
|
-
'**/
|
|
4
|
+
'**/target/**',
|
|
6
5
|
'**/.next/**',
|
|
7
|
-
'**/next*/**',
|
|
8
6
|
'**/.husky/**',
|
|
9
7
|
'**/.vscode/**',
|
|
10
8
|
'**/.idea/**',
|
|
@@ -16,8 +14,14 @@ export const sharedExclusionPatterns = [
|
|
|
16
14
|
'**/webpack*.*',
|
|
17
15
|
'**/babel*.*',
|
|
18
16
|
'**/tailwind*.*',
|
|
19
|
-
'**/tsconfig.json',
|
|
20
17
|
'**/turbo.json',
|
|
18
|
+
'**/tsconfig.json',
|
|
19
|
+
'vite-env.d.ts',
|
|
20
|
+
'**/*.svg',
|
|
21
|
+
'**/**.md',
|
|
22
|
+
'**/Messages_*_*.json',
|
|
23
|
+
];
|
|
24
|
+
const testAndMockExclusionPatterns = [
|
|
21
25
|
'**/__tests__/**',
|
|
22
26
|
'**/__test__/**',
|
|
23
27
|
'**/tests/**',
|
|
@@ -27,34 +31,43 @@ export const sharedExclusionPatterns = [
|
|
|
27
31
|
'**/**spec*.*',
|
|
28
32
|
'**/mock*/**',
|
|
29
33
|
'**/mocks/**',
|
|
34
|
+
'**/__mocks__/**',
|
|
30
35
|
'**/_mock_/**',
|
|
31
36
|
'**/**Mock**/**',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
];
|
|
38
|
+
const typeAndMetaExclusionPatterns = ['**/*.types.*', '**/*.d.ts.*'];
|
|
39
|
+
export const sharedExclusionPatterns = [
|
|
40
|
+
...baseExclusionPatterns,
|
|
41
|
+
...testAndMockExclusionPatterns,
|
|
42
|
+
...typeAndMetaExclusionPatterns,
|
|
43
|
+
'**/**hmr**',
|
|
44
|
+
'**/**config**',
|
|
45
|
+
'**/**cucumber**',
|
|
46
|
+
];
|
|
47
|
+
export const sharedLintExclusionPatterns = [
|
|
48
|
+
...baseExclusionPatterns,
|
|
49
|
+
...testAndMockExclusionPatterns,
|
|
50
|
+
...typeAndMetaExclusionPatterns,
|
|
35
51
|
'**/**hmr**',
|
|
36
52
|
'**/**config**',
|
|
37
53
|
'**/**cucumber**',
|
|
38
|
-
'**/Messages_*_*.json',
|
|
39
|
-
'**/**.md',
|
|
40
54
|
];
|
|
41
55
|
export const sharedTypesExclusionPatterns = [
|
|
42
|
-
|
|
56
|
+
...baseExclusionPatterns,
|
|
57
|
+
...testAndMockExclusionPatterns,
|
|
58
|
+
'**/**config**',
|
|
59
|
+
'**/**cucumber**',
|
|
60
|
+
];
|
|
61
|
+
export const sharedCodeFormatterIgnorePatterns = [
|
|
43
62
|
'**/dist/**',
|
|
44
|
-
'**/
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
'
|
|
51
|
-
'
|
|
52
|
-
'**/
|
|
53
|
-
'
|
|
54
|
-
'**/turbo.json',
|
|
55
|
-
'**/tsconfig.json',
|
|
56
|
-
'vite-env.d.ts',
|
|
57
|
-
'**/*.svg',
|
|
58
|
-
'**/**.md',
|
|
59
|
-
'**/Messages_*_*.json',
|
|
63
|
+
'**/custom-elements*/**',
|
|
64
|
+
'**/loader/**',
|
|
65
|
+
'**/react/**',
|
|
66
|
+
'**/vue/**',
|
|
67
|
+
'**/apps/container/**',
|
|
68
|
+
'**/apps/pci-databases-analytics/src/components/ui/**',
|
|
69
|
+
'**/apps/pci-databases-analytics/src/lib/utils.ts',
|
|
70
|
+
'**/**.json',
|
|
71
|
+
'**/README.md',
|
|
72
|
+
'CHANGELOG.md',
|
|
60
73
|
];
|