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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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';

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 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 @@
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 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