@ faircopy/ templ
走开 微温 用于 公平复制。它从中提取了用户化副本 .templ 带有每个字符源图的文件,因此诊断指向原始模板.
安装
npm i -D faircopy @faircopy/templ
使用量
// faircopy.config.ts
import { defineConfig } from '@faircopy/config'
import { templ } from '@faircopy/templ'
export default defineConfig({
files: ['**/*.templ'],
adapters: [templ()],
rules: {
'no-em-dash': 'error',
'no-weasel-words': 'error',
},
})
被提取的东西
- HTML 标记之间的可见文本,包括turl表达式周围的静态部分
- 外观为流言的被解释和生取的 Go 字符串文字,包括组件参数
alt, (中文(简体) ),title, (中文(简体) ),placeholder, (中文(简体) ),aria-label,以及aria-description属性值
评论,URL,标识符,类似CSS的值,以及面向代码的字符串被过滤出. 内部内容 <script>, (中文(简体) ), <style>, (中文(简体) ), <code>, (中文(简体) ), <pre>,以及 <kbd> 被跳过.
选项
templ({
// Lint prose-like interpreted and raw Go strings. Default true.
lintGoStrings: true,
// Lint the default prose attributes, disable attributes, or provide a custom list.
lintAttributes: true,
// lintAttributes: false,
// lintAttributes: { attributes: ['alt', 'data-copy'] },
// Add tags whose entire contents should be skipped.
skipTags: ['markdown'],
})
添加 data-faircopy-ignore 以跳过该元素及其后人的方式:
<section data-faircopy-ignore>
<p>This content is not linted.</p>
</section>