@@ -122,6 +122,58 @@ ruleTester.run('no-unknown-wire-adapters', rule, {
122
122
} ,
123
123
] ,
124
124
} ,
125
+ {
126
+ code : `import { wire } from 'lwc';
127
+ import { apexMethod } from '@salesforce/apex/Namespace.Classname.apexMethodReference';
128
+
129
+ class Test {
130
+ @wire(apexMethod)
131
+ wiredProp;
132
+ }` ,
133
+ options : [
134
+ {
135
+ adapters : [
136
+ { module : '@salesforce/apex/*' , identifier : '*' } ,
137
+ ] ,
138
+ } ,
139
+ ] ,
140
+ } ,
141
+ {
142
+ code : `import { wire } from 'lwc';
143
+ import { getFoo } from 'adapterFoo';
144
+ import { apexMethod } from '@salesforce/apex/Namespace.Classname.apexMethodReference';
145
+
146
+ class Test {
147
+ @wire(apexMethod)
148
+ wiredProp;
149
+
150
+ @wire(getFoo)
151
+ wiredFoo;
152
+ }` ,
153
+ options : [
154
+ {
155
+ adapters : [
156
+ { module : 'adapterFoo' , identifier : 'getFoo' } ,
157
+ { module : '@salesforce/apex/*' , identifier : '*' } ,
158
+ ] ,
159
+ } ,
160
+ ] ,
161
+ } ,
162
+ {
163
+ code : `import { wire } from 'lwc';
164
+ import startRequest from '@salesforce/apexContinuation/SampleContinuationClass.startRequest';
165
+
166
+ class Test {
167
+ @wire(startRequest) wiredProp;
168
+ }` ,
169
+ options : [
170
+ {
171
+ adapters : [
172
+ { module : '@salesforce/**' , identifier : '*' } ,
173
+ ] ,
174
+ } ,
175
+ ]
176
+ } ,
125
177
] ,
126
178
invalid : [
127
179
{
@@ -198,5 +250,131 @@ ruleTester.run('no-unknown-wire-adapters', rule, {
198
250
} ,
199
251
] ,
200
252
} ,
253
+ // verify matches is not using includes.
254
+ {
255
+ code : `import { wire } from 'lwc';
256
+ import { getPost } from 'adapter';
257
+
258
+ class Test {
259
+ @wire(getPost) wiredProp;
260
+ }` ,
261
+ options : [
262
+ {
263
+ adapters : [ { module : 'adapter' , identifier : 'getPosts' } ] ,
264
+ } ,
265
+ ] ,
266
+ errors : [
267
+ {
268
+ message : '"getPost" from "adapter" is not a known adapter.' ,
269
+ } ,
270
+ ] ,
271
+ } ,
272
+ // code sensitive.
273
+ {
274
+ code : `import { wire } from 'lwc';
275
+ import { getFoo } from 'adapter';
276
+
277
+ class Test {
278
+ @wire(getFoo) wiredProp;
279
+ }` ,
280
+ options : [
281
+ {
282
+ adapters : [ { module : 'adapter' , identifier : 'getfoo' } ] ,
283
+ } ,
284
+ ] ,
285
+ errors : [
286
+ {
287
+ message : '"getFoo" from "adapter" is not a known adapter.' ,
288
+ } ,
289
+ ] ,
290
+ } ,
291
+ // matches multiple module, but not identifier
292
+ {
293
+ code : `import { wire } from 'lwc';
294
+ import { apexMethod } from '@salesforce/apex/Namespace.Classname.apexMethodReference';
295
+
296
+ class Test {
297
+ @wire(apexMethod)
298
+ wiredProp;
299
+ }` ,
300
+ options : [
301
+ {
302
+ adapters : [
303
+ { module : '@salesforce/apex/*' , identifier : 'default' } ,
304
+ ] ,
305
+ } ,
306
+ ] ,
307
+ errors : [
308
+ {
309
+ message : '"apexMethod" from "@salesforce/apex/Namespace.Classname.apexMethodReference" is not a known adapter.' ,
310
+ } ,
311
+ ] ,
312
+ } ,
313
+ // matches multiple identifiers, but only one module.
314
+ {
315
+ code : `import { wire } from 'lwc';
316
+ import { apexMethod } from '@salesforce/apex/Namespace.Classname.apexMethodReference';
317
+ import { fooMethod } from '@salesforce/apex/Foo.Namespace';
318
+
319
+ class Test {
320
+ @wire(apexMethod)
321
+ wiredProp;
322
+
323
+ @wire(fooMethod)
324
+ wiredValue;
325
+ }` ,
326
+ options : [
327
+ {
328
+ adapters : [
329
+ { module : '@salesforce/apex/Foo.Namespace' , identifier : '*' } ,
330
+ ] ,
331
+ } ,
332
+ ] ,
333
+ errors : [
334
+ {
335
+ message : '"apexMethod" from "@salesforce/apex/Namespace.Classname.apexMethodReference" is not a known adapter.' ,
336
+ } ,
337
+ ] ,
338
+ } ,
339
+ {
340
+ code : `import { wire } from 'lwc';
341
+ import startRequest from '@salesforce/apex/Continuation/SampleContinuationClass.startRequest';
342
+
343
+ class Test {
344
+ @wire(startRequest) wiredProp;
345
+ }` ,
346
+ options : [
347
+ {
348
+ adapters : [
349
+ { module : '@salesforce/apex/*' , identifier : '*' } ,
350
+ ] ,
351
+ } ,
352
+ ] ,
353
+ errors : [
354
+ {
355
+ message : '"default" from "@salesforce/apex/Continuation/SampleContinuationClass.startRequest" is not a known adapter.' ,
356
+ } ,
357
+ ] ,
358
+ } ,
359
+ {
360
+ code : `import { wire } from 'lwc';
361
+ import startRequest from '@salesforce/apexContinuation/SampleContinuationClass.startRequest';
362
+
363
+ class Test {
364
+ @wire(startRequest) wiredProp;
365
+ }` ,
366
+ options : [
367
+ {
368
+ adapters : [
369
+ { module : '@salesforce/apex*' , identifier : '*' } ,
370
+ ] ,
371
+ } ,
372
+ ] ,
373
+ errors : [
374
+ {
375
+ message : '"default" from "@salesforce/apexContinuation/SampleContinuationClass.startRequest" is not a known adapter.' ,
376
+ } ,
377
+ ] ,
378
+ } ,
201
379
] ,
202
380
} ) ;
0 commit comments