Skip to content

Commit

Permalink
fix(define-macros-order): update rule to support interface/type expor…
Browse files Browse the repository at this point in the history
…t in <script lang="ts" setup/> (#2040)
  • Loading branch information
Jungzl authored Nov 19, 2022
1 parent cc1b8d9 commit 8dc3cd9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/define-macros-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function getTargetStatementPosition(scriptSetup, program) {
'TSInterfaceDeclaration',
'TSTypeAliasDeclaration',
'DebuggerStatement',
'EmptyStatement'
'EmptyStatement',
'ExportNamedDeclaration'
])

for (const [index, item] of program.body.entries()) {
Expand Down
22 changes: 22 additions & 0 deletions tests/lib/rules/define-macros-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@ tester.run('define-macros-order', rule, {
</script>
`,
options: optionsEmitsFirst
},
{
filename: 'test.vue',
code: `
<script setup lang="ts">
import { bar } from 'foo'
export interface Props {
msg?: string
labels?: string[]
}
defineEmits(['update:test'])
const props = withDefaults(defineProps<Props>(), {
msg: 'hello',
labels: () => ['one', 'two']
})
console.log('test')
</script>
`,
options: optionsEmitsFirst,
parserOptions: {
parser: require.resolve('@typescript-eslint/parser')
}
}
],
invalid: [
Expand Down

0 comments on commit 8dc3cd9

Please sign in to comment.