@nordcraft/search 1.0.61 → 1.0.63
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/rules/issues/actions/actionRules.index.js +2 -0
- package/dist/rules/issues/actions/actionRules.index.js.map +1 -1
- package/dist/rules/issues/actions/duplicateActionArgumentNameRule.js +18 -0
- package/dist/rules/issues/actions/duplicateActionArgumentNameRule.js.map +1 -0
- package/dist/rules/issues/actions/duplicateActionArgumentNameRule.test.js +131 -0
- package/dist/rules/issues/actions/duplicateActionArgumentNameRule.test.js.map +1 -0
- package/dist/rules/issues/formulas/duplicateFormulaArgumentNameRule.js +18 -0
- package/dist/rules/issues/formulas/duplicateFormulaArgumentNameRule.js.map +1 -0
- package/dist/rules/issues/formulas/duplicateFormulaArgumentNameRule.test.js +163 -0
- package/dist/rules/issues/formulas/duplicateFormulaArgumentNameRule.test.js.map +1 -0
- package/dist/rules/issues/formulas/formulaRules.index.js +2 -0
- package/dist/rules/issues/formulas/formulaRules.index.js.map +1 -1
- package/dist/rules/issues/formulas/unknownRepeatIndexFormulaRule.js +5 -4
- package/dist/rules/issues/formulas/unknownRepeatIndexFormulaRule.js.map +1 -1
- package/dist/rules/issues/formulas/unknownRepeatIndexFormulaRule.test.js +121 -0
- package/dist/rules/issues/formulas/unknownRepeatIndexFormulaRule.test.js.map +1 -1
- package/dist/rules/issues/formulas/unknownRepeatItemFormulaRule.js +6 -4
- package/dist/rules/issues/formulas/unknownRepeatItemFormulaRule.js.map +1 -1
- package/dist/rules/issues/formulas/unknownRepeatItemFormulaRule.test.js +137 -0
- package/dist/rules/issues/formulas/unknownRepeatItemFormulaRule.test.js.map +1 -1
- package/dist/rules/issues/style/unknownClassnameRule.js +1 -1
- package/dist/rules/issues/style/unknownClassnameRule.js.map +1 -1
- package/package.json +3 -3
- package/src/rules/issues/actions/actionRules.index.ts +2 -0
- package/src/rules/issues/actions/duplicateActionArgumentNameRule.test.ts +146 -0
- package/src/rules/issues/actions/duplicateActionArgumentNameRule.ts +21 -0
- package/src/rules/issues/formulas/duplicateFormulaArgumentNameRule.test.ts +180 -0
- package/src/rules/issues/formulas/duplicateFormulaArgumentNameRule.ts +21 -0
- package/src/rules/issues/formulas/formulaRules.index.ts +2 -0
- package/src/rules/issues/formulas/unknownRepeatIndexFormulaRule.test.ts +128 -0
- package/src/rules/issues/formulas/unknownRepeatIndexFormulaRule.ts +5 -4
- package/src/rules/issues/formulas/unknownRepeatItemFormulaRule.test.ts +143 -0
- package/src/rules/issues/formulas/unknownRepeatItemFormulaRule.ts +6 -4
- package/src/rules/issues/style/unknownClassnameRule.ts +1 -1
- package/src/types.d.ts +2 -0
|
@@ -65,6 +65,134 @@ describe('unknownRepeatIndexFormulaRule', () => {
|
|
|
65
65
|
'value',
|
|
66
66
|
])
|
|
67
67
|
})
|
|
68
|
+
test('should find unknown repeat index formulas outside of nodes', () => {
|
|
69
|
+
const problems = Array.from(
|
|
70
|
+
searchProject({
|
|
71
|
+
files: {
|
|
72
|
+
formulas: {},
|
|
73
|
+
components: {
|
|
74
|
+
test: {
|
|
75
|
+
name: 'test',
|
|
76
|
+
nodes: {},
|
|
77
|
+
formulas: {},
|
|
78
|
+
apis: {},
|
|
79
|
+
attributes: {},
|
|
80
|
+
variables: {},
|
|
81
|
+
workflows: {
|
|
82
|
+
myWorkflow: {
|
|
83
|
+
name: 'myWorkflow',
|
|
84
|
+
parameters: [],
|
|
85
|
+
actions: [
|
|
86
|
+
{
|
|
87
|
+
name: '@toddle/logToConsole',
|
|
88
|
+
group: 'debugging',
|
|
89
|
+
label: 'Log to console',
|
|
90
|
+
arguments: [
|
|
91
|
+
{
|
|
92
|
+
name: 'Label',
|
|
93
|
+
formula: { type: 'value', value: '' },
|
|
94
|
+
description: 'A label for the message.',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'Data',
|
|
98
|
+
type: { type: 'Any' },
|
|
99
|
+
formula: {
|
|
100
|
+
type: 'path',
|
|
101
|
+
path: ['ListItem', 'Index'],
|
|
102
|
+
},
|
|
103
|
+
description:
|
|
104
|
+
'The data you want to log to the console.',
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
description: 'Log a message to the browser console.',
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
rules: [unknownRepeatIndexFormulaRule],
|
|
116
|
+
}),
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
expect(problems).toHaveLength(1)
|
|
120
|
+
expect(problems[0].code).toBe('unknown repeat index formula')
|
|
121
|
+
expect(problems[0].path).toEqual([
|
|
122
|
+
'components',
|
|
123
|
+
'test',
|
|
124
|
+
'workflows',
|
|
125
|
+
'myWorkflow',
|
|
126
|
+
'actions',
|
|
127
|
+
0,
|
|
128
|
+
'arguments',
|
|
129
|
+
'1',
|
|
130
|
+
'formula',
|
|
131
|
+
])
|
|
132
|
+
})
|
|
133
|
+
test('should find unknown repeat index outside of a component', () => {
|
|
134
|
+
const problems = Array.from(
|
|
135
|
+
searchProject({
|
|
136
|
+
files: {
|
|
137
|
+
formulas: {
|
|
138
|
+
myFormula: {
|
|
139
|
+
name: 'myFormula',
|
|
140
|
+
formula: {
|
|
141
|
+
name: '@toddle/concatenate',
|
|
142
|
+
type: 'function',
|
|
143
|
+
arguments: [
|
|
144
|
+
{
|
|
145
|
+
name: '0',
|
|
146
|
+
type: {
|
|
147
|
+
type: 'Array \\| String \\| Object',
|
|
148
|
+
},
|
|
149
|
+
formula: {
|
|
150
|
+
path: ['Args', 'First'],
|
|
151
|
+
type: 'path',
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: '0',
|
|
156
|
+
type: {
|
|
157
|
+
type: 'Array \\| String \\| Object',
|
|
158
|
+
},
|
|
159
|
+
formula: {
|
|
160
|
+
type: 'path',
|
|
161
|
+
path: ['ListItem', 'Index'],
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
display_name: 'Concatenate',
|
|
166
|
+
variableArguments: true,
|
|
167
|
+
},
|
|
168
|
+
version: 2,
|
|
169
|
+
arguments: [
|
|
170
|
+
{
|
|
171
|
+
name: 'First',
|
|
172
|
+
formula: null,
|
|
173
|
+
testValue: 'sdfsdf',
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
description: 'sdfsdfsdf',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
components: {},
|
|
180
|
+
},
|
|
181
|
+
rules: [unknownRepeatIndexFormulaRule],
|
|
182
|
+
}),
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
expect(problems).toHaveLength(1)
|
|
186
|
+
expect(problems[0].code).toBe('unknown repeat index formula')
|
|
187
|
+
expect(problems[0].path).toEqual([
|
|
188
|
+
'formulas',
|
|
189
|
+
'myFormula',
|
|
190
|
+
'formula',
|
|
191
|
+
'arguments',
|
|
192
|
+
1,
|
|
193
|
+
'formula',
|
|
194
|
+
])
|
|
195
|
+
})
|
|
68
196
|
test('should ignore known repeat index formulas', () => {
|
|
69
197
|
const problems = Array.from(
|
|
70
198
|
searchProject({
|
|
@@ -10,13 +10,14 @@ export const unknownRepeatIndexFormulaRule: Rule = {
|
|
|
10
10
|
nodeType !== 'formula' ||
|
|
11
11
|
value.type !== 'path' ||
|
|
12
12
|
value.path?.[0] !== 'ListItem' ||
|
|
13
|
-
value.path?.[1] !== 'Index'
|
|
14
|
-
path.length < 3 ||
|
|
15
|
-
path[0] !== 'components' ||
|
|
16
|
-
path[2] !== 'nodes'
|
|
13
|
+
value.path?.[1] !== 'Index'
|
|
17
14
|
) {
|
|
18
15
|
return
|
|
19
16
|
}
|
|
17
|
+
if (path[0] !== 'components' || path[2] !== 'nodes') {
|
|
18
|
+
// Any use outside of a component node is invalid
|
|
19
|
+
return report(path)
|
|
20
|
+
}
|
|
20
21
|
const [_components, componentName, _nodes, nodeId] = path as string[]
|
|
21
22
|
const component = files.components[componentName]
|
|
22
23
|
if (!component) {
|
|
@@ -65,6 +65,149 @@ describe('unknownRepeatItemFormulaRule', () => {
|
|
|
65
65
|
'value',
|
|
66
66
|
])
|
|
67
67
|
})
|
|
68
|
+
test('should find unknown repeat item outside of nodes', () => {
|
|
69
|
+
const problems = Array.from(
|
|
70
|
+
searchProject({
|
|
71
|
+
files: {
|
|
72
|
+
formulas: {},
|
|
73
|
+
components: {
|
|
74
|
+
test: {
|
|
75
|
+
name: 'test',
|
|
76
|
+
nodes: {},
|
|
77
|
+
formulas: {},
|
|
78
|
+
apis: {},
|
|
79
|
+
attributes: {},
|
|
80
|
+
variables: {},
|
|
81
|
+
onLoad: {
|
|
82
|
+
trigger: 'load',
|
|
83
|
+
actions: [
|
|
84
|
+
{
|
|
85
|
+
name: '@toddle/logToConsole',
|
|
86
|
+
group: 'debugging',
|
|
87
|
+
label: 'Log to console',
|
|
88
|
+
arguments: [
|
|
89
|
+
{
|
|
90
|
+
name: 'Label',
|
|
91
|
+
formula: { type: 'value', value: '' },
|
|
92
|
+
description: 'A label for the message.',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'Data',
|
|
96
|
+
type: { type: 'Any' },
|
|
97
|
+
formula: {
|
|
98
|
+
type: 'function',
|
|
99
|
+
name: '@toddle/concatenate',
|
|
100
|
+
arguments: [
|
|
101
|
+
{
|
|
102
|
+
name: '0',
|
|
103
|
+
formula: { type: 'value', value: 'Hello' },
|
|
104
|
+
type: { type: 'Array \\| String \\| Object' },
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: '0',
|
|
108
|
+
formula: {
|
|
109
|
+
type: 'path',
|
|
110
|
+
path: ['ListItem', 'Item'],
|
|
111
|
+
},
|
|
112
|
+
type: { type: 'Array \\| String \\| Object' },
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
variableArguments: true,
|
|
116
|
+
display_name: 'Concatenate',
|
|
117
|
+
},
|
|
118
|
+
description: 'The data you want to log to the console.',
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
description: 'Log a message to the browser console.',
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
rules: [unknownRepeatItemFormulaRule],
|
|
129
|
+
}),
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
expect(problems).toHaveLength(1)
|
|
133
|
+
expect(problems[0].code).toBe('unknown repeat item formula')
|
|
134
|
+
expect(problems[0].path).toEqual([
|
|
135
|
+
'components',
|
|
136
|
+
'test',
|
|
137
|
+
'onLoad',
|
|
138
|
+
'actions',
|
|
139
|
+
'0',
|
|
140
|
+
'arguments',
|
|
141
|
+
'1',
|
|
142
|
+
'formula',
|
|
143
|
+
'arguments',
|
|
144
|
+
1,
|
|
145
|
+
'formula',
|
|
146
|
+
])
|
|
147
|
+
})
|
|
148
|
+
test('should find unknown repeat item outside of a component', () => {
|
|
149
|
+
const problems = Array.from(
|
|
150
|
+
searchProject({
|
|
151
|
+
files: {
|
|
152
|
+
formulas: {
|
|
153
|
+
myFormula: {
|
|
154
|
+
name: 'myFormula',
|
|
155
|
+
formula: {
|
|
156
|
+
name: '@toddle/concatenate',
|
|
157
|
+
type: 'function',
|
|
158
|
+
arguments: [
|
|
159
|
+
{
|
|
160
|
+
name: '0',
|
|
161
|
+
type: {
|
|
162
|
+
type: 'Array \\| String \\| Object',
|
|
163
|
+
},
|
|
164
|
+
formula: {
|
|
165
|
+
path: ['Args', 'First'],
|
|
166
|
+
type: 'path',
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: '0',
|
|
171
|
+
type: {
|
|
172
|
+
type: 'Array \\| String \\| Object',
|
|
173
|
+
},
|
|
174
|
+
formula: {
|
|
175
|
+
type: 'path',
|
|
176
|
+
path: ['ListItem', 'Item'],
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
display_name: 'Concatenate',
|
|
181
|
+
variableArguments: true,
|
|
182
|
+
},
|
|
183
|
+
version: 2,
|
|
184
|
+
arguments: [
|
|
185
|
+
{
|
|
186
|
+
name: 'First',
|
|
187
|
+
formula: null,
|
|
188
|
+
testValue: 'sdfsdf',
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
description: 'sdfsdfsdf',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
components: {},
|
|
195
|
+
},
|
|
196
|
+
rules: [unknownRepeatItemFormulaRule],
|
|
197
|
+
}),
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
expect(problems).toHaveLength(1)
|
|
201
|
+
expect(problems[0].code).toBe('unknown repeat item formula')
|
|
202
|
+
expect(problems[0].path).toEqual([
|
|
203
|
+
'formulas',
|
|
204
|
+
'myFormula',
|
|
205
|
+
'formula',
|
|
206
|
+
'arguments',
|
|
207
|
+
1,
|
|
208
|
+
'formula',
|
|
209
|
+
])
|
|
210
|
+
})
|
|
68
211
|
test('should ignore known repeat item formulas', () => {
|
|
69
212
|
const problems = Array.from(
|
|
70
213
|
searchProject({
|
|
@@ -10,13 +10,15 @@ export const unknownRepeatItemFormulaRule: Rule = {
|
|
|
10
10
|
nodeType !== 'formula' ||
|
|
11
11
|
value.type !== 'path' ||
|
|
12
12
|
value.path?.[0] !== 'ListItem' ||
|
|
13
|
-
value.path?.[1] !== 'Item'
|
|
14
|
-
path.length < 3 ||
|
|
15
|
-
path[0] !== 'components' ||
|
|
16
|
-
path[2] !== 'nodes'
|
|
13
|
+
value.path?.[1] !== 'Item'
|
|
17
14
|
) {
|
|
18
15
|
return
|
|
19
16
|
}
|
|
17
|
+
if (path[0] !== 'components' || path[2] !== 'nodes') {
|
|
18
|
+
// Any use outside of a component node is invalid
|
|
19
|
+
// For instance in global formulas or in workflows
|
|
20
|
+
return report(path)
|
|
21
|
+
}
|
|
20
22
|
const [_components, componentName, _nodes, nodeId] = path as string[]
|
|
21
23
|
const component = files.components[componentName]
|
|
22
24
|
if (!component) {
|
|
@@ -12,7 +12,7 @@ export const unknownClassnameRule: Rule<{
|
|
|
12
12
|
nodeType !== 'style-variant' ||
|
|
13
13
|
typeof value.variant.className !== 'string' ||
|
|
14
14
|
value.element.type !== 'element' ||
|
|
15
|
-
isDefined(value.element.classes[value.variant.className])
|
|
15
|
+
isDefined(value.element.classes?.[value.variant.className])
|
|
16
16
|
) {
|
|
17
17
|
return
|
|
18
18
|
}
|
package/src/types.d.ts
CHANGED
|
@@ -41,7 +41,9 @@ import type { NoReferenceVariableRuleFix } from './rules/issues/variables/noRefe
|
|
|
41
41
|
import type { NoPostNavigateActionRuleFix } from './rules/issues/workflows/noPostNavigateAction'
|
|
42
42
|
|
|
43
43
|
type Code =
|
|
44
|
+
| 'duplicate action argument name'
|
|
44
45
|
| 'duplicate event trigger'
|
|
46
|
+
| 'duplicate formula argument name'
|
|
45
47
|
| 'duplicate url parameter'
|
|
46
48
|
| 'duplicate workflow parameter'
|
|
47
49
|
| 'duplicate route'
|