-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathno-expression-contains-module-level-variable-ref.js
More file actions
52 lines (45 loc) · 1.76 KB
/
no-expression-contains-module-level-variable-ref.js
File metadata and controls
52 lines (45 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
const { RuleTester } = require('eslint');
const { RULE_TESTER_CONFIG } = require('./shared');
const lwcGraphAnalyzer = require('../../../lib/index');
const ruleTester = new RuleTester(RULE_TESTER_CONFIG);
ruleTester.run(
'@salesforce/lwc-graph-analyzer/no-expression-contains-module-level-variable-ref',
lwcGraphAnalyzer.rules['no-expression-contains-module-level-variable-ref'],
{
valid: [],
invalid: [
{
code: `
import { LightningElement, wire, api } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import findContacts from '@salesforce/apex/ContactController.findContacts';
import { testFunction } from 'test/functoins/testFunctoins';
const testModuleVar = "test";
export default class Example extends LightningElement {
get searchKey() {
let var1, var2 = "hello";
var1 = testModuleVar;
return "serch key";
}
testFunction(val){
return val;
}
@wire(findContacts, { searchKey: '$searchKey' })
contacts;
}`,
filename: 'lwc-code.js',
errors: [
{
message: `This getter references a variable defined at the module level: 'testModuleVar'.`
}
]
}
]
}
);