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

fix: Remove node:assert dependency #633

Merged
merged 1 commit into from
Sep 27, 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
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