rofrischmann/elodin

View on GitHub
core/prettier-plugin-elodin/src/parser.js

Summary

Maintainability
A
0 mins
Test Coverage
import { format } from '@elodin/format'

export default function parse(text, _, options) {
  const formatted = format(text)

  const errors = formatted.errors
  let formattedText = formatted.code

  if (errors.length > 0) {
    let formattedText = text
  }

  return {
    ast_type: 'elodin-ast',
    body: formattedText,
    error: errors[0],
    end: text.length,
    source: text,
    start: 0,
  }
}