forked from darkreader/darkreader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintplugin.js
30 lines (30 loc) · 995 Bytes
/
.eslintplugin.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
module.exports.rules = {
'jsx-uses-m-pragma': {
create(context) {
const pragma = 'm';
const usePragma = () => context.markVariableAsUsed(pragma);
return {
JSXOpeningElement: usePragma,
JSXOpeningFragment: usePragma,
};
},
},
'jsx-uses-vars': {
create(context) {
return {
JSXOpeningElement(node) {
let variable;
const jsxTag = node.name;
if (jsxTag.type === 'JSXIdentifier') {
variable = jsxTag.name;
} else if (jsxTag.type === 'JSXMemberExpression') {
variable = jsxTag.object.name;
} else {
console.warn('Unsupported JSX identifier', jsxTag);
}
context.markVariableAsUsed(variable);
},
};
},
},
};