Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: migrate eslint to flat config format (#11827)

boojackdfde9ff47965
diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js
deleted file mode 100644
index 91e992b113..0000000000
--- a/frontend/.eslintrc.js
+++ /dev/null
@@ -1,60 +0,0 @@
-module.exports = {
- env: {
- "vue/setup-compiler-macros": true,
- },
- parser: "vue-eslint-parser",
- parserOptions: {
- parser: "@typescript-eslint/parser",
- sourceType: "module",
- },
- extends: [
- "eslint:recommended",
- "plugin:vue/vue3-recommended",
- "@vue/typescript/recommended",
- "plugin:prettier/recommended",
- ],
- rules: {
- "no-empty-pattern": "error",
- "no-useless-escape": "error",
- "prettier/prettier": [
- "error",
- {
- useTabs: false,
- tabWidth: 2,
- singleQuote: false,
- trailingComma: "es5",
- printWidth: 80,
- },
- ],
- "@typescript-eslint/consistent-type-imports": [
- "error",
- { fixStyle: "separate-type-imports", prefer: "type-imports" },
- ],
- "@typescript-eslint/no-empty-interface": "error",
- "@typescript-eslint/no-unused-vars": [
- "error",
- { varsIgnorePattern: "^_", args: "none" },
- ],
- "vue/no-mutating-props": "error",
- "vue/no-unused-components": "error",
- "vue/no-useless-template-attributes": "error",
- "@typescript-eslint/no-explicit-any": "off",
- "@typescript-eslint/no-non-null-assertion": "off",
- "vue/multi-word-component-names": "off",
- },
- ignorePatterns: [
- "node_modules",
- "build",
- "dist",
- "public",
- "components.d.ts",
- ],
- overrides: [
- {
- files: ["./*.js"],
- env: {
- node: true,
- },
- },
- ],
-};
diff --git a/frontend/eslint.config.mjs b/frontend/eslint.config.mjs
new file mode 100644
index 0000000000..c49297d99a
--- /dev/null
+++ b/frontend/eslint.config.mjs
@@ -0,0 +1,45 @@
+import { FlatCompat } from "@eslint/eslintrc";
+import js from "@eslint/js";
+import pluginVue from "eslint-plugin-vue";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = path.dirname(__filename);
+const compat = new FlatCompat({
+ baseDirectory: __dirname,
+ recommendedConfig: js.configs.recommended,
+});
+
+// Reference: https://github.com/vuejs/eslint-config-typescript/issues/76#issuecomment-2051234597
+export default [
+ js.configs.recommended,
+ ...pluginVue.configs["flat/recommended"],
+ ...compat.extends("@vue/eslint-config-typescript/recommended"),
+ ...compat.extends("@vue/eslint-config-prettier/skip-formatting"),
+ {
+ files: ["**/*.js", "**/*.vue", "**/*.ts", "**/*.tsx"],
+ languageOptions: {
+ sourceType: "module",
+ },
+ },
+ {
+ ignores: ["**/dist/**", "**/node_modules/**", "**/proto/**"],
+ },
+ {
+ rules: {
+ "no-empty-pattern": "error",
+ "no-useless-escape": "error",
+ "@typescript-eslint/no-empty-interface": "error",
+ "@typescript-eslint/no-unused-vars": [
+ "error",
+ { varsIgnorePattern: "^_", args: "none" },
+ ],
+ "@typescript-eslint/no-explicit-any": "off",
+ "vue/no-mutating-props": "error",
+ "vue/no-unused-components": "error",
+ "vue/no-useless-template-attributes": "error",
+ "vue/multi-word-component-names": "off",
+ },
+ },
+];
diff --git a/frontend/package.json b/frontend/package.json
index d6e0252adf..684cb1c22c 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -10,8 +10,8 @@
"dev-embed": "export BB_GIT_COMMIT_ID_FE=`git rev-parse HEAD` && export NODE_OPTIONS=--max_old_space_size=8000 && npm run copy:all && vite build --mode dev --outDir=../backend/server/dist --emptyOutDir",
"release-docker": "export NODE_OPTIONS=--max_old_space_size=8000 && npm run copy:all && vite build --mode release",
"release-aws": "export NODE_OPTIONS=--max_old_space_size=8000 && npm run copy:all && vite build --mode release-aws",
- "lint": "ESLINT_USE_FLAT_CONFIG=false eslint --cache --ext .js,.ts,.tsx,.vue src",
- "lint:fix": "ESLINT_USE_FLAT_CONFIG=false eslint --cache --ext .js,.ts,.tsx,.vue --fix src",
+ "lint": "ESLINT_USE_FLAT_CONFIG=true eslint --cache src",
+ "lint:fix": "ESLINT_USE_FLAT_CONFIG=true eslint --cache --fix src",
"bundle-visualize": "vite-bundle-visualizer -c vite.config.ts",
"type-check": "export NODE_OPTIONS=--max_old_space_size=8000 && vue-tsc --build --force",
"test": "vitest run --passWithNoTests",
diff --git a/frontend/src/components/AlterSchemaPrepForm/ProjectStandardView.vue b/frontend/src/components/AlterSchemaPrepForm/ProjectStandardView.vue
index 6415ad8d46..12c5d831bc 100644
--- a/frontend/src/components/AlterSchemaPrepForm/ProjectStandardView.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/ProjectStandardView.vue
@@ -113,7 +113,6 @@
</template>
<script lang="ts" setup>
-/* eslint-disable vue/no-mutating-props */
import { NCollapse, NCollapseItem, NCheckbox } from "naive-ui";
import { reactive, computed, watch } from "vue";
import { EnvironmentV1Name, InstanceV1EngineIcon } from "@/components/v2";
diff --git a/frontend/src/components/AnomalyCenter/AnomalyTable.vue b/frontend/src/components/AnomalyCenter/AnomalyTable.vue
index 480e8a4343..0541f5e52e 100644
--- a/frontend/src/components/AnomalyCenter/AnomalyTable.vue
+++ b/frontend/src/components/AnomalyCenter/AnomalyTable.vue
@@ -227,7 +227,6 @@ const action = (anomaly: Anomaly): Action => {
};
default:
return {
- // eslint-disable-next-line @typescript-eslint/no-empty-function
onClick: () => {},
title: "",
};
diff --git a/frontend/src/components/DeploymentConfigTool/DeploymentConfigTool.vue b/frontend/src/components/DeploymentConfigTool/DeploymentConfigTool.vue
index 34c8f579a7..6aeb4a19bd 100644
--- a/frontend/src/components/DeploymentConfigTool/DeploymentConfigTool.vue
+++ b/frontend/src/components/DeploymentConfigTool/DeploymentConfigTool.vue
@@ -18,7 +18,6 @@
</template>
<script lang="ts">
-/* eslint-disable vue/no-mutating-props */
import type { PropType } from "vue";
import { defineComponent } from "vue";
import type { ComposedDatabase } from "@/types";
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue
index 3a1be5a66e..e0f3966b15 100644
--- a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue
+++ b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue
@@ -581,7 +581,6 @@ MIIEvQ...
</template>
<script setup lang="ts">
-/* eslint-disable vue/no-mutating-props */
import { NButton, NRadioGroup, NRadio, NCheckbox, NInput } from "naive-ui";
import { watch, reactive, computed } from "vue";
import { useI18n } from "vue-i18n";
diff --git a/frontend/src/components/VCS/VCSProviderBasicInfoPanel.vue b/frontend/src/components/VCS/VCSProviderBasicInfoPanel.vue
index 86eb46e4b2..c67a325ce5 100644
--- a/frontend/src/components/VCS/VCSProviderBasicInfoPanel.vue
+++ b/frontend/src/components/VCS/VCSProviderBasicInfoPanel.vue
@@ -389,7 +389,6 @@ const accessTokenPlaceholder = computed(() => {
});
const changeAccessToken = (value: string) => {
- // eslint-disable-next-line vue/no-mutating-props
props.config.accessToken = value;
};
diff --git a/frontend/src/shims-3rd-party.d.ts b/frontend/src/shims-3rd-party.d.ts
index 7206cd9cd5..6f5b424459 100644
--- a/frontend/src/shims-3rd-party.d.ts
+++ b/frontend/src/shims-3rd-party.d.ts
@@ -1,4 +1,3 @@
-/* eslint-disable prettier/prettier */
declare module "pev2" {
import type { defineComponent } from "vue";
const Plan: ReturnType<typeof defineComponent>;
diff --git a/frontend/src/store/modules/v1/subscription.ts b/frontend/src/store/modules/v1/subscription.ts
index 9ca5a30933..ac0bfae9ff 100644
--- a/frontend/src/store/modules/v1/subscription.ts
+++ b/frontend/src/store/modules/v1/subscription.ts
@@ -28,7 +28,7 @@ export const useSubscriptionV1Store = defineStore("subscription_v1", {
featureMatrix: new Map<FeatureType, boolean[]>(),
}),
getters: {
- instanceCountLimit(state): number {
+ instanceCountLimit(): number {
const limit =
PLANS.find((plan) => plan.type === this.currentPlan)
?.maximumInstanceCount ?? 0;
@@ -37,7 +37,7 @@ export const useSubscriptionV1Store = defineStore("subscription_v1", {
}
return limit;
},
- userCountLimit(state): number {
+ userCountLimit(): number {
const limit =
PLANS.find((plan) => plan.type === this.currentPlan)
?.maximumSeatCount ?? 0;
@@ -59,7 +59,7 @@ export const useSubscriptionV1Store = defineStore("subscription_v1", {
}
return planTypeFromJSON(state.subscription.plan);
},
- isFreePlan(state): boolean {
+ isFreePlan(): boolean {
return this.currentPlan == PlanType.FREE;
},
expireAt(state): string {
@@ -114,7 +114,7 @@ export const useSubscriptionV1Store = defineStore("subscription_v1", {
const total = trialEndTime.diff(state.subscription.startedTime, "day");
return daysBeforeExpire / total < 0.5;
},
- existTrialLicense(state): boolean {
+ existTrialLicense(): boolean {
const settingStore = useSettingV1Store();
return !!settingStore.getSettingByName("bb.enterprise.trial");
},
@@ -130,17 +130,17 @@ export const useSubscriptionV1Store = defineStore("subscription_v1", {
}
return this.canUpgradeTrial;
},
- canUpgradeTrial(state): boolean {
+ canUpgradeTrial(): boolean {
return (
this.isSelfHostLicense &&
this.isTrialing &&
this.currentPlan < PlanType.ENTERPRISE
);
},
- isSelfHostLicense(state): boolean {
+ isSelfHostLicense(): boolean {
return import.meta.env.MODE.toLowerCase() !== "release-aws";
},
- purchaseLicenseUrl(state): string {
+ purchaseLicenseUrl(): string {
return import.meta.env.BB_PURCHASE_LICENSE_URL;
},
},
diff --git a/frontend/src/views/sql-editor/Sheet/context.ts b/frontend/src/views/sql-editor/Sheet/context.ts
index 43e9d0a25e..afba36111b 100644
--- a/frontend/src/views/sql-editor/Sheet/context.ts
+++ b/frontend/src/views/sql-editor/Sheet/context.ts
@@ -114,7 +114,7 @@ export const provideSheetContext = () => {
events: new Emittery(),
};
- context.events.on("refresh", ({ views }) => {
+ context.events.on("refresh", () => {
// Nothing todo
});