aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar+git@gmail.com>2026-07-13 23:28:46 +0530
committerArpit Chakladar <arpitchakladar+git@gmail.com>2026-07-13 23:28:46 +0530
commitdfba7ff6fff7bde33b40a343a2318b35c429b40f (patch)
tree52a813c1705a952312c20c328b00fa845a3453f9
parent68777ec421d41be0da27013afd4165ae7d658d26 (diff)
downloadbanglar-bhumi-utils-dfba7ff6fff7bde33b40a343a2318b35c429b40f.tar.gz
banglar-bhumi-utils-dfba7ff6fff7bde33b40a343a2318b35c429b40f.zip
refactor: fixed all of the eslint warnings and errors
-rw-r--r--config/webpack/loader/arrange-shared-module-loader.js6
-rw-r--r--config/webpack/plugins/create-injected-shared-modules-webpack-plugin.js1
-rw-r--r--config/webpack/plugins/create-manifest-webpack-plugin/index.js1
-rw-r--r--config/webpack/plugins/create-rules-webpack-plugin.js1
-rw-r--r--config/webpack/plugins/inject-script-webpack-plugin.js7
-rw-r--r--eslint.config.js11
-rw-r--r--src/scripts/common/stop-blocking.ts53
7 files changed, 60 insertions, 20 deletions
diff --git a/config/webpack/loader/arrange-shared-module-loader.js b/config/webpack/loader/arrange-shared-module-loader.js
index 31c5d61..63fd62d 100644
--- a/config/webpack/loader/arrange-shared-module-loader.js
+++ b/config/webpack/loader/arrange-shared-module-loader.js
@@ -27,7 +27,11 @@ export default function(source) {
if (moduleIndex >= 0) {
const currentSharedModuleName = sharedModules[moduleIndex];
- if (!(sortedSharedModules.includes(currentSharedModuleName) || modulesToBeIncluded.includes(currentSharedModuleName))) {
+ const alreadyIncluded = (
+ sortedSharedModules.includes(currentSharedModuleName)
+ || modulesToBeIncluded.includes(currentSharedModuleName));
+
+ if (!alreadyIncluded) {
modulesToBeIncluded.push(currentSharedModuleName);
}
}
diff --git a/config/webpack/plugins/create-injected-shared-modules-webpack-plugin.js b/config/webpack/plugins/create-injected-shared-modules-webpack-plugin.js
index 6cd8523..c94ae86 100644
--- a/config/webpack/plugins/create-injected-shared-modules-webpack-plugin.js
+++ b/config/webpack/plugins/create-injected-shared-modules-webpack-plugin.js
@@ -21,6 +21,7 @@ class CreateInjectedSharedModulesPlugin {
/**
* @param {import("webpack").Compiler} compiler
+ * @returns {void}
*/
apply(compiler) {
compiler.hooks.compilation.tap("CreateInjectedSharedModulesPlugin", (compilation) => {
diff --git a/config/webpack/plugins/create-manifest-webpack-plugin/index.js b/config/webpack/plugins/create-manifest-webpack-plugin/index.js
index f5a4963..95d0be8 100644
--- a/config/webpack/plugins/create-manifest-webpack-plugin/index.js
+++ b/config/webpack/plugins/create-manifest-webpack-plugin/index.js
@@ -38,6 +38,7 @@ class CreateManifestPlugin {
/**
* @param {import("webpack").Compiler} compiler
+ * @returns {void}
*/
apply(compiler) {
compiler.hooks.compilation.tap("CreateManifestPlugin", (compilation) => {
diff --git a/config/webpack/plugins/create-rules-webpack-plugin.js b/config/webpack/plugins/create-rules-webpack-plugin.js
index 10e5fdd..ce2fbef 100644
--- a/config/webpack/plugins/create-rules-webpack-plugin.js
+++ b/config/webpack/plugins/create-rules-webpack-plugin.js
@@ -11,6 +11,7 @@ import webpack from "webpack";
class CreateRulesPlugin {
/**
* @param {import("webpack").Compiler} compiler
+ * @returns {void}
*/
apply(compiler) {
compiler.hooks.compilation.tap("CreateRulesPlugin", (compilation) => {
diff --git a/config/webpack/plugins/inject-script-webpack-plugin.js b/config/webpack/plugins/inject-script-webpack-plugin.js
index 0a5d784..16b2e98 100644
--- a/config/webpack/plugins/inject-script-webpack-plugin.js
+++ b/config/webpack/plugins/inject-script-webpack-plugin.js
@@ -14,6 +14,7 @@ import { getInjectedCode } from "../utils/injected-code.js";
class InjectScriptPlugin {
/**
* @param {import("webpack").Compiler} compiler
+ * @returns {void}
*/
apply(compiler) {
compiler.hooks.compilation.tap("InjectScriptPlugin", (compilation) => {
@@ -26,14 +27,16 @@ class InjectScriptPlugin {
async(assets) => {
for (const assetName in assets) {
if (/\.js$/.test(assetName)) {
- const injectedCodeResponse = getInjectedCode(compilation.getAsset(assetName).source.source());
+ const assetSource = compilation.getAsset(assetName).source.source();
+ const injectedCodeResponse = getInjectedCode(assetSource);
const scriptInjectorModuleName = getFileName("script-injector", "shared", true);
compilation.updateAsset(
assetName,
new webpack.sources.RawSource(injectedCodeResponse[0])
);
+ const injectedFileName = `scripts/injected/${path.basename(assetName)}`;
assets["scripts/" + path.basename(assetName)] = new webpack.sources.RawSource(
- `$${scriptInjectorModuleName}.injectScriptHead("scripts/injected/${path.basename(assetName)}", ${injectedCodeResponse[1]});`
+ `$${scriptInjectorModuleName}.injectScriptHead("${injectedFileName}", ${injectedCodeResponse[1]});`
);
}
}
diff --git a/eslint.config.js b/eslint.config.js
index 4f528f4..adbbe97 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -75,11 +75,16 @@ export default tseslint.config(
{
files: ["**/*.js"],
- ...tseslint.configs.disableTypeChecked
+ ...tseslint.configs.disableTypeChecked,
+ rules: {
+ ...tseslint.configs.disableTypeChecked.rules,
+ "@typescript-eslint/explicit-function-return-type": "off"
+ }
},
{
files: ["webpack.config.js", "config/**/*.js"],
+ ...tseslint.configs.disableTypeChecked,
languageOptions: {
globals: {
...globals.node,
@@ -90,7 +95,9 @@ export default tseslint.config(
}
},
rules: {
- "no-console": "off"
+ ...tseslint.configs.disableTypeChecked.rules,
+ "no-console": "off",
+ "@typescript-eslint/explicit-function-return-type": "off"
}
}
);
diff --git a/src/scripts/common/stop-blocking.ts b/src/scripts/common/stop-blocking.ts
index bdebfe9..8588834 100644
--- a/src/scripts/common/stop-blocking.ts
+++ b/src/scripts/common/stop-blocking.ts
@@ -4,26 +4,49 @@
* is disabled. Reverts the prototypes after patching to avoid
* interfering with other code.
*/
+
+type JQueryBindFn = (
+ eventName: string,
+ handler: (event: JQuery.Event) => unknown
+) => JQuery;
+
+type JQueryKeydownFn = (
+ handler: (event: JQuery.Event) => unknown
+) => JQuery;
+
+type JQueryPrototypeShape = {
+ bind: JQueryBindFn;
+ keydown: JQueryKeydownFn
+};
+
+const jQueryPrototype = $.prototype as unknown as JQueryPrototypeShape;
+
document.addEventListener("DOMContentLoaded", () => {
- const proxiedBind = $.prototype.bind;
+ const proxiedBind = jQueryPrototype.bind;
/** Proxies jQuery `.bind()` to no-op the `"cut copy paste"` event. */
- $.prototype.bind = function() {
- if (arguments[0].trim() === "cut copy paste") {
- arguments[1] = (_: any) => {};
- }
-
- return proxiedBind.apply(this, Array.from(arguments) as any);
+ jQueryPrototype.bind = function(
+ this: JQuery,
+ ...args: Parameters<JQueryBindFn>
+ ): JQuery {
+ const [eventName, handler] = args;
+ const noop = (): undefined => undefined;
+ return proxiedBind.call(
+ this,
+ eventName,
+ eventName.trim() === "cut copy paste" ? noop : handler
+ );
};
- const proxiedKeydown = $.prototype.keydown;
+ const proxiedKeydown = jQueryPrototype.keydown;
/** Proxies jQuery `.keydown()` so all key presses are allowed. */
- $.prototype.keydown = function() {
- arguments[0] = (_: any) => true;
-
- return proxiedKeydown.apply(this, Array.from(arguments) as any);
+ jQueryPrototype.keydown = function(
+ this: JQuery,
+ ..._args: Parameters<JQueryKeydownFn>
+ ): JQuery {
+ return proxiedKeydown.call(this, () => true);
};
- $.prototype.bind = proxiedBind;
- $.prototype.keydown = proxiedKeydown;
- document.oncontextmenu = () => true;
+ jQueryPrototype.bind = proxiedBind;
+ jQueryPrototype.keydown = proxiedKeydown;
+ document.oncontextmenu = (): boolean => true;
});