代码拉取完成,页面将自动刷新
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import pluginVue from 'eslint-plugin-vue';
import prettierRecommended from 'eslint-plugin-prettier/recommended';
import {
configureVueProject,
defineConfigWithVueTs,
vueTsConfigs
} from '@vue/eslint-config-typescript';
import vueConfigPrettier from '@vue/eslint-config-prettier';
configureVueProject({
// Whether to parse TypeScript syntax in Vue templates.
// Defaults to `true`.
// Setting it to `false` could improve performance.
// But TypeScript syntax in Vue templates will then lead to syntax errors.
// Also, type-aware rules won't be applied to expressions in templates in that case.
tsSyntaxInTemplates: true,
// Optional: specify the script langs in `.vue` files
// Defaults to `['ts']`.
scriptLangs: [
'ts',
// [!DISCOURAGED]
// Include 'js' to allow plain `<script>` or `<script setup>` blocks.
// This might result-in false positive or negatives in some rules for `.vue` files.
// Note you also need to configure `allowJs: true` and `checkJs: true`
// in corresponding `tsconfig.json` files.
'js',
// [!STRONGLY DISCOURAGED]
// Include 'tsx' to allow `<script lang="tsx">` blocks.
// This would be in conflict with all type-aware rules.
'tsx',
// [!STRONGLY DISCOURAGED]
// Include 'jsx' to allow `<script lang="jsx">` blocks.
// This would be in conflict with all type-aware rules and may result in false positives.
'jsx'
],
// <https://github.com/vuejs/eslint-plugin-vue/issues/1910#issuecomment-1819993961>
// Optional: the root directory to resolve the `.vue` files, defaults to `process.cwd()`.
// You may need to set this to the root directory of your project if you have a monorepo.
// This is useful when you allow any other languages than `ts` in `.vue` files.
// Our config helper would resolve and parse all the `.vue` files under `rootDir`,
// and only apply the loosened rules to the files that do need them.
rootDir: import.meta.dirname
});
/** @type {import('eslint').Linter.Config[]} */
export default defineConfigWithVueTs(
{ files: ['**/*.{js,mjs,cjs,ts,vue}'] },
{
languageOptions: {
globals: globals.browser,
ecmaVersion: 12,
sourceType: 'module',
parserOptions: {
parser: tseslint.parser
}
}
},
// js
pluginJs.configs.recommended,
{
rules: {
'no-unused-vars': 'off',
'no-undef': 'off'
}
},
// ts
...tseslint.configs.recommended,
{
rules: {
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-explicit-any': 'warn'
}
},
// vue
...pluginVue.configs['flat/essential'],
vueTsConfigs.recommended,
{
files: ['**/*.vue'],
languageOptions: { parserOptions: { parser: tseslint.parser } }
},
{
rules: {
...vueConfigPrettier.rules,
'prettier/prettier': [
'warn',
{
singleQuote: true
}
],
'vue/multi-word-component-names': 'off',
'vue/attribute-hyphenation': 'off',
'vue/no-v-html': 'off',
'vue/v-on-event-hyphenation': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-explicit-any': 'off'
}
},
{
ignores: ['node_modules', '/dist', '.idea', '.vscode']
},
// prettier
prettierRecommended,
{
rules: {
'prettier/prettier': ['warn', { singleQuote: true }]
}
}
);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。