1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-25 17:25:16 +03:00

chore: add eslint

* add eslint with space rules to cover what sonarcloud doesn't
* run lint in travis
* add eslint vue config
This commit is contained in:
Tomas Chmelevskij 2020-10-02 00:00:36 +02:00
parent bc47878b30
commit d396d97e5e
33 changed files with 884 additions and 188 deletions

18
.eslintrc.js Normal file
View file

@ -0,0 +1,18 @@
module.exports = {
parserOptions: {
ecmaVersion: 2020,
sourceType: "module"
},
extends: ["plugin:vue/recommended"],
env: {
node: true,
jquery: true,
es2017: true,
browser: true,
webextensions: true
},
rules: {
"no-trailing-spaces": "error",
"eol-last": "error"
}
};

1
.gitignore vendored
View file

@ -13,6 +13,7 @@ dist_cordova/
debug/ debug/
release/ release/
testresults/ testresults/
.eslintcache
# OSX # OSX
.DS_store .DS_store

View file

@ -41,6 +41,7 @@ before_install:
} }
script: script:
- yarn lint
- yarn test - yarn test
- yarn gulp release - yarn gulp release

View file

@ -13,7 +13,9 @@
"release": "run-script-os", "release": "run-script-os",
"release:default": "NODE_ENV=production gulp release", "release:default": "NODE_ENV=production gulp release",
"release:windows": "set NODE_ENV=production&& gulp release", "release:windows": "set NODE_ENV=production&& gulp release",
"test": "karma start test/karma.conf.js" "test": "karma start test/karma.conf.js",
"lint": "eslint --ext .js,.vue src",
"lint:fix": "eslint --fix src"
}, },
"window": { "window": {
"icon": "images/bf_icon_128.png", "icon": "images/bf_icon_128.png",
@ -82,6 +84,8 @@
"command-exists": "^1.2.8", "command-exists": "^1.2.8",
"cordova-lib": "^9.0.1", "cordova-lib": "^9.0.1",
"del": "^5.0.0", "del": "^5.0.0",
"eslint": "^7.16.0",
"eslint-plugin-vue": "^7.3.0",
"follow-redirects": "^1.10.0", "follow-redirects": "^1.10.0",
"fs-extra": "^8.1.0", "fs-extra": "^8.1.0",
"glob": "^7.1.6", "glob": "^7.1.6",
@ -95,6 +99,7 @@
"gulp-xml-transformer": "^3.0.0", "gulp-xml-transformer": "^3.0.0",
"gulp-yarn": "^2.0.0", "gulp-yarn": "^2.0.0",
"gulp-zip": "^5.0.0", "gulp-zip": "^5.0.0",
"husky": "^4.3.0",
"karma": "^4.0.1", "karma": "^4.0.1",
"karma-chai": "^0.1.0", "karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.0.0", "karma-chrome-launcher": "^3.0.0",
@ -122,5 +127,10 @@
}, },
"optionalDependencies": { "optionalDependencies": {
"gulp-appdmg": "^1.0.3" "gulp-appdmg": "^1.0.3"
},
"husky": {
"hooks": {
"pre-commit": "yarn lint"
}
} }
} }

View file

@ -32,13 +32,13 @@ i18next.on('initialized', function() {
const app = new Vue({ const app = new Vue({
i18n: vueI18n, i18n: vueI18n,
data: betaflightModel, el: '#main-wrapper',
components: { components: {
BatteryLegend, BatteryLegend,
BetaflightLogo, BetaflightLogo,
StatusBar, StatusBar,
}, },
el: '#main-wrapper', data: betaflightModel,
}); });
}); });

View file

@ -1,5 +1,7 @@
<template> <template>
<div class="battery-legend">{{ reading }}</div> <div class="battery-legend">
{{ reading }}
</div>
</template> </template>
<script> <script>
const NO_BATTERY_VOLTAGE_MAXIMUM = 1.8; // Maybe is better to add a call to MSP_BATTERY_STATE but is not available for all versions const NO_BATTERY_VOLTAGE_MAXIMUM = 1.8; // Maybe is better to add a call to MSP_BATTERY_STATE but is not available for all versions

View file

@ -6,7 +6,11 @@
:value="usageDown" :value="usageDown"
unit="%" unit="%"
/> />
<ReadingStat message="statusbar_usage_upload" :value="usageUp" unit="%" /> <ReadingStat
message="statusbar_usage_upload"
:value="usageUp"
unit="%"
/>
</div> </div>
</template> </template>
@ -14,6 +18,9 @@
import ReadingStat from "./ReadingStat.vue"; import ReadingStat from "./ReadingStat.vue";
export default { export default {
components: {
ReadingStat,
},
props: { props: {
usageDown: { usageDown: {
type: Number, type: Number,
@ -22,8 +29,5 @@ export default {
type: Number, type: Number,
}, },
}, },
components: {
ReadingStat,
},
}; };
</script> </script>

View file

@ -1,10 +1,26 @@
<template> <template>
<div id="status-bar"> <div id="status-bar">
<PortUtilization :usage-down="portUsageDown" :usage-up="portUsageUp" /> <PortUtilization
<ReadingStat message="statusbar_packet_error" :value="packetError" /> :usage-down="portUsageDown"
<ReadingStat message="statusbar_i2c_error" :value="i2cError" /> :usage-up="portUsageUp"
<ReadingStat message="statusbar_cycle_time" :value="cycleTime" /> />
<ReadingStat message="statusbar_cpu_load" :value="cpuLoad" unit="%" /> <ReadingStat
message="statusbar_packet_error"
:value="packetError"
/>
<ReadingStat
message="statusbar_i2c_error"
:value="i2cError"
/>
<ReadingStat
message="statusbar_cycle_time"
:value="cycleTime"
/>
<ReadingStat
message="statusbar_cpu_load"
:value="cpuLoad"
unit="%"
/>
<StatusBarVersion <StatusBarVersion
:configurator-version="configuratorVersion" :configurator-version="configuratorVersion"
:firmware-version="firmwareVersion" :firmware-version="firmwareVersion"
@ -20,6 +36,11 @@ import ReadingStat from "./ReadingStat.vue";
import PortUtilization from "./PortUtilization.vue"; import PortUtilization from "./PortUtilization.vue";
export default { export default {
components: {
PortUtilization,
ReadingStat,
StatusBarVersion,
},
props: { props: {
portUsageDown: { portUsageDown: {
type: Number, type: Number,
@ -56,10 +77,5 @@ export default {
type: String, type: String,
}, },
}, },
components: {
PortUtilization,
ReadingStat,
StatusBarVersion,
},
}; };
</script> </script>

View file

@ -72,7 +72,6 @@ TABS.gps.initialize = function (callback) {
$('td', row).eq(2).find('progress').val(FC.GPS_DATA.cno[i]); $('td', row).eq(2).find('progress').val(FC.GPS_DATA.cno[i]);
} }
const message = { const message = {
action: 'center', action: 'center',
lat: lat, lat: lat,
@ -161,8 +160,6 @@ TABS.gps.initialize = function (callback) {
}; };
TABS.gps.cleanup = function (callback) { TABS.gps.cleanup = function (callback) {
if (callback) callback(); if (callback) callback();
}; };

View file

@ -741,7 +741,6 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
case "function-a": case "function-a":
case "function-f": case "function-f":
return true; return true;
break;
} }
return false; return false;
} }
@ -754,7 +753,6 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
case "function-f": case "function-f":
case "function-g": case "function-g":
return true; return true;
break;
} }
} else { } else {
switch (activeFunction) { switch (activeFunction) {
@ -768,7 +766,6 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
case "function-o": case "function-o":
case "function-g": case "function-g":
return true; return true;
break;
} }
} }
return false; return false;
@ -781,7 +778,6 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
case "function-a": case "function-a":
case "function-f": case "function-f":
return true; return true;
break;
} }
} }
return false; return false;
@ -793,7 +789,6 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
case "function-s": case "function-s":
case "function-g": case "function-g":
return false; return false;
break;
case "function-r": case "function-r":
case "function-b": case "function-b":
if (semver.lt(FC.CONFIG.apiVersion, "1.20.0")) if (semver.lt(FC.CONFIG.apiVersion, "1.20.0"))
@ -801,7 +796,6 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
break; break;
default: default:
return true; return true;
break;
} }
} }
@ -813,10 +807,8 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
case "function-a": case "function-a":
case "function-f": case "function-f":
return true; return true;
break;
default: default:
return false; return false;
break;
} }
} }
} }

View file

@ -284,7 +284,6 @@ TABS.motors.initialize = function (callback) {
motor_mah_drawing_e = $('.motors-bat-mah-drawing'), motor_mah_drawing_e = $('.motors-bat-mah-drawing'),
motor_mah_drawn_e = $('.motors-bat-mah-drawn'); motor_mah_drawn_e = $('.motors-bat-mah-drawn');
const rawDataTextElements = { const rawDataTextElements = {
x: [], x: [],
y: [], y: [],
@ -455,7 +454,6 @@ TABS.motors.initialize = function (callback) {
motorVoltage.text(i18n.getMessage('motorsVoltageValue', [FC.ANALOG.voltage])); motorVoltage.text(i18n.getMessage('motorsVoltageValue', [FC.ANALOG.voltage]));
motor_mah_drawing_e.text(i18n.getMessage('motorsADrawingValue', [FC.ANALOG.amperage.toFixed(2)])); motor_mah_drawing_e.text(i18n.getMessage('motorsADrawingValue', [FC.ANALOG.amperage.toFixed(2)]));
motor_mah_drawn_e.text(i18n.getMessage('motorsmAhDrawnValue', [FC.ANALOG.mAhdrawn])); motor_mah_drawn_e.text(i18n.getMessage('motorsmAhDrawnValue', [FC.ANALOG.mAhdrawn]));
} }
GUI.interval_add('motors_power_data_pull_slow', power_data_pull, 250, true); // 4 fps GUI.interval_add('motors_power_data_pull_slow', power_data_pull, 250, true); // 4 fps
@ -714,8 +712,6 @@ TABS.motors.initialize = function (callback) {
$('.motor_testing .telemetry .motor-' + i).html(telemetryText); $('.motor_testing .telemetry .motor-' + i).html(telemetryText);
} }
} }
// servo indicators are still using old (not flexible block scale), it will be changed in the future accordingly // servo indicators are still using old (not flexible block scale), it will be changed in the future accordingly

675
yarn.lock

File diff suppressed because it is too large Load diff