Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to ESLint 9, new TypeScript ESLint, and more #156

Merged
merged 8 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions .eslintrc

This file was deleted.

21 changes: 21 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @ts-check

// @ts-ignore Needed due to moduleResolution Node vs Bundler
import { tanstackConfig } from "@tanstack/config/eslint";

export default [
...tanstackConfig,
{
name: "tanstack/temp",
rules: {
"@typescript-eslint/array-type": "off",
"@typescript-eslint/method-signature-style": "off",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
"@typescript-eslint/require-await": "off",
"no-async-promise-executor": "off",
"no-empty": "off",
},
},
];
5 changes: 5 additions & 0 deletions fixtures/sample/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

import rootConfig from "../../eslint.config.js";

export default [...rootConfig];
4 changes: 2 additions & 2 deletions fixtures/sample/loader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from "path";
import { Sample } from "./types";
import path from "node:path";
import { fileURLToPath } from "node:url";
import * as fs from "node:fs";
import type { Sample } from "./types";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand Down
5 changes: 5 additions & 0 deletions fixtures/sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"author": {
"name": "akfish",
"email": "[email protected]"
},
"scripts": {
"build": "tsc --noEmit",
"test:eslint": "eslint ./loader.ts ./server.ts ./types.ts"
},
"license": "MIT",
"devDependencies": {
"@types/finalhandler": "^1.1.1",
Expand Down
4 changes: 2 additions & 2 deletions fixtures/sample/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from "path";
import * as http from "http";
import * as path from "node:path";
import * as http from "node:http";
import finalhandler from "finalhandler";
import serveStatic from "serve-static";

Expand Down
2 changes: 1 addition & 1 deletion fixtures/sample/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Palette } from "@vibrant/color";
import type { Palette } from "@vibrant/color";

