Skip to content

Commit

Permalink
Added eslint to webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Sep 27, 2024
1 parent 017a2d7 commit 6fd526e
Show file tree
Hide file tree
Showing 123 changed files with 555 additions and 347 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"no-unused-expressions": "error",
"curly": "error",
"class-methods-use-this": "warn",
"no-console": "warn"
"no-console": "warn",
"@typescript-eslint/no-empty-interface": "off",
"no-extra-boolean-cast": "off"
}
}
186 changes: 183 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2869,6 +2869,7 @@
"dotenv": "^16.3.1",
"downshift": "6.0.6",
"eslint": "^8.33.0",
"eslint-webpack-plugin": "^4.2.0",
"fuse.js": "6.5.3",
"github-directory-downloader": "^1.3.6",
"glob": "^10.3.12",
Expand Down
37 changes: 21 additions & 16 deletions src/commands/Chatbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,31 @@ export class Chatbot {

const cspSource = webView.webview.cspSource;

const fetchLocalization = async (requestId: string) => {
if (!requestId) {
return;
}

const fileContents = await getLocalizationFile();

webView.webview.postMessage({
command: GeneralCommands.toVSCode.getLocalization,
requestId,
payload: fileContents
});
};

webView.webview.onDidReceiveMessage(async (message) => {
switch (message.command) {
const { command, requestId, payload, data } = message;

switch (command) {
case PreviewCommands.toVSCode.open:
if (message.data) {
commands.executeCommand('vscode.open', message.data);
if (payload || data) {
commands.executeCommand('vscode.open', payload || data);
}
return;
break;
case GeneralCommands.toVSCode.getLocalization:
const { requestId } = message;
if (!requestId) {
return;
}

const fileContents = await getLocalizationFile();

webView.webview.postMessage({
command: GeneralCommands.toVSCode.getLocalization,
requestId,
payload: fileContents
});
fetchLocalization(requestId);
return;
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/commands/Folders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ export class Folders {
folder.locales && folder.locales.length > 0 ? folder.locales : i18nSettings;

let defaultLocale;
let sourcePath = folderPath;
let localeFolders: ContentFolder[] = [];
const sourcePath = folderPath;
const localeFolders: ContentFolder[] = [];

if (i18nConfig && i18nConfig.length > 0) {
for (const i18n of i18nConfig) {
Expand Down
39 changes: 22 additions & 17 deletions src/commands/Preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,32 @@ export class Preview {
webView.dispose();
});

const fetchLocalization = async (requestId: string) => {
if (!requestId) {
return;
}

const fileContents = await getLocalizationFile();

webView.webview.postMessage({
command: GeneralCommands.toVSCode.getLocalization,
requestId,
payload: fileContents
});
};

webView.webview.onDidReceiveMessage(async (message) => {
switch (message.command) {
const { command, payload, requestId } = message;

switch (command) {
case PreviewCommands.toVSCode.open:
if (message.payload) {
commands.executeCommand('vscode.open', message.payload);
if (payload) {
commands.executeCommand('vscode.open', payload);
}
return;
break;
case GeneralCommands.toVSCode.getLocalization:
const { requestId } = message;
if (!requestId) {
return;
}

const fileContents = await getLocalizationFile();

webView.webview.postMessage({
command: GeneralCommands.toVSCode.getLocalization,
requestId,
payload: fileContents
});
return;
fetchLocalization(requestId);
break;
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/commands/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ categories: []

// Initialize command
subscriptions.push(
commands.registerCommand(COMMAND_NAME.init, async (cb: Function) => {
commands.registerCommand(COMMAND_NAME.init, async (cb: () => void) => {
await Project.init();

if (cb) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ export class i18n {
sourceLocale: I18nConfig,
targetLocale: I18nConfig
) {
return new Promise<ParsedFrontMatter>(async (resolve) => {
await window.withProgress(
return new Promise<ParsedFrontMatter>((resolve) => {
window.withProgress(
{
location: ProgressLocation.Notification,
title: l10n.t(LocalizationKey.commandsI18nTranslateProgressTitle),
Expand Down
Loading

0 comments on commit 6fd526e

Please sign in to comment.