Skip to content

Commit

Permalink
patch: bump balena-lint to 7.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
aethernet committed Oct 30, 2023
1 parent 3eea1c4 commit 93dee42
Show file tree
Hide file tree
Showing 22 changed files with 2,462 additions and 552 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
extends: ["./node_modules/@balena/lint/config/.eslintrc.js"],
root: true,
ignorePatterns: ["node_modules/", "dist/", "examples/", "tests/"],
rules: {
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-var-requires": "off",
},
};
1 change: 0 additions & 1 deletion lib/gui/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import * as windowProgress from './os/window-progress';
import MainPage from './pages/main/MainPage';
import './css/main.css';
import * as i18next from 'i18next';
import { promises } from 'dns';
import { SourceMetadata } from '../../shared/typings/source-selector';

window.addEventListener(
Expand Down
8 changes: 7 additions & 1 deletion lib/gui/app/components/drive-selector/drive-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export class DriveSelector extends React.Component<
status: string,
drive: { device: string; size: number },
) {
let size;
switch (status) {
case compatibility.containsImage():
return warning.sourceDrive();
Expand All @@ -310,9 +311,11 @@ export class DriveSelector extends React.Component<
case compatibility.system():
return warning.systemDrive();
case compatibility.tooSmall():
const size =
size =
this.state.image?.recommendedDriveSize || this.state.image?.size || 0;
return warning.tooSmall({ size }, drive);
default:
return '';
}
}

