-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathno-prop.js
40 lines (37 loc) · 945 Bytes
/
no-prop.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
'use strict';
const rule = require( '../../src/rules/no-prop' );
const RuleTester = require( '../../tools/rule-tester' );
const error = 'Prefer direct property access to .prop/$.prop';
const errorRemove = 'Prefer direct property access to .removeProp/$.removeProp';
const ruleTester = new RuleTester();
ruleTester.run( 'no-prop', rule, {
valid: [ 'prop()', '[].prop()', 'div.prop()', 'div.prop', 'removeProp()', 'div.removeProp()' ],
invalid: [
{
code: '$.prop()',
errors: [ error ]
},
{
code: '$("div").prop()',
errors: [ error ]
},
{
code: '$div.prop()',
errors: [ error ]
},
{
code: '$("div").first().prop()',
errors: [ error ]
},
{
code: '$("div").append($("input").prop())',
errors: [ error ]
},
// $.removeProp util is disallowed too as the rule is shared
// with $.prop, but $.removeProp doesn't exist
{
code: '$("div").removeProp()',
errors: [ errorRemove ]
}
]
} );