@finedesign/cli 0.2.0 → 0.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 +11 -1
- package/README.md +44 -19
- package/data/1.24.9/catalog.json +1 -1
- package/data/1.24.9/manifest.json +2 -2
- package/data/1.25.0/catalog.json +1 -1
- package/data/1.25.0/manifest.json +5 -5
- package/package.json +2 -1
- package/skills/fine-design/SKILL.md +2 -2
- package/skills/fine-design/references/component-guide.md +1 -1
- package/src/cli.mjs +150 -9
- package/src/core/catalog.mjs +300 -19
- package/src/core/contracts.mjs +6 -1
- package/src/core/html.cjs +140 -20
- package/src/core/lint.mjs +302 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { parse } from '@babel/parser';
|
|
4
|
+
import { ToolError } from './errors.mjs';
|
|
5
|
+
import { suggestSimilarComponents } from './catalog.mjs';
|
|
6
|
+
|
|
7
|
+
const CODE_FILE_PATTERN = /\.(?:[cm]?[jt]sx?|html?)$/i;
|
|
8
|
+
const IGNORED_DIRS = new Set(['node_modules', '.git', 'dist', 'lib', 'es', '.dumi', 'coverage', 'artifacts']);
|
|
9
|
+
const BUTTON_TYPES = new Set(['primary', 'secondary', 'normal', 'negative', 'link', 'text', 'text-normal', 'bare']);
|
|
10
|
+
|
|
11
|
+
const KNOWN_TYPE_EXPORTS = new Set([
|
|
12
|
+
'AffixProps', 'AffixTarget', 'AlertProps', 'AlertType', 'AnchorProps', 'AvatarProps',
|
|
13
|
+
'BadgeProps', 'ButtonGroupProps', 'ButtonHTMLType', 'ButtonProps', 'ButtonSize', 'ButtonType',
|
|
14
|
+
'CheckGroupDirection', 'CheckGroupProps', 'CheckProps', 'ComboCheckProps',
|
|
15
|
+
'ComboDropdownAsyncParams', 'ComboDropdownGroupItem', 'ComboDropdownItem', 'ComboProps',
|
|
16
|
+
'DatePickerMode', 'DatePickerProps', 'DatetimeProps', 'DialogAnimation', 'DialogImperativeProps',
|
|
17
|
+
'DialogProps', 'DialogTheme', 'DialogTitleAlign', 'DrawerEdge', 'DrawerPlacement', 'DrawerProps',
|
|
18
|
+
'FileItem', 'FilePreviewActionProps', 'FilePreviewFileActionsRender', 'FilePreviewFileActionsRenderInfo',
|
|
19
|
+
'FilePreviewProps', 'FormItemProps', 'FormLayout', 'FormProps', 'IRuleDescriptor',
|
|
20
|
+
'InputCountConfig', 'InputCountInfo', 'InputProps', 'InputRef', 'InputSize', 'InputState',
|
|
21
|
+
'InputValue', 'TextAreaProps', 'InputNumberControlInfo', 'InputNumberControlTooltip',
|
|
22
|
+
'InputNumberControlTooltipProps', 'InputNumberProps', 'InputNumberRef', 'InputNumberSize',
|
|
23
|
+
'InputNumberState', 'InputNumberStep', 'InputNumberValidationProps', 'InputNumberValue',
|
|
24
|
+
'LabelProps', 'ListProps', 'PaginationProps', 'PaginationThemeType', 'RadioGroupDirection',
|
|
25
|
+
'RadioGroupProps', 'RadioProps', 'SegmentItemProps', 'SegmentProps', 'SkeletonProps',
|
|
26
|
+
'SpinProps', 'StepDirection', 'StepItemProps', 'StepProps', 'StepStatus', 'TableColumn',
|
|
27
|
+
'TableProps', 'TableRowSelection', 'TableSize', 'VirtualListHolderComponent', 'VirtualListProps',
|
|
28
|
+
'VirtualListRef', 'VirtualListScrollConfig', 'VirtualListScrollTo', 'BreadcrumbItem',
|
|
29
|
+
'BreadcrumbProps', 'CascaderPlacement', 'CascaderProps', 'MCascaderProps', 'DataTableProps',
|
|
30
|
+
'DataTableSize', 'DataTableColumnType', 'DataTableRowSelection', 'DividerDirection',
|
|
31
|
+
'DividerProp', 'InstructionProps', 'InstructionType', 'LocaleProviderProps', 'MenuItemProps',
|
|
32
|
+
'MenuProps', 'ModalMaskProps', 'PopConfirmProps', 'PopoverPlacement', 'PopoverProps',
|
|
33
|
+
'ProgressProps', 'PromptProps', 'ResultProps', 'ResultSize', 'SplitterProps', 'SwitchProps',
|
|
34
|
+
'TabDirection', 'TabItemProp', 'TabProp', 'TabSize', 'TabTheme', 'TagProps', 'TagShape',
|
|
35
|
+
'TagSize', 'TooltipEffect', 'TooltipPlacement', 'TooltipProps', 'TreeProps', 'TreeRef',
|
|
36
|
+
'TreeDropPosition', 'TreeEventDataNode', 'TriggerProps', 'UploadCustomRequest', 'UploadFile',
|
|
37
|
+
'UploadProgress', 'UploadProps', 'UploadRef', 'MessageProps', 'NotificationProps', 'ToastProps',
|
|
38
|
+
'ToastType', 'ColorPickerProps', 'GradientColorPickerProps', 'SingleColorPickerProps',
|
|
39
|
+
'VirtualTableProps', 'Column', 'ColumnAlign', 'RenderInfo', 'SortOrder', 'SpanRect',
|
|
40
|
+
'WatermarkProps', 'AutoCompleteProps', 'CarouselProps', 'CarouselRef', 'CollapseProps',
|
|
41
|
+
'ConfigProviderProps', 'Theme', 'ThemeAlgorithm', 'ThemeToken', 'DropdownButtonProps',
|
|
42
|
+
'DropdownButtonType', 'DropdownProps', 'ImageProps', 'NavigationDividerProps',
|
|
43
|
+
'NavigationItemGroupProps', 'NavigationItemProps', 'NavigationItemType', 'NavigationProps',
|
|
44
|
+
'NavigationTheme', 'SubNavigationProps', 'SelectDisplayValueType', 'SelectProps',
|
|
45
|
+
'SliderRangeProps', 'SliderRef', 'SliderSingleProps', 'TreeSelectProps', 'TreeTagProps',
|
|
46
|
+
'TypographyProps', 'TIMEZONE_KEY', 'NextTableCellProps', 'NextTableColumnGroupProps',
|
|
47
|
+
'NextTableColumnProps', 'NextTableHeaderCellProps', 'NextTableProps'
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
const EXTRA_VALUE_EXPORTS = new Set([
|
|
51
|
+
'DateUtils',
|
|
52
|
+
'getAllCheckedKeys',
|
|
53
|
+
'getHalfCheckedKeys'
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
function collectFiles(targetPath) {
|
|
57
|
+
const resolved = path.resolve(targetPath);
|
|
58
|
+
if (!fs.existsSync(resolved)) {
|
|
59
|
+
throw new ToolError('INVALID_ARGUMENT', `Lint target does not exist: ${targetPath}`, 2);
|
|
60
|
+
}
|
|
61
|
+
const results = [];
|
|
62
|
+
function walk(current) {
|
|
63
|
+
const stat = fs.statSync(current);
|
|
64
|
+
if (stat.isFile()) {
|
|
65
|
+
if (CODE_FILE_PATTERN.test(current)) results.push(current);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (!stat.isDirectory()) return;
|
|
69
|
+
for (const entry of fs.readdirSync(current, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
70
|
+
if (entry.isDirectory()) {
|
|
71
|
+
if (!IGNORED_DIRS.has(entry.name) && !entry.name.startsWith('.')) {
|
|
72
|
+
walk(path.join(current, entry.name));
|
|
73
|
+
}
|
|
74
|
+
} else if (entry.isFile() && CODE_FILE_PATTERN.test(entry.name)) {
|
|
75
|
+
results.push(path.join(current, entry.name));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
walk(resolved);
|
|
80
|
+
return results;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function lineOfIndex(content, index) {
|
|
84
|
+
let line = 1;
|
|
85
|
+
for (let i = 0; i < index; i++) {
|
|
86
|
+
if (content.charCodeAt(i) === 10) line++;
|
|
87
|
+
}
|
|
88
|
+
return line;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function codeSources(file, content) {
|
|
92
|
+
if (!/\.html?$/i.test(file)) return [{ content, startLine: 1 }];
|
|
93
|
+
return [...content.matchAll(/<!--[\s\S]*?-->|<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi)]
|
|
94
|
+
.filter((match) => {
|
|
95
|
+
if (match[1] === undefined) return false;
|
|
96
|
+
const type = match[1].match(/\btype\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i);
|
|
97
|
+
return !type || /^(?:module|(?:text|application)\/(?:javascript|ecmascript|babel|typescript))$/i.test(type[1] ?? type[2] ?? type[3]);
|
|
98
|
+
})
|
|
99
|
+
.map((match) => ({ content: match[2], startLine: lineOfIndex(content, match.index + match[0].indexOf('>') + 1) }));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function bindPattern(pattern, scope) {
|
|
103
|
+
if (!pattern) return;
|
|
104
|
+
if (pattern.type === 'Identifier') scope.bindings.set(pattern.name, null);
|
|
105
|
+
else if (pattern.type === 'ObjectPattern') {
|
|
106
|
+
for (const prop of pattern.properties) bindPattern(prop.type === 'RestElement' ? prop.argument : prop.value, scope);
|
|
107
|
+
} else if (pattern.type === 'ArrayPattern') {
|
|
108
|
+
for (const element of pattern.elements) bindPattern(element, scope);
|
|
109
|
+
} else if (pattern.type === 'AssignmentPattern') bindPattern(pattern.left, scope);
|
|
110
|
+
else if (pattern.type === 'RestElement') bindPattern(pattern.argument, scope);
|
|
111
|
+
else if (pattern.type === 'TSParameterProperty') bindPattern(pattern.parameter, scope);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function collectScopes(program) {
|
|
115
|
+
const scopes = new WeakMap();
|
|
116
|
+
function collect(node, scope) {
|
|
117
|
+
if (node.type === 'FunctionDeclaration' || node.type === 'ClassDeclaration') bindPattern(node.id, scope);
|
|
118
|
+
const isFunction = /Function(?:Declaration|Expression)$|Method$/.test(node.type);
|
|
119
|
+
if (isFunction || ['Program', 'BlockStatement', 'CatchClause', 'ForStatement', 'ForInStatement', 'ForOfStatement', 'SwitchStatement', 'StaticBlock', 'ClassDeclaration', 'ClassExpression'].includes(node.type)) {
|
|
120
|
+
scope = { parent: scope, bindings: new Map(), varScope: isFunction || node.type === 'Program' || node.type === 'StaticBlock' ? null : scope.varScope };
|
|
121
|
+
scope.varScope ||= scope;
|
|
122
|
+
if (isFunction || node.type === 'ClassExpression') bindPattern(node.id, scope);
|
|
123
|
+
for (const param of node.params || []) bindPattern(param, scope);
|
|
124
|
+
if (node.type === 'CatchClause') bindPattern(node.param, scope);
|
|
125
|
+
}
|
|
126
|
+
scopes.set(node, scope);
|
|
127
|
+
if (node.type === 'ImportDeclaration') {
|
|
128
|
+
for (const spec of node.specifiers) {
|
|
129
|
+
bindPattern(spec.local, scope);
|
|
130
|
+
if (node.source.value === '@fx-ui/fine-design' && node.importKind !== 'type' && spec.importKind !== 'type') {
|
|
131
|
+
if (spec.type === 'ImportSpecifier') scope.bindings.set(spec.local.name, { component: spec.imported.name ?? spec.imported.value });
|
|
132
|
+
else if (spec.type === 'ImportNamespaceSpecifier') scope.bindings.set(spec.local.name, { namespace: true });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} else if (node.type === 'VariableDeclaration') {
|
|
136
|
+
const targetScope = node.kind === 'var' ? scope.varScope : scope;
|
|
137
|
+
for (const declaration of node.declarations) {
|
|
138
|
+
bindPattern(declaration.id, targetScope);
|
|
139
|
+
if (declaration.id.type !== 'ObjectPattern') continue;
|
|
140
|
+
for (const prop of declaration.id.properties) {
|
|
141
|
+
if (prop.type !== 'ObjectProperty' || prop.computed) continue;
|
|
142
|
+
const local = prop.value.type === 'AssignmentPattern' ? prop.value.left : prop.value;
|
|
143
|
+
if (local.type === 'Identifier') targetScope.bindings.set(local.name, { component: String(prop.key.name ?? prop.key.value), source: declaration.init, scope });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
for (const child of Object.values(node)) {
|
|
148
|
+
if (Array.isArray(child)) child.filter((item) => item?.type).forEach((item) => collect(item, scope));
|
|
149
|
+
else if (child?.type) collect(child, scope);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
collect(program);
|
|
153
|
+
return scopes;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function findBinding(scope, name) {
|
|
157
|
+
for (; scope; scope = scope.parent) {
|
|
158
|
+
if (scope.bindings.has(name)) return scope.bindings.get(name);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function isFineDesignNamespace(node, scope) {
|
|
163
|
+
if (!node) return false;
|
|
164
|
+
if (node.type === 'Identifier' || node.type === 'JSXIdentifier') {
|
|
165
|
+
const binding = findBinding(scope, node.name);
|
|
166
|
+
return Boolean(binding?.namespace || (node.name === 'FineDesign' && binding === undefined));
|
|
167
|
+
}
|
|
168
|
+
return ['MemberExpression', 'JSXMemberExpression'].includes(node.type) && !node.computed &&
|
|
169
|
+
node.object.name === 'window' && node.property.name === 'FineDesign' && findBinding(scope, 'window') === undefined;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// shortcut: resolve direct imports/destructuring only; add data-flow analysis if reassigned aliases need checking.
|
|
173
|
+
function componentName(node, scope) {
|
|
174
|
+
if (node.type === 'JSXIdentifier') {
|
|
175
|
+
const binding = findBinding(scope, node.name);
|
|
176
|
+
if (binding?.component && (!Object.hasOwn(binding, 'source') || isFineDesignNamespace(binding.source, binding.scope))) return binding.component;
|
|
177
|
+
} else if (node.type === 'JSXMemberExpression' && isFineDesignNamespace(node.object, scope)) {
|
|
178
|
+
return node.property.name;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function lintFiles(catalog, targets = ['.']) {
|
|
183
|
+
const files = [...new Set(targets.flatMap((t) => collectFiles(t)))];
|
|
184
|
+
const validValueExports = new Set(EXTRA_VALUE_EXPORTS);
|
|
185
|
+
const aliasToOwner = new Map();
|
|
186
|
+
for (const component of catalog.components) {
|
|
187
|
+
for (const exp of component.exports) {
|
|
188
|
+
if (!exp.includes('.')) validValueExports.add(exp);
|
|
189
|
+
}
|
|
190
|
+
if (component.id === 'svg-icon') {
|
|
191
|
+
for (const icon of component.aliases) validValueExports.add(icon);
|
|
192
|
+
} else {
|
|
193
|
+
for (const alias of component.aliases) {
|
|
194
|
+
aliasToOwner.set(alias.toLowerCase(), component);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const diagnostics = [];
|
|
200
|
+
|
|
201
|
+
for (const file of files) {
|
|
202
|
+
const content = fs.readFileSync(file, 'utf8');
|
|
203
|
+
const typescript = /\.[cm]?tsx?$/i.test(file);
|
|
204
|
+
const report = (node, rule, severity, message, suggestion) => diagnostics.push({
|
|
205
|
+
file, line: node.loc.start.line, rule, severity, message, suggestion
|
|
206
|
+
});
|
|
207
|
+
const checkExport = (name, node, allowTypes = false, typeOnly = false) => {
|
|
208
|
+
if (validValueExports.has(name) || (allowTypes && KNOWN_TYPE_EXPORTS.has(name))) return;
|
|
209
|
+
if (typeOnly && name.endsWith('Props')) return;
|
|
210
|
+
|
|
211
|
+
const owner = aliasToOwner.get(name.toLowerCase());
|
|
212
|
+
let suggestion = 'Run "fine-design list" or "fine-design search" to verify public exports.';
|
|
213
|
+
if (owner) {
|
|
214
|
+
suggestion = `"${name}" is not a root export; use "${owner.exports.join(' / ')}"${name.includes('.') ? '' : ` (or compound subcomponent on ${owner.exports[0]})`} instead.`;
|
|
215
|
+
} else if (/(?:Outlined|Filled)$/.test(name)) {
|
|
216
|
+
const similarIcons = suggestSimilarComponents(catalog, name, 3);
|
|
217
|
+
suggestion = `"${name}" is not one of the 56 built-in icons.${similarIcons.length ? ` Closest matches: ${similarIcons.join(', ')}.` : ''} Run "fine-design doc SvgIcon --section 内置图标列表" to view all valid icon names.`;
|
|
218
|
+
} else {
|
|
219
|
+
const similar = suggestSimilarComponents(catalog, name, 3);
|
|
220
|
+
if (similar.length) suggestion = `Did you mean: ${similar.join(', ')}?`;
|
|
221
|
+
}
|
|
222
|
+
report(node, 'unknown-export', 'error', `Unknown export "${name}" from @fx-ui/fine-design.`, suggestion);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
function visit(node, scopes) {
|
|
226
|
+
const scope = scopes.get(node);
|
|
227
|
+
if (node.type === 'ImportDeclaration') {
|
|
228
|
+
const source = node.source.value;
|
|
229
|
+
if (/^(?:@fx-ui\/fine-design\/(?:es|lib)\/icons|@ant-design\/icons)$/.test(source)) {
|
|
230
|
+
report(node, 'deep-or-foreign-icon-import', 'error', `Avoid importing icons from "${source}".`,
|
|
231
|
+
'Import the 56 built-in icons or SvgIcon directly from "@fx-ui/fine-design".');
|
|
232
|
+
}
|
|
233
|
+
if (source === '@fx-ui/fine-design') {
|
|
234
|
+
for (const spec of node.specifiers.filter((item) => item.type === 'ImportSpecifier')) {
|
|
235
|
+
const typeOnly = node.importKind === 'type' || spec.importKind === 'type';
|
|
236
|
+
checkExport(spec.imported.name ?? spec.imported.value, spec, typescript || typeOnly, typeOnly);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
} else if (node.type === 'VariableDeclarator' && node.id.type === 'ObjectPattern') {
|
|
240
|
+
const init = node.init;
|
|
241
|
+
if (isFineDesignNamespace(init, scope)) {
|
|
242
|
+
for (const prop of node.id.properties) {
|
|
243
|
+
if (prop.type === 'ObjectProperty' && !prop.computed) checkExport(String(prop.key.name ?? prop.key.value), prop);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
} else if (node.type === 'JSXOpeningElement') {
|
|
247
|
+
const component = componentName(node.name, scope);
|
|
248
|
+
for (const attr of node.attributes.filter((item) => item.type === 'JSXAttribute')) {
|
|
249
|
+
const name = attr.name.name;
|
|
250
|
+
const value = (attr.value?.expression || attr.value)?.value;
|
|
251
|
+
if (component === 'Button' && name === 'type' && typeof value === 'string' && !BUTTON_TYPES.has(value)) {
|
|
252
|
+
report(attr, 'invalid-button-type', 'error', `Invalid Button type="${value}".`,
|
|
253
|
+
'Use type="primary" / "secondary" / "normal" / "negative" / "link" / "text" / "text-normal" / "bare", with the boolean danger prop for destructive actions.');
|
|
254
|
+
} else if (component === 'NextTable' && name === 'columns') {
|
|
255
|
+
report(attr, 'next-table-columns-prop', 'error', 'NextTable does not accept a "columns" prop.',
|
|
256
|
+
'Declare <NextTable.Column>, <NextTable.HeaderCell>, and <NextTable.Cell dataKey="..."> children instead.');
|
|
257
|
+
} else if (component === 'Dialog' && name === 'onCloseBtnClick') {
|
|
258
|
+
report(attr, 'dialog-deprecated-close-btn', 'warning', 'Dialog "onCloseBtnClick" is deprecated and fires alongside "onCancel" when clicking the close button.',
|
|
259
|
+
'Handle close and cancel solely via "onCancel".');
|
|
260
|
+
} else if (component === 'Tag' && name === 'color') {
|
|
261
|
+
report(attr, 'tag-color-prop', 'warning', 'Tag does not support a "color" prop.',
|
|
262
|
+
'Use semantic type ("default" | "primary" | "success" | "warning" | "error") or custom style={{ color, backgroundColor }}.');
|
|
263
|
+
} else if (component === 'ConfigProvider' && name === 'prefixCls' && value === 'fd') {
|
|
264
|
+
report(attr, 'config-provider-dumi-prefix', 'warning', 'ConfigProvider has hardcoded prefixCls="fd" (used only by the Dumi doc site).',
|
|
265
|
+
'Remove prefixCls="fd" so components match the default "f-" CSS class prefix in production and UMD builds.');
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
for (const child of Object.values(node)) {
|
|
270
|
+
if (Array.isArray(child)) child.filter((item) => item?.type).forEach((item) => visit(item, scopes));
|
|
271
|
+
else if (child?.type) visit(child, scopes);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
for (const source of codeSources(file, content)) {
|
|
276
|
+
let ast;
|
|
277
|
+
try {
|
|
278
|
+
ast = parse(source.content, {
|
|
279
|
+
sourceType: 'unambiguous', startLine: source.startLine, attachComment: false,
|
|
280
|
+
plugins: [...(typescript ? [['typescript', { dts: /\.d\.[cm]?ts$/i.test(file) }]] : []),
|
|
281
|
+
...(!typescript || /tsx$/i.test(file) ? ['jsx'] : [])]
|
|
282
|
+
});
|
|
283
|
+
} catch (error) {
|
|
284
|
+
if (!(error instanceof SyntaxError)) throw error;
|
|
285
|
+
report({ loc: { start: error.loc } }, 'parse-error', 'error', error.message, 'Fix the syntax error before checking Fine Design APIs.');
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
visit(ast.program, collectScopes(ast.program));
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const errorCount = diagnostics.filter((d) => d.severity === 'error').length;
|
|
293
|
+
const warningCount = diagnostics.filter((d) => d.severity === 'warning').length;
|
|
294
|
+
return {
|
|
295
|
+
version: catalog.version,
|
|
296
|
+
scannedFiles: files.length,
|
|
297
|
+
errorCount,
|
|
298
|
+
warningCount,
|
|
299
|
+
passed: errorCount === 0,
|
|
300
|
+
diagnostics
|
|
301
|
+
};
|
|
302
|
+
}
|