From 922535b68cef552620b573133b84c03fa73177ef Mon Sep 17 00:00:00 2001 From: ota-meshi Date: Sat, 13 May 2023 10:24:09 +0900 Subject: [PATCH] Add support for `defineOptions` to `vue/order-in-components` rule --- lib/rules/order-in-components.js | 16 ++++++++-- tests/lib/rules/order-in-components.js | 41 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/lib/rules/order-in-components.js b/lib/rules/order-in-components.js index cf9dba9d4..50e270625 100644 --- a/lib/rules/order-in-components.js +++ b/lib/rules/order-in-components.js @@ -334,8 +334,18 @@ module.exports = { } } - return utils.executeOnVue(context, (obj) => { - checkOrder(obj.properties) - }) + return utils.compositingVisitors( + utils.executeOnVue(context, (obj) => { + checkOrder(obj.properties) + }), + utils.defineScriptSetupVisitor(context, { + onDefineOptionsEnter(node) { + if (node.arguments.length === 0) return + const define = node.arguments[0] + if (define.type !== 'ObjectExpression') return + checkOrder(define.properties) + } + }) + ) } } diff --git a/tests/lib/rules/order-in-components.js b/tests/lib/rules/order-in-components.js index 873df3b0f..b12c41a33 100644 --- a/tests/lib/rules/order-in-components.js +++ b/tests/lib/rules/order-in-components.js @@ -165,6 +165,19 @@ ruleTester.run('order-in-components', rule, { new Vue() `, parserOptions: { ecmaVersion: 6 } + }, + { + filename: 'example.vue', + code: ` + + `, + parser: require.resolve('vue-eslint-parser'), + parserOptions } ], @@ -943,6 +956,34 @@ ruleTester.run('order-in-components', rule, { line: 5 } ] + }, + { + filename: 'example.vue', + code: ` + + `, + parser: require.resolve('vue-eslint-parser'), + parserOptions, + output: ` + + `, + errors: [ + { + message: + 'The "name" property should be above the "inheritAttrs" property on line 4.', + line: 5 + } + ] } ] })