// Tests for the conventions/comment-format rule // (web/eslint-plugins/conventions/comment-format.js). // // Pure AST check (comment nodes + line counts), standard RuleTester. The // svelte pass pins the two comment kinds the token stream never sees: template // `` comments (AST nodes) and CSS in `", filename: "Component.svelte", options: [{ maxRatio: 1 }], }, { // Script and ', filename: "Component.svelte", options: [{ maxRatio: 1 }], }, ], invalid: [ { // The template comment the ts pass could never see, over the cap. code: "\n
Hello
", filename: "Component.svelte", options: [{ maxRatio: 1 }], errors: [{ messageId: "blockTooLong" }], }, { // ", filename: "Component.svelte", options: [{ maxRatio: 1 }], errors: [{ messageId: "blockTooLong", line: 2 }], }, { // A comment nested in markup is collected too (not Program.body). code: "
\n\t\n
", filename: "Component.svelte", options: [{ maxRatio: 1 }], errors: [{ messageId: "blockTooLong" }], }, { // Template comment lines count toward density: 2 of 4 non-blank. code: "\n\n

x

\n

y

", filename: "Component.svelte", options: [{ maxBlockLines: 5, maxRatio: 0.4 }], errors: [{ messageId: "tooDense" }], }, { // Script and template comments share one density budget. code: '\n\n

c

', filename: "Component.svelte", options: [{ maxBlockLines: 5, maxRatio: 0.3 }], errors: [{ messageId: "tooDense" }], }, { // CSS lines count toward density too: 2 of 8 non-blank. Consecutive // CSS comments stay separate blocks (each one line, under the cap). code: "

x

\n", filename: "Component.svelte", options: [{ maxBlockLines: 5, maxRatio: 0.2 }], errors: [{ messageId: "tooDense" }], }, { // All three kinds over the cap: one report per block, by position. code: "\n", filename: "Component.svelte", options: [{ maxRatio: 1 }], errors: [ { messageId: "blockTooLong", line: 1 }, { messageId: "blockTooLong", line: 9 }, ], }, { // Both violations in one file produce two reports. code: "\n

x

", filename: "Component.svelte", options: [{ maxBlockLines: 5, maxRatio: 0.5 }], errors: [{ messageId: "blockTooLong" }, { messageId: "tooDense" }], }, ], });