script-indent.js 1.6 KB

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