-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathno-serialize.js
56 lines (52 loc) · 1.16 KB
/
no-serialize.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
'use strict';
const rule = require( '../../src/rules/no-serialize' );
const RuleTester = require( '../../tools/rule-tester' );
const serializeError = 'Prefer FormData or URLSearchParams to .serialize';
const arrayError = 'Prefer FormData or URLSearchParams to .serializeArray';
const ruleTester = new RuleTester();
ruleTester.run( 'no-serialize', rule, {
valid: [
'serialize()',
'[].serialize()',
'div.serialize()',
'div.serialize',
'serializeArray()',
'[].serializeArray()',
'div.serializeArray()',
'div.serializeArray'
],
invalid: [
{
code: '$("div").serialize()',
errors: [ serializeError ]
},
{
code: '$div.serialize()',
errors: [ serializeError ]
},
{
code: '$("div").first().serialize()',
errors: [ serializeError ]
},
{
code: '$("div").append($("input").serialize())',
errors: [ serializeError ]
},
{
code: '$("div").serializeArray()',
errors: [ arrayError ]
},
{
code: '$div.serializeArray()',
errors: [ arrayError ]
},
{
code: '$("div").first().serializeArray()',
errors: [ arrayError ]
},
{
code: '$("div").append($("input").serializeArray())',
errors: [ arrayError ]
}
]
} );