script-indent.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @author Toru Nagashima
  3. * See LICENSE file in root directory for full license.
  4. */
  5. 'use strict'
  6. const indentCommon = require('../utils/indent-common')
  7. module.exports = {
  8. meta: {
  9. type: 'layout',
  10. docs: {
  11. description: 'enforce consistent indentation in `<script>`',
  12. categories: undefined,
  13. url: 'https://eslint.vuejs.org/rules/script-indent.html'
  14. },
  15. fixable: 'whitespace',
  16. schema: [
  17. {
  18. anyOf: [{ type: 'integer', minimum: 1 }, { enum: ['tab'] }]
  19. },
  20. {
  21. type: 'object',
  22. properties: {
  23. baseIndent: { type: 'integer', minimum: 0 },
  24. switchCase: { type: 'integer', minimum: 0 },
  25. ignores: {
  26. type: 'array',
  27. items: {
  28. allOf: [
  29. { type: 'string' },
  30. { not: { type: 'string', pattern: ':exit$' } },
  31. { not: { type: 'string', pattern: '^\\s*$' } }
  32. ]
  33. },
  34. uniqueItems: true,
  35. additionalItems: false
  36. }
  37. },
  38. additionalProperties: false
  39. }
  40. ]
  41. },
  42. /** @param {RuleContext} context */
  43. create(context) {
  44. return indentCommon.defineVisitor(context, context.getSourceCode(), {})
  45. }
  46. }