-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
66 lines (64 loc) · 1.81 KB
/
index.ts
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
import { Rule } from "eslint";
const plugin = {
rules: {
"no-anchor-tag": {
meta: {
type: "problem",
docs: {
description: "Disallow the use of anchor tags",
category: "Best Practices",
recommended: true,
},
fixable: "code",
schema: [], // No options for this rule
},
create: function (context) {
return {
JSXOpeningElement(_codePath: any, node: any) {
if (node.name.type === "JSXIdentifier" && node.name === "a") {
context.report({
node,
message: "Avoid using anchor tags",
fix: (fixer: { remove: (arg0: any) => any }) =>
fixer.remove(node),
});
}
},
};
},
} as Rule.RuleModule,
"no-json-parse": {
meta: {
type: "suggestion",
docs: {
description: "Disallow the use of JSON.parse",
category: "Best Practices",
recommended: true,
},
fixable: "code",
schema: [], // No options for this rule
},
create: function (context) {
return {
CallExpression(node) {
if (
node.callee.type === "MemberExpression" &&
node.callee.object.type === "Identifier" &&
node.callee.object.name === "JSON" &&
node.callee.property.type === "Identifier" &&
node.callee.property.name === "parse"
) {
context.report({
node,
message: "Avoid using JSON.parse",
fix: (fixer: { remove: (arg0: any) => any }) =>
fixer.remove(node),
});
}
},
};
},
} as Rule.RuleModule,
},
};
export = plugin;