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 assert package reference #626

Closed
wants to merge 5 commits into from
Closed
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
5 changes: 2 additions & 3 deletions packages/eslint-scope/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@
* @module escope
*/

import assert from "node:assert";

import ScopeManager from "./scope-manager.js";
import Referencer from "./referencer.js";
import Reference from "./reference.js";
import Variable from "./variable.js";

import eslintScopeVersion from "./version.js";
import { assert } from "./util/assert.js";


/**
* Set the default options
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 "./util/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 "./util/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 "./util/assert.js";

const { Syntax } = estraverse;

Expand Down
18 changes: 18 additions & 0 deletions packages/eslint-scope/lib/util/assert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @fileoverview This file provides a utility function `assert` that checks whether a given condition is true
* and throws an error with a specified message if the condition is false.
* @author Amaresh S M
*/

/**
* Asserts that a condition is true. If the condition is false, an error is thrown with the provided message.
* @param {boolean} condition The condition that is being asserted. If `false`, an error will be thrown.
* @param {string} [message="Assertion failed."] The error message that will be thrown if the condition is false.
* @returns {void}
* @throws {Error} Throws an error if the condition is not met.
*/
export function assert(condition, message = "Assertion failed.") {
if (!condition) {
throw new Error(message);
}
}
2 changes: 1 addition & 1 deletion packages/eslint-scope/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
input: "./lib/index.js",
external: ["assert", "estraverse", "esrecurse"],
external: ["estraverse", "esrecurse"],
treeshake: false,
output: {
format: "cjs",
Expand Down