script-indent.js 1.6 KB

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