Expand Down Expand Up @@ -444,6 +447,9 @@ export class DriveSelector extends React.Component<
isDrivelistDrive(row) && row.isSystem ? ['system'] : []
}
rowKey="displayName"
// TODO: check why this is not passing the typescheck
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
onCheck={(rows: Drive[]) => {
let newSelection = rows.filter(isDrivelistDrive);
if (this.props.multipleSelection) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ExclamationTriangleSvg from '@fortawesome/fontawesome-free/svgs/solid/triangle-exclamation.svg';
import * as _ from 'lodash';
import * as React from 'react';
import { Badge, Flex, Txt, ModalProps } from 'rendition';
import { Modal, ScrollableFlex } from '../../styled-components';
Expand Down
1 change: 1 addition & 0 deletions lib/gui/app/components/safe-webview/safe-webview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class SafeWebview extends React.PureComponent<
ref={this.webviewRef}
partition={ELECTRON_SESSION}
style={style}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
allowpopups="true"
/>
Expand Down
5 changes: 5 additions & 0 deletions lib/gui/app/components/source-selector/source-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ export class SourceSelector extends React.Component<
SourceType: Source,
auth?: Authentication,
): { promise: Promise<void>; cancel: () => void } {
// eslint-disable-next-line
let cancelled = false;
return {
cancel: () => {
Expand Down Expand Up @@ -519,6 +520,8 @@ export class SourceSelector extends React.Component<
}

private async onDrop(event: React.DragEvent<HTMLDivElement>) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const [file] = event.dataTransfer.files;
if (file) {
await this.selectSource(file.path, 'File').promise;
Expand Down Expand Up @@ -584,6 +587,8 @@ export class SourceSelector extends React.Component<
let image: SourceMetadata | DrivelistDrive =
selectionImage !== undefined ? selectionImage : ({} as SourceMetadata);

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
image = image.drive ?? image;

let cancelURLSelection = () => {
Expand Down
9 changes: 5 additions & 4 deletions lib/gui/app/models/flash-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,21 @@ export function setProgressState(
});
}

export function getFlashResults() {
export function getFlashResults(): any {
return store.getState().toJS().flashResults;
}

export function getFlashState() {
return store.getState().get('flashState').toJS();
export function getFlashState(): any {
const flashState = store.getState().get('flashState')! as any;
return flashState.toJS();
}

export function wasLastFlashCancelled() {
return _.get(getFlashResults(), ['cancelled'], false);
}

export function getLastFlashSourceChecksum(): string {
return getFlashResults().sourceChecksum;
return getFlashResults()!.sourceChecksum;
}

export function getLastFlashErrorCode() {
Expand Down
1 change: 1 addition & 0 deletions lib/gui/app/models/leds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function blink(t: number) {
return Math.floor(t) % 2;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function one(_t: number) {
return 1;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/gui/app/modules/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const anonymizeSentryData = (
return event;
};

const extractPathRegex = /(.*)(^|\s)(file\:\/\/)?(\w\:)?([\\\/].+)/;
const extractPathRegex = /(.*)(^|\s)(file:\/\/)?(\w:)?([\\/].+)/;
const etcherSegmentMarkers = ['app.asar', 'Resources'];

export const anonymizePath = (input: string) => {
Expand Down Expand Up @@ -156,7 +156,7 @@ function flattenObject(obj: any) {
const toReturn: AnalyticsPayload = {};

for (const i in obj) {
if (!obj.hasOwnProperty(i)) {
if (!Object.prototype.hasOwnProperty.call(obj, i)) {
continue;
}

Expand All @@ -168,7 +168,7 @@ function flattenObject(obj: any) {
if (typeof obj[i] === 'object' && obj[i] !== null) {
const flatObject = flattenObject(obj[i]);
for (const x in flatObject) {
if (!flatObject.hasOwnProperty(x)) {
if (!Object.prototype.hasOwnProperty.call(flatObject, x)) {
continue;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/gui/app/modules/image-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import * as settings from '../models/settings';
import * as analytics from '../modules/analytics';
import * as windowProgress from '../os/window-progress';
import { startApiAndSpawnChild } from './api';
import { terminateScanningServer } from '../app';

/**
* @summary Handle a flash error and log it to analytics
Expand Down Expand Up @@ -81,6 +80,7 @@ async function performWrite(

console.log({ image, drives });

// eslint-disable-next-line no-async-promise-executor
return await new Promise(async (resolve, reject) => {
const flashResults: FlashResults = {};

Expand All @@ -92,7 +92,7 @@ async function performWrite(
flashInstanceUuid: flashState.getFlashUuid(),
};

const onFail = ({ device, error }) => {
const onFail = ({ device, error }: { device: any; error: any }) => {
console.log('fail event');
console.log(device);
console.log(error);
Expand All @@ -103,7 +103,7 @@ async function performWrite(
finish();
};

const onDone = (event) => {
const onDone = (event: any) => {
console.log('done event');
event.results.errors = event.results.errors.map(
(data: Dictionary<any> & { message: string }) => {
Expand Down
5 changes: 3 additions & 2 deletions lib/gui/app/pages/main/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ interface MainPageState {
}

export class MainPage extends React.Component<
{},
object,
MainPageState & MainPageStateFromStore
> {
constructor(props: {}) {
constructor(props: object) {
super(props);
this.state = {
current: 'main',
Expand Down Expand Up @@ -273,6 +273,7 @@ export class MainPage extends React.Component<
paddingTop="14px"
style={{
// Allow window to be dragged from header
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
WebkitAppRegion: 'drag',
position: 'relative',
Expand Down
1 change: 1 addition & 0 deletions lib/gui/app/renderer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
import { main } from './app';
import './i18n';
Expand Down
22 changes: 16 additions & 6 deletions lib/gui/app/styled-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import * as _ from 'lodash';
import * as React from 'react';
import {
Alert as AlertBase,
Expand Down Expand Up @@ -113,14 +112,25 @@ export const DetailsText = (props: FlexProps) => (

const modalFooterShadowCss = css`
overflow: auto;
background: 0, linear-gradient(rgba(255, 255, 255, 0), white 70%) 0 100%, 0,
background:
0,
linear-gradient(rgba(255, 255, 255, 0), white 70%) 0 100%,
0,
linear-gradient(rgba(255, 255, 255, 0), rgba(221, 225, 240, 0.5) 70%) 0 100%;
background-repeat: no-repeat;
background-size: 100% 40px, 100% 40px, 100% 8px, 100% 8px;
background-size:
100% 40px,
100% 40px,
100% 8px,
100% 8px;
background-repeat: no-repeat;
background-color: white;
background-size: 100% 40px, 100% 40px, 100% 8px, 100% 8px;
background-size:
100% 40px,
100% 40px,
100% 8px,
100% 8px;
background-attachment: local, local, scroll, scroll;
`;

Expand Down Expand Up @@ -238,7 +248,7 @@ export interface GenericTableProps<T> extends BaseTableProps<T> {

const GenericTable: <T>(
props: GenericTableProps<T>,
) => React.ReactElement<GenericTableProps<T>> = <T extends {}>({
) => React.ReactElement<GenericTableProps<T>> = <T extends object>({
refFn,
...props
}: GenericTableProps<T>) => (
Expand Down Expand Up @@ -318,7 +328,7 @@ function StyledTable<T>() {
`;
}

export const Table = <T extends {}>(props: GenericTableProps<T>) => {
export const Table = <T extends object>(props: GenericTableProps<T>) => {
const TypedStyledFunctional = StyledTable<T>();
return <TypedStyledFunctional {...props} />;
};
14 changes: 4 additions & 10 deletions lib/gui/etcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ let mainWindow: any = null;

remoteMain.initialize();

const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

async function checkForUpdates(interval: number) {
// We use a while loop instead of a setInterval to preserve
// async execution time between each function call
Expand Down Expand Up @@ -138,14 +140,6 @@ electron.app.on('open-url', async (event, data) => {
await selectImageURL(data);
});

interface AutoUpdaterConfig {
autoDownload?: boolean;
autoInstallOnAppQuit?: boolean;
allowPrerelease?: boolean;
fullChangelog?: boolean;
allowDowngrade?: boolean;
}

async function createMainWindow() {
const fullscreen = Boolean(await settings.get('fullscreen'));
const defaultWidth = settings.DEFAULT_WIDTH;
Expand Down Expand Up @@ -195,7 +189,7 @@ async function createMainWindow() {
// Prevent external resources from being loaded (like images)
// when dropping them on the WebView.
// See https://github.com/electron/electron/issues/5919
mainWindow.webContents.on('will-navigate', (event) => {
mainWindow.webContents.on('will-navigate', (event: any) => {
event.preventDefault();
});

Expand Down Expand Up @@ -272,7 +266,7 @@ async function main(): Promise<void> {
const webview = electron.webContents.fromId(id);

// Open link in browser if it's opened as a 'foreground-tab'
webview.setWindowOpenHandler((event) => {
webview!.setWindowOpenHandler((event) => {
const url = new URL(event.url);
if (
(url.protocol === 'http:' || url.protocol === 'https:') &&
Expand Down
1 change: 1 addition & 0 deletions lib/util/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ipc.config.silent = true;
// The purpose behind this change is for this process
// to emit a "disconnect" event as soon as the GUI
// process is closed, so we can kill this process as well.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore (0 is a valid value for stopRetrying and is not the same as false)
ipc.config.stopRetrying = 0;

Expand Down
1 change: 1 addition & 0 deletions lib/util/child-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ async function write(options: WriteOptions) {
const onFail = (destination: SourceDestination, error: Error) => {
emitFail({
// TODO: device should be destination
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore (destination.drive is private)
device: destination.drive,
error: toJSON(error),
Expand Down
1 change: 0 additions & 1 deletion lib/util/drive-scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ if (platform !== 'linux' || euid === 0) {
if (platform === 'win32') {
const {
DriverlessDeviceAdapter: driverless,
// tslint:disable-next-line:no-var-requires
} = require('etcher-sdk/build/scanner/adapters/driverless');
adapters.push(new driverless());
}
Expand Down
5 changes: 5 additions & 0 deletions lib/util/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ type Drive =

function prepareDrive(drive: Drive) {
if (drive instanceof sdk.sourceDestination.BlockDevice) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore (BlockDevice.drive is private)
return drive.drive;
} else if (drive instanceof sdk.sourceDestination.UsbbootDrive) {
// This is a workaround etcher expecting a device string and a size
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
drive.device = drive.usbDevice.portId;
drive.size = null;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
drive.progress = 0;
drive.disabled = true;
Expand Down Expand Up @@ -140,9 +143,11 @@ function updateDriveProgress(
progress: number,
) {
const drives = getDrives();
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const driveInMap = drives[drive.device];
if (driveInMap) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
drives[drive.device] = { ...driveInMap, progress };
setDrives(drives);
Expand Down
Loading

0 comments on commit 93dee42

Please sign in to comment.