-
Notifications
You must be signed in to change notification settings - Fork 3
/
msg-doc.js
49 lines (43 loc) · 1.22 KB
/
msg-doc.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
41
42
43
44
45
46
47
48
49
'use strict';
const utils = require( '../utils.js' );
// TODO: Support `new mw.Message( store, key )` syntax
const methodNames = [ 'msg', 'message', 'deferMsg', '$i18n' ];
// Links to https://www.mediawiki.org/wiki/Special:MyLanguage/Help:System_message#Using_messages
const message = 'All possible message keys should be documented. See https://w.wiki/4r9a for details.';
module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Ensures message keys are documented when they are constructed.'
},
schema: []
},
create: function ( context ) {
return {
'CallExpression[callee.type="MemberExpression"]': function ( node ) {
if (
methodNames.includes( node.callee.property.name ) &&
node.arguments.length &&
utils.requiresCommentList( context, node.arguments[ 0 ] )
) {
context.report( {
node: node,
message: message
} );
}
},
'NewExpression[callee.type="MemberExpression"]': function ( node ) {
if (
node.callee.object.name === 'mw' &&
node.callee.property.name === 'Message' &&
utils.requiresCommentList( context, node.arguments[ 0 ] )
) {
context.report( {
node: node,
message: message
} );
}
}
};
}
};