Skip to content

Commit

Permalink
fix: Remove node:assert dependency (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas authored Sep 27, 2024
1 parent 8b18dc5 commit 433a89d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
17 changes: 17 additions & 0 deletions packages/eslint-scope/lib/assert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @fileoverview Assertion utilities.
* @author Nicholas C. Zakas
*/

/**
* Throws an error if the given condition is not truthy.
* @param {boolean} condition The condition to check.
* @param {string} message The message to include with the error.
* @returns {void}
* @throws {Error} When the condition is not truthy.
*/
export function assert(condition, message = "Assertion failed.") {
if (!condition) {
throw new Error(message);
}
}
2 changes: 1 addition & 1 deletion packages/eslint-scope/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* @module escope
*/

import assert from "node:assert";
import { assert } from "./assert.js";

import ScopeManager from "./scope-manager.js";
import Referencer from "./referencer.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/lib/referencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Reference from "./reference.js";
import Variable from "./variable.js";
import PatternVisitor from "./pattern-visitor.js";
import { Definition, ParameterDefinition } from "./definition.js";
import assert from "node:assert";
import { assert } from "./assert.js";

const { Syntax } = estraverse;

Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/lib/scope-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
SwitchScope,
WithScope
} from "./scope.js";
import assert from "node:assert";
import { assert } from "./assert.js";

/**
* @constructor ScopeManager
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/lib/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import estraverse from "estraverse";
import Reference from "./reference.js";
import Variable from "./variable.js";
import { Definition } from "./definition.js";
import assert from "node:assert";
import { assert } from "./assert.js";

const { Syntax } = estraverse;

Expand Down

0 comments on commit 433a89d

Please sign in to comment.