first commit
This commit is contained in:
60
app_vue/node_modules/eslint-plugin-vue/lib/rules/no-export-in-script-setup.js
generated
vendored
Normal file
60
app_vue/node_modules/eslint-plugin-vue/lib/rules/no-export-in-script-setup.js
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @author Yosuke Ota
|
||||
* See LICENSE file in root directory for full license.
|
||||
*/
|
||||
'use strict'
|
||||
|
||||
const utils = require('../utils')
|
||||
|
||||
/**
|
||||
* @typedef {import('@typescript-eslint/types').TSESTree.ExportAllDeclaration} TSESTreeExportAllDeclaration
|
||||
* @typedef {import('@typescript-eslint/types').TSESTree.ExportDefaultDeclaration} TSESTreeExportDefaultDeclaration
|
||||
* @typedef {import('@typescript-eslint/types').TSESTree.ExportNamedDeclaration} TSESTreeExportNamedDeclaration
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'disallow `export` in `<script setup>`',
|
||||
categories: ['vue3-essential'],
|
||||
url: 'https://eslint.vuejs.org/rules/no-export-in-script-setup.html'
|
||||
},
|
||||
fixable: null,
|
||||
schema: [],
|
||||
messages: {
|
||||
forbidden: '`<script setup>` cannot contain ES module exports.'
|
||||
}
|
||||
},
|
||||
/** @param {RuleContext} context */
|
||||
create(context) {
|
||||
/** @param {ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration} node */
|
||||
function verify(node) {
|
||||
const tsNode =
|
||||
/** @type {TSESTreeExportAllDeclaration | TSESTreeExportDefaultDeclaration | TSESTreeExportNamedDeclaration} */ (
|
||||
node
|
||||
)
|
||||
if (tsNode.exportKind === 'type') {
|
||||
return
|
||||
}
|
||||
if (tsNode.type === 'ExportNamedDeclaration') {
|
||||
if (
|
||||
tsNode.specifiers.length > 0 &&
|
||||
tsNode.specifiers.every((spec) => spec.exportKind === 'type')
|
||||
) {
|
||||
return
|
||||
}
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'forbidden'
|
||||
})
|
||||
}
|
||||
|
||||
return utils.defineScriptSetupVisitor(context, {
|
||||
ExportAllDeclaration: verify,
|
||||
ExportDefaultDeclaration: verify,
|
||||
ExportNamedDeclaration: verify
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user