script-indent.js 1.6 KB

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