Skip to content

Commit 2e3071e

Browse files
upgrade eslint
1 parent f192e7d commit 2e3071e

File tree

117 files changed

+501
-630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+501
-630
lines changed

.ncurc.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
{
2-
"reject": ["pixelmatch", "mime", "@types/mime", "file-typ"]
2+
"reject": [
3+
// These deps are esm only
4+
"pixelmatch",
5+
"mime",
6+
"@types/mime",
7+
"file-type",
8+
// We support node 18 and above
9+
"@types/node"
10+
]
311
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
1919
"release": "pnpm build && auto shipit",
2020
"generate-package": "turbo gen package",
21-
"generate-plugin": "turbo gen plugin"
21+
"generate-plugin": "turbo gen plugin",
22+
"check-updates": "ncu --packageFile '{,*/**/}package.json'"
2223
},
2324
"devDependencies": {
2425
"@auto-it/all-contributors": "^11.2.1",
@@ -28,6 +29,7 @@
2829
"@jimp/config-typescript": "workspace:*",
2930
"@turbo/gen": "^2.1.1",
3031
"auto": "^11.2.1",
32+
"npm-check-updates": "^17.1.1",
3133
"prettier": "^3.3.3",
3234
"turbo": "^2.1.1"
3335
}

packages/config-eslint/base.js

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,28 @@
1-
const { resolve } = require("node:path");
1+
import js from "@eslint/js";
2+
import eslintConfigPrettier from "eslint-config-prettier";
3+
import turboPlugin from "eslint-plugin-turbo";
4+
import tseslint from "typescript-eslint";
25

3-
const project = resolve(process.cwd(), "tsconfig.json");
4-
5-
/** @type {import("eslint").Linter.Config} */
6-
module.exports = {
7-
extends: [
8-
"eslint:recommended",
9-
"prettier",
10-
"eslint-config-turbo",
11-
"plugin:@typescript-eslint/recommended",
12-
],
13-
plugins: ["only-warn"],
14-
globals: {
15-
React: true,
16-
JSX: true,
17-
},
18-
env: {
19-
node: true,
6+
export default [
7+
js.configs.recommended,
8+
eslintConfigPrettier,
9+
...tseslint.configs.recommended,
10+
{
11+
ignores: [
12+
// Ignore dotfiles
13+
".*.js",
14+
"node_modules/",
15+
"dist/",
16+
"**/browser.js",
17+
],
2018
},
21-
settings: {
22-
"import/resolver": {
23-
typescript: {
24-
project,
25-
},
19+
{
20+
name: "eslint-config-turbo (recreated flat)",
21+
plugins: {
22+
turbo: { rules: turboPlugin.rules },
2623
},
27-
},
28-
parser: "@typescript-eslint/parser",
29-
parserOptions: {
30-
project,
31-
},
32-
ignorePatterns: [
33-
// Ignore dotfiles
34-
".*.js",
35-
"node_modules/",
36-
"dist/",
37-
"**/browser.js",
38-
],
39-
overrides: [
40-
{
41-
files: ["*.js?(x)", "*.ts?(x)"],
24+
rules: {
25+
"turbo/no-undeclared-env-vars": "error",
4226
},
43-
],
44-
};
27+
},
28+
];

packages/config-eslint/package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@
44
"license": "MIT",
55
"private": true,
66
"main": "base.js",
7+
"type": "module",
78
"scripts": {
89
"clean": "rm -rf node_modules .tshy .tshy-build dist .turbo"
910
},
1011
"devDependencies": {
11-
"@typescript-eslint/eslint-plugin": "^7.2.0",
12-
"@typescript-eslint/parser": "^7.2.0",
1312
"eslint-config-prettier": "^9.1.0",
14-
"eslint-config-turbo": "^1.12.5",
15-
"eslint-plugin-only-warn": "^1.1.0",
13+
"eslint-config-turbo": "^2.1.1",
1614
"typescript": "^5.5.4"
1715
},
1816
"publishConfig": {},
19-
"sideEffects": false
17+
"sideEffects": false,
18+
"dependencies": {
19+
"@eslint/js": "^9.9.1",
20+
"@types/eslint__js": "^8.42.3",
21+
"typescript-eslint": "^8.3.0"
22+
}
2023
}

packages/config-vitest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"devDependencies": {
1616
"@jimp/config-typescript": "workspace:*",
1717
"@jimp/test-utils": "workspace:*",
18-
"eslint": "^8.57.0",
18+
"eslint": "^9.9.1",
1919
"typescript": "^5.5.4",
2020
"vitest": "^2.0.5"
2121
},

packages/core/.eslintrc.cjs

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/core/eslint.config.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import shared from "@jimp/config-eslint/base.js";
2+
export default [
3+
...shared,
4+
{
5+
rules: {
6+
"@typescript-eslint/no-explicit-any": "off",
7+
},
8+
},
9+
];

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@types/file-type": "^10.9.1",
3131
"@types/mime": "^3.0.4",
3232
"@types/node": "^18.19.48",
33-
"eslint": "^8.57.0",
33+
"eslint": "^9.9.1",
3434
"tshy": "^3.0.2",
3535
"typescript": "^5.5.4",
3636
"vitest": "^2.0.5"

packages/core/src/index.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export interface JimpPlugin {
9090
}
9191

9292
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
93-
k: infer I,
93+
k: infer I
9494
) => void
9595
? I
9696
: never;
@@ -272,8 +272,8 @@ export function createJimp<
272272
if (Array.isArray(bitmap.data)) {
273273
data = Buffer.concat(
274274
bitmap.data.map((hex) =>
275-
Buffer.from(hex.toString(16).padStart(8, "0"), "hex"),
276-
),
275+
Buffer.from(hex.toString(16).padStart(8, "0"), "hex")
276+
)
277277
);
278278
}
279279

