mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-05-21 05:25:45 +08:00
🔧 Eslint v9
This commit is contained in:
95
eslint/jsonEslint.js
Normal file
95
eslint/jsonEslint.js
Normal file
@@ -0,0 +1,95 @@
|
||||
import eslint_jsonc from "eslint-plugin-jsonc";
|
||||
import jsonc_parser from "jsonc-eslint-parser";
|
||||
|
||||
const pkgJsonConfig = {
|
||||
files: ["package.json"],
|
||||
plugins: {
|
||||
jsonc: eslint_jsonc,
|
||||
},
|
||||
languageOptions: {
|
||||
parser: jsonc_parser,
|
||||
},
|
||||
rules: {
|
||||
"jsonc/comma-dangle": ["error", "never"],
|
||||
"jsonc/sort-keys": [
|
||||
"error",
|
||||
{
|
||||
pathPattern: "^$",
|
||||
order: [
|
||||
"name",
|
||||
"version",
|
||||
"description",
|
||||
"type",
|
||||
"packageManager",
|
||||
"scripts",
|
||||
"lint-staged",
|
||||
"keywords",
|
||||
"author",
|
||||
"license",
|
||||
"respository",
|
||||
"homepage",
|
||||
"bugs",
|
||||
"dependencies",
|
||||
"devDependencies",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const tscJsonConfig = {
|
||||
files: ["tsconfig.json"],
|
||||
plugins: {
|
||||
jsonc: eslint_jsonc,
|
||||
},
|
||||
languageOptions: {
|
||||
parser: jsonc_parser,
|
||||
},
|
||||
rules: {
|
||||
"jsonc/comma-dangle": ["error", "never"],
|
||||
"jsonc/sort-keys": [
|
||||
"error",
|
||||
{
|
||||
pathPattern: "^$",
|
||||
order: [
|
||||
"compilerOptions",
|
||||
"include",
|
||||
"exclude",
|
||||
"extends",
|
||||
"files",
|
||||
"references",
|
||||
"typeAcquisition",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const jsoncConfig = {
|
||||
files: ["source/data/out/**/*.json"],
|
||||
plugins: {
|
||||
jsonc: eslint_jsonc,
|
||||
},
|
||||
languageOptions: {
|
||||
parser: jsonc_parser,
|
||||
},
|
||||
rules: {
|
||||
"jsonc/comma-dangle": ["error", "never"],
|
||||
"jsonc/sort-keys": [
|
||||
"error",
|
||||
{
|
||||
pathPattern: "^$",
|
||||
order: {
|
||||
type: "asc",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const jsonEslintConfig = [
|
||||
...eslint_jsonc.configs["flat/recommended-with-json"],
|
||||
pkgJsonConfig,
|
||||
tscJsonConfig,
|
||||
jsoncConfig,
|
||||
];
|
||||
86
eslint/vueEslint.js
Normal file
86
eslint/vueEslint.js
Normal file
@@ -0,0 +1,86 @@
|
||||
import eslint_js from "@eslint/js";
|
||||
import eslint_ts from "typescript-eslint";
|
||||
import eslint_vue from "eslint-plugin-vue";
|
||||
import eslint_prettier from "eslint-plugin-prettier";
|
||||
import eslint_import from "eslint-plugin-import";
|
||||
import vue_parser from "vue-eslint-parser";
|
||||
import pluginVue from "eslint-plugin-vue";
|
||||
import globals from "globals";
|
||||
|
||||
const tsConfigRules = {
|
||||
"@typescript-eslint/consistent-type-assertions": [
|
||||
"error",
|
||||
{
|
||||
assertionStyle: "angle-bracket",
|
||||
},
|
||||
],
|
||||
"@typescript-eslint/no-import-type-side-effects": "error",
|
||||
"@typescript-eslint/strict-boolean-expressions": "error",
|
||||
"import/order": [
|
||||
"error",
|
||||
{
|
||||
groups: ["builtin", "external", "internal", "parent", "sibling", "index", "unknown"],
|
||||
"newlines-between": "always",
|
||||
alphabetize: {
|
||||
order: "asc",
|
||||
caseInsensitive: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
"prettier/prettier": "error",
|
||||
};
|
||||
|
||||
const tsConfig = {
|
||||
files: ["*.ts"],
|
||||
plugins: {
|
||||
typescript: eslint_ts,
|
||||
import: eslint_import,
|
||||
prettier: eslint_prettier,
|
||||
},
|
||||
languageOptions: {
|
||||
parser: eslint_ts.parser,
|
||||
parserOptions: {
|
||||
project: "tsconfig.json",
|
||||
tsconfigRootDir: ".",
|
||||
},
|
||||
},
|
||||
rules: tsConfigRules,
|
||||
};
|
||||
|
||||
const vueConfig = {
|
||||
plugins: {
|
||||
vue: eslint_vue,
|
||||
import: eslint_import,
|
||||
prettier: eslint_prettier,
|
||||
},
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.es2021,
|
||||
TGApp: "readonly",
|
||||
window: "readonly",
|
||||
},
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
parser: vue_parser,
|
||||
parserOptions: {
|
||||
project: "tsconfig.json",
|
||||
parser: eslint_ts.parser,
|
||||
extraFileExtensions: [".vue"],
|
||||
tsconfigRootDir: ".",
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
...tsConfigRules,
|
||||
"vue/multi-word-component-names": "off",
|
||||
},
|
||||
};
|
||||
|
||||
export const vueEslintConfig = [
|
||||
eslint_js.configs.recommended,
|
||||
...eslint_ts.configs.recommended,
|
||||
...eslint_vue.configs["flat/essential"],
|
||||
...pluginVue.configs["flat/essential"],
|
||||
tsConfig,
|
||||
vueConfig,
|
||||
];
|
||||
33
eslint/ymlEslint.js
Normal file
33
eslint/ymlEslint.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import eslint_yml from "eslint-plugin-yml";
|
||||
import yml_parser from "yaml-eslint-parser";
|
||||
import eslint_import from "eslint-plugin-import";
|
||||
|
||||
const ymlEslintConfig = {
|
||||
files: ["*.yaml", "*.yml"],
|
||||
plugins: {
|
||||
yml: eslint_yml,
|
||||
import: eslint_import,
|
||||
},
|
||||
languageOptions: {
|
||||
parser: yml_parser,
|
||||
parserOptions: {
|
||||
defaultYAMLVersion: "1.2",
|
||||
project: "./tsconfig.json",
|
||||
extraFileExtensions: [".yaml", ".yml"],
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
"yml/indent": ["error", 2],
|
||||
"yml/key-spacing": ["error"],
|
||||
"yml/quotes": [
|
||||
"error",
|
||||
{
|
||||
prefer: "double",
|
||||
avoidEscape: true,
|
||||
},
|
||||
],
|
||||
"yml/sort-keys": ["error", "asc"],
|
||||
},
|
||||
};
|
||||
|
||||
export default ymlEslintConfig;
|
||||
Reference in New Issue
Block a user