-
Notifications
You must be signed in to change notification settings - Fork 11
For linting, we'd need to be able to emit a full AST, including nodes for the template #39
Copy link
Copy link
Open
Description
In order to get the index / replacement / splice management out of eslint-plugin-ember or other tooling, additional APIs may be needed -- or a unified AST may need to be provided -- or more tooling so folks don't have to manage the template removing / insertion again.
eslint-plugin-ember
- runs
@glimmer/syntaxover the template and re-stitches together AST nodes- enables type-aware linting
- enables one lint tool (eslint) instead of two (template-lint)
- enables fixers to be able to be implemented with the whole context of a module
prettier-plugin-ember-template-tag & ember-template-lint
- current strategy:
- extract templates
- format JS
- format templates with offsets
- place templates back in placeholder spots
Motivation
- index splicing is really easy to get wrong in javascript.
- any
<template>manipulation really belongs with the tool that already is supporting content-tag, because it can more easily assure that parsing and serialization is correct.
Ideas:
format
makes the prettier plugin implementation easier.
the intermediary format is never seen.
import { format } from 'content-tag';
let outputGjsString = format(gjsString, (contentTagContent, positionInfo /* for reporting */) => {
// no-op
return contentTagContent;
// or,
return prettier(contentTagContent, { parser: 'glimmer'});
});parseAst + serializeAst
This would produce a JSON AST for the whole JS + <template> contents, and would require @glimmer/syntax for now, but I've volunteered myself to learn Rust and have a go at a rust-based glimmer template parser.
import { parseAst, serializeAst } from 'content-tag';
import { parse /* or whatever this was called */ } from '@glimmer/syntax';
// no <template> or intermediary format seen in here
let ast = parseAst(gjsString, { glimmerParse: parse });
let outputGjs = serializeAst(ast);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels