Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade eslint to version 9 and flat config #222

Merged
merged 3 commits into from
Dec 24, 2024
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
5 changes: 0 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ updates:
- "vuetify"
development-dependencies:
dependency-type: "development"
exclude-patterns:
- "eslint"
- "@typescript-eslint/parser"
- "@typescript-eslint/eslint-plugin"
- "@vue/eslint-config-typescript"

- package-ecosystem: "gomod"
directory: "/"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ jobs:
- name: Lint frontend
working-directory: ./web
run: |
yarn lint
yarn run eslint
yarn prettier --check .
3 changes: 0 additions & 3 deletions web/.eslintignore

This file was deleted.

52 changes: 0 additions & 52 deletions web/.eslintrc.cjs

This file was deleted.

46 changes: 46 additions & 0 deletions web/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import globals from "globals";
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier";
import pluginVue from "eslint-plugin-vue";
import vueParser from "vue-eslint-parser";
import vueTsEslintConfig from "@vue/eslint-config-typescript";

export default tseslint.config(
{
ignores: [
"**/*.guard.ts",
"**/dist/",
"**/node_modules/",
"src/parser/query.ts",
],
},
{
extends: [
eslint.configs.recommended,
...pluginVue.configs["flat/vue2-strongly-recommended"],
...vueTsEslintConfig(),
...tseslint.configs.recommendedTypeChecked,
],
languageOptions: {
parser: vueParser,
globals: globals.browser,
parserOptions: {
ecmaVersion: 2021,
extraFileExtensions: [".vue"],
sourceType: "module",
parser: tseslint.parser,
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
files: ["**/*.{ts,vue}"],
rules: {
"no-console": "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"vue/multi-word-component-names": "off",
"vue/no-reserved-component-names": "off",
},
},
eslintConfigPrettier,
);
16 changes: 10 additions & 6 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "vite",
"build": "vite build",
"serve": "vite preview",
"lint": "eslint --ext .js,.ts,.vue --fix .",
"lint": "eslint --fix .",
"format": "prettier --check --write .",
"nearley": "nearleyc src/parser/query.ne -o src/parser/query.ts"
},
Expand All @@ -27,26 +27,30 @@
"vuetify": "^2.6.14"
},
"devDependencies": {
"@types/eslint": "^9.6.1",
"@types/moo": "^0.5.9",
"@types/nearley": "^2.11.5",
"@types/node": "^22.10.2",
"@types/vue-moment": "^4.0.7",
"@types/webpack-env": "^1.18.5",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"@typescript-eslint/eslint-plugin": "^8.18.2",
"@typescript-eslint/parser": "^8.18.2",
"@vitejs/plugin-vue2": "^2.3.3",
"@vue/eslint-config-typescript": "^13.0.0",
"eslint": "^8.57.1",
"@vue/eslint-config-typescript": "^14.1.4",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-vue": "^9.32.0",
"globals": "^15.14.0",
"prettier": "^3.4.2",
"sass": "~1.83.0",
"ts-auto-guard": "^5.0.1",
"typescript": "~5.7.2",
"typescript-eslint": "^8.18.2",
"unplugin-vue-components": "^0.28.0",
"vite": "^6.0.5",
"vite-plugin-checker": "^0.8.0",
"vite-plugin-node-polyfills": "^0.22.0"
"vite-plugin-node-polyfills": "^0.22.0",
"vue-eslint-parser": "^9.4.3"
},
"browserslist": [
"> 1%",
Expand Down
2 changes: 1 addition & 1 deletion web/src/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ const APIClient = {
if (guard(response.data)) {
return response.data;
}
throw "Unexpected response, types mismatch";
throw new Error("Unexpected response, types mismatch");
},
};

