/** * 共通 lint core(①' 検出器一本化) * * AI 生成物(.html / .tsx / .jsx / .vue)の class 文字列を抽出し、 * rules.json の自動検出ルールを matcher.ts(tokenize/matches) 経由で適用する。 * * 旧構成の問題(red-team / Codex review で判明): * - hook-check-rule.sh が matcher.ts を使わず独自の `cls.includes(p)` で判定し、 * "top-0" を "p-0" に誤検出する既知バグ(matcher.spec.ts:201 相当)を再導入していた * - .html かつ class="..." だけが対象で、.tsx の className / single-quote / backtick が素通り * * この module を hook / lint-generated CLI / benchmark score が共有することで、 * 判定ロジックを一箇所(matcher.ts)に集約し drift をなくす。 */ import type { LintViolation } from "./types.js"; export type { LintViolation } from "./types.js"; /** * ソース文字列から class 文字列群を抽出する。 * * 対応: * - HTML: class="a b" / class='a b' * - JSX: className="a b" / className={'a b'} / className={`a b`} * - Vue: :class="a b"(静的部分のみ。式は best-effort) * * 既知の限界(regex 抽出の構造的天井。完全対応は AST ベース = S4 の領域): * - `className={clsx('a', cond && 'b')}` のようなクォート無し式は拾えない * - `className={`a ${x}`}` のテンプレ補間 `${x}` の中身は展開できない * - Vue `:class="{ 'a': cond }"` の object/array 構文は静的抽出できない * これらは検出漏れ(false negative)であり、誤検出(false positive)にはしない。 */ export declare function extractClassStrings(source: string): string[]; /** * ソース文字列を lint し、自動検出ルール違反を返す。 * * **範囲は class lint + html-attr lint まで。composition lint(ネスト modal / * interactive 内 interactive 等、DOM パース前提の合成検査)は含まない。** * したがって本関数の `[]` は「class / html-attr の違反なし」であって、CI や * check_html と同じ判定ではない。composition 込みの判定は単一 lint API * `lint()`(src/utils/lint.ts、npm 公開 entry `melta-ds-mcp/lint`)を使うこと。 * check_html / CI の lint CLI / PostToolUse hook はすべて lint() 経由で本関数を呼ぶ。 * npm 公開 entry `melta-ds-mcp/lint-core` は互換のため残している(1.9.0 で lint へ移行)。 * * @param source 生成物のソース(HTML/JSX/Vue 文字列) * @returns 違反リスト(error / warn 混在。呼び出し側で severity 判定) */ export declare function lintSource(source: string): LintViolation[];