index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. module.exports = {
  2. env: {
  3. browser: true,
  4. node: true,
  5. 'jest/globals': true
  6. },
  7. extends: [
  8. 'standard',
  9. 'plugin:import/errors',
  10. 'plugin:import/warnings',
  11. 'plugin:vue/recommended'
  12. ],
  13. plugins: [
  14. 'jest',
  15. 'unicorn',
  16. 'vue'
  17. ],
  18. settings: {
  19. 'import/resolver': {
  20. node: { extensions: ['.js', '.mjs'] }
  21. }
  22. },
  23. rules: {
  24. /**********************/
  25. /* General Code Rules */
  26. /**********************/
  27. // Enforce import order
  28. 'import/order': 'error',
  29. // Imports should come first
  30. 'import/first': 'error',
  31. // Other import rules
  32. 'import/no-mutable-exports': 'error',
  33. // Allow unresolved imports
  34. 'import/no-unresolved': 'off',
  35. // Allow paren-less arrow functions only when there's no braces
  36. 'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
  37. // Allow async-await
  38. 'generator-star-spacing': 'off',
  39. // Allow debugger during development
  40. 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
  41. 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
  42. // Prefer const over let
  43. 'prefer-const': ['error', {
  44. destructuring: 'any',
  45. ignoreReadBeforeAssign: false
  46. }],
  47. // No single if in an "else" block
  48. 'no-lonely-if': 'error',
  49. // Force curly braces for control flow,
  50. // including if blocks with a single statement
  51. curly: ['error', 'all'],
  52. // No async function without await
  53. 'require-await': 'error',
  54. // Force dot notation when possible
  55. 'dot-notation': 'error',
  56. 'no-var': 'error',
  57. // Force object shorthand where possible
  58. 'object-shorthand': 'error',
  59. // No useless destructuring/importing/exporting renames
  60. 'no-useless-rename': 'error',
  61. /**********************/
  62. /* Unicorn Rules */
  63. /**********************/
  64. // Pass error message when throwing errors
  65. 'unicorn/error-message': 'error',
  66. // Uppercase regex escapes
  67. 'unicorn/escape-case': 'error',
  68. // Array.isArray instead of instanceof
  69. 'unicorn/no-array-instanceof': 'error',
  70. // Prevent deprecated `new Buffer()`
  71. 'unicorn/no-new-buffer': 'error',
  72. // Keep regex literals safe!
  73. 'unicorn/no-unsafe-regex': 'off',
  74. // Lowercase number formatting for octal, hex, binary (0x12 instead of 0X12)
  75. 'unicorn/number-literal-case': 'error',
  76. // ** instead of Math.pow()
  77. 'unicorn/prefer-exponentiation-operator': 'error',
  78. // includes over indexOf when checking for existence
  79. 'unicorn/prefer-includes': 'error',
  80. // String methods startsWith/endsWith instead of more complicated stuff
  81. 'unicorn/prefer-starts-ends-with': 'error',
  82. // textContent instead of innerText
  83. 'unicorn/prefer-text-content': 'error',
  84. // Enforce throwing type error when throwing error while checking typeof
  85. 'unicorn/prefer-type-error': 'error',
  86. // Use new when throwing error
  87. 'unicorn/throw-new-error': 'error',
  88. /**********************/
  89. /* Vue Rules */
  90. /**********************/
  91. // Disable template errors regarding invalid end tags
  92. 'vue/no-parsing-error': ['error', {
  93. 'x-invalid-end-tag': false
  94. }],
  95. // Maximum 5 attributes per line instead of one
  96. 'vue/max-attributes-per-line': ['error', {
  97. singleline: 5
  98. }]
  99. }
  100. }