Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hipstersmoothie committed Apr 8, 2024
1 parent 5eee8c9 commit 3a7220f
Show file tree
Hide file tree
Showing 85 changed files with 273 additions and 153 deletions.
10 changes: 0 additions & 10 deletions .eslintrc.js

This file was deleted.

9 changes: 7 additions & 2 deletions packages/config-eslint/base.js
Expand Up @@ -4,7 +4,12 @@ const project = resolve(process.cwd(), "tsconfig.json");

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["eslint:recommended", "prettier", "eslint-config-turbo"],
extends: [
"eslint:recommended",
"prettier",
"eslint-config-turbo",
"plugin:@typescript-eslint/recommended",
],
plugins: ["only-warn"],
globals: {
React: true,
Expand Down Expand Up @@ -35,4 +40,4 @@ module.exports = {
files: ["*.js?(x)", "*.ts?(x)"],
},
],
};
};
1 change: 1 addition & 0 deletions packages/config-eslint/package.json
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.0",
"license": "MIT",
"private": true,
"main": "base.js",
"scripts": {
"clean": "rm -rf node_modules"
},
Expand Down
2 changes: 0 additions & 2 deletions packages/config-vitest/package.json
Expand Up @@ -4,13 +4,11 @@
"private": true,
"repository": "jimp-dev/jimp",
"scripts": {
"lint": "eslint .",
"dev": "tshy --watch"
},
"author": "Andrew Lisowski <lisowski54@gmail.com>",
"license": "MIT",
"devDependencies": {
"@jimp/config-eslint": "workspace:*",
"@jimp/config-typescript": "workspace:*",
"@jimp/test-utils": "workspace:*",
"eslint": "^8.57.0",
Expand Down
6 changes: 2 additions & 4 deletions packages/config-vitest/tsconfig.json
Expand Up @@ -2,7 +2,5 @@
"extends": "@jimp/config-typescript/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
}
}
5 changes: 5 additions & 0 deletions packages/core/.eslintrc.cjs
@@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [require.resolve("@jimp/config-eslint/base.js")],
};
6 changes: 2 additions & 4 deletions packages/core/tsconfig.json
Expand Up @@ -2,7 +2,5 @@
"extends": "@jimp/config-typescript/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
}
}
5 changes: 5 additions & 0 deletions packages/diff/.eslintrc.cjs
@@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [require.resolve("@jimp/config-eslint/base.js")],
};
6 changes: 2 additions & 4 deletions packages/diff/tsconfig.json
Expand Up @@ -2,7 +2,5 @@
"extends": "@jimp/config-typescript/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
}
}
1 change: 0 additions & 1 deletion packages/docs/package.json
Expand Up @@ -4,7 +4,6 @@
"type": "module",
"version": "0.0.1",
"scripts": {
"lint": "eslint .",
"dev": "astro dev",
"start": "astro dev",
"build-website": "rm -rf dist && astro check && astro build",
Expand Down
5 changes: 5 additions & 0 deletions packages/jimp/.eslintrc copy.cjs
@@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [require.resolve("@jimp/config-eslint/base.js")],
};
1 change: 1 addition & 0 deletions packages/jimp/src/callbacks.test.ts
Expand Up @@ -62,6 +62,7 @@ describe("Callbacks", () => {
const clone = targetImg.clone();

expect(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(clone[op as keyof typeof clone] as any)(...args)
).toMatchSnapshot();
});
Expand Down
6 changes: 2 additions & 4 deletions packages/jimp/tsconfig.json
Expand Up @@ -2,7 +2,5 @@
"extends": "@jimp/config-typescript/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
}
}
5 changes: 5 additions & 0 deletions packages/read-file/.eslintrc.cjs
@@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [require.resolve("@jimp/config-eslint/base.js")],
};
6 changes: 2 additions & 4 deletions packages/read-file/tsconfig.json
Expand Up @@ -2,7 +2,5 @@
"extends": "@jimp/config-typescript/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
}
}
5 changes: 5 additions & 0 deletions packages/test-utils/.eslintrc.cjs
@@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [require.resolve("@jimp/config-eslint/base.js")],
};
5 changes: 3 additions & 2 deletions packages/test-utils/src/index.ts
Expand Up @@ -2,12 +2,13 @@ import { expect } from "vitest";
import { Bitmap } from "@jimp/types";
import path from "path";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function hashForEach<Hash extends Record<string, any>>(
hash: Hash,
func: (key: keyof Hash, value: Hash[keyof Hash]) => void
) {
for (const key in hash)
if (hash.hasOwnProperty(key)) {
if (key in hash) {
func(key, hash[key]);
}
}
Expand Down Expand Up @@ -134,7 +135,7 @@ export function testImgToStr(testImage: Bitmap) {
colors2[c] = k;
});

let unknownColors = new Set<number>();
const unknownColors = new Set<number>();

