122 lines
3.4 KiB
TypeScript
122 lines
3.4 KiB
TypeScript
/*
|
|
MORE:
|
|
https://juejin.cn/post/7403244457263628300#heading-11
|
|
*/
|
|
import pluginVitest from '@vitest/eslint-plugin';
|
|
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting';
|
|
import { configureVueProject, defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript';
|
|
import { flatConfigs as eslintPluginImportX_flatConfigs } from 'eslint-plugin-import-x';
|
|
import oxlint from 'eslint-plugin-oxlint';
|
|
import perfectionist from 'eslint-plugin-perfectionist';
|
|
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
|
|
import pluginVue from 'eslint-plugin-vue';
|
|
|
|
// https://github.com/vuejs/eslint-config-typescript/#advanced-setup
|
|
configureVueProject({ scriptLangs: ['ts', 'tsx', 'js', 'jsx'] });
|
|
|
|
const _ignores = [
|
|
// >>>
|
|
// eslint-disable-next-line unicorn/no-await-expression-member
|
|
(await import('@eslint/compat')).includeIgnoreFile(
|
|
// eslint-disable-next-line unicorn/import-style, unicorn/no-await-expression-member
|
|
(await import('node:path')).default.resolve(import.meta.dirname, '.gitignore'),
|
|
),
|
|
// <<<
|
|
|
|
// >>>
|
|
// eslint-disable-next-line unicorn/no-await-expression-member
|
|
(await import('eslint/config')).globalIgnores([
|
|
'**/dist/**',
|
|
'**/dist-ssr/**',
|
|
'**/coverage/**',
|
|
'auto-imports.d.ts',
|
|
'components.d.ts',
|
|
'typed-router.d.ts',
|
|
// .oxlintrc.json > ignorePatterns >>>
|
|
'src/shadcn/**',
|
|
'src/components/InspiraUI/**',
|
|
'public/**',
|
|
'**/**.no-lint.ts',
|
|
'**/**.nolint.ts',
|
|
// <<< .oxlintrc.json
|
|
]),
|
|
// <<<
|
|
];
|
|
|
|
export default defineConfigWithVueTs(
|
|
{
|
|
name: 'app/files-to-lint',
|
|
files: ['**/*.{ts,mts,tsx,vue}'],
|
|
},
|
|
|
|
_ignores,
|
|
|
|
pluginVue.configs['flat/essential'],
|
|
vueTsConfigs.recommended,
|
|
|
|
{
|
|
...pluginVitest.configs.recommended,
|
|
files: ['src/**/__tests__/*'],
|
|
},
|
|
|
|
...oxlint.configs['flat/recommended'],
|
|
skipFormatting,
|
|
|
|
// region >> eslint-plugin-unicorn >>
|
|
eslintPluginUnicorn.configs.recommended,
|
|
{
|
|
rules: {
|
|
'unicorn/filename-case': 'off',
|
|
'unicorn/no-console-spaces': 'off',
|
|
'unicorn/no-null': 'off',
|
|
'unicorn/no-useless-spread': 'off',
|
|
'unicorn/prevent-abbreviations': 'off',
|
|
},
|
|
},
|
|
// endregion <<< eslint-plugin-unicorn <<<
|
|
|
|
// region >>> eslint-plugin-import-x >>>
|
|
eslintPluginImportX_flatConfigs.recommended,
|
|
{
|
|
rules: {
|
|
'import-x/no-unresolved': 'off', // https://github.com/pzmosquito/eslint-import-resolver-vite/blob/67da5e259ee4c9da4c44d81b93364ae2777d00eb/index.js#L100
|
|
'import-x/newline-after-import': 'error',
|
|
'import-x/first': 'error',
|
|
},
|
|
},
|
|
// endregion <<< eslint-plugin-import-x <<<
|
|
|
|
// region >>> eslint-plugin-perfectionist >>>
|
|
// https://perfectionist.dev/guide/getting-started
|
|
perfectionist.configs['recommended-natural'],
|
|
{
|
|
rules: {
|
|
'perfectionist/sort-classes': 'off',
|
|
'perfectionist/sort-interfaces': 'off',
|
|
'perfectionist/sort-objects': 'off',
|
|
'perfectionist/sort-imports': ['error'],
|
|
'perfectionist/sort-modules': 'off',
|
|
},
|
|
},
|
|
// endregion <<< eslint-plugin-perfectionist <<<
|
|
|
|
{
|
|
rules: {
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
'vue/block-order': [
|
|
'error',
|
|
{
|
|
order: ['script', 'template', 'style'],
|
|
},
|
|
],
|
|
'vue/define-macros-order': [
|
|
'error',
|
|
{
|
|
order: ['defineOptions', 'defineProps', 'defineEmits', 'defineSlots'],
|
|
},
|
|
],
|
|
'vue/multi-word-component-names': 'off',
|
|
},
|
|
},
|
|
);
|