feat: 接入eslint
This commit is contained in:
parent
3f220f7943
commit
a4555ac862
@ -1,13 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "ci_monitor",
|
"name": "ci_monitor",
|
||||||
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",
|
"image": "mcr.microsoft.com/devcontainers/typescript-node:20",
|
||||||
"customizations": {
|
"customizations": {
|
||||||
"vscode": {
|
"vscode": {
|
||||||
"settings": {
|
"settings": {
|
||||||
"files.autoSave": "afterDelay",
|
"files.autoSave": "afterDelay",
|
||||||
"editor.guides.bracketPairs": true,
|
"editor.guides.bracketPairs": true,
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
"editor.formatOnSave": true
|
"editor.formatOnSave": true,
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.fixAll.eslint": "always"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"extensions": [
|
"extensions": [
|
||||||
"eamodio.gitlens",
|
"eamodio.gitlens",
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
import moment from "moment";
|
||||||
|
|
||||||
import db from "../../db";
|
import db from "../../db";
|
||||||
import service from "../../service";
|
import service from "../../service";
|
||||||
import moment from "moment";
|
|
||||||
import { Gitlab } from "../../types/gitlab";
|
|
||||||
import { DB } from "../../types/db";
|
import { DB } from "../../types/db";
|
||||||
|
import { Gitlab } from "../../types/gitlab";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取全部的pipeline列表
|
* 获取全部的pipeline列表
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import project from "./project";
|
|
||||||
import pipeline from "./pipeline";
|
import pipeline from "./pipeline";
|
||||||
|
import project from "./project";
|
||||||
import user from "./user";
|
import user from "./user";
|
||||||
import view from "./view";
|
import view from "./view";
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import pbClient from "../pbClient";
|
|
||||||
import { managePb404 } from "../../utils/pbTools";
|
|
||||||
import { DB } from "../../types/db";
|
import { DB } from "../../types/db";
|
||||||
|
import { managePb404 } from "../../utils/pbTools";
|
||||||
|
import pbClient from "../pbClient";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过其 ID 检索一个管道。
|
* 通过其 ID 检索一个管道。
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
import { DB } from "../../types/db";
|
||||||
import { managePb404 } from "../../utils/pbTools";
|
import { managePb404 } from "../../utils/pbTools";
|
||||||
import pbClient from "../pbClient";
|
import pbClient from "../pbClient";
|
||||||
import { DB } from "../../types/db";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过其 ID 检索单个项目。
|
* 通过其 ID 检索单个项目。
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
import { DB } from "../../types/db";
|
||||||
import { managePb404 } from "../../utils/pbTools";
|
import { managePb404 } from "../../utils/pbTools";
|
||||||
import pbClient from "../pbClient";
|
import pbClient from "../pbClient";
|
||||||
import { DB } from "../../types/db";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据提供的ID从数据库检索单个用户。
|
* 根据提供的ID从数据库检索单个用户。
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
import { DB } from "../../types/db";
|
||||||
import { managePb404 } from "../../utils/pbTools";
|
import { managePb404 } from "../../utils/pbTools";
|
||||||
import pbClient from "../pbClient";
|
import pbClient from "../pbClient";
|
||||||
import { DB } from "../../types/db";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据给定的周来检索完整的统计信息。
|
* 根据给定的周来检索完整的统计信息。
|
||||||
|
22
eslint.config.js
Normal file
22
eslint.config.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import pluginJs from "@eslint/js";
|
||||||
|
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
||||||
|
import globals from "globals";
|
||||||
|
import tseslint from "typescript-eslint";
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{ files: ["**/*.{js,mjs,cjs,ts}"] },
|
||||||
|
{ languageOptions: { globals: globals.browser } },
|
||||||
|
pluginJs.configs.recommended,
|
||||||
|
...tseslint.configs.recommended,
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
"simple-import-sort": simpleImportSort,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
"@typescript-eslint/no-namespace": "off",
|
||||||
|
"simple-import-sort/imports": "error",
|
||||||
|
"simple-import-sort/exports": "error",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
16
package.json
16
package.json
@ -3,20 +3,26 @@
|
|||||||
"module": "index.ts",
|
"module": "index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "bun run index.ts"
|
"start": "bun run index.ts",
|
||||||
|
"lint": "eslint --fix ."
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bun-types": "latest"
|
"@eslint/js": "^9.7.0",
|
||||||
|
"@types/lodash": "^4.14.202",
|
||||||
|
"@types/node-schedule": "^2.1.6",
|
||||||
|
"bun-types": "latest",
|
||||||
|
"eslint": "9.x",
|
||||||
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||||
|
"globals": "^15.8.0",
|
||||||
|
"typescript-eslint": "^7.17.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node-schedule": "^2.1.6",
|
|
||||||
"@types/lodash": "^4.14.202",
|
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.30.1",
|
||||||
"node-schedule": "^2.1.1",
|
"node-schedule": "^2.1.1",
|
||||||
"pocketbase": "^0.21.1"
|
"pocketbase": "^0.21.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
import { scheduleJob } from "node-schedule";
|
import { scheduleJob } from "node-schedule";
|
||||||
|
|
||||||
import manageRobot from "../controllers/manageRobot";
|
import manageRobot from "../controllers/manageRobot";
|
||||||
import syncPipLine from "./syncPipLine";
|
import syncPipLine from "./syncPipLine";
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Gitlab } from "../../types/gitlab";
|
import { Gitlab } from "../../types/gitlab";
|
||||||
|
|
||||||
export const gitlabReqWarp = async <T = any>(
|
export const gitlabReqWarp = async <T = any>(
|
||||||
func: Function,
|
func: () => Promise<T>,
|
||||||
default_value: any
|
default_value: any
|
||||||
): Promise<T> => {
|
): Promise<T> => {
|
||||||
try {
|
try {
|
||||||
|
@ -84,7 +84,9 @@ const netTool = async <T = any>({
|
|||||||
try {
|
try {
|
||||||
resText = await res.text();
|
resText = await res.text();
|
||||||
resData = JSON.parse(resText);
|
resData = JSON.parse(resText);
|
||||||
} catch {}
|
} catch {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
|
||||||
// 记录响应
|
// 记录响应
|
||||||
logResponse(res, method, headers, payload, resData || resText);
|
logResponse(res, method, headers, payload, resData || resText);
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
export const managePb404 = async <T>(dbFunc: Function): Promise<T | null> => {
|
export const managePb404 = async <T>(
|
||||||
|
dbFunc: () => Promise<T>
|
||||||
|
): Promise<T | null> => {
|
||||||
try {
|
try {
|
||||||
return await dbFunc();
|
return await dbFunc();
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user