-
Notifications
You must be signed in to change notification settings - Fork 0
/
count.js
33 lines (33 loc) · 966 Bytes
/
count.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
module.exports = {
meta: {
docs: {
description: "Enforce limit the number of 'any' types"
},
schema: [
{
type: "integer",
minimum: 0,
default: 5
}
]
},
create: function (context) {
let anyCount = 0;
const maxCount = context.options[0] || 5; // default to 5
return {
TSAnyKeyword(node) {
anyCount++;
if (anyCount > maxCount) {
context.report({
node,
message: `In file ${context.getFilename()} at line ${
node.loc.start.line
}, column ${
node.loc.start.column
}: The "any" type has been used more than ${maxCount} times.`,
});
}
},
};
},
};