112 lines
4.4 KiB
TypeScript
112 lines
4.4 KiB
TypeScript
import js from "@eslint/js";
|
||
import globals from "globals";
|
||
import tseslint from "typescript-eslint";
|
||
import pluginVue from "eslint-plugin-vue";
|
||
import { defineConfig } from "eslint/config";
|
||
import stylistic from "@stylistic/eslint-plugin";
|
||
|
||
export default defineConfig([
|
||
{
|
||
files: ["**/*.{js,mjs,cjs,ts,mts,cts,vue}",],
|
||
plugins: { js, },
|
||
extends: ["js/recommended",],
|
||
languageOptions: {
|
||
globals: {
|
||
...globals.browser,
|
||
...globals.node,}, },
|
||
},
|
||
tseslint.configs.recommended,
|
||
{
|
||
files: ["src/**/*.ts", "eslint.config.ts",],
|
||
plugins: {
|
||
"@stylistic": stylistic,
|
||
},
|
||
rules: {
|
||
"spaced-comment": "error",
|
||
"space-before-function-paren": "off",
|
||
"semi-spacing": ["error", {"before": false,
|
||
"after": true,},],
|
||
"@typescript-eslint/no-unused-vars": "warn",
|
||
"@stylistic/indent": ["error", 4, { SwitchCase: 1, },],
|
||
"@typescript-eslint/no-explicit-any": "off",
|
||
"@typescript-eslint/no-extra-semi": "off",
|
||
"@typescript-eslint/no-inferrable-types": "off",
|
||
"@typescript-eslint/ban-ts-comment": "warn",
|
||
"@typescript-eslint/member-delimiter-style": "off",
|
||
"@stylistic/semi": ["error", "always",], // 控制行尾部分号
|
||
"@stylistic/brace-style": ["error", "allman", { allowSingleLine: true, },],
|
||
"@stylistic/comma-dangle": [
|
||
"error",
|
||
{
|
||
arrays: "always",
|
||
objects: "always",
|
||
imports: "never",
|
||
exports: "never",
|
||
functions: "never",
|
||
},
|
||
], // 数组和对象键值对最后一个逗号
|
||
"@stylistic/quotes": ["error", "double",],
|
||
"@typescript-eslint/space-before-function-paren": "off",
|
||
"@typescript-eslint/comma-spacing": ["off", { before: false,
|
||
after: true, },], // 使用eslint的,不用ts的
|
||
// "@typescript-eslint/strict-boolean-expressions": ["error", {
|
||
// allowString: false,
|
||
// },],
|
||
"@stylistic/object-property-newline": "warn",
|
||
},
|
||
},
|
||
pluginVue.configs["flat/essential"],
|
||
pluginVue.configs["flat/strongly-recommended"],
|
||
{
|
||
files: ["**/*.vue",],
|
||
plugins: {
|
||
"@stylistic": stylistic,
|
||
},
|
||
languageOptions: {
|
||
parserOptions: { parser: tseslint.parser, },
|
||
},
|
||
rules: {
|
||
"vue/html-indent": ["error", 4,],
|
||
// "vue/max-attributes-per-line": ["error", {
|
||
// "singleline": {
|
||
// "max": 1,
|
||
// },
|
||
// "multiline": {
|
||
// "max": 1,
|
||
// },
|
||
// },],
|
||
"spaced-comment": "error",
|
||
"space-before-function-paren": "off",
|
||
"semi-spacing": ["error", {"before": false,
|
||
"after": true,},],
|
||
"@typescript-eslint/no-unused-vars": "warn",
|
||
"@stylistic/indent": ["error", 4, { SwitchCase: 1, },],
|
||
"@typescript-eslint/no-explicit-any": "off",
|
||
"@typescript-eslint/no-extra-semi": "off",
|
||
"@typescript-eslint/no-inferrable-types": "off",
|
||
"@typescript-eslint/ban-ts-comment": "warn",
|
||
"@typescript-eslint/member-delimiter-style": "off",
|
||
"@stylistic/semi": ["error", "always",], // 控制行尾部分号
|
||
"@stylistic/brace-style": ["error", "allman", { allowSingleLine: true, },],
|
||
"@stylistic/comma-dangle": [
|
||
"error",
|
||
{
|
||
arrays: "always",
|
||
objects: "always",
|
||
imports: "never",
|
||
exports: "never",
|
||
functions: "never",
|
||
},
|
||
], // 数组和对象键值对最后一个逗号
|
||
"@stylistic/quotes": ["error", "double",],
|
||
"@typescript-eslint/space-before-function-paren": "off",
|
||
"@typescript-eslint/comma-spacing": ["off", { before: false,
|
||
after: true, },], // 使用eslint的,不用ts的
|
||
// "@typescript-eslint/strict-boolean-expressions": ["error", {
|
||
// allowString: false,
|
||
// },],
|
||
"@stylistic/object-property-newline": "warn",
|
||
},
|
||
},
|
||
]);
|