export interface Sample {
name: string;
Expand Down
4 changes: 4 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"cache": true,
"dependsOn": ["^build"],
"outputs": ["{projectRoot}/dist"]
},
"test:eslint": {
"cache": true,
"dependsOn": ["^build"]
}
}
}
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,25 @@
"name": "node-vibrant-monorepo",
"private": true,
"packageManager": "[email protected]",
"type": "module",
"scripts": {
"compile:tsc": "tsc",
"build": "lerna run build",
"lint": "run-p -c lint:*",
"lint:packages": "eslint ./packages",
"lint:fixtures": "eslint ./fixtures",
"prettier": "prettier --ignore-unknown .",
"prettier:write": "pnpm run prettier --write",
"test": "run-p -c test:*",
"test:sherif": "sherif",
"test:lib": "lerna run test:lib",
"test:eslint": "lerna run test:eslint",
"test:format": "pnpm run prettier --check",
"test:knip": "knip",
"prepare": "husky install && playwright install chromium"
},
"devDependencies": {
"@tanstack/config": "^0.14.2",
"@types/node": "^18.15.3",
"@types/table": "^4.0.5",
"@typescript-eslint/eslint-plugin": "^5.6.0",
"@typescript-eslint/parser": "^5.6.0",
"eslint": "^8.6.0",
"eslint": "^9.17.0",
"husky": "^7.0.4",
"knip": "^5.41.0",
"lerna": "^8.1.9",
Expand Down
10 changes: 4 additions & 6 deletions packages/node-vibrant/__tests__/common/helper.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { expect } from "vitest";
import { VibrantStatic } from "@vibrant/core";
import { Builder } from "@vibrant/core";
import type { Palette, Swatch } from "@vibrant/color";
import * as util from "@vibrant/color";
import { getBorderCharacters, table } from "table";
import type { Builder, VibrantStatic } from "@vibrant/core";
import type { Palette, Swatch } from "@vibrant/color";
import type {
TestSample,
SamplePathKey,
TestSample,
} from "../../../../fixtures/sample/loader";

import { table, getBorderCharacters } from "table";

const TABLE_OPTS = {
border: getBorderCharacters("void"),
};
Expand Down
5 changes: 5 additions & 0 deletions packages/node-vibrant/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

import rootConfig from "../../eslint.config.js";

export default [...rootConfig];
6 changes: 2 additions & 4 deletions packages/node-vibrant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@
"dist",
"src"
],
"directories": {
"example": "examples"
},
"dependencies": {
"@types/node": "^18.15.3",
"@vibrant/core": "^4.0.0-alpha.3",
Expand All @@ -77,7 +74,8 @@
"scripts": {
"build": "vite build",
"test:lib": "vitest run",
"test:lib:watch": "vitest watch"
"test:lib:watch": "vitest watch",
"test:eslint": "eslint ./src ./__tests__"
},
"bugs": {
"url": "https://github.com/akfish/node-vibrant/issues"
Expand Down
5 changes: 5 additions & 0 deletions packages/vibrant-color/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

import rootConfig from "../../eslint.config.js";

export default [...rootConfig];
3 changes: 2 additions & 1 deletion packages/vibrant-color/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "4.0.0-alpha.3",
"description": "Color utilities for vibrant",
"scripts": {
"build": "vite build"
"build": "vite build",
"test:eslint": "eslint ./src"
},
"type": "module",
"types": "dist/esm/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/vibrant-color/src/converter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Vec3 } from "./";
import type { Vec3 } from "./";

export const DELTAE94_DIFF_STATUS = {
NA: 0,
Expand Down
3 changes: 2 additions & 1 deletion packages/vibrant-color/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { rgbToHex, rgbToHsl } from "./converter";

export * from "./converter";
import { rgbToHsl, rgbToHex } from "./converter";

export interface Filter {
(red: number, green: number, blue: number, alpha: number): boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/vibrant-core/__tests__/builder.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, it, describe } from "vitest";
import { describe, expect, it } from "vitest";

import { Builder } from "../src/builder";

Expand Down
5 changes: 5 additions & 0 deletions packages/vibrant-core/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

import rootConfig from "../../eslint.config.js";

export default [...rootConfig];
3 changes: 2 additions & 1 deletion packages/vibrant-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"test:lib": "vitest run",
"test:lib:watch": "vitest watch",
"build": "vite build"
"build": "vite build",
"test:eslint": "eslint ./src ./__tests__"
},
"type": "module",
"types": "dist/esm/index.d.ts",
Expand Down
10 changes: 6 additions & 4 deletions packages/vibrant-core/src/options.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Palette, Swatch, Filter } from "@vibrant/color";
import { Image, ImageClass, ImageSource, ImageOptions } from "@vibrant/image";
import { Quantizer, QuantizerOptions } from "@vibrant/quantizer";
import { Filter, Palette, Swatch } from "@vibrant/color";
import { Image, ImageSource } from "@vibrant/image";
import { Quantizer } from "@vibrant/quantizer";
import { Generator } from "@vibrant/generator";
import { StageOptions, ProcessOptions } from "./pipeline";
import { assignDeep } from "./utils";
import type { ProcessOptions, StageOptions } from "./pipeline";
import type { QuantizerOptions } from "@vibrant/quantizer";
import type { ImageClass, ImageOptions } from "@vibrant/image";

export interface Options extends ImageOptions, QuantizerOptions {
useWorker: boolean;
Expand Down
9 changes: 5 additions & 4 deletions packages/vibrant-core/src/pipeline/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ImageData, applyFilters } from "@vibrant/image";
import { Quantizer } from "@vibrant/quantizer";
import { Generator } from "@vibrant/generator";
import { Palette, Swatch, Filter } from "@vibrant/color";
import { applyFilters } from "@vibrant/image";
import type { ImageData } from "@vibrant/image";
import type { Quantizer } from "@vibrant/quantizer";
import type { Generator } from "@vibrant/generator";
import type { Filter, Palette, Swatch } from "@vibrant/color";

export class Stage<T> {
private _map: { [name: string]: T } = {};
Expand Down
2 changes: 1 addition & 1 deletion packages/vibrant-core/src/pipeline/worker/host.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { runInWorker } from "@vibrant/worker";
import { Pipeline } from "../index";
import type { Pipeline } from "../index";

export function runPipelineInWorker(self: Window, pipeline: Pipeline) {
runInWorker(self, (imageData, opts) => pipeline.process(imageData, opts));
Expand Down
2 changes: 1 addition & 1 deletion packages/vibrant-core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src", "vite.config.ts"]
"include": ["__tests__", "src", "vite.config.ts"]
}
5 changes: 5 additions & 0 deletions packages/vibrant-generator-default/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

import rootConfig from "../../eslint.config.js";

export default [...rootConfig];
3 changes: 2 additions & 1 deletion packages/vibrant-generator-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "4.0.0-alpha.3",
"description": "Default generator that generates the original vibrant palette",
"scripts": {
"build": "vite build"
"build": "vite build",
"test:eslint": "eslint ./src"
},
"type": "module",
"types": "dist/esm/index.d.ts",
Expand Down
7 changes: 4 additions & 3 deletions packages/vibrant-generator-default/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Swatch, Palette } from "@vibrant/color";
import { Generator } from "@vibrant/generator";
import { hslToRgb } from "@vibrant/color";
/* eslint-disable prefer-const, @typescript-eslint/no-unnecessary-condition */
import { Swatch, hslToRgb } from "@vibrant/color";
import type { Generator } from "@vibrant/generator";
import type { Palette } from "@vibrant/color";

interface DefaultGeneratorOptions {
targetDarkLuma: number;
Expand Down
5 changes: 5 additions & 0 deletions packages/vibrant-generator/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

import rootConfig from "../../eslint.config.js";

export default [...rootConfig];
3 changes: 2 additions & 1 deletion packages/vibrant-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "4.0.0-alpha.3",
"description": "Helpers and typings for writing a vibrant generator",
"scripts": {
"build": "vite build"
"build": "vite build",
"test:eslint": "eslint ./src"
},
"type": "module",
"types": "dist/esm/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/vibrant-generator/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Palette, Swatch } from "@vibrant/color";
import { Resolvable } from "@vibrant/types";
import type { Palette, Swatch } from "@vibrant/color";
import type { Resolvable } from "@vibrant/types";

export interface Generator {
(swatches: Swatch[], opts?: Object): Resolvable<Palette>;
(swatches: Swatch[], opts?: object): Resolvable<Palette>;
}
5 changes: 5 additions & 0 deletions packages/vibrant-image-browser/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

import rootConfig from "../../eslint.config.js";

export default [...rootConfig];
3 changes: 2 additions & 1 deletion packages/vibrant-image-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"build": "vite build",
"test:lib": "vitest run",
"test:lib:watch": "vitest watch"
"test:lib:watch": "vitest watch",
"test:eslint": "eslint ./src ./__tests__"
},
"type": "module",
"types": "dist/esm/index.d.ts",
Expand Down
8 changes: 3 additions & 5 deletions packages/vibrant-image-browser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {
ImageOptions,
ImageData as VibrantImageData,
import { ImageBase, ImageCallback, ImageOptions } from "@vibrant/image";
import type {
ImageSource,
ImageCallback,
ImageBase,
ImageData as VibrantImageData,
} from "@vibrant/image";

function isRelativeUrl(url: string): boolean {
Expand Down
5 changes: 5 additions & 0 deletions packages/vibrant-image-node/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

import rootConfig from "../../eslint.config.js";

export default [...rootConfig];
3 changes: 2 additions & 1 deletion packages/vibrant-image-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "4.0.0-alpha.3",
"description": "Node.js vibrant ImageClass implementation",
"scripts": {
"build": "vite build"
"build": "vite build",
"test:eslint": "eslint ./src"
},
"type": "module",
"types": "dist/esm/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion packages/vibrant-image-node/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ImageBase, ImageData, ImageSource } from "@vibrant/image";
import { ImageBase } from "@vibrant/image";
import configure from "@jimp/custom";
import types from "@jimp/types";
import resize from "@jimp/plugin-resize";
import type { ImageData, ImageSource } from "@vibrant/image";

const Jimp = configure({
types: [types],
Expand Down
5 changes: 5 additions & 0 deletions packages/vibrant-image/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

import rootConfig from "../../eslint.config.js";

export default [...rootConfig];
Loading
Loading