Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .eslintignore

This file was deleted.

127 changes: 0 additions & 127 deletions .eslintrc

This file was deleted.

8 changes: 5 additions & 3 deletions .prettierrc.cjs → .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
// 一行最多 120 字符
export default {
// 一行最多 120 字符..
printWidth: 120,
// 使用 2 个空格缩进
tabWidth: 2,
Expand All @@ -17,6 +17,8 @@ module.exports = {
trailingComma: 'all',
// 大括号内的首尾需要空格
bracketSpacing: true,
// jsx 标签的反尖括号需要换行
jsxBracketSameLine: false,
// 箭头函数,只有一个参数的时候,也需要括号
arrowParens: 'always',
// 每个文件格式化的范围是文件的全部内容
Expand All @@ -33,5 +35,5 @@ module.exports = {
// vue 文件中的 script 和 style 内不用缩进
vueIndentScriptAndStyle: false,
// 换行符使用 lf
endOfLine: 'auto',
endOfLine: 'lf',
};
151 changes: 151 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import antfu from '@antfu/eslint-config';
import { globalIgnores } from 'eslint/config';
import prettier from 'eslint-plugin-prettier/recommended';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import vueCss from 'eslint-plugin-vue-scoped-css';
import globals from 'globals';
import typescript from 'typescript-eslint';

export default antfu(
{
typescript: true,
vue: true,
jsonc: false,
yaml: false,
markdown: false,
formatters: false,
},
[
...vueCss.configs['flat/recommended'],
prettier,
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest,
defineProps: 'readonly',
defineEmits: 'readonly',
},
ecmaVersion: 6,
sourceType: 'module',

parserOptions: {
parser: typescript.parser,
allowImportExportEverywhere: true,

ecmaFeatures: {
jsx: true,
},
},
},

plugins: {
'simple-import-sort': simpleImportSort,
},

settings: {
'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
},

rules: {
/* Closed due to template running
* (Recommended to open!)
*/
'no-console': 'off',
'ts/no-explicit-any': 'off',

/* Disallow person rules */
'antfu/top-level-function': 'off',
'antfu/if-newline': 'off',
'n/prefer-global/process': 'off',

/* If you need control the imports sequence, must be off
* https://github.com/vuejs/vue-eslint-parser/issues/58
*/
'import/first': 'off',

/* Allow start with _ */
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'vue/no-unused-vars': [
'error',
{
ignorePattern: '^_',
},
],
// Using ts/no-unused-vars instead
'no-unused-vars': 'off',

/* Some variables are initialized in the function */
'@typescript-eslint/no-use-before-define': 'off',
'no-use-before-define': 'off',

/* Disable antfu sort, use simple sort import */
'perfectionist/sort-imports': 'off',
'perfectionist/sort-named-imports': 'off',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
// Disable unused-imports rules in other presets
'unused-imports/no-unused-imports': 'off',
'unused-imports/no-unused-vars': 'off',
},
},
{
files: ['**/*.vue'],

rules: {
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
'vue/custom-event-name-casing': ['error', 'kebab-case'],
'vue/block-order': [
'error',
{
order: ['template', 'script', 'style'],
},
],
'vue/block-lang': [
'error',
{
script: {
lang: ['ts', 'tsx'],
},
},
],
'vue/multi-word-component-names': 'off',
'vue/no-reserved-props': 'off',
'vue/no-v-html': 'off',

'vue-scoped-css/no-parsing-error': 'off',
'vue-scoped-css/no-unused-selector': 'off',
'vue-scoped-css/enforce-style-type': [
'error',
{
allows: ['scoped'],
},
],
'vue/padding-line-between-blocks': ['error', 'never'],
},
},
globalIgnores([
'**/snapshot*',
'**/dist',
'**/lib',
'**/es',
'**/esm',
'**/node_modules',
'src/_common',
'**/static',
'**/cypress',
'script/test/cypress',
'**/_site',
'**/temp*',
'**/static/',
'!**/.prettierrc.js',
]),
],
);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"vue-router": "^4.5.0"
},
"devDependencies": {
"@antfu/eslint-config": "^4.10.1",
"@babel/preset-env": "^7.26.9",
"@types/babel__traverse": "~7.20.6",
"@types/lodash-es": "^4.17.12",
Expand Down
Loading
Loading