eslint.config.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. const js = require('@eslint/js');
  2. const vue = require('eslint-plugin-vue');
  3. const globals = require('globals');
  4. module.exports = [
  5. // Base JavaScript configuration
  6. js.configs.recommended,
  7. // Vue.js configuration for Vue 2
  8. ...vue.configs['flat/essential'],
  9. {
  10. files: ['**/*.{js,vue}'],
  11. languageOptions: {
  12. ecmaVersion: 2022,
  13. sourceType: 'module',
  14. globals: {
  15. ...globals.browser,
  16. ...globals.node,
  17. // Laravel Mix globals
  18. mix: 'readonly',
  19. // jQuery and Bootstrap globals
  20. $: 'readonly',
  21. jQuery: 'readonly',
  22. bootstrap: 'readonly',
  23. // Laravel Echo
  24. Echo: 'readonly',
  25. // Common browser APIs
  26. process: 'readonly'
  27. }
  28. },
  29. rules: {
  30. // Vue-specific rules for Vue 2
  31. 'vue/multi-word-component-names': 'off',
  32. 'vue/no-v-model-argument': 'off',
  33. 'vue/no-multiple-template-root': 'error',
  34. // General JavaScript rules
  35. 'no-console': 'warn',
  36. 'no-debugger': 'warn',
  37. 'no-unused-vars': ['error', {
  38. argsIgnorePattern: '^_',
  39. varsIgnorePattern: '^_'
  40. }],
  41. 'prefer-const': 'error',
  42. 'no-var': 'error',
  43. // Code style
  44. 'indent': ['error', 2],
  45. 'quotes': ['error', 'single'],
  46. 'semi': ['error', 'always'],
  47. 'comma-dangle': ['error', 'never'],
  48. 'object-curly-spacing': ['error', 'always'],
  49. 'array-bracket-spacing': ['error', 'never'],
  50. // Best practices
  51. 'eqeqeq': 'error',
  52. 'no-eval': 'error',
  53. 'no-implied-eval': 'error',
  54. 'no-new-func': 'error'
  55. }
  56. },
  57. // Specific configuration for Vue files
  58. {
  59. files: ['**/*.vue'],
  60. rules: {
  61. 'vue/html-indent': ['error', 2],
  62. 'vue/html-self-closing': ['error', {
  63. html: {
  64. void: 'never',
  65. normal: 'any',
  66. component: 'always'
  67. }
  68. }],
  69. 'vue/max-attributes-per-line': ['error', {
  70. singleline: 3,
  71. multiline: 1
  72. }]
  73. }
  74. },
  75. // Configuration for Laravel Mix and build files
  76. {
  77. files: ['webpack.mix.js', 'webpack.config.js'],
  78. languageOptions: {
  79. globals: {
  80. ...globals.node
  81. }
  82. },
  83. rules: {
  84. 'no-console': 'off'
  85. }
  86. },
  87. // Ignore patterns
  88. {
  89. ignores: [
  90. 'node_modules/**',
  91. 'vendor/**',
  92. 'public/js/**',
  93. 'public/css/**',
  94. 'storage/**',
  95. 'bootstrap/cache/**',
  96. '.ddev/**'
  97. ]
  98. }
  99. ];