Skip to content

Commit

Permalink
Ib add linter (#2)
Browse files Browse the repository at this point in the history
* Add eslint

* Add validate workflow
  • Loading branch information
Corb3nik authored Jan 8, 2025
1 parent 6f5e92a commit 99e105b
Show file tree
Hide file tree
Showing 15 changed files with 2,818 additions and 778 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Validate

on:
push:
branches:
- 'main'
pull_request:

env:
NODE_VERSION: 20
PNPM_VERSION: 9

jobs:
validate:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout project
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
run_install: false

- name: Install dependencies
run: pnpm install

- name: Typecheck
run: pnpm typecheck

- name: Lint
run: pnpm lint

- name: Build
run: pnpm build
9 changes: 9 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defaultConfig } from "@caido/eslint-config";

export default [
...defaultConfig({
stylistic: false,
compat: false,
}),
];

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
"typecheck": "pnpm -r typecheck",
"build": "caido-dev build",
"watch": "caido-dev watch",
"lint": "biome check --write ./packages/*/src"
"lint": "eslint --fix packages/*/src"
},
"devDependencies": {
"@caido-community/dev": "0.0.5",
"@biomejs/biome": "1.8.3",
"typescript": "5.5.4",
"tailwindcss": "3.4.13",
"tailwindcss-primeui": "0.3.4",
"@caido/eslint-config": "0.0.4",
"@caido/tailwindcss": "0.0.1",
"@vitejs/plugin-vue": "5.2.1",
"postcss-prefixwrap": "1.51.0"
"eslint": "9.17.0",
"postcss-prefixwrap": "1.51.0",
"tailwindcss": "3.4.13",
"tailwindcss-primeui": "0.3.4",
"typescript": "5.5.4"
}
}
2 changes: 1 addition & 1 deletion packages/backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DefineAPI, SDK } from "caido:plugin";

export type API = DefineAPI<{}>;
export type API = DefineAPI<never>;

export function init(sdk: SDK<API>) {}
3 changes: 1 addition & 2 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"typecheck": "vue-tsc --noEmit",
"build": "vite build"
"typecheck": "vue-tsc --noEmit"
},
"dependencies": {
"@caido/primevue": "0.1.1",
Expand Down
16 changes: 8 additions & 8 deletions packages/frontend/src/data/response.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
interface Response {
protocol: string;
uniqueId: string; // Converted to camelCase for consistency
fullId: string; // Converted to camelCase for consistency
qType: string; // Query type
rawRequest: string;
rawResponse: string;
remoteAddress: string;
timestamp: string; // Use Date type for parsing if necessary
protocol: string;
uniqueId: string; // Converted to camelCase for consistency
fullId: string; // Converted to camelCase for consistency
qType: string; // Query type
rawRequest: string;
rawResponse: string;
remoteAddress: string;
timestamp: string; // Use Date type for parsing if necessary
}
103 changes: 53 additions & 50 deletions packages/frontend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,66 @@
import { Classic } from "@caido/primevue";
import { createPinia } from "pinia";
import PrimeVue from "primevue/config";
import { createApp, ref } from "vue";

import App from "./views/App.vue";

import "./styles/index.css";

import { createPinia } from "pinia";
import { SDKPlugin } from "./plugins/sdk";
import "./styles/index.css";
import type { FrontendSDK } from "./types";
import App from "./views/App.vue";

const eventBus = new EventTarget();
export default eventBus;

// This is the entry point for the frontend plugin
export let QuickSSRFBtn: any;
export let QuickSSRFBtn: ReturnType<FrontendSDK["sidebar"]["registerItem"]>;
export const QuickSSRFBtnCount = ref(0);
export const init = (sdk: FrontendSDK) => {
const app = createApp(App);
const pinia = createPinia();
app.use(pinia);
// Load the PrimeVue component library
app.use(PrimeVue, {
unstyled: true,
pt: Classic,
});

// Provide the FrontendSDK
app.use(SDKPlugin, sdk);

// Create the root element for the app
const root = document.createElement("div");
Object.assign(root.style, {
height: "100%",
width: "100%",
});
const event = new CustomEvent("updateSelected");

// Set the ID of the root element
// We use the manifest ID to ensure that the ID is unique per-plugin
// This is necessary to prevent styling conflicts between plugins
// The value here should be the same as the prefixWrap plugin in postcss.config.js
root.id = `plugin--quickssrf`;

// Mount the app to the root element
app.mount(root);

// Add the page to the navigation
// Make sure to use a unique name for the page
sdk.navigation.addPage("/quickssrf", {
body: root,
onEnter: () => {
QuickSSRFBtnCount.value = 0;
QuickSSRFBtn.setCount(QuickSSRFBtnCount.value);
eventBus.dispatchEvent(event);
},
});

QuickSSRFBtn = sdk.sidebar.registerItem("QuickSSRF", "/quickssrf", {
icon: "fas fa-globe",
});
QuickSSRFBtn.setCount(QuickSSRFBtnCount.value);
const app = createApp(App);
const pinia = createPinia();
app.use(pinia);
// Load the PrimeVue component library
app.use(PrimeVue, {
unstyled: true,
pt: Classic,
});

// Provide the FrontendSDK
app.use(SDKPlugin, sdk);

// Create the root element for the app
const root = document.createElement("div");
Object.assign(root.style, {
height: "100%",
width: "100%",
});
const event = new CustomEvent("updateSelected");

/*
* Set the ID of the root element
* We use the manifest ID to ensure that the ID is unique per-plugin
* This is necessary to prevent styling conflicts between plugins
* The value here should be the same as the prefixWrap plugin in postcss.config.js
*/
root.id = "plugin--quickssrf";

// Mount the app to the root element
app.mount(root);

/*
* Add the page to the navigation
* Make sure to use a unique name for the page
*/
sdk.navigation.addPage("/quickssrf", {
body: root,
onEnter: () => {
QuickSSRFBtnCount.value = 0;
QuickSSRFBtn.setCount(QuickSSRFBtnCount.value);
eventBus.dispatchEvent(event);
},
});

QuickSSRFBtn = sdk.sidebar.registerItem("QuickSSRF", "/quickssrf", {
icon: "fas fa-globe",
});
QuickSSRFBtn.setCount(QuickSSRFBtnCount.value);
};
12 changes: 7 additions & 5 deletions packages/frontend/src/plugins/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { type InjectionKey, type Plugin, inject } from "vue";
import { inject, type InjectionKey, type Plugin } from "vue";

import type { FrontendSDK } from "@/types";

const KEY: InjectionKey<FrontendSDK> = Symbol("FrontendSDK");

// This is the plugin that will provide the FrontendSDK to VueJS
// To access the frontend SDK from within a component, use the `useSDK` function.
/*
* This is the plugin that will provide the FrontendSDK to VueJS
* To access the frontend SDK from within a component, use the `useSDK` function.
*/
export const SDKPlugin: Plugin = (app, sdk: FrontendSDK) => {
app.provide(KEY, sdk);
app.provide(KEY, sdk);
};

// This is the function that will be used to access the FrontendSDK from within a component.
export const useSDK = () => {
return inject(KEY) as FrontendSDK;
return inject(KEY) as FrontendSDK;
};
Loading

0 comments on commit 99e105b

Please sign in to comment.