Improve transpilation error handling for missing closing tags
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 52/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- babel, javascript
- 領域
- build-system
研究方向
執行提供的 shell script 以重現此行為,從 .babelrc 中的 Babel 外掛程式設定和 index.js 輸入開始。將產生的輸出與預期的失敗進行比較:轉譯應拒絕缺少的結束標籤,而不是靜默捨棄 h1 元素。
由索引模型根據 Issue 內容生成。
描述
Consider this sample code, which accidentally omits a closing tag.
import htm from 'htm'
const h = (type, props, ...children) => ({type, props, children});
const html = htm.bind(h)
console.log(JSON.stringify(html`<h1>Hello, world!`));
In this case, the user intended to include a closing tag </h1>, and so the user's desired logged result is {"type":"h1","props":null,"children":["Hello, world!"]}
Transpile htm away using this script.
shell script
#!/bin/sh -ex
rm -rf babel-htm-errors
mkdir babel-htm-errors
cd babel-htm-errors
npm init -y
npm i -D @babel/cli @babel/core babel-plugin-htm
cat <<EOF > .babelrc
{
"plugins": [
["htm", {
"pragma": "h"
}]
]
}
EOF
cat <<EOF > index.js
import htm from 'htm'
const h = (type, props, ...children) => ({type, props, children});
const html = htm.bind(h)
console.log(JSON.stringify(html\`<h1>Hello, world!\`));
EOF
npx babel index.js > output.mjs
node output.mjs
Expected: Transpilation should fail with an error.
Actual: The html line transpiles to:
console.log(JSON.stringify("Hello, world!"));
The <h1> tag is silently dropped.
(Note that this error behavior is different from the runtime behavior of htm with mismatching closing tags; see issue #166.)
- 主要語言
- JavaScript
- 星號
- 9k
- 分支
- 181
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
developit/htm 的其他 Issue
-
Sarthak 未關閉
難度 5/5 一週以上 新手友好度 1/100
-
Tugas 未關閉
難度 5/5 一週以上 新手友好度 10/100
-
Tugas 未關閉
難度 5/5 一週以上 新手友好度 1/100
-
難度 5/5 一週以上 新手友好度 20/100
-
難度 2/5 1-3 小時 新手友好度 35/100
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 75/100
mksglu/context-mode#1200 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
neondatabase/website#5944 ·
-
module: core
難度 2/5 1-3 小時 新手友好度 75/100
bigbluebutton/bigbluebutton#25849 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
jaegertracing/jaeger-ui#4506 ·