-
Notifications
You must be signed in to change notification settings - Fork 649
Expand file tree
/
Copy pathcheck-enumerated-histograms.ts
More file actions
42 lines (39 loc) · 1.37 KB
/
check-enumerated-histograms.ts
File metadata and controls
42 lines (39 loc) · 1.37 KB
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
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {createRule} from './utils/ruleCreator.ts';
export default createRule({
name: 'check-enumerated-histograms',
meta: {
type: 'problem',
docs: {
description: 'check arguments when recording enumerated histograms',
category: 'Possible Errors',
},
fixable: 'code',
messages: {
invalidArgument:
'When calling \'recordEnumeratedHistogram\' the third argument should be of the form \'SomeEnum.MAX_VALUE\'.',
},
schema: [], // no options
},
defaultOptions: [],
create: function(context) {
return {
CallExpression(node) {
if (node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier' &&
node.callee.object.name === 'InspectorFrontendHostInstance' && node.callee.property.type === 'Identifier' &&
node.callee.property.name === 'recordEnumeratedHistogram') {
const argumentNode = node.arguments[2];
if (argumentNode.type !== 'MemberExpression' || argumentNode.property.type !== 'Identifier' ||
argumentNode.property.name !== 'MAX_VALUE') {
context.report({
node,
messageId: 'invalidArgument',
});
}
}
},
};
},
});