no-export-in-script-setup.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * @author Yosuke Ota
  3. * See LICENSE file in root directory for full license.
  4. */
  5. 'use strict'
  6. const utils = require('../utils')
  7. module.exports = {
  8. meta: {
  9. type: 'problem',
  10. docs: {
  11. description: 'disallow `export` in `<script setup>`',
  12. // TODO Switch in the major version.
  13. // categories: ['vue3-essential'],
  14. categories: undefined,
  15. url: 'https://eslint.vuejs.org/rules/no-export-in-script-setup.html'
  16. },
  17. fixable: null,
  18. schema: [],
  19. messages: {
  20. forbidden: '`<script setup>` cannot contain ES module exports.'
  21. }
  22. },
  23. /** @param {RuleContext} context */
  24. create(context) {
  25. /** @param {ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration} node */
  26. function report(node) {
  27. context.report({
  28. node,
  29. messageId: 'forbidden'
  30. })
  31. }
  32. return utils.defineScriptSetupVisitor(context, {
  33. ExportAllDeclaration: report,
  34. ExportDefaultDeclaration: report,
  35. ExportNamedDeclaration: report
  36. })
  37. }
  38. }