-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
27 lines (24 loc) · 968 Bytes
/
index.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
const documentCookieMemberSelector =
'MemberExpression[object.name="document"][property.name="cookie"]';
const windowDocumentCookieMemberSelector =
'MemberExpression[object.object.name="window"][object.property.name="document"][property.name="cookie"]';
// 'MemberExpression[object.name="window"][property.name="document"]~Identifier[name="cookie"]';
const localStorageSelector = 'Identifier[name="localStorage"]';
module.exports = {
rules: {
"no-document-cookie": {
create: (context) => ({
[documentCookieMemberSelector]: (node) =>
context.report(node, "Do not use document.cookie directly."),
[windowDocumentCookieMemberSelector]: (node) =>
context.report(node, "Do not use document.cookie directly."),
}),
},
"no-localstorage": {
create: (context) => ({
[localStorageSelector]: (node) =>
context.report(node, "Do not use localStorage directly."),
}),
},
},
};