-
Notifications
You must be signed in to change notification settings - Fork 15
/
eslint-local-rules.js
40 lines (37 loc) · 1.13 KB
/
eslint-local-rules.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
const FUNCTION_NAMES = ['usePropDeprecationWarning', 'useDeprecationWarning']
module.exports = {
'future-proof-deprecation-warning': {
meta: {
type: 'suggestion',
fixable: null,
docs: {
description:
'Ensure a deprecation warning is preceded by a TODO comment with a ticket reference',
category: 'Picasso Best Practices',
recommended: false,
},
schema: [],
},
create: function (context) {
return {
CallExpression(node) {
if (FUNCTION_NAMES.includes(node.callee.name)) {
const sourceCode = context.getSourceCode()
const commentBefore = sourceCode.getCommentsBefore(node)
const hasTodoComment = commentBefore.some(
comment =>
comment.value.includes('TODO') ||
comment.value.includes('FIXME')
)
if (!hasTodoComment) {
context.report({
node,
message: `${node.callee.name} must be preceded by a TODO comment with a ticket reference `,
})
}
}
},
}
},
},
}