for (let y = 0; y < testImage.height; y++) {
for (let x = 0; x < w; x++) {
Expand Down
6 changes: 2 additions & 4 deletions packages/test-utils/tsconfig.json
Expand Up @@ -2,7 +2,5 @@
"extends": "@jimp/config-typescript/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
}
}
5 changes: 5 additions & 0 deletions packages/types/.eslintrc.cjs
@@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [require.resolve("@jimp/config-eslint/base.js")],
};
5 changes: 5 additions & 0 deletions packages/types/src/index.ts
Expand Up @@ -14,6 +14,7 @@ export interface Bitmap {

export interface Format<
Mime extends string = string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ExportOptions extends Record<string, any> | undefined = undefined,
> {
mime: Mime;
Expand Down Expand Up @@ -51,19 +52,23 @@ export interface JimpClass {
getPixelColor: (x: number, y: number) => number;
setPixelColor: (hex: number, x: number, y: number) => JimpClass;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
scan(f: (x: number, y: number, idx: number) => any): JimpClass;
scan(
x: number,
y: number,
w: number,
h: number,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
cb: (x: number, y: number, idx: number) => any
): JimpClass;
scan(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
x: number | ((x: number, y: number, idx: number) => any),
y?: number,
w?: number,
h?: number,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
f?: (x: number, y: number, idx: number) => any
): JimpClass;
}
6 changes: 2 additions & 4 deletions packages/types/tsconfig.json
Expand Up @@ -2,7 +2,5 @@
"extends": "@jimp/config-typescript/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
}
}
5 changes: 5 additions & 0 deletions packages/utils/.eslintrc.cjs
@@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [require.resolve("@jimp/config-eslint/base.js")],
};
6 changes: 6 additions & 0 deletions packages/utils/src/index.ts
Expand Up @@ -8,11 +8,13 @@ export function clone<I extends JimpClass>(image: I): I {
data: Buffer.from(image.bitmap.data),
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
return new (image.constructor as any)(newBitmap);
}

export function scan<I extends JimpClass>(
image: I,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
f: (this: I, x: number, y: number, idx: number) => any
): I;
export function scan<I extends { bitmap: Bitmap }>(
Expand All @@ -21,20 +23,24 @@ export function scan<I extends { bitmap: Bitmap }>(
y: number,
w: number,
h: number,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
cb: (x: number, y: number, idx: number) => any
): I;
export function scan<I extends { bitmap: Bitmap }>(
image: I,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
xArg: number | ((x: number, y: number, idx: number) => any),
yArg?: number,
wArg?: number,
hArg?: number,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
cbArg?: (x: number, y: number, idx: number) => any
): I {
let x: number;
let y: number;
let w: number;
let h: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let cb: (x: number, y: number, idx: number) => any;

if (typeof xArg === "function") {
Expand Down
6 changes: 2 additions & 4 deletions packages/utils/tsconfig.json
Expand Up @@ -2,7 +2,5 @@
"extends": "@jimp/config-typescript/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
}
}
5 changes: 5 additions & 0 deletions plugins/js-bmp/.eslintrc.cjs
@@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [require.resolve("@jimp/config-eslint/base.js")],
};
1 change: 1 addition & 0 deletions plugins/js-bmp/src/index.ts
Expand Up @@ -7,6 +7,7 @@ export type { BmpColor } from "bmp-ts";
export { BmpCompression } from "bmp-ts";

type Pretty<T> = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[K in keyof T]: T[K] extends (...args: any[]) => any
? T[K]
: T[K] extends object
Expand Down
6 changes: 2 additions & 4 deletions plugins/js-bmp/tsconfig.json
Expand Up @@ -2,7 +2,5 @@
"extends": "@jimp/config-typescript/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
}
}
5 changes: 5 additions & 0 deletions plugins/js-gif/.eslintrc.cjs
@@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [require.resolve("@jimp/config-eslint/base.js")],
};
6 changes: 2 additions & 4 deletions plugins/js-gif/tsconfig.json
Expand Up @@ -2,7 +2,5 @@
"extends": "@jimp/config-typescript/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
}
}
5 changes: 5 additions & 0 deletions plugins/js-jpeg/.eslintrc.cjs
@@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [require.resolve("@jimp/config-eslint/base.js")],
};
6 changes: 2 additions & 4 deletions plugins/js-jpeg/tsconfig.json
Expand Up @@ -2,7 +2,5 @@
"extends": "@jimp/config-typescript/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
}
}
5 changes: 5 additions & 0 deletions plugins/js-png/.eslintrc.cjs
@@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [require.resolve("@jimp/config-eslint/base.js")],
};
6 changes: 2 additions & 4 deletions plugins/js-png/tsconfig.json
Expand Up @@ -2,7 +2,5 @@
"extends": "@jimp/config-typescript/base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
}
}
5 changes: 5 additions & 0 deletions plugins/js-tiff/.eslintrc.cjs
@@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [require.resolve("@jimp/config-eslint/base.js")],
};

0 comments on commit 3a7220f

Please sign in to comment.