// 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
x
\ny
", filename: "Component.svelte", options: [{ maxBlockLines: 5, maxRatio: 0.4 }], errors: [{ messageId: "tooDense" }], }, { // Script and template comments share one density budget. code: '\n\nc
', 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: "\nx
", filename: "Component.svelte", options: [{ maxBlockLines: 5, maxRatio: 0.5 }], errors: [{ messageId: "blockTooLong" }, { messageId: "tooDense" }], }, ], });