@@ -316,7 +316,7 @@ export function createJimp<
316316
}
317317

318318
const image = new CustomJimp(
319-
await format.decode(actualBuffer),
319+
await format.decode(actualBuffer)
320320
) as InstanceType<typeof CustomJimp> & ExtraMethodMap;
321321

322322
attemptExifRotate(image, actualBuffer);
@@ -386,6 +386,7 @@ export function createJimp<
386386
let outputImage: Jimp;
387387

388388
if (format.hasAlpha) {
389+
// eslint-disable-next-line @typescript-eslint/no-this-alias
389390
outputImage = this;
390391
} else {
391392
outputImage = new CustomJimp({
@@ -456,7 +457,7 @@ export function createJimp<
456457
const mimeType = mime.getType(path);
457458
await writeFile(
458459
path,
459-
await this.getBuffer(mimeType as SupportedMimeTypes, options),
460+
await this.getBuffer(mimeType as SupportedMimeTypes, options)
460461
);
461462
}
462463

@@ -657,7 +658,7 @@ export function createJimp<
657658
mode?: BlendMode;
658659
opacitySource?: number;
659660
opacityDest?: number;
660-
} = {},
661+
} = {}
661662
) {
662663
return composite(this, src, x, y, options);
663664
}
@@ -687,14 +688,14 @@ export function createJimp<
687688
y: number,
688689
w: number,
689690
h: number,
690-
cb: (x: number, y: number, idx: number) => any,
691+
cb: (x: number, y: number, idx: number) => any
691692
): this;
692693
scan(
693694
x: number | ((x: number, y: number, idx: number) => any),
694695
y?: number,
695696
w?: number,
696697
h?: number,
697-
f?: (x: number, y: number, idx: number) => any,
698+
f?: (x: number, y: number, idx: number) => any
698699
): this {
699700
return scan(this, x as any, y as any, w as any, h as any, f as any);
700701
}

packages/core/src/utils/composite.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Edge, JimpClass } from "@jimp/types";
22

33
import { BlendMode } from "./constants.js";
44
import * as compositeModes from "./composite-modes.js";
5-
import { limit255, scan } from "@jimp/utils";
5+
import { limit255 } from "@jimp/utils";
66

77
export function composite<I extends JimpClass>(
88
baseImage: I,
@@ -13,7 +13,7 @@ export function composite<I extends JimpClass>(
1313
mode?: BlendMode;
1414
opacitySource?: number;
1515
opacityDest?: number;
16-
} = {},
16+
} = {}
1717
) {
1818
if (!(src instanceof baseImage.constructor)) {
1919
throw new Error("The source must be a Jimp image");
@@ -23,11 +23,8 @@ export function composite<I extends JimpClass>(
2323
throw new Error("x and y must be numbers");
2424
}
2525

26-
let {
27-
mode = BlendMode.SRC_OVER,
28-
opacitySource = 1.0,
29-
opacityDest = 1.0,
30-
} = options;
26+
const { mode = BlendMode.SRC_OVER } = options;
27+
let { opacitySource = 1.0, opacityDest = 1.0 } = options;
3128

3229
if (
3330
typeof opacitySource !== "number" ||
@@ -41,7 +38,6 @@ export function composite<I extends JimpClass>(
4138
opacityDest = 1.0;
4239
}
4340

44-
// eslint-disable-next-line import/namespace
4541
const blendmode = compositeModes[mode];
4642

4743
// round input
@@ -76,7 +72,7 @@ export function composite<I extends JimpClass>(
7672
b: baseImage.bitmap.data[dstIdx + 2]! / 255,
7773
a: baseImage.bitmap.data[dstIdx + 3]! / 255,
7874
},
79-
opacitySource,
75+
opacitySource
8076
);
8177

8278
baseImage.bitmap.data[dstIdx + 0] = limit255(blended.r * 255);

0 commit comments

Comments
 (0)