Skip to content

Commit ac16bd5

Browse files
committed
fix test
1 parent bf75b8a commit ac16bd5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/simplify.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import * as recast from 'recast'
1313
export const equivalentSimplified = (left: string, right: string) => {
1414
if (left === right) return true
1515
if (/\S/.test(left) !== /\S/.test(right)) return false // if one is just whitespace but the other isn't, don't consider them equivalent
16+
17+
// hack, we're going to strip out comments but hash directives are important
18+
const startDirectives = [left, right].map(line => `${line.trim()}\n`.match(/^\/\/ codegen:.*\n/)?.[0])
19+
if (startDirectives.some(Boolean) && startDirectives[0] !== startDirectives[1]) return false
20+
1621
try {
1722
return simplifyCode(left) === simplifyCode(right)
1823
} catch {

test/rule.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ tester.run('codegen', codegen.rules.codegen, {
8787
// codegen:start {preset: doesNotExist}
8888
// codegen:end
8989
`,
90-
errors: [{message: /unknown preset doesNotExist. Available presets: .*/}],
90+
errors: [{message: /Unknown preset doesNotExist. Available presets: .*/}],
9191
},
9292
{
9393
name: 'invalid yaml',

0 commit comments

Comments
 (0)