Skip to content

Commit

Permalink
fix some fixable eslint issues (#106)
Browse files Browse the repository at this point in the history
* fix some fixable eslint issues

* Update updater.ts

* Update updater.ts

---------

Co-authored-by: Shalitha Suranga <shalithasuranga@gmail.com>
  • Loading branch information
bhavya3024 and shalithasuranga authored Mar 19, 2024
1 parent ca1aed0 commit cd25139
Show file tree
Hide file tree
Showing 9 changed files with 1,371 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/api/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ExtensionStats } from '../types/api/extensions';

export function dispatch(extensionId: string, event: string, data?: any): Promise<void> {
return new Promise(async (resolve: any, reject: any) => {
let stats = await getStats();
const stats = await getStats();
if(!stats.loaded.includes(extensionId)) {
reject({
code: 'NE_EX_EXTNOTL',
Expand All @@ -12,7 +12,7 @@ export function dispatch(extensionId: string, event: string, data?: any): Promis
}
else if(stats.connected.includes(extensionId)) {
try {
let result = await websocket.sendMessage('extensions.dispatch', {extensionId, event, data});
const result = await websocket.sendMessage('extensions.dispatch', {extensionId, event, data});
resolve(result);
}
catch(err: any) {
Expand Down
4 changes: 2 additions & 2 deletions src/api/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ export function getStats(path: string): Promise<Stats> {
};

function arrayBufferToBase64(data: ArrayBuffer): string {
let bytes: Uint8Array = new Uint8Array(data);
const bytes: Uint8Array = new Uint8Array(data);
let asciiStr: string = '';

for(let byte of bytes) {
for(const byte of bytes) {
asciiStr += String.fromCharCode(byte);
}

Expand Down
4 changes: 2 additions & 2 deletions src/api/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export function init(options: InitOptions = {}): void {
}

if(options.exportCustomMethods && window.NL_CMETHODS && window.NL_CMETHODS.length > 0) {
for(let method of window.NL_CMETHODS) {
for(const method of window.NL_CMETHODS) {
Neutralino.custom[method] = (...args) => {
let data = {};
for(let [argi, argv] of args.entries()) {
for(const [argi, argv] of args.entries()) {
if(typeof argv == 'object' && !Array.isArray(argv) && argv != null) {
data = {...data, ...argv};
}
Expand Down
8 changes: 4 additions & 4 deletions src/api/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Manifest } from '../types/api/updater';
let manifest: Manifest = null;

export function checkForUpdates(url: string): Promise<Manifest> {
function isValidManifest(manifest: any): manifest is Manifest {
function isValidManifest(manifest: Manifest): manifest is Manifest {
if(manifest.applicationId && manifest.applicationId == window.NL_APPID
&& manifest.version && manifest.resourcesURL) {
return true;
Expand All @@ -21,7 +21,7 @@ export function checkForUpdates(url: string): Promise<Manifest> {
});
}
try {
let response = await fetch(url);
const response = await fetch(url);
manifest = JSON.parse(await response.text());

if(isValidManifest(manifest)) {
Expand Down Expand Up @@ -53,8 +53,8 @@ export function install(): Promise<void> {
});
}
try {
let response = await fetch(manifest.resourcesURL);
let resourcesBuffer = await response.arrayBuffer();
const response = await fetch(manifest.resourcesURL);
const resourcesBuffer = await response.arrayBuffer();
await filesystem.writeBinaryFile(window.NL_PATH + "/resources.neu", resourcesBuffer);

resolve({
Expand Down
2 changes: 1 addition & 1 deletion src/browser/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function off(event: string, handler: (ev: CustomEvent) => void): Promise<
};

export function dispatch(event: string, data?: any): Promise<Response> {
let customEvent = new CustomEvent(event, {detail: data});
const customEvent = new CustomEvent(event, {detail: data});
window.dispatchEvent(customEvent);
return Promise.resolve({
success: true,
Expand Down
6 changes: 3 additions & 3 deletions src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function base64ToBytesArray(data: string): ArrayBuffer {
let binaryData: string = window.atob(data);
let len: number = binaryData.length;
let bytes: Uint8Array = new Uint8Array(len);
const binaryData: string = window.atob(data);
const len: number = binaryData.length;
const bytes: Uint8Array = new Uint8Array(len);

for (let i = 0; i < len; i++) {
bytes[i] = binaryData.charCodeAt(i);
Expand Down
2 changes: 1 addition & 1 deletion src/types/api/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export interface Manifest {
applicationId: string;
version: string;
resourcesURL: string;
}
}
16 changes: 8 additions & 8 deletions src/ws/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import * as events from '../browser/events';
import { base64ToBytesArray } from '../helpers';

let ws;
let nativeCalls = {};
let offlineMessageQueue = [];
let extensionMessageQueue = {}
const nativeCalls = {};
const offlineMessageQueue = [];
const extensionMessageQueue = {}

export function init() {
initAuth();
Expand Down Expand Up @@ -59,8 +59,8 @@ function registerLibraryEvents() {
return;
}

let stats = await extensions.getStats();
for(let extension of stats.connected) {
const stats = await extensions.getStats();
for(const extension of stats.connected) {
events.dispatch('extensionReady', extension);
}
});
Expand Down Expand Up @@ -115,7 +115,7 @@ function registerSocketEvents() {
});

ws.addEventListener('close', async (event) => {
let error = {
const error = {
code: 'NE_CL_NSEROFF',
message: 'Neutralino server is offline. Try restarting the application'
};
Expand All @@ -129,9 +129,9 @@ function registerSocketEvents() {

async function processQueue(messageQueue: any[]) {
while(messageQueue.length > 0) {
let message = messageQueue.shift();
const message = messageQueue.shift();
try {
let response = await sendMessage(message.method, message.data);
const response = await sendMessage(message.method, message.data);
message.resolve(response);
}
catch(err: any) {
Expand Down
Loading

2 comments on commit cd25139

@Sadaf-A
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @shalithasuranga,
I don't think we need this yarn.lock file added here
Thank you

@shalithasuranga
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Sadaf-A, sure, thanks, we can delete it when we work on something in this repo 🎉

Please sign in to comment.