MCPcopy Create free account
hub / github.com/ampproject/amphtml / verifyPath

Function verifyPath

build-system/eslint-rules/json-configuration.js:17–42  ·  view source on GitHub ↗

* @param {*} node * @return {Object}

(node)

Source from the content-addressed store, hash-verified

15 * @return {Object}
16 */
17 function verifyPath(node) {
18 for (let n = node; n; n = n.parent) {
19 const {parent} = n;
20 const {type} = parent;
21
22 if (type === 'ArrayExpression' || type === 'ObjectExpression') {
23 continue;
24 }
25
26 if (type === 'Property' && parent.value === n) {
27 continue;
28 }
29
30 if (type === 'CallExpression') {
31 const {name} = parent.callee;
32 if (name === 'jsonConfiguration' || name === 'jsonLiteral') {
33 break;
34 }
35 }
36
37 return context.report({
38 node,
39 message: 'Value must descend from object/array literals only.',
40 });
41 }
42 }
43
44 return {
45 'CallExpression[callee.name=jsonConfiguration]': function (node) {

Callers 1

Calls 1

reportMethod · 0.45

Tested by

no test coverage detected