| 1 |
import globals from 'globals' |
| 2 |
import path from 'node:path' |
| 3 |
import { fileURLToPath } from 'node:url' |
| 4 |
import js from '@eslint/js' |
| 5 |
import { FlatCompat } from '@eslint/eslintrc' |
| 6 |
import pluginVue from 'eslint-plugin-vue' |
| 7 |
import { |
| 8 |
defineConfigWithVueTs, |
| 9 |
vueTsConfigs, |
| 10 |
configureVueProject |
| 11 |
} from '@vue/eslint-config-typescript' |
| 12 |
|
| 13 |
const __filename = fileURLToPath(import.meta.url) |
| 14 |
const __dirname = path.dirname(__filename) |
| 15 |
const compat = new FlatCompat({ |
| 16 |
baseDirectory: __dirname, |
| 17 |
recommendedConfig: js.configs.recommended, |
| 18 |
allConfig: js.configs.all |
| 19 |
}) |
| 20 |
|
| 21 |
// Correct `scriptLangs` configuration |
| 22 |
configureVueProject({ |
| 23 |
scriptLangs: ['ts'], // Allow only TypeScript in `<script>` blocks |
| 24 |
rootDir: __dirname // Set the root directory for `.vue` files |
| 25 |
}) |
| 26 |
|
| 27 |
export default defineConfigWithVueTs([ |
| 28 |
// Add Vue's flat configuration and TypeScript configurations |
| 29 |
pluginVue.configs['flat/recommended'], // Recommended Vue rules for flat config |
| 30 |
vueTsConfigs.recommended, // Recommended TypeScript rules |
| 31 |
...compat.extends( |
| 32 |
'eslint:recommended', |
| 33 |
'@vue/eslint-config-prettier/skip-formatting' |
| 34 |
), |
| 35 |
{ |
| 36 |
// General ESLint settings |
| 37 |
ignores: ['node_modules/**', 'dist/**'], // Ignored directories |
| 38 |
files: ['**/*.js', '**/*.ts', '**/*.vue'], // Files to lint |
| 39 |
languageOptions: { |
| 40 |
globals: { |
| 41 |
...globals.node, // Node.js globals |
| 42 |
...globals.browser // Browser globals (window, document, DOM APIs) |
| 43 |
}, |
| 44 |
ecmaVersion: 'latest', // Use the latest ECMAScript version |
| 45 |
sourceType: 'module' // Set source type to ES module |
| 46 |
}, |
| 47 |
rules: { |
| 48 |
// Disable unused-vars rules globally |
| 49 |
'no-unused-vars': 'off' // Turn off the base rule |
| 50 |
} |
| 51 |
} |
| 52 |
]) |
| 53 |
|