How to use the @parcel/codeframe function in @parcel/codeframe

To help you get started, we’ve selected a few @parcel/codeframe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github parcel-bundler / parcel / packages / core / utils / src / prettyDiagnostic.js View on Github external
stack: '',
    codeframe: '',
    hints: [],
  };

  result.message =
    mdAnsi(`**${origin ?? 'unknown'}**: `) +
    (skipFormatting ? message : mdAnsi(message));
  result.stack = stack || '';

  if (codeFrame !== undefined) {
    let highlights = Array.isArray(codeFrame.codeHighlights)
      ? codeFrame.codeHighlights
      : [codeFrame.codeHighlights];

    let formattedCodeFrame = formatCodeFrame(codeFrame.code, highlights, {
      useColor: true,
      syntaxHighlighting: true,
      language:
        // $FlowFixMe sketchy null checks do not matter here...
        language || (filePath ? path.extname(filePath).substr(1) : undefined),
    });

    result.codeframe +=
      typeof filePath !== 'string'
        ? ''
        : chalk.underline(
            `${filePath}:${highlights[0].start.line}:${highlights[0].start.column}\n`,
          );
    result.codeframe += formattedCodeFrame;
  }

@parcel/codeframe

Blazing fast, zero configuration web application bundler

MIT
Latest version published 8 months ago

Package Health Score

87 / 100
Full package analysis

Popular @parcel/codeframe functions

Similar packages