MCPcopy
hub / github.com/ampproject/amphtml / callScopedQuerySelector

Function callScopedQuerySelector

build-system/eslint-rules/query-selector.js:73–107  ·  view source on GitHub ↗

* @param {CompilerNode} node

(node)

Source from the content-addressed store, hash-verified

71 * @param {CompilerNode} node
72 */
73 function callScopedQuerySelector(node) {
74 const {callee} = node;
75 if (!callee.name.startsWith('scopedQuerySelector')) {
76 return;
77 }
78
79 const leadingComments = context.getCommentsBefore(node);
80 const ok = leadingComments.some((comment) => {
81 return comment.value === 'OK';
82 });
83 if (ok) {
84 return;
85 }
86
87 const selector = getSelector(node, 1);
88
89 if (!isValidSelector(selector)) {
90 context.report({
91 node,
92 message: 'Failed to parse CSS Selector `' + selector + '`',
93 });
94 return;
95 }
96
97 if (selectorNeedsScope(selector)) {
98 return;
99 }
100
101 context.report({
102 node,
103 message:
104 'using scopedQuerySelector here is actually ' +
105 "unnecessary, since you don't use child selector semantics.",
106 });
107 }
108
109 /**
110 * @param {CompilerNode} node

Callers 1

CallExpressionFunction · 0.85

Calls 4

isValidSelectorFunction · 0.85
selectorNeedsScopeFunction · 0.85
getSelectorFunction · 0.70
reportMethod · 0.45

Tested by

no test coverage detected