diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000000..7e154687b6 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npm run lint-staged diff --git a/lib/gui/app/components/settings/settings.tsx b/lib/gui/app/components/settings/settings.tsx index 5e46b1a095..4c8129c8a5 100644 --- a/lib/gui/app/components/settings/settings.tsx +++ b/lib/gui/app/components/settings/settings.tsx @@ -14,18 +14,18 @@ * limitations under the License. */ -import GithubSvg from "@fortawesome/fontawesome-free/svgs/brands/github.svg"; -import * as _ from "lodash"; -import * as React from "react"; -import { Box, Checkbox, Flex, Txt } from "rendition"; +import GithubSvg from '@fortawesome/fontawesome-free/svgs/brands/github.svg'; +import * as _ from 'lodash'; +import * as React from 'react'; +import { Box, Checkbox, Flex, Txt } from 'rendition'; -import { version, packageType } from "../../../../../package.json"; -import * as settings from "../../models/settings"; -import * as analytics from "../../modules/analytics"; -import { open as openExternal } from "../../os/open-external/services/open-external"; -import { Modal } from "../../styled-components"; -import * as i18next from "i18next"; -import { etcherProInfo } from "../../utils/etcher-pro-specific"; +import { version, packageType } from '../../../../../package.json'; +import * as settings from '../../models/settings'; +import * as analytics from '../../modules/analytics'; +import { open as openExternal } from '../../os/open-external/services/open-external'; +import { Modal } from '../../styled-components'; +import * as i18next from 'i18next'; +import { etcherProInfo } from '../../utils/etcher-pro-specific'; interface Setting { name: string; @@ -35,18 +35,18 @@ interface Setting { async function getSettingsList(): Promise { const list: Setting[] = [ { - name: "errorReporting", - label: i18next.t("settings.errorReporting"), + name: 'errorReporting', + label: i18next.t('settings.errorReporting'), }, { - name: "autoBlockmapping", - label: i18next.t("settings.trimExtPartitions"), + name: 'autoBlockmapping', + label: i18next.t('settings.trimExtPartitions'), }, ]; - if (["appimage", "nsis", "dmg"].includes(packageType)) { + if (['appimage', 'nsis', 'dmg'].includes(packageType)) { list.push({ - name: "updatesEnabled", - label: i18next.t("settings.autoUpdate"), + name: 'updatesEnabled', + label: i18next.t('settings.autoUpdate'), }); } return list; @@ -62,7 +62,7 @@ const InfoBox = (props: any) => ( {props.label} - {props.value}{" "} + {props.value}{' '} ); @@ -89,7 +89,7 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) { const toggleSetting = async (setting: string) => { const value = currentSettings[setting]; - analytics.logEvent("Toggle setting", { setting, value }); + analytics.logEvent('Toggle setting', { setting, value }); await settings.set(setting, !value); setCurrentSettings({ ...currentSettings, @@ -101,7 +101,7 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) { - {i18next.t("settings.settings")} + {i18next.t('settings.settings')} } done={() => toggleModal(false)} @@ -122,7 +122,7 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) { })} {EPInfo !== undefined && ( - {i18next.t("settings.systemInformation")} + {i18next.t('settings.systemInformation')} {EPInfo.get_serial() === undefined ? ( ) : ( @@ -135,13 +135,13 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) { alignItems="center" color="#00aeef" style={{ - width: "fit-content", - cursor: "pointer", + width: 'fit-content', + cursor: 'pointer', fontSize: 14, }} onClick={() => openExternal( - "https://github.com/balena-io/etcher/blob/master/CHANGELOG.md" + 'https://github.com/balena-io/etcher/blob/master/CHANGELOG.md', ) } > @@ -150,7 +150,7 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) { fill="currentColor" style={{ marginRight: 8 }} /> - {version} + {version} diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 16bc01802c..5e8c1fde37 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -44,7 +44,7 @@ "esbuild-loader": "4.0.2", "etcher-sdk": "8.7.2", "file-loader": "6.2.0", - "husky": "8.0.3", + "husky": "^8.0.3", "i18next": "23.6.0", "immutable": "4.3.4", "lint-staged": "15.0.1", diff --git a/package.json b/package.json index 019539f685..68862d2441 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "lint-css": "prettier --write lib/**/*.css", "lint-ts": "balena-lint --fix --typescript typings lib tests scripts/clean-shrinkwrap.ts webpack.config.ts", "lint": "npm run lint-ts && npm run lint-css", + "lint-staged": "lint-staged", "sanity-checks": "bash scripts/ci/ensure-all-file-extensions-in-gitattributes.sh", "start": "./node_modules/.bin/electron .", "test-gui": "electron-mocha --recursive --reporter spec --window-config tests/gui/window-config.json --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox --renderer tests/gui/**/*.ts", @@ -32,11 +33,12 @@ "test-windows": "npm run lint && npm run test-gui && npm run test-shared && npm run sanity-checks", "test": "echo npm run test-{linux,windows,macos}", "watch": "webpack serve --no-optimization-minimize --config ./webpack.dev.config.ts", - "webpack": "webpack" + "webpack": "webpack", + "prepare": "husky install" }, "husky": { "hooks": { - "pre-commit": "lint-staged" + "pre-commit": "npm run lint-staged" } }, "lint-staged": { @@ -85,7 +87,7 @@ "esbuild-loader": "4.0.2", "etcher-sdk": "8.7.2", "file-loader": "6.2.0", - "husky": "8.0.3", + "husky": "^8.0.3", "i18next": "23.6.0", "immutable": "4.3.4", "lint-staged": "15.0.1",