Skip to content

Commit

Permalink
chore: update code for this repository to new eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
favna committed May 28, 2024
1 parent 5fa84e0 commit a21a59e
Show file tree
Hide file tree
Showing 36 changed files with 68 additions and 207 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

23 changes: 0 additions & 23 deletions .eslintrc

This file was deleted.

31 changes: 31 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sapphireEslintConfig from './packages/eslint-config/dist/esm/index.mjs';

/**
* @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
*/
const config = [
{
ignores: ['node_modules/', '**/dist/', '**/docs/', '**/*.d.ts', '**/coverage/']
},
...sapphireEslintConfig,
{
files: ['**/*.test.ts'],
rules: {
'@typescript-eslint/no-extraneous-class': 'off'
}
},
{
files: ['**/PaginatedMessage.ts'],
rules: {
'@typescript-eslint/member-ordering': 'off'
}
},
{
files: ['**/omitKeysFromObject.ts'],
rules: {
'@typescript-eslint/ban-types': 'off'
}
}
];

export default config;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"clean": "node scripts/clean.mjs",
"clean:full": "node scripts/clean-full.mjs",
"lint": "eslint packages --ext mjs,js,ts,tsx --fix",
"lint": "eslint packages --fix",
"format": "prettier --ignore-path=.prettierignore --write \"packages/**/{src,tests,scripts}/**/*.{mjs,ts,js}\"",
"test": "vitest run",
"build": "yarn workspace @sapphire/node-utilities build && turbo run build",
Expand Down Expand Up @@ -37,7 +37,7 @@
"cz-conventional-changelog": "^3.3.0",
"discord-api-types": "^0.37.85",
"discord.js": "^14.15.2",
"eslint": "^8.57.0",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"lint-staged": "^15.2.5",
Expand Down Expand Up @@ -70,7 +70,7 @@
},
"lint-staged": {
"*": "prettier --ignore-unknown --write",
"*.{mjs,js,ts}": "eslint --fix --ext mjs,js,ts"
"*.{mjs,js,ts}": "eslint --fix"
},
"config": {
"commitizen": {
Expand Down
2 changes: 1 addition & 1 deletion packages/async-queue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/async-queue",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"docs": "typedoc-json-parser",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
Expand Down
2 changes: 1 addition & 1 deletion packages/bitfield/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/bitfield",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/cron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/cron",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/decorators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/decorators",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/discord-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/discord-utilities",
"scripts": {
"test": "vitest run",
"lint": "eslint src --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"sideEffects": false,
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/discord.js-utilities",
"scripts": {
"lint": "eslint src --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:types",
"build:types": "concurrently \"yarn:build:types:*\"",
"build:types:cjs": "rollup-type-bundler -d dist/cjs -ot .cts",
Expand Down
2 changes: 1 addition & 1 deletion packages/duration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/duration",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-result/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/eslint-plugin-result",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup",
"prepack": "yarn build",
"bump": "cliff-jumper",
Expand Down
2 changes: 1 addition & 1 deletion packages/event-iterator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/event-iterator",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/fetch",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/lexure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/lexure",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/node-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/utilities",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/phisherman/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/phisherman",
"scripts": {
"lint": "eslint src --ext ts --fix",
"lint": "eslint src --fix",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
1 change: 0 additions & 1 deletion packages/phisherman/src/lib/Phisherman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { fetch, FetchMethods, FetchResultTypes, QueryError } from '@sapphire/fet
import type { PhishermanInfoType, PhishermanReportType, PhishermanReturnType } from './PhishermanTypes';
import os from 'node:os';

// eslint-disable-next-line @typescript-eslint/no-inferrable-types
const packageVersion: string = '[VI]{{inject}}[/VI]';

const agent = `Sapphire Phisherman/${packageVersion} (undici) ${os.platform()}/${os.release()} (https://github.com/sapphiredev/utilities/tree/main/packages/phisherman)`;
Expand Down
2 changes: 1 addition & 1 deletion packages/prettier-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/prettier-config",
"scripts": {
"test": "vitest run",
"lint": "yarn test && yarn build && eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "yarn test && yarn build && eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsc -b src",
"prepack": "yarn build",
"bump": "cliff-jumper",
Expand Down
2 changes: 1 addition & 1 deletion packages/ratelimits/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/ratelimits",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/result/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/result",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/snowflake/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/snowflake",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/stopwatch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/stopwatch",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/time-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"sideEffects": false,
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/time-utilities",
"scripts": {
"lint": "eslint src --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/timer-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/timer-manager",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/timestamp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/timestamp",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",
Expand Down
1 change: 0 additions & 1 deletion packages/timestamp/src/lib/Timestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ const tokenResolvers = new Map<string, TokenResolver>([
}
]
]);
/* eslint-enable max-len */

export type TimeResolvable = Date | number | string;

Expand Down
2 changes: 1 addition & 1 deletion packages/ts-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/ts-config",
"scripts": {
"test": "vitest run",
"lint": "eslint tests --ext mjs,ts --fix -c ../../.eslintrc",
"lint": "eslint tests --fix -c ../../eslint.config.mjs",
"build": "tsc -b tests",
"bump": "cliff-jumper",
"check-update": "cliff-jumper --dry-run"
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/utilities",
"scripts": {
"test": "vitest run",
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
"lint": "eslint src tests --fix -c ../../eslint.config.mjs",
"build": "tsup && run-s \"build:*\"",
"build:rename-cjs-index": "yarn tsx ../../scripts/rename-cjs-index.cts",
"build:dynamic-side-effects": "yarn tsx ../../scripts/dynamic-side-effects.cts utilities",
Expand Down
6 changes: 3 additions & 3 deletions packages/utilities/src/lib/deepClone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function deepClone<T>(source: T): T {
}

if (Array.isArray(source)) {
const output = new (source.constructor as ArrayConstructor)(source.length) as unknown as T & T extends (infer S)[] ? S[] : never;
const output = new (source.constructor as ArrayConstructor)(source.length) as unknown as T extends (infer S)[] ? S[] : never;

for (let i = 0; i < source.length; i++) {
output[i] = deepClone(source[i]);
Expand All @@ -44,7 +44,7 @@ export function deepClone<T>(source: T): T {
}

if (source instanceof Map) {
const output = new (source.constructor as MapConstructor)() as unknown as T & T extends Map<infer K, infer V> ? Map<K, V> : never;
const output = new (source.constructor as MapConstructor)() as unknown as T extends Map<infer K, infer V> ? Map<K, V> : never;

for (const [key, value] of source.entries()) {
output.set(key, deepClone(value));
Expand All @@ -54,7 +54,7 @@ export function deepClone<T>(source: T): T {
}

if (source instanceof Set) {
const output = new (source.constructor as SetConstructor)() as unknown as T & T extends Set<infer K> ? Set<K> : never;
const output = new (source.constructor as SetConstructor)() as unknown as T extends Set<infer K> ? Set<K> : never;

for (const value of source.values()) {
output.add(deepClone(value));
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/src/lib/mergeObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function mergeObjects<A extends object, B extends object>(objTarget: A, o
for (const [key, value] of Object.entries(objSource)) {
const targetValue = Reflect.get(objTarget, key);
if (isObject(value)) {
Reflect.set(objTarget, key, isObject(targetValue) ? mergeObjects(targetValue, value as object) : value);
Reflect.set(objTarget, key, isObject(targetValue) ? mergeObjects(targetValue, value) : value);
} else if (!isObject(targetValue)) {
Reflect.set(objTarget, key, value);
}
Expand Down
1 change: 0 additions & 1 deletion packages/utilities/src/lib/noop.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// eslint-disable-next-line @typescript-eslint/no-empty-function
export function noop() {}
2 changes: 1 addition & 1 deletion packages/utilities/tests/poll.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('poll', () => {
test.each(['foo', true])('GIVEN %j THEN throws TypeError', async (waitBetweenRetries) => {
const cb = vi.fn(cbRaw);
const cbCondition = vi.fn(cbConditionRaw);
const result = poll(cb, cbCondition, { waitBetweenRetries: waitBetweenRetries as any });
const result = poll(cb, cbCondition, { waitBetweenRetries });

await expect(result).rejects.toStrictEqual(new TypeError('Expected waitBetweenRetries to be a number'));
expect(cb).toBeCalledTimes(0);
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/tests/pollSync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('pollSync', () => {
test.each(['foo', true])('GIVEN %j THEN throws TypeError', (waitBetweenRetries) => {
const cb = vi.fn(cbRaw);
const cbCondition = vi.fn(cbConditionRaw);
const callback = () => pollSync(cb, cbCondition, { waitBetweenRetries: waitBetweenRetries as any });
const callback = () => pollSync(cb, cbCondition, { waitBetweenRetries });

expect(callback).toThrowError(new TypeError('Expected waitBetweenRetries to be a number'));
expect(cb).toBeCalledTimes(0);
Expand Down
1 change: 1 addition & 0 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"include": [
"vitest.config.ts",
"vitest.workspace.ts",
"eslint.config.mjs",
"packages/",
"scripts/"
]
Expand Down
Loading

0 comments on commit a21a59e

Please sign in to comment.