eslint.config.mjs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // Polyfill for structuredClone if it doesn't exist
  2. if (typeof structuredClone !== 'function') {
  3. globalThis.structuredClone = function(obj) {
  4. return JSON.parse(JSON.stringify(obj));
  5. };
  6. }
  7. import path from 'node:path'
  8. import { fileURLToPath } from 'node:url'
  9. import vue from 'eslint-plugin-vue'
  10. import typescriptEslint from '@typescript-eslint/eslint-plugin'
  11. import globals from 'globals'
  12. import parser from 'vue-eslint-parser'
  13. import js from '@eslint/js'
  14. import { FlatCompat } from '@eslint/eslintrc'
  15. import { defineConfig } from "eslint/config"
  16. const __filename = fileURLToPath(import.meta.url)
  17. const __dirname = path.dirname(__filename)
  18. const compat = new FlatCompat({
  19. baseDirectory: __dirname,
  20. recommendedConfig: js.configs.recommended,
  21. allConfig: js.configs.all,
  22. })
  23. const baseConfig = [
  24. {
  25. ignores: [
  26. '**/.nuxt',
  27. 'coverage/*',
  28. 'vendor/*',
  29. 'dist/*',
  30. 'models/models.ts',
  31. ],
  32. },
  33. ...compat.extends(
  34. '@nuxtjs/eslint-config-typescript',
  35. 'plugin:nuxt/recommended',
  36. 'eslint:recommended',
  37. 'plugin:@typescript-eslint/recommended',
  38. 'plugin:vue/vue3-recommended',
  39. 'plugin:prettier/recommended',
  40. 'plugin:you-dont-need-lodash-underscore/compatible',
  41. ),
  42. {
  43. plugins: {
  44. vue,
  45. '@typescript-eslint': typescriptEslint,
  46. },
  47. languageOptions: {
  48. globals: {
  49. ...globals.browser,
  50. ...globals.node,
  51. useRuntimeConfig: 'readonly',
  52. useAsyncData: 'readonly',
  53. navigateTo: 'readonly',
  54. computed: 'readonly',
  55. ref: 'readonly',
  56. definePageMeta: 'readonly',
  57. useRouter: 'readonly',
  58. useRoute: 'readonly',
  59. useI18n: 'readonly',
  60. onMounted: 'readonly',
  61. onUnmounted: 'readonly',
  62. watch: 'readonly',
  63. useRepo: 'readonly',
  64. },
  65. parser,
  66. ecmaVersion: 2020,
  67. sourceType: 'module',
  68. parserOptions: {
  69. parser: '@typescript-eslint/parser',
  70. tsconfigRootDir: __dirname,
  71. },
  72. },
  73. rules: {
  74. 'no-console': 0,
  75. 'vue/valid-v-slot': [
  76. 'error',
  77. {
  78. allowModifiers: true,
  79. },
  80. ],
  81. 'vue/multi-word-component-names': 0,
  82. '@typescript-eslint/no-inferrable-types': 0,
  83. },
  84. },
  85. ]
  86. // Directory-specific configurations
  87. baseConfig.push(
  88. {
  89. files: ['layouts/**/*.vue'],
  90. rules: {
  91. 'vue/multi-word-component-names': 0,
  92. },
  93. },
  94. {
  95. files: ['pages/**/*.vue'],
  96. rules: {
  97. 'vue/multi-word-component-names': 0,
  98. },
  99. },
  100. {
  101. files: ['tests/**/*'],
  102. rules: {
  103. '@typescript-eslint/ban-ts-comment': 0,
  104. '@typescript-eslint/no-unused-vars': 0,
  105. '@typescript-eslint/no-explicit-any': 0,
  106. 'require-await': 0,
  107. },
  108. }
  109. )
  110. export default defineConfig(baseConfig)