Skip to content

Commit

Permalink
refactor: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehurpeau committed Nov 5, 2023
1 parent d474f59 commit cb0fda3
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 26 deletions.
22 changes: 11 additions & 11 deletions dist/index-node18.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from 'path';
import util from 'util';
import path from 'node:path';
import util from 'node:util';
import chalk from 'chalk';
import semver from 'semver';
import semverUtils from 'semver-utils';
import fs, { readFileSync, writeFileSync } from 'fs';
import fs, { readFileSync, writeFileSync } from 'node:fs';
import { resolve } from 'import-meta-resolve';
import { globSync } from 'glob';

Expand Down Expand Up @@ -568,17 +568,17 @@ function createGetDependencyPackageJson({
} else {
try {
pkg = internalCustomLoadPackageJsonFromNodeModules(pkgDepName, pkgDirname);
} catch (err) {
if (!(err instanceof Error)) throw err;
if (err.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
throw err;
} catch (error) {
if (!(error instanceof Error)) throw error;
if (error.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
throw error;
}
const match = / in (.*[/\\]package\.json)\s+imported from/.exec(err.message);
const match = / in (.*[/\\]package\.json)\s+imported from/.exec(error.message);
if (match) {
const [, matchPackageJson] = match;
pkg = internalReadPkgJson(matchPackageJson);
} else {
throw err;
throw error;
}
}
}
Expand Down Expand Up @@ -700,8 +700,8 @@ function createCheckPackage({
async run() {
try {
await this.fn();
} catch (err) {
throw new Error(`${this.name} failed: ${err.message}`);
} catch (error) {
throw new Error(`${this.name} failed: ${error.message}`);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index-node18.mjs.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
],
"ignorePatterns": ["*.d.ts"],
"rules": {
"complexity": ["error", 20]
"complexity": ["error", 20],
"@typescript-eslint/max-params": "warn"
},
"overrides": [
{
Expand Down
4 changes: 2 additions & 2 deletions src/check-package-with-workspaces.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-lines */
import fs from 'fs';
import path from 'path';
import fs from 'node:fs';
import path from 'node:path';
import { globSync } from 'glob';
import type { Except } from 'type-fest';
import type {
Expand Down
8 changes: 4 additions & 4 deletions src/check-package.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-lines */
import path from 'path';
import util from 'util';
import path from 'node:path';
import util from 'node:util';
import { checkDirectDuplicateDependencies } from './checks/checkDirectDuplicateDependencies';
import { checkDirectPeerDependencies } from './checks/checkDirectPeerDependencies';
import { checkExactVersions } from './checks/checkExactVersions';
Expand Down Expand Up @@ -336,8 +336,8 @@ export function createCheckPackage({
async run(): Promise<void> {
try {
await this.fn();
} catch (err) {
throw new Error(`${this.name} failed: ${(err as Error).message}`);
} catch (error) {
throw new Error(`${this.name} failed: ${(error as Error).message}`);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/utils/createGetDependencyPackageJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@ export function createGetDependencyPackageJson({
pkgDepName,
pkgDirname,
);
} catch (err: unknown) {
if (!(err instanceof Error)) throw err;
} catch (error: unknown) {
if (!(error instanceof Error)) throw error;

if (
(err as NodeJS.ErrnoException).code !==
(error as NodeJS.ErrnoException).code !==
'ERR_PACKAGE_PATH_NOT_EXPORTED'
) {
throw err;
throw error;
}

const match = / in (.*[/\\]package\.json)\s+imported from/.exec(
err.message,
error.message,
);

if (match) {
const [, matchPackageJson] = match;
pkg = internalReadPkgJson(matchPackageJson);
} else {
throw err;
throw error;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/pkgJsonUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, writeFileSync } from 'fs';
import { readFileSync, writeFileSync } from 'node:fs';
import { resolve as importResolve } from 'import-meta-resolve';
import type { PackageJson } from './packageTypes';

Expand Down

0 comments on commit cb0fda3

Please sign in to comment.