Skip to content

Commit

Permalink
fix: remove assert package reference
Browse files Browse the repository at this point in the history
  • Loading branch information
amareshsm committed Sep 12, 2024
1 parent 79c6e93 commit 35df06e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
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';

Check failure on line 54 in packages/eslint-scope/lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

A space is required after '{'

Check failure on line 54 in packages/eslint-scope/lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

A space is required before '}'

Check failure on line 54 in packages/eslint-scope/lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

Strings must use doublequote


/**
* 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';

Check failure on line 31 in packages/eslint-scope/lib/referencer.js

View workflow job for this annotation

GitHub Actions / Lint

Strings must use doublequote

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';

Check failure on line 39 in packages/eslint-scope/lib/scope-manager.js

View workflow job for this annotation

GitHub Actions / Lint

Strings must use doublequote

/**
* @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';

Check failure on line 30 in packages/eslint-scope/lib/scope.js

View workflow job for this annotation

GitHub Actions / Lint

Strings must use doublequote

const { Syntax } = estraverse;

Expand Down
21 changes: 21 additions & 0 deletions packages/eslint-scope/lib/util/assert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @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.

Check failure on line 8 in packages/eslint-scope/lib/util/assert.js

View workflow job for this annotation

GitHub Actions / Lint

Expected only 0 line after block description
*
* @param {boolean} condition - The condition that is being asserted. If `false`, an error will be thrown.

Check failure on line 10 in packages/eslint-scope/lib/util/assert.js

View workflow job for this annotation

GitHub Actions / Lint

There must be no hyphen before @param description
* @param {string} [message="Assertion failed."] - The error message that will be thrown if the condition is false.

Check failure on line 11 in packages/eslint-scope/lib/util/assert.js

View workflow job for this annotation

GitHub Actions / Lint

There must be no hyphen before @param description
* @returns {void}
*

Check failure on line 13 in packages/eslint-scope/lib/util/assert.js

View workflow job for this annotation

GitHub Actions / Lint

Expected no lines between tags
* @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

0 comments on commit 35df06e

Please sign in to comment.