MCPcopy
hub / github.com/prettier/prettier / locStart

Function locStart

src/language-js/location/start.js:11–28  ·  view source on GitHub ↗

@param {Node | Comment} node @return {number}

(node)

Source from the content-addressed store, hash-verified

9@return {number}
10*/
11function locStart(node) {
12 // @ts-expect-error -- safe
13 const start = node.range?.[0] ?? node.start;
14
15 /* c8 ignore next 3 */
16 if (process.env.NODE_ENV !== "production" && !isIndex(start)) {
17 throw new TypeError("Can't not locate node.");
18 }
19
20 // Handle nodes with decorators. They should start at the first decorator
21 // @ts-expect-error -- safe
22 const firstDecorator = (node.declaration?.decorators ?? node.decorators)?.[0];
23 if (firstDecorator) {
24 return Math.min(locStart(firstDecorator), start);
25 }
26
27 return start;
28}
29
30export { locStart };

Callers 15

overrides.jsFile · 0.90
hasSameLocStartFunction · 0.90
onEnterFunction · 0.90
rebalanceLogicalTreeFunction · 0.90
assertCommentsFunction · 0.90
assertRawFunction · 0.90
setContentEndFunction · 0.90
iterateClassMembersPathFunction · 0.90
isPreviousLineEmptyFunction · 0.90

Calls 1

isIndexFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…