3 ms·
Because if you do: import markdown from 'markdown-in-js'; var markdown = function() { } var foo = markdown` #Header ... `; It will incorrectly rewr
by Touche 10y ago
Because if you do:
import markdown from 'markdown-in-js';
var markdown = function() { }
var foo = markdown` #Header ... `;
It will incorrectly rewrite this template literal. And while they could potentially fill this hole, it doesn't change the fact this is unreadable code; there's nothing from the code that signifies it will be converted into some function calls the way that JSX or GraphQL at least have some visual signifiers.
JSX and GraphQL, I'm not a fan of either, but are at least real projects with standards texts written for. This is not a criticism of this project, but the practice of installing a bunch of AST transforms to save you a couple of keystrokes creates code that reads as 1 thing, but compiles to something much different.
If you don't recognize how changing your code to mean something different based on an AST is essentially creating a one-off language, I don't know how to help you.
- morgante 10y ago> It will incorrectly rewrite this template literal. That is a bug and should be fixed. I'm not sure what visual signifiers that GraphQL has which this doesn't. It's a fairly clear pattern of what's going on. I really don't see what is "unreadable" about it.
- Touche 10y agoIt's a leaky abstraction. The point is to make your code do something other than what you described it as doing (because it will do it "better"). That's what makes it unreadable; hiding behavior from code decreases readability. I'm not that familiar with GraphQL, but as far as I can tell it doesn't depend on AST transforms. It seems to be a DSL that uses tagged templates. There's nothing wrong with DSLs.