script-indent.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. // eslint-disable-next-line eslint-plugin/prefer-message-ids
  9. meta: {
  10. type: 'layout',
  11. docs: {
  12. description: 'enforce consistent indentation in `<script>`',
  13. categories: undefined,
  14. url: 'https://eslint.vuejs.org/rules/script-indent.html'
  15. },
  16. fixable: 'whitespace',
  17. schema: [
  18. {
  19. anyOf: [{ type: 'integer', minimum: 1 }, { enum: ['tab'] }]
  20. },
  21. {
  22. type: 'object',
  23. properties: {
  24. baseIndent: { type: 'integer', minimum: 0 },
  25. switchCase: { type: 'integer', minimum: 0 },
  26. ignores: {
  27. type: 'array',
  28. items: {
  29. allOf: [
  30. { type: 'string' },
  31. { not: { type: 'string', pattern: ':exit$' } },
  32. { not: { type: 'string', pattern: '^\\s*$' } }
  33. ]
  34. },
  35. uniqueItems: true,
  36. additionalItems: false
  37. }
  38. },
  39. additionalProperties: false
  40. }
  41. ]
  42. },
  43. /** @param {RuleContext} context */
  44. create(context) {
  45. return indentCommon.defineVisitor(context, context.getSourceCode(), {})
  46. }
  47. }