Skip to content

Commit

Permalink
invalid cases with block comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Omri Luzon committed Dec 16, 2022
1 parent cef520c commit 415733a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions packages/eslint-plugin/tests/rules/block-spacing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,49 @@ ruleTester.run('block-spacing', rule, {
);
}),
),

// With block comments
...typeDeclarations.flatMap<InvalidBlockSpacingTestCase>(typeDec => {
const property =
typeDec.nodeType === AST_NODE_TYPES.TSEnumDeclaration
? 'bar = 1'
: 'bar: true;';
return [
{
code: `${typeDec.stringPrefix}{ /* comment */ ${property} /* comment */ } /* never */`,
output: `${typeDec.stringPrefix}{/* comment */ ${property} /* comment */} /* never */`,
options: ['never'],
errors: [
{
type: typeDec.nodeType,
messageId: 'extra',
data: { location: 'after', token: '{' },
},
{
type: typeDec.nodeType,
messageId: 'extra',
data: { location: 'before', token: '}' },
},
],
},
{
code: `${typeDec.stringPrefix}{/* comment */ ${property} /* comment */} /* always */`,
output: `${typeDec.stringPrefix}{ /* comment */ ${property} /* comment */ } /* always */`,
options: ['always'],
errors: [
{
type: typeDec.nodeType,
messageId: 'missing',
data: { location: 'after', token: '{' },
},
{
type: typeDec.nodeType,
messageId: 'missing',
data: { location: 'before', token: '}' },
},
],
},
];
}),
],
});

0 comments on commit 415733a

Please sign in to comment.