forked from ember-cli/eslint-plugin-ember
-
Notifications
You must be signed in to change notification settings - Fork 0
/
no-tracked-properties-from-args.js
99 lines (86 loc) · 2.15 KB
/
no-tracked-properties-from-args.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const rule = require('../../../lib/rules/no-tracked-properties-from-args');
const RuleTester = require('eslint').RuleTester;
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
const ruleTester = new RuleTester({
parser: require.resolve('@babel/eslint-parser'),
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
});
ruleTester.run('no-tracked-properties-from-args', rule, {
valid: [
`
import { tracked } from '@glimmer/tracking'
class Test {
@someDecorator test = this.args.test
}`,
`
import { tracked } from '@glimmer/tracking'
class Test {
@tracked test = this.someValue
}`,
`
import { tracked } from '@glimmer/tracking'
class Test {
@tracked test = 7
}`,
`
import { tracked } from '@glimmer/tracking'
class Test {
test = 7
}`,
`
import { tracked } from '@glimmer/tracking'
class Test {
test = "test"
}`,
`
import { tracked } from '@glimmer/tracking'
class Test {
@tracked test = this.notArgs.args.test
}`,
`
import { tracked as fooTracked } from '@glimmer/tracking';
class Test {
@fooTracked test = this.notArgs.args.test
}
`,
],
invalid: [
{
code: `
import { tracked } from '@glimmer/tracking'
class Test {
@tracked test = this.args.test;
}`,
output: null,
errors: [
{
messageId: 'main',
type: 'PropertyDefinition',
},
],
},
{
code: `
import { tracked as fooTracked } from '@glimmer/tracking';
class Test {
@fooTracked test = this.args.test
}
`,
output: null,
errors: [
{
messageId: 'main',
type: 'PropertyDefinition',
},
],
},
],
});