Skip to main content
Glama
push-based

Angular Toolkit MCP

by push-based
utils.ts1.38 kB
import { Issue } from '@code-pushup/models'; import { Rule } from 'postcss'; /** * Convert a Root to an Issue source object and adjust its position based on startLine. * It creates a "linkable" source object for the issue. * By default, the source location is 0 indexed, so we add 1 to the startLine to make it work in file links. * * @param rule The AST rule to convert into a linkable source object. * @param startLine The positions of the asset contain the style rules. */ export function styleAstRuleToSource( { source }: Pick<Rule, 'source'>, startLine = 0, // 0 indexed ): Issue['source'] { if (source?.input.file == null) { throw new Error( 'style parsing was not initialized with a file path. Check the postcss options.', ); } const offset = startLine - 1; // -1 because PostCss is 1 indexed so we have to substract 1 to make is work in 0 based index return { file: source.input.file, position: { startLine: (source?.start?.line ?? 1) + offset + 1, // +1 because the code works 0 indexed and file links work 1 indexed. ...(source?.start?.column && { startColumn: source?.start?.column }), ...(source?.end?.line && { endLine: source?.end?.line + offset + 1 }), // +1 because the code works 0 indexed and file links work 1 indexed. ...(source?.end?.column && { endColumn: source?.end?.column }), }, }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/push-based/angular-toolkit-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server