Skip to content

Commit e041ed1

Browse files
committed
chore(): format fix
1 parent 76b458e commit e041ed1

File tree

4 files changed

+36
-19
lines changed

4 files changed

+36
-19
lines changed

packages/angular-mcp-server/src/lib/tools/ds/report-violations/report-all-violations.tool.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ import {
1616
} from '../shared/violation-analysis/formatters.js';
1717
import type { BaseViolationAudit } from '../shared/violation-analysis/types.js';
1818
import { loadAndValidateDsComponentsFile } from '../../../validation/ds-components-file-loader.validation.js';
19-
import {
19+
import {
2020
AllViolationsReport,
2121
AllViolationsComponentReport,
2222
AllViolationsEntry,
2323
AllViolationsReportByFile,
2424
FileViolationReport,
25-
ComponentViolationInFile
25+
ComponentViolationInFile,
2626
} from './models/types.js';
2727

2828
interface ReportAllViolationsOptions extends BaseHandlerOptions {
@@ -38,7 +38,8 @@ export const reportAllViolationsSchema = {
3838
groupBy: {
3939
type: 'string',
4040
enum: ['component', 'file'],
41-
description: 'How to group the results: "component" (default) groups by design system component showing all files affected by each component, "file" groups by file path showing all components violated in each file',
41+
description:
42+
'How to group the results: "component" (default) groups by design system component showing all files affected by each component, "file" groups by file path showing all components violated in each file',
4243
default: 'component',
4344
},
4445
}),
@@ -52,26 +53,34 @@ export const reportAllViolationsSchema = {
5253
* Extracts deprecated class and replacement from violation message
5354
* Performance optimized with caching to avoid repeated regex operations
5455
*/
55-
const messageParsingCache = new Map<string, { violation: string; replacement: string }>();
56+
const messageParsingCache = new Map<
57+
string,
58+
{ violation: string; replacement: string }
59+
>();
5660

57-
function parseViolationMessage(message: string): { violation: string; replacement: string } {
61+
function parseViolationMessage(message: string): {
62+
violation: string;
63+
replacement: string;
64+
} {
5865
// Check cache first
5966
const cached = messageParsingCache.get(message);
6067
if (cached) {
6168
return cached;
6269
}
6370

6471
// Clean up HTML tags
65-
const cleanMessage = message.replace(/<code>/g, '`').replace(/<\/code>/g, '`');
66-
72+
const cleanMessage = message
73+
.replace(/<code>/g, '`')
74+
.replace(/<\/code>/g, '`');
75+
6776
// Extract deprecated class - look for patterns like "class `offer-badge`" or "class `btn, btn-primary`"
6877
const classMatch = cleanMessage.match(/class `([^`]+)`/);
6978
const violation = classMatch ? classMatch[1] : 'unknown';
70-
79+
7180
// Extract replacement component - look for "Use `ComponentName`"
7281
const replacementMatch = cleanMessage.match(/Use `([^`]+)`/);
7382
const replacement = replacementMatch ? replacementMatch[1] : 'unknown';
74-
83+
7584
const result = { violation, replacement };
7685
messageParsingCache.set(message, result);
7786
return result;
@@ -216,8 +225,8 @@ export const reportAllViolationsHandler = createHandler<
216225
},
217226
(result) => {
218227
const isFileGrouping = 'files' in result;
219-
const isEmpty = isFileGrouping
220-
? result.files.length === 0
228+
const isEmpty = isFileGrouping
229+
? result.files.length === 0
221230
: result.components.length === 0;
222231

223232
if (isEmpty) {

packages/angular-mcp-server/src/lib/tools/ds/report-violations/report-violations.tool.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import {
77
COMMON_ANNOTATIONS,
88
} from '../shared/models/schema-helpers.js';
99
import { analyzeViolationsBase } from '../shared/violation-analysis/base-analyzer.js';
10-
import { groupIssuesByFile, filterFailedAudits } from '../shared/violation-analysis/formatters.js';
10+
import {
11+
groupIssuesByFile,
12+
filterFailedAudits,
13+
} from '../shared/violation-analysis/formatters.js';
1114
import { BaseViolationResult } from '../shared/violation-analysis/types.js';
1215
import { ComponentViolationReport, ViolationEntry } from './models/types.js';
1316

@@ -32,8 +35,10 @@ export const reportViolationsSchema = {
3235
*/
3336
function parseViolationMessage(message: string): string {
3437
// Clean up HTML tags
35-
const cleanMessage = message.replace(/<code>/g, '`').replace(/<\/code>/g, '`');
36-
38+
const cleanMessage = message
39+
.replace(/<code>/g, '`')
40+
.replace(/<\/code>/g, '`');
41+
3742
// Extract deprecated class - look for patterns like "class `offer-badge`" or "class `btn, btn-primary`"
3843
const classMatch = cleanMessage.match(/class `([^`]+)`/);
3944
return classMatch ? classMatch[1] : 'unknown';
@@ -66,7 +71,7 @@ export const reportViolationsHandler = createHandler<
6671

6772
for (const [fileName, { lines, message }] of Object.entries(fileGroups)) {
6873
const violation = parseViolationMessage(message);
69-
74+
7075
violations.push({
7176
file: fileName,
7277
lines: lines.sort((a, b) => a - b),

packages/angular-mcp-server/src/lib/tools/ds/shared/models/schema-helpers.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ export const COMMON_SCHEMA_PROPERTIES = {
1313

1414
componentName: {
1515
type: 'string' as const,
16-
description: 'The class name of the design system component to check for violations (e.g., DsButton, DsBadge, DsCard). This should be the TypeScript class name, not the selector.',
16+
description:
17+
'The class name of the design system component to check for violations (e.g., DsButton, DsBadge, DsCard). This should be the TypeScript class name, not the selector.',
1718
},
1819

1920
groupBy: {
2021
type: 'string' as const,
2122
enum: ['file', 'folder'] as const,
22-
description: 'How to group the violation results in the output. "file" groups violations by individual file paths, "folder" groups by directory structure.',
23+
description:
24+
'How to group the violation results in the output. "file" groups violations by individual file paths, "folder" groups by directory structure.',
2325
default: 'file' as const,
2426
},
2527
} as const;

packages/angular-mcp-server/src/lib/tools/ds/shared/violation-analysis/formatters.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ export function groupIssuesByFile(
8787

8888
if (!fileGroups[fileName]) {
8989
// Normalize message inline (remove directory prefix)
90-
const directoryPrefix = directory.endsWith('/') ? directory : directory + '/';
90+
const directoryPrefix = directory.endsWith('/')
91+
? directory
92+
: directory + '/';
9193
const normalizedMessage = message.includes(directoryPrefix)
9294
? message.replace(directoryPrefix, '')
9395
: message;
@@ -111,4 +113,3 @@ export function groupIssuesByFile(
111113

112114
return fileGroups;
113115
}
114-

0 commit comments

Comments
 (0)