Expand Down
10 changes: 5 additions & 5 deletions web/src/components/CTFWizardDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ function createService() {
service_by_port_loading.value = false;
EventBus.emit("showMessage", `Service ${serviceName.value} created.`);
})
.catch((err: string) => {
.catch((err: Error) => {
service_by_port_error.value = true;
service_by_port_loading.value = false;
EventBus.emit("showError", err);
EventBus.emit("showError", err.message);
});
}

Expand All @@ -192,15 +192,15 @@ function createFlagTags() {
.then((res) => {
const rejected = res.filter((r) => r.status === "rejected");
if (rejected.length != 0) {
throw rejected.map((r) => r.reason as string).join("; ");
throw new Error(rejected.map((r) => r.reason as string).join("; "));
}
visible.value = false;
flag_regex_loading.value = false;
})
.catch((err: string) => {
.catch((err: Error) => {
flag_regex_error.value = true;
flag_regex_loading.value = false;
EventBus.emit("showError", err);
EventBus.emit("showError", err.message);
});
}
</script>
4 changes: 2 additions & 2 deletions web/src/components/ConverterResetDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ function resetConverterAction() {
.then(() => {
visible.value = false;
})
.catch((err: string) => {
.catch((err: Error) => {
error.value = true;
loading.value = false;
EventBus.emit("showError", err);
EventBus.emit("showError", err.message);
});
}
</script>
12 changes: 6 additions & 6 deletions web/src/components/Converters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ onMounted(() => {
});

function refreshConverters() {
store.updateTags().catch((err: string) => {
EventBus.emit("showError", `Failed to update tags: ${err}`);
store.updateTags().catch((err: Error) => {
EventBus.emit("showError", `Failed to update tags: ${err.message}`);
});
store.updateConverters().catch((err: string) => {
EventBus.emit("showError", `Failed to update converters: ${err}`);
store.updateConverters().catch((err: Error) => {
EventBus.emit("showError", `Failed to update converters: ${err.message}`);
});
}

Expand All @@ -170,8 +170,8 @@ function showErrorLog(process: ProcessStats, converter: ConverterStatistics) {
fetchStderrError.value = "Stderr is empty";
}
})
.catch((err: string | Error) => {
fetchStderrError.value = err.toString();
.catch((err: Error) => {
fetchStderrError.value = err.message;
})
.finally(() => {
loadingStderr.value = false;
Expand Down
10 changes: 5 additions & 5 deletions web/src/components/Graph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,8 @@ graphStore.$subscribe((_mutation, state) => {
theme: colorscheme,
},
} as ApexCharts.ApexOptions)
.catch((err: string) => {
EventBus.emit("showError", `Failed to update graph: ${err}`);
.catch((err: Error) => {
EventBus.emit("showError", `Failed to update graph: ${err.message}`);
});
});
chartData.value = [];
Expand All @@ -683,7 +683,7 @@ onMounted(() => {
function setChartTagOptions(typ: string, active: boolean) {
nextTick(() => {
const sel = chartTags.value;
for (var i = 0; i < sel.length; i++) {
for (let i = 0; i < sel.length; i++) {
if (sel[i].startsWith(`${typ}/`)) {
sel.splice(i--, 1);
}
Expand Down Expand Up @@ -716,8 +716,8 @@ function fetchGraphLocal() {
query as string,
type as GraphType,
)
.catch((err: string) => {
EventBus.emit("showError", `Failed to update graph: ${err}`);
.catch((err: Error) => {
EventBus.emit("showError", `Failed to update graph: ${err.message}`);
});
}
</script>
Expand Down
8 changes: 4 additions & 4 deletions web/src/components/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ onMounted(() => {
.then(() => {
if (store.tags?.length === 0) EventBus.emit("showCTFWizard");
})
.catch((err: string) => {
EventBus.emit("showError", `Failed to update tags: ${err}`);
.catch((err: Error) => {
EventBus.emit("showError", `Failed to update tags: ${err.message}`);
});
store.updateStatus().catch((err: string) => {
EventBus.emit("showError", `Failed to update status: ${err}`);
store.updateStatus().catch((err: Error) => {
EventBus.emit("showError", `Failed to update status: ${err.message}`);
});
});

Expand Down
15 changes: 9 additions & 6 deletions web/src/components/PcapOverIP.vue
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ onMounted(() => {
});

function refresh() {
store.updatePcapOverIPEndpoints().catch((err: string) => {
store.updatePcapOverIPEndpoints().catch((err: Error) => {
EventBus.emit(
"showError",
`Failed to update PCAP-over-IP endpoints: ${err}`,
`Failed to update PCAP-over-IP endpoints: ${err.message}`,
);
});
}
Expand All @@ -224,10 +224,13 @@ function add() {
newAddress.value = "";
refresh();
})
.catch((err: string) => {
.catch((err: Error) => {
addDialogLoading.value = false;
addDialogError.value = true;
EventBus.emit("showError", `Failed to add PCAP-over-IP endpoint: ${err}`);
EventBus.emit(
"showError",
`Failed to add PCAP-over-IP endpoint: ${err.message}`,
);
});
}
function del() {
Expand All @@ -240,10 +243,10 @@ function del() {
delDialogLoading.value = false;
refresh();
})
.catch((err: string) => {
.catch((err: Error) => {
EventBus.emit(
"showError",
`Failed to delete PCAP-over-IP endpoint: ${err}`,
`Failed to delete PCAP-over-IP endpoint: ${err.message}`,
);
delDialogError.value = true;
delDialogLoading.value = false;
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/Pcaps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ const headers = [
];

onMounted(() => {
store.updatePcaps().catch((err: string) => {
EventBus.emit("showError", `Failed to update pcaps: ${err}`);
store.updatePcaps().catch((err: Error) => {
EventBus.emit("showError", `Failed to update pcaps: ${err.message}`);
});
});
</script>
Expand Down
Loading
Loading