Skip to content

Commit

Permalink
fix(order-in-components): allow autofix with TypeScript PropType (#1955)
Browse files Browse the repository at this point in the history
  • Loading branch information
acupofspirt committed Sep 2, 2022
1 parent 446ecca commit 2f55173
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rules/order-in-components.js
Expand Up @@ -171,7 +171,9 @@ function isNotSideEffectsNode(node, visitorKeys) {
node.type === 'Literal' ||
// es2015
node.type === 'ArrowFunctionExpression' ||
node.type === 'TemplateElement'
node.type === 'TemplateElement' ||
// typescript
node.type === 'TSAsExpression'
) {
skipNode = node
} else if (
Expand Down
35 changes: 35 additions & 0 deletions tests/lib/rules/order-in-components.js
Expand Up @@ -908,6 +908,41 @@ ruleTester.run('order-in-components', rule, {
line: 15
}
]
},
{
filename: 'example.vue',
code: `
<script lang="ts">
export default {
setup () {},
props: {
foo: { type: Array as PropType<number[]> },
},
};
</script>
`,
parser: require.resolve('vue-eslint-parser'),
parserOptions: {
...parserOptions,
parser: { ts: require.resolve('@typescript-eslint/parser') }
},
output: `
<script lang="ts">
export default {
props: {
foo: { type: Array as PropType<number[]> },
},
setup () {},
};
</script>
`,
errors: [
{
message:
'The "props" property should be above the "setup" property on line 4.',
line: 5
}
]
}
]
})

0 comments on commit 2f55173

Please sign in to comment.