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

Frontend: add more checks #2905

Closed
Closed
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
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ module.exports = {
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': 'error',
'sort-imports': 'off',
'import/no-unresolved': 'error',
'import/named': 'error',
'import/default': 'error',
'import/namespace': 'error',
'import/no-extraneous-dependencies': 'error',
'import/no-mutable-exports': 'error',
'@typescript-eslint/no-useless-constructor': ['error'],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-shadow': ['error'],
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ jobs:
- name: Bun lint
run: bun --cwd ./core/frontend lint

- name: Type-checking
run: bun --cwd ./core/frontend run type-check

- name: Bun build
run: bun run --cwd ./core/frontend build

Expand Down
3 changes: 2 additions & 1 deletion core/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"dev": "vite --host",
"build": "NODE_ENV=production vite build",
"serve": "echo 'This is a preview server for testing the built website. Please use `dev` command over `serve`.\nStarting preview server in 5 seconds..\n';sleep 5; vite preview",
"lint": "eslint --max-warnings=0 --ext .js,.vue --ignore-path .gitignore --ignore-pattern src/components/vue-tour src"
"lint": "eslint --max-warnings=0 --ext .js,.vue --ignore-path .gitignore --ignore-pattern src/components/vue-tour src",
"type-check": "tsc --noEmit"
},
"dependencies": {
"@google/model-viewer": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion core/frontend/src/components/kraken/BackAlleyTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export default Vue.extend({
return []
}

return (this.manifest as ExtensionData[]).sort(
return (this.manifest as ExtensionData[]).sort( // eslint-disable-line no-extra-parens
(a, b) => (b?.repo_info?.downloads ?? 0) - (a?.repo_info?.downloads ?? 0),
)
},
Expand Down
26 changes: 15 additions & 11 deletions core/frontend/src/components/vehiclesetup/calibration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class Calibrator {
* @param {PreflightCalibration} type
*/
private static start(type: PreflightCalibration): void {
const getParamValue = (mapping: Partial<Record<PreflightCalibration, number>>): number => {
return mapping[type] ?? 0;
};

mavlink2rest.sendMessage({
header: {
system_id: 255,
Expand All @@ -65,38 +69,38 @@ class Calibrator {
},
message: {
type: MAVLinkType.COMMAND_LONG,
param1: {
param1: getParamValue({
[PreflightCalibration.GYROSCOPE]: 1,
[PreflightCalibration.GYROSCOPE_TEMPERATURE]: 3,
}[type] || 0,
}),
param2: type === PreflightCalibration.MAGNETOMETER ? 1 : 0,
param3: type === PreflightCalibration.PRESSURE ? 1 : 0,
param4: {
param4: getParamValue({
[PreflightCalibration.RC]: 1,
[PreflightCalibration.RC_TRIM]: 2,
}[type] || 0,
param5: {
}),
param5: getParamValue({
[PreflightCalibration.ACCELEROMETER]: 1,
[PreflightCalibration.BOARD_LEVEL]: 2,
[PreflightCalibration.ACCELEROMETER_TEMPERATURE]: 3,
[PreflightCalibration.SIMPLE_ACCELEROMETER]: 4,
}[type] || 0,
param6: {
}),
param6: getParamValue({
[PreflightCalibration.COMPASS_MOTOR_INTERFERENCE]: 1,
[PreflightCalibration.AIRPSEED]: 2,
}[type] || 0,
param7: {
}),
param7: getParamValue({
[PreflightCalibration.ESC]: 1,
[PreflightCalibration.BAROMETER_TEMPERATURE]: 3,
}[type] || 0,
}),
command: {
type: MavCmd.MAV_CMD_PREFLIGHT_CALIBRATION,
},
target_system: autopilot_data.system_id,
target_component: 1,
confirmation: 0,
},
})
});
}

/**
Expand Down
4 changes: 2 additions & 2 deletions core/frontend/src/one-more-time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class OneMoreTime {
const id = setInterval(() => {
// Check if object does not exist anymore or if it was destroyed by vue
// eslint-disable-next-line
if (!ref.deref() || ref.deref()._isDestroyed) {
if (!ref.deref() || (ref.deref() as any)._isDestroyed) {
this.stop()
clearInterval(id)
}
Expand Down Expand Up @@ -131,7 +131,7 @@ export class OneMoreTime {
}

// Celebrate and dance so free
[Symbol.dispose](): void {
[(Symbol as any).dispose](): void {
this.stop()
}

Expand Down
10 changes: 0 additions & 10 deletions core/frontend/src/style/colors/vuetify.js

This file was deleted.

2 changes: 1 addition & 1 deletion core/frontend/src/types/autopilot/parameter-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default class ParametersTable {
console.log(`ignoring ${name} : ${parameter}`)
continue
}
this.metadata[name] = parameter
this.metadata[name] = (parameter as Metadata)
}
}
}
Expand Down
14 changes: 1 addition & 13 deletions core/frontend/src/types/shims-general.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
declare module '*.svg' {
const value: string
export default value
}

declare module '*.jpg' {
const value: string
export default value
}

declare module '*.png' {
const value: string
export default value
}

declare module '*.glb' {
const value: string
export default value
}

declare module 'vue-tooltip-directive'

declare module '@/assets/colors/default'
declare module '@/assets/colors/blue_robotics'
declare module '@/assets/colors/vuetify'
declare module 'vue-tooltip-directive'
3 changes: 1 addition & 2 deletions core/frontend/src/utils/ardupilot_mavlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ export function getMode(): number {
}

export async function setMode(mode: number, tries?: number): Promise<void> {
tries = tries || 5
let current_try = 0
return new Promise<void>(async (resolve, reject) => {
while (getMode() !== mode && current_try < tries) {
while (getMode() !== mode && current_try < (tries ?? 5)) {
current_try += 1
mavlink2rest.sendCommandLong(
MavCmd.MAV_CMD_DO_SET_MODE,
Expand Down
3 changes: 1 addition & 2 deletions core/frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "bundler",
"moduleResolution": "node",
"moduleDetection": "force",
"skipLibCheck": true,
"esModuleInterop": true,
Expand All @@ -15,7 +15,6 @@
"baseUrl": ".",
"experimentalDecorators": true,
"types": [
"webpack-env",
"vite/client"
],
"paths": {
Expand Down