-
Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathfake-rule.ts
42 lines (39 loc) · 1.03 KB
/
fake-rule.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
/**
* @file Fake rule to be able to test createTestingLibraryRule and
* detectTestingLibraryUtils properly
*/
import { TSESTree } from '@typescript-eslint/experimental-utils';
import { createTestingLibraryRule } from '../lib/create-testing-library-rule';
export const RULE_NAME = 'fake-rule';
type Options = [];
type MessageIds = 'fakeError';
export default createTestingLibraryRule<Options, MessageIds>({
name: RULE_NAME,
meta: {
type: 'problem',
docs: {
description: 'Fake rule to test rule maker and detection helpers',
category: 'Possible Errors',
recommended: false,
},
messages: {
fakeError: 'fake error reported',
},
fixable: null,
schema: [],
},
defaultOptions: [],
create(context) {
const reportRenderIdentifier = (node: TSESTree.Identifier) => {
if (node.name === 'render') {
context.report({
node,
messageId: 'fakeError',
});
}
};
return {
'CallExpression Identifier': reportRenderIdentifier,
};
},
});