@nordcraft/search 1.0.43 → 1.0.45
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/dist/problems.worker.js +4 -2
- package/dist/problems.worker.js.map +1 -1
- package/dist/rules/actions/legacyActionRule.fix.js +140 -0
- package/dist/rules/actions/legacyActionRule.fix.js.map +1 -0
- package/dist/rules/actions/legacyActionRule.js +3 -144
- package/dist/rules/actions/legacyActionRule.js.map +1 -1
- package/dist/rules/actions/legacyActionRule.test.js +4 -3
- package/dist/rules/actions/legacyActionRule.test.js.map +1 -1
- package/dist/rules/actions/noReferenceProjectActionRule.js +33 -40
- package/dist/rules/actions/noReferenceProjectActionRule.js.map +1 -1
- package/dist/rules/apis/noReferenceApiRule.js +7 -2
- package/dist/rules/apis/noReferenceApiRule.js.map +1 -1
- package/dist/rules/apis/noReferenceApiRule.test.js +65 -1
- package/dist/rules/apis/noReferenceApiRule.test.js.map +1 -1
- package/dist/rules/attributes/noReferenceAttributeRule.js +5 -1
- package/dist/rules/attributes/noReferenceAttributeRule.js.map +1 -1
- package/dist/rules/attributes/noReferenceAttributeRule.test.js +33 -1
- package/dist/rules/attributes/noReferenceAttributeRule.test.js.map +1 -1
- package/dist/rules/components/noReferenceComponentRule.js +18 -28
- package/dist/rules/components/noReferenceComponentRule.js.map +1 -1
- package/dist/rules/events/duplicateEventTriggerRule.js +2 -1
- package/dist/rules/events/duplicateEventTriggerRule.js.map +1 -1
- package/dist/rules/events/noReferenceEventRule.js +6 -2
- package/dist/rules/events/noReferenceEventRule.js.map +1 -1
- package/dist/rules/events/noReferenceEventRule.test.js +57 -1
- package/dist/rules/events/noReferenceEventRule.test.js.map +1 -1
- package/dist/rules/formulas/legacyFormulaRule.fix.js +574 -0
- package/dist/rules/formulas/legacyFormulaRule.fix.js.map +1 -0
- package/dist/rules/formulas/legacyFormulaRule.js +5 -580
- package/dist/rules/formulas/legacyFormulaRule.js.map +1 -1
- package/dist/rules/formulas/noReferenceComponentFormulaRule.js +8 -1
- package/dist/rules/formulas/noReferenceComponentFormulaRule.js.map +1 -1
- package/dist/rules/formulas/noReferenceProjectFormulaRule.js +63 -72
- package/dist/rules/formulas/noReferenceProjectFormulaRule.js.map +1 -1
- package/dist/rules/noReferenceNodeRule.js +22 -0
- package/dist/rules/noReferenceNodeRule.js.map +1 -0
- package/dist/rules/noReferenceNodeRule.test.js +131 -0
- package/dist/rules/noReferenceNodeRule.test.js.map +1 -0
- package/dist/rules/style/invalidStyleSyntaxRule.js +28 -0
- package/dist/rules/style/invalidStyleSyntaxRule.js.map +1 -0
- package/dist/rules/style/invalidStyleSyntaxRule.test.js +100 -0
- package/dist/rules/style/invalidStyleSyntaxRule.test.js.map +1 -0
- package/dist/searchProject.js +57 -16
- package/dist/searchProject.js.map +1 -1
- package/dist/util/removeUnused.fix.js +3 -0
- package/dist/util/removeUnused.fix.js.map +1 -0
- package/package.json +4 -3
- package/src/problems.worker.ts +4 -2
- package/src/rules/actions/legacyActionRule.fix.ts +157 -0
- package/src/rules/actions/legacyActionRule.test.ts +4 -3
- package/src/rules/actions/legacyActionRule.ts +3 -159
- package/src/rules/actions/noReferenceProjectActionRule.ts +39 -47
- package/src/rules/apis/noReferenceApiRule.test.ts +67 -1
- package/src/rules/apis/noReferenceApiRule.ts +9 -2
- package/src/rules/attributes/noReferenceAttributeRule.test.ts +35 -1
- package/src/rules/attributes/noReferenceAttributeRule.ts +7 -2
- package/src/rules/components/noReferenceComponentRule.ts +23 -34
- package/src/rules/events/duplicateEventTriggerRule.ts +2 -1
- package/src/rules/events/noReferenceEventRule.test.ts +59 -1
- package/src/rules/events/noReferenceEventRule.ts +8 -3
- package/src/rules/formulas/legacyFormulaRule.fix.ts +661 -0
- package/src/rules/formulas/legacyFormulaRule.ts +9 -670
- package/src/rules/formulas/noReferenceComponentFormulaRule.ts +15 -3
- package/src/rules/formulas/noReferenceProjectFormulaRule.ts +70 -77
- package/src/rules/noReferenceNodeRule.test.ts +140 -0
- package/src/rules/noReferenceNodeRule.ts +27 -0
- package/src/rules/style/invalidStyleSyntaxRule.test.ts +106 -0
- package/src/rules/style/invalidStyleSyntaxRule.ts +35 -0
- package/src/searchProject.ts +66 -22
- package/src/types.d.ts +33 -10
- package/src/util/removeUnused.fix.ts +5 -0
- package/dist/memos/getAllCustomPropertiesBySyntax.js +0 -43
- package/dist/memos/getAllCustomPropertiesBySyntax.js.map +0 -1
- package/dist/rules/style-variables/ambiguousStyleVariableSyntaxRule.js +0 -50
- package/dist/rules/style-variables/ambiguousStyleVariableSyntaxRule.js.map +0 -1
- package/dist/rules/style-variables/ambiguousStyleVariableSyntaxRule.test.js +0 -265
- package/dist/rules/style-variables/ambiguousStyleVariableSyntaxRule.test.js.map +0 -1
- package/src/memos/getAllCustomPropertiesBySyntax.ts +0 -68
- package/src/rules/style-variables/ambiguousStyleVariableSyntaxRule.test.ts +0 -278
- package/src/rules/style-variables/ambiguousStyleVariableSyntaxRule.ts +0 -65
package/src/types.d.ts
CHANGED
|
@@ -14,21 +14,26 @@ import type { ToddleComponent } from '@nordcraft/core/dist/component/ToddleCompo
|
|
|
14
14
|
import type { Formula } from '@nordcraft/core/dist/formula/formula'
|
|
15
15
|
import type { PluginFormula } from '@nordcraft/core/dist/formula/formulaTypes'
|
|
16
16
|
import type { Theme } from '@nordcraft/core/dist/styling/theme'
|
|
17
|
+
import type { PluginAction } from '@nordcraft/core/dist/types'
|
|
17
18
|
import type {
|
|
18
19
|
ApiService,
|
|
19
|
-
PluginAction,
|
|
20
20
|
ProjectFiles,
|
|
21
21
|
Route,
|
|
22
22
|
ToddleProject,
|
|
23
23
|
} from '@nordcraft/ssr/dist/ssr.types'
|
|
24
24
|
import type { LegacyActionRuleFix } from './rules/actions/legacyActionRule'
|
|
25
25
|
import type { NoReferenceProjectActionRuleFix } from './rules/actions/noReferenceProjectActionRule'
|
|
26
|
+
import type { NoReferenceApiRuleFix } from './rules/apis/noReferenceApiRule'
|
|
27
|
+
import type { NoReferenceAttributeRuleFix } from './rules/attributes/noReferenceAttributeRule'
|
|
26
28
|
import type { NoReferenceComponentRuleFix } from './rules/components/noReferenceComponentRule'
|
|
29
|
+
import type { NoReferenceEventRuleFix } from './rules/events/noReferenceEventRule'
|
|
27
30
|
import type { LegacyFormulaRuleFix } from './rules/formulas/legacyFormulaRule'
|
|
31
|
+
import type { NoReferenceComponentFormulaRuleFix } from './rules/formulas/noReferenceComponentFormulaRule'
|
|
28
32
|
import type { NoReferenceProjectFormulaRuleFix } from './rules/formulas/noReferenceProjectFormulaRule'
|
|
33
|
+
import type { NoReferenceNodeRuleFix } from './rules/noReferenceNodeRule'
|
|
34
|
+
import type { InvalidStyleSyntaxRuleFix } from './rules/style/invalidStyleSyntaxRule'
|
|
29
35
|
|
|
30
36
|
type Code =
|
|
31
|
-
| 'ambiguous style variable syntax'
|
|
32
37
|
| 'duplicate event trigger'
|
|
33
38
|
| 'duplicate url parameter'
|
|
34
39
|
| 'duplicate workflow parameter'
|
|
@@ -36,6 +41,7 @@ type Code =
|
|
|
36
41
|
| 'invalid api parser mode'
|
|
37
42
|
| 'invalid api proxy body setting'
|
|
38
43
|
| 'invalid element child'
|
|
44
|
+
| 'invalid style syntax'
|
|
39
45
|
| 'legacy action'
|
|
40
46
|
| 'legacy api'
|
|
41
47
|
| 'legacy formula'
|
|
@@ -49,6 +55,7 @@ type Code =
|
|
|
49
55
|
| 'no-reference component workflow'
|
|
50
56
|
| 'no-reference component'
|
|
51
57
|
| 'no-reference event'
|
|
58
|
+
| 'no-reference node'
|
|
52
59
|
| 'no-reference project action'
|
|
53
60
|
| 'no-reference project formula'
|
|
54
61
|
| 'no-reference variable'
|
|
@@ -251,9 +258,9 @@ type FormulaNode<F = Formula> = {
|
|
|
251
258
|
component?: ToddleComponent<Function>
|
|
252
259
|
} & Base
|
|
253
260
|
|
|
254
|
-
type ActionModelNode = {
|
|
261
|
+
type ActionModelNode<A = ActionModel> = {
|
|
255
262
|
nodeType: 'action-model'
|
|
256
|
-
value:
|
|
263
|
+
value: A
|
|
257
264
|
component: ToddleComponent<Function>
|
|
258
265
|
} & Base
|
|
259
266
|
|
|
@@ -293,6 +300,15 @@ type StyleVariantNode = {
|
|
|
293
300
|
value: { variant: StyleVariant; element: ElementNodeModel }
|
|
294
301
|
} & Base
|
|
295
302
|
|
|
303
|
+
type StyleNode = {
|
|
304
|
+
nodeType: 'style-declaration'
|
|
305
|
+
value: {
|
|
306
|
+
styleProperty: string
|
|
307
|
+
styleValue: string
|
|
308
|
+
element: ElementNodeModel
|
|
309
|
+
}
|
|
310
|
+
} & Base
|
|
311
|
+
|
|
296
312
|
export type NodeType =
|
|
297
313
|
| ActionModelNode
|
|
298
314
|
| ComponentAPIInputNode
|
|
@@ -312,6 +328,7 @@ export type NodeType =
|
|
|
312
328
|
| ProjectFormulaNode
|
|
313
329
|
| ProjectThemeNode
|
|
314
330
|
| ProjectRoute
|
|
331
|
+
| StyleNode
|
|
315
332
|
| StyleVariantNode
|
|
316
333
|
|
|
317
334
|
type FixType =
|
|
@@ -320,6 +337,12 @@ type FixType =
|
|
|
320
337
|
| NoReferenceComponentRuleFix
|
|
321
338
|
| NoReferenceProjectFormulaRuleFix
|
|
322
339
|
| NoReferenceProjectActionRuleFix
|
|
340
|
+
| NoReferenceApiRuleFix
|
|
341
|
+
| NoReferenceAttributeRuleFix
|
|
342
|
+
| NoReferenceEventRuleFix
|
|
343
|
+
| NoReferenceComponentFormulaRuleFix
|
|
344
|
+
| NoReferenceNodeRuleFix
|
|
345
|
+
| InvalidStyleSyntaxRuleFix
|
|
323
346
|
|
|
324
347
|
export interface Rule<T = unknown, V = NodeType> {
|
|
325
348
|
category: Category
|
|
@@ -330,10 +353,10 @@ export interface Rule<T = unknown, V = NodeType> {
|
|
|
330
353
|
data: V,
|
|
331
354
|
state?: ApplicationState | undefined,
|
|
332
355
|
) => void
|
|
333
|
-
fixes?: Partial<
|
|
334
|
-
Record<
|
|
335
|
-
FixType,
|
|
336
|
-
(data: V, state?: ApplicationState | undefined) => ProjectFiles | void
|
|
337
|
-
>
|
|
338
|
-
>
|
|
356
|
+
fixes?: Partial<Record<FixType, FixFunction>>
|
|
339
357
|
}
|
|
358
|
+
|
|
359
|
+
export type FixFunction<T extends NodeType> = (
|
|
360
|
+
data: T,
|
|
361
|
+
state?: ApplicationState,
|
|
362
|
+
) => ProjectFiles | void
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export const getAllCustomPropertiesBySyntax = (memo, { files, }) => memo('allCustomPropertiesBySyntax', () => {
|
|
2
|
-
const store = {};
|
|
3
|
-
const add = (propName, syntax, fullPath) => {
|
|
4
|
-
if (syntax.type !== 'primitive')
|
|
5
|
-
return;
|
|
6
|
-
const sName = syntax.name;
|
|
7
|
-
store[propName] ??= {};
|
|
8
|
-
store[propName][sName] ??= [];
|
|
9
|
-
store[propName][sName].push({ syntax, path: fullPath });
|
|
10
|
-
};
|
|
11
|
-
for (const [componentKey, component] of Object.entries(files.components)) {
|
|
12
|
-
for (const [nodeKey, node] of Object.entries(component?.nodes ?? {})) {
|
|
13
|
-
if (node.type !== 'element' && node.type !== 'component')
|
|
14
|
-
continue;
|
|
15
|
-
for (const [propName, prop] of Object.entries(node.customProperties ?? {})) {
|
|
16
|
-
add(propName, prop.syntax, [
|
|
17
|
-
'components',
|
|
18
|
-
componentKey,
|
|
19
|
-
'nodes',
|
|
20
|
-
nodeKey,
|
|
21
|
-
'customProperties',
|
|
22
|
-
propName,
|
|
23
|
-
]);
|
|
24
|
-
}
|
|
25
|
-
node.variants?.forEach((variant, variantIndex) => {
|
|
26
|
-
for (const [propName, prop] of Object.entries(variant.customProperties ?? {})) {
|
|
27
|
-
add(propName, prop.syntax, [
|
|
28
|
-
'components',
|
|
29
|
-
componentKey,
|
|
30
|
-
'nodes',
|
|
31
|
-
nodeKey,
|
|
32
|
-
'variants',
|
|
33
|
-
String(variantIndex),
|
|
34
|
-
'customProperties',
|
|
35
|
-
propName,
|
|
36
|
-
]);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return store;
|
|
42
|
-
});
|
|
43
|
-
//# sourceMappingURL=getAllCustomPropertiesBySyntax.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAllCustomPropertiesBySyntax.js","sourceRoot":"","sources":["../../src/memos/getAllCustomPropertiesBySyntax.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,IAAY,EACZ,EACE,KAAK,GAGN,EACD,EAAE,CACF,IAAI,CAAC,6BAA6B,EAAE,GAAG,EAAE;IACvC,MAAM,KAAK,GAGP,EAAE,CAAA;IAEN,MAAM,GAAG,GAAG,CACV,QAAgB,EAChB,MAAqB,EACrB,QAAkB,EAClB,EAAE;QACF,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW;YAAE,OAAM;QACvC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAA;QACzB,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;QACtB,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QAC7B,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IACzD,CAAC,CAAA;IAED,KAAK,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QACzE,KAAK,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;YACrE,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW;gBAAE,SAAQ;YAElE,KAAK,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAC3C,IAAI,CAAC,gBAAgB,IAAI,EAAE,CAC5B,EAAE,CAAC;gBACF,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE;oBACzB,YAAY;oBACZ,YAAY;oBACZ,OAAO;oBACP,OAAO;oBACP,kBAAkB;oBAClB,QAAQ;iBACT,CAAC,CAAA;YACJ,CAAC;YAED,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE;gBAC/C,KAAK,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAC3C,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAC/B,EAAE,CAAC;oBACF,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE;wBACzB,YAAY;wBACZ,YAAY;wBACZ,OAAO;wBACP,OAAO;wBACP,UAAU;wBACV,MAAM,CAAC,YAAY,CAAC;wBACpB,kBAAkB;wBAClB,QAAQ;qBACT,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAC,CAAA"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { getAllCustomPropertiesBySyntax } from '../../memos/getAllCustomPropertiesBySyntax';
|
|
2
|
-
export const ambiguousStyleVariableSyntaxRule = {
|
|
3
|
-
code: 'ambiguous style variable syntax',
|
|
4
|
-
level: 'error',
|
|
5
|
-
category: 'Other',
|
|
6
|
-
visit: (report, args) => {
|
|
7
|
-
const { nodeType, value, files, memo, path } = args;
|
|
8
|
-
if (nodeType !== 'component-node')
|
|
9
|
-
return;
|
|
10
|
-
if (value.type !== 'element' && value.type !== 'component')
|
|
11
|
-
return;
|
|
12
|
-
const check = (propName, syntax, basePath) => {
|
|
13
|
-
if (syntax.type !== 'primitive')
|
|
14
|
-
return;
|
|
15
|
-
const allCustomPropertiesBySyntax = getAllCustomPropertiesBySyntax(memo, {
|
|
16
|
-
files,
|
|
17
|
-
})[propName];
|
|
18
|
-
const conflicts = Object.entries(allCustomPropertiesBySyntax)
|
|
19
|
-
.filter(([name]) => name !== syntax.name)
|
|
20
|
-
.flatMap(([, entries]) => entries);
|
|
21
|
-
if (conflicts.length > 0) {
|
|
22
|
-
report(basePath, {
|
|
23
|
-
name: propName,
|
|
24
|
-
duplicates: conflicts,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
for (const [propName, prop] of Object.entries(value.customProperties ?? {})) {
|
|
29
|
-
check(propName, prop.syntax, [
|
|
30
|
-
...path,
|
|
31
|
-
'customProperties',
|
|
32
|
-
propName,
|
|
33
|
-
'name',
|
|
34
|
-
]);
|
|
35
|
-
}
|
|
36
|
-
value.variants?.forEach((variant, variantIndex) => {
|
|
37
|
-
for (const [propName, prop] of Object.entries(variant.customProperties ?? {})) {
|
|
38
|
-
check(propName, prop.syntax, [
|
|
39
|
-
...path,
|
|
40
|
-
'variants',
|
|
41
|
-
String(variantIndex),
|
|
42
|
-
'customProperties',
|
|
43
|
-
propName,
|
|
44
|
-
'name',
|
|
45
|
-
]);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=ambiguousStyleVariableSyntaxRule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ambiguousStyleVariableSyntaxRule.js","sourceRoot":"","sources":["../../../src/rules/style-variables/ambiguousStyleVariableSyntaxRule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAA;AAG3F,MAAM,CAAC,MAAM,gCAAgC,GAGxC;IACH,IAAI,EAAE,iCAAiC;IACvC,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,OAAO;IACjB,KAAK,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EA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EAAE,YAAY,EAAE,EAAE;YAChD,KAAK,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAC3C,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAC/B,EAAE,CAAC;gBACF,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE;oBAC3B,GAAG,IAAI;oBACP,UAAU;oBACV,MAAM,CAAC,YAAY,CAAC;oBACpB,kBAAkB;oBAClB,QAAQ;oBACR,MAAM;iBACP,CAAC,CAAA;YACJ,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
import { searchProject } from '../../searchProject';
|
|
3
|
-
import { ambiguousStyleVariableSyntaxRule } from './ambiguousStyleVariableSyntaxRule';
|
|
4
|
-
describe('ambiguousStyleVariableSyntaxRule', () => {
|
|
5
|
-
test('should report when there are style variables with the same name but different syntax', () => {
|
|
6
|
-
const problems = Array.from(searchProject({
|
|
7
|
-
files: {
|
|
8
|
-
components: {
|
|
9
|
-
component1: {
|
|
10
|
-
name: 'component1',
|
|
11
|
-
nodes: {
|
|
12
|
-
node1: {
|
|
13
|
-
type: 'element',
|
|
14
|
-
customProperties: {
|
|
15
|
-
'--my-variable': {
|
|
16
|
-
syntax: { type: 'primitive', name: 'length' },
|
|
17
|
-
formula: { type: 'value', value: '10px' },
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
attrs: {},
|
|
21
|
-
style: {},
|
|
22
|
-
children: [],
|
|
23
|
-
events: {},
|
|
24
|
-
classes: {},
|
|
25
|
-
tag: 'div',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
apis: {},
|
|
29
|
-
attributes: {},
|
|
30
|
-
variables: {},
|
|
31
|
-
formulas: {},
|
|
32
|
-
},
|
|
33
|
-
component2: {
|
|
34
|
-
name: 'component2',
|
|
35
|
-
nodes: {
|
|
36
|
-
node2: {
|
|
37
|
-
type: 'element',
|
|
38
|
-
customProperties: {
|
|
39
|
-
'--my-variable': {
|
|
40
|
-
syntax: { type: 'primitive', name: 'color' },
|
|
41
|
-
formula: { type: 'value', value: '#ff0000' },
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
attrs: {},
|
|
45
|
-
style: {},
|
|
46
|
-
children: [],
|
|
47
|
-
events: {},
|
|
48
|
-
classes: {},
|
|
49
|
-
tag: 'div',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
apis: {},
|
|
53
|
-
attributes: {},
|
|
54
|
-
variables: {},
|
|
55
|
-
formulas: {},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
rules: [ambiguousStyleVariableSyntaxRule],
|
|
60
|
-
}));
|
|
61
|
-
expect(problems).toHaveLength(2);
|
|
62
|
-
expect(problems[0].code).toBe('ambiguous style variable syntax');
|
|
63
|
-
expect(problems[1].code).toBe('ambiguous style variable syntax');
|
|
64
|
-
expect(problems[0].details.name).toBe('--my-variable');
|
|
65
|
-
expect(problems[1].details.name).toBe('--my-variable');
|
|
66
|
-
expect(problems[0].details.duplicates).toEqual([
|
|
67
|
-
{
|
|
68
|
-
path: [
|
|
69
|
-
'components',
|
|
70
|
-
'component2',
|
|
71
|
-
'nodes',
|
|
72
|
-
'node2',
|
|
73
|
-
'customProperties',
|
|
74
|
-
'--my-variable',
|
|
75
|
-
],
|
|
76
|
-
syntax: { type: 'primitive', name: 'color' },
|
|
77
|
-
},
|
|
78
|
-
]);
|
|
79
|
-
expect(problems[1].details.duplicates).toEqual([
|
|
80
|
-
{
|
|
81
|
-
path: [
|
|
82
|
-
'components',
|
|
83
|
-
'component1',
|
|
84
|
-
'nodes',
|
|
85
|
-
'node1',
|
|
86
|
-
'customProperties',
|
|
87
|
-
'--my-variable',
|
|
88
|
-
],
|
|
89
|
-
syntax: { type: 'primitive', name: 'length' },
|
|
90
|
-
},
|
|
91
|
-
]);
|
|
92
|
-
});
|
|
93
|
-
test('should not report when style variables have same name and same syntax', () => {
|
|
94
|
-
const problems = Array.from(searchProject({
|
|
95
|
-
files: {
|
|
96
|
-
components: {
|
|
97
|
-
component1: {
|
|
98
|
-
name: 'component1',
|
|
99
|
-
nodes: {
|
|
100
|
-
node1: {
|
|
101
|
-
type: 'element',
|
|
102
|
-
customProperties: {
|
|
103
|
-
'--my-variable': {
|
|
104
|
-
syntax: { type: 'primitive', name: 'length' },
|
|
105
|
-
formula: { type: 'value', value: '10px' },
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
attrs: {},
|
|
109
|
-
style: {},
|
|
110
|
-
children: [],
|
|
111
|
-
events: {},
|
|
112
|
-
classes: {},
|
|
113
|
-
tag: 'div',
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
apis: {},
|
|
117
|
-
attributes: {},
|
|
118
|
-
variables: {},
|
|
119
|
-
formulas: {},
|
|
120
|
-
},
|
|
121
|
-
component2: {
|
|
122
|
-
name: 'component2',
|
|
123
|
-
nodes: {
|
|
124
|
-
node2: {
|
|
125
|
-
type: 'element',
|
|
126
|
-
customProperties: {
|
|
127
|
-
'--my-variable': {
|
|
128
|
-
syntax: { type: 'primitive', name: 'length' },
|
|
129
|
-
formula: { type: 'value', value: '20px' },
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
attrs: {},
|
|
133
|
-
style: {},
|
|
134
|
-
children: [],
|
|
135
|
-
events: {},
|
|
136
|
-
classes: {},
|
|
137
|
-
tag: 'div',
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
apis: {},
|
|
141
|
-
attributes: {},
|
|
142
|
-
variables: {},
|
|
143
|
-
formulas: {},
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
rules: [ambiguousStyleVariableSyntaxRule],
|
|
148
|
-
}));
|
|
149
|
-
expect(problems).toHaveLength(0);
|
|
150
|
-
});
|
|
151
|
-
test('should handle variant customProperties too', () => {
|
|
152
|
-
const problems = Array.from(searchProject({
|
|
153
|
-
files: {
|
|
154
|
-
components: {
|
|
155
|
-
component1: {
|
|
156
|
-
name: 'component1',
|
|
157
|
-
nodes: {
|
|
158
|
-
node1: {
|
|
159
|
-
type: 'element',
|
|
160
|
-
customProperties: {
|
|
161
|
-
'--my-variable': {
|
|
162
|
-
syntax: { type: 'primitive', name: 'length' },
|
|
163
|
-
formula: { type: 'value', value: '10px' },
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
variants: [
|
|
167
|
-
{
|
|
168
|
-
breakpoint: 'medium',
|
|
169
|
-
style: {},
|
|
170
|
-
customProperties: {
|
|
171
|
-
'--my-variable': {
|
|
172
|
-
syntax: { type: 'primitive', name: 'color' },
|
|
173
|
-
formula: { type: 'value', value: '#ff0000' },
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
],
|
|
178
|
-
attrs: {},
|
|
179
|
-
style: {},
|
|
180
|
-
children: [],
|
|
181
|
-
events: {},
|
|
182
|
-
classes: {},
|
|
183
|
-
tag: 'div',
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
apis: {},
|
|
187
|
-
attributes: {},
|
|
188
|
-
variables: {},
|
|
189
|
-
formulas: {},
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
rules: [ambiguousStyleVariableSyntaxRule],
|
|
194
|
-
}));
|
|
195
|
-
// Should flag both the base and the variant for conflicting syntax
|
|
196
|
-
expect(problems).toHaveLength(2);
|
|
197
|
-
expect(problems.map((p) => p.details.name)).toEqual([
|
|
198
|
-
'--my-variable',
|
|
199
|
-
'--my-variable',
|
|
200
|
-
]);
|
|
201
|
-
});
|
|
202
|
-
test('should ignore non-primitive syntax', () => {
|
|
203
|
-
const problems = Array.from(searchProject({
|
|
204
|
-
files: {
|
|
205
|
-
components: {
|
|
206
|
-
component1: {
|
|
207
|
-
name: 'component1',
|
|
208
|
-
nodes: {
|
|
209
|
-
node1: {
|
|
210
|
-
type: 'element',
|
|
211
|
-
customProperties: {
|
|
212
|
-
'--my-variable': {
|
|
213
|
-
syntax: {
|
|
214
|
-
type: 'keyword',
|
|
215
|
-
keywords: ['auto', 'inherit'],
|
|
216
|
-
},
|
|
217
|
-
formula: { type: 'value', value: '10px' },
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
attrs: {},
|
|
221
|
-
style: {},
|
|
222
|
-
children: [],
|
|
223
|
-
events: {},
|
|
224
|
-
classes: {},
|
|
225
|
-
tag: 'div',
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
apis: {},
|
|
229
|
-
attributes: {},
|
|
230
|
-
variables: {},
|
|
231
|
-
formulas: {},
|
|
232
|
-
},
|
|
233
|
-
component2: {
|
|
234
|
-
name: 'component2',
|
|
235
|
-
nodes: {
|
|
236
|
-
node2: {
|
|
237
|
-
type: 'element',
|
|
238
|
-
customProperties: {
|
|
239
|
-
'--my-variable': {
|
|
240
|
-
syntax: { type: 'primitive', name: 'color' },
|
|
241
|
-
formula: { type: 'value', value: '#ff0000' },
|
|
242
|
-
},
|
|
243
|
-
},
|
|
244
|
-
attrs: {},
|
|
245
|
-
style: {},
|
|
246
|
-
children: [],
|
|
247
|
-
events: {},
|
|
248
|
-
classes: {},
|
|
249
|
-
tag: 'div',
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
apis: {},
|
|
253
|
-
attributes: {},
|
|
254
|
-
variables: {},
|
|
255
|
-
formulas: {},
|
|
256
|
-
},
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
rules: [ambiguousStyleVariableSyntaxRule],
|
|
260
|
-
}));
|
|
261
|
-
// Should not report because non-primitive should be skipped
|
|
262
|
-
expect(problems).toHaveLength(0);
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
//# sourceMappingURL=ambiguousStyleVariableSyntaxRule.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ambiguousStyleVariableSyntaxRule.test.js","sourceRoot":"","sources":["../../../src/rules/style-variables/ambiguousStyleVariableSyntaxRule.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAA;AAErF,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAChD,IAAI,CAAC,sFAAsF,EAAE,GAAG,EAAE;QAChG,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CACzB,aAAa,CAAC;YACZ,KAAK,EAAE;gBACL,UAAU,EAAE;oBACV,UAAU,EAAE;wBACV,IAAI,EAAE,YAAY;wBAClB,KAAK,EAAE;4BACL,KAAK,EAAE;gCACL,IAAI,EAAE,SAAS;gCACf,gBAAgB,EAAE;oCAChB,eAAe,EAAE;wCACf,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;wCAC7C,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE;qCAC1C;iCACF;gCACD,KAAK,EAAE,EAAE;gCACT,KAAK,EAAE,EAAE;gCACT,QAAQ,EAAE,EAAE;gCACZ,MAAM,EAAE,EAAE;gCACV,OAAO,EAAE,EAAE;gCACX,GAAG,EAAE,KAAK;6BACX;yBACF;wBACD,IAAI,EAAE,EAAE;wBACR,UAAU,EAAE,EAAE;wBACd,SAAS,EAAE,EAAE;wBACb,QAAQ,EAAE,EAAE;qBACb;oBACD,UAAU,EAAE;wBACV,IAAI,EAAE,YAAY;wBAClB,KAAK,EAAE;4BACL,KAAK,EAAE;gCACL,IAAI,EAAE,SAAS;gCACf,gBAAgB,EAAE;oCAChB,eAAe,EAAE;wCACf,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,E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OAAO,EAAE,EAAE;gCACX,GAAG,EAAE,KAAK;6BACX;yBACF;wBACD,IAAI,EAAE,EAAE;wBACR,UAAU,EAAE,EAAE;wBACd,SAAS,EAAE,EAAE;wBACb,QAAQ,EAAE,EAAE;qBACb;oBACD,UAAU,EAAE;wBACV,IAAI,EAAE,YAAY;wBAClB,KAAK,EAAE;4BACL,KAAK,EAAE;gCACL,IAAI,EAAE,SAAS;gCACf,gBAAgB,EAAE;oCAChB,eAAe,EAAE;wCACf,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE;wCAC5C,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE;qCAC7C;iCACF;gCACD,KAAK,EAAE,EAAE;gCACT,KAAK,EAAE,EAAE;gCACT,QAAQ,EAAE,EAAE;gCACZ,MAAM,EAAE,EAAE;gCACV,OAAO,EAAE,EAAE;gCACX,GAAG,EAAE,KAAK;6BACX;yBACF;wBACD,IAAI,EAAE,EAAE;wBACR,UAAU,EAAE,EAAE;wBACd,SAAS,EAAE,EAAE;wBACb,QAAQ,EAAE,EAAE;qBACb;iBACF;aACF;YACD,KAAK,EAAE,CAAC,gCAAgC,CAAC;SAC1C,CAAC,CACH,CAAA;QAED,4DAA4D;QAC5D,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { CssSyntaxNode } from '@nordcraft/core/dist/styling/customProperty'
|
|
2
|
-
import type { ProjectFiles } from '@nordcraft/ssr/dist/ssr.types'
|
|
3
|
-
import type { MemoFn } from '../types'
|
|
4
|
-
|
|
5
|
-
export const getAllCustomPropertiesBySyntax = (
|
|
6
|
-
memo: MemoFn,
|
|
7
|
-
{
|
|
8
|
-
files,
|
|
9
|
-
}: {
|
|
10
|
-
files: Omit<ProjectFiles, 'config'> & Partial<Pick<ProjectFiles, 'config'>>
|
|
11
|
-
},
|
|
12
|
-
) =>
|
|
13
|
-
memo('allCustomPropertiesBySyntax', () => {
|
|
14
|
-
const store: Record<
|
|
15
|
-
string,
|
|
16
|
-
Record<string, Array<{ syntax: CssSyntaxNode; path: string[] }>>
|
|
17
|
-
> = {}
|
|
18
|
-
|
|
19
|
-
const add = (
|
|
20
|
-
propName: string,
|
|
21
|
-
syntax: CssSyntaxNode,
|
|
22
|
-
fullPath: string[],
|
|
23
|
-
) => {
|
|
24
|
-
if (syntax.type !== 'primitive') return
|
|
25
|
-
const sName = syntax.name
|
|
26
|
-
store[propName] ??= {}
|
|
27
|
-
store[propName][sName] ??= []
|
|
28
|
-
store[propName][sName].push({ syntax, path: fullPath })
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
for (const [componentKey, component] of Object.entries(files.components)) {
|
|
32
|
-
for (const [nodeKey, node] of Object.entries(component?.nodes ?? {})) {
|
|
33
|
-
if (node.type !== 'element' && node.type !== 'component') continue
|
|
34
|
-
|
|
35
|
-
for (const [propName, prop] of Object.entries(
|
|
36
|
-
node.customProperties ?? {},
|
|
37
|
-
)) {
|
|
38
|
-
add(propName, prop.syntax, [
|
|
39
|
-
'components',
|
|
40
|
-
componentKey,
|
|
41
|
-
'nodes',
|
|
42
|
-
nodeKey,
|
|
43
|
-
'customProperties',
|
|
44
|
-
propName,
|
|
45
|
-
])
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
node.variants?.forEach((variant, variantIndex) => {
|
|
49
|
-
for (const [propName, prop] of Object.entries(
|
|
50
|
-
variant.customProperties ?? {},
|
|
51
|
-
)) {
|
|
52
|
-
add(propName, prop.syntax, [
|
|
53
|
-
'components',
|
|
54
|
-
componentKey,
|
|
55
|
-
'nodes',
|
|
56
|
-
nodeKey,
|
|
57
|
-
'variants',
|
|
58
|
-
String(variantIndex),
|
|
59
|
-
'customProperties',
|
|
60
|
-
propName,
|
|
61
|
-
])
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return store
|
|
68
|
-
})
|