/** * @author Yosuke Ota * See LICENSE file in root directory for full license. */ 'use strict' const utils = require('../../utils/index') module.exports = { supported: '>=3.3.0', /** @param {RuleContext} context @returns {RuleListener} */ createScriptVisitor(context) { const sourceCode = context.getSourceCode() return utils.defineScriptSetupVisitor(context, { onDefineOptionsEnter(node) { context.report({ node, messageId: 'forbiddenDefineOptions', fix(fixer) { return fix(fixer, node) } }) } }) /** * @param {RuleFixer} fixer * @param {CallExpression} node defineOptions() node */ function fix(fixer, node) { if (node.arguments.length === 0) return null const scriptSetup = utils.getScriptSetupElement(context) if (!scriptSetup) return null if ( scriptSetup.parent.children .filter(utils.isVElement) .some( (node) => node.name === 'script' && !utils.hasAttribute(node, 'setup') ) ) { // has `\n` ), fixer.removeRange(removeRange) ] } } }