script-indent.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // eslint-disable-next-line eslint-plugin/require-meta-fixable -- fixer is not recognized
  17. fixable: 'whitespace',
  18. schema: [
  19. {
  20. anyOf: [{ type: 'integer', minimum: 1 }, { enum: ['tab'] }]
  21. },
  22. {
  23. type: 'object',
  24. properties: {
  25. baseIndent: { type: 'integer', minimum: 0 },
  26. switchCase: { type: 'integer', minimum: 0 },
  27. ignores: {
  28. type: 'array',
  29. items: {
  30. allOf: [
  31. { type: 'string' },
  32. { not: { type: 'string', pattern: ':exit$' } },
  33. { not: { type: 'string', pattern: String.raw`^\s*$` } }
  34. ]
  35. },
  36. uniqueItems: true,
  37. additionalItems: false
  38. }
  39. },
  40. additionalProperties: false
  41. }
  42. ]
  43. },
  44. /** @param {RuleContext} context */
  45. create(context) {
  46. return indentCommon.defineVisitor(context, context.getSourceCode(), {})
  47. }
  48. }