|
| 1 | +// SPDX-FileCopyrightText: 2026 LibreCode coop and contributors |
| 2 | +// SPDX-License-Identifier: AGPL-3.0-or-later |
| 3 | + |
| 4 | +const js = require('@eslint/js') |
| 5 | +const globals = require('globals') |
| 6 | +const vue = require('eslint-plugin-vue') |
| 7 | +const tsPlugin = require('@typescript-eslint/eslint-plugin') |
| 8 | +const tsParser = require('@typescript-eslint/parser') |
| 9 | +const vueParser = require('vue-eslint-parser') |
| 10 | +const vitest = require('eslint-plugin-vitest') |
| 11 | + |
| 12 | +const vitestGlobals = { |
| 13 | + afterAll: 'readonly', |
| 14 | + afterEach: 'readonly', |
| 15 | + beforeAll: 'readonly', |
| 16 | + beforeEach: 'readonly', |
| 17 | + describe: 'readonly', |
| 18 | + expect: 'readonly', |
| 19 | + it: 'readonly', |
| 20 | + test: 'readonly', |
| 21 | + vi: 'readonly', |
| 22 | +} |
| 23 | + |
| 24 | +module.exports = [ |
| 25 | + { |
| 26 | + ignores: ['dist/**', 'dist-demo/**', 'node_modules/**', '.eslintrc.js'], |
| 27 | + }, |
| 28 | + js.configs.recommended, |
| 29 | + { |
| 30 | + files: ['**/*.{ts,vue}'], |
| 31 | + languageOptions: { |
| 32 | + parser: vueParser, |
| 33 | + parserOptions: { |
| 34 | + parser: tsParser, |
| 35 | + ecmaVersion: 2021, |
| 36 | + sourceType: 'module', |
| 37 | + }, |
| 38 | + globals: { |
| 39 | + ...globals.browser, |
| 40 | + ...globals.es2021, |
| 41 | + }, |
| 42 | + }, |
| 43 | + plugins: { |
| 44 | + vue, |
| 45 | + '@typescript-eslint': tsPlugin, |
| 46 | + }, |
| 47 | + rules: { |
| 48 | + ...vue.configs['flat/essential'].rules, |
| 49 | + ...tsPlugin.configs.recommended.rules, |
| 50 | + 'no-undef': 'off', |
| 51 | + '@typescript-eslint/no-explicit-any': 'off', |
| 52 | + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', |
| 53 | + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', |
| 54 | + }, |
| 55 | + }, |
| 56 | + { |
| 57 | + files: ['eslint.config.js', '**/*.config.js', '**/*.config.cjs', 'postcss.config.js'], |
| 58 | + languageOptions: { |
| 59 | + globals: { |
| 60 | + ...globals.node, |
| 61 | + ...globals.es2021, |
| 62 | + }, |
| 63 | + sourceType: 'script', |
| 64 | + }, |
| 65 | + rules: { |
| 66 | + 'no-undef': 'off', |
| 67 | + }, |
| 68 | + }, |
| 69 | + { |
| 70 | + files: ['vite.config.ts', 'vitest.config.ts'], |
| 71 | + languageOptions: { |
| 72 | + globals: { |
| 73 | + ...globals.node, |
| 74 | + ...globals.es2021, |
| 75 | + }, |
| 76 | + }, |
| 77 | + }, |
| 78 | + { |
| 79 | + files: ['tests/**/*.ts'], |
| 80 | + plugins: { |
| 81 | + vitest, |
| 82 | + }, |
| 83 | + languageOptions: { |
| 84 | + globals: { |
| 85 | + ...globals.browser, |
| 86 | + ...globals.es2021, |
| 87 | + ...vitestGlobals, |
| 88 | + }, |
| 89 | + }, |
| 90 | + rules: { |
| 91 | + ...(vitest.configs?.recommended?.rules || {}), |
| 92 | + }, |
| 93 | + }, |
| 94 | +] |
0 commit comments