Skip to content

Commit 9a57ba3

Browse files
committed
refactor: style consistency
1 parent 24686d0 commit 9a57ba3

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/index.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function createVisitor (options) {
130130
}
131131
}
132132

133-
const isRequireAssert = (id, init) => {
133+
function isRequireAssert (id, init) {
134134
if (!isCallExpression(init)) {
135135
return false;
136136
}
@@ -143,9 +143,9 @@ function createVisitor (options) {
143143
return false;
144144
}
145145
return isIdentifier(id) || isObjectPattern(id);
146-
};
146+
}
147147

148-
const isRequireAssertStrict = (id, init) => {
148+
function isRequireAssertDotStrict (id, init) {
149149
if (!isMemberExpression(init)) {
150150
return false;
151151
}
@@ -157,9 +157,9 @@ function createVisitor (options) {
157157
return false;
158158
}
159159
return prop.name === 'strict';
160-
};
160+
}
161161

162-
const isRemovalTarget = (id, init) => isRequireAssert(id, init) || isRequireAssertStrict(id, init);
162+
const isRemovalTarget = (id, init) => isRequireAssert(id, init) || isRequireAssertDotStrict(id, init);
163163

164164
const nodeToRemove = new WeakSet();
165165

test/test.mjs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function testWithGeneratedFixture (ext, code) {
2525
const expected = readFileSync(expectedFilepath).toString();
2626

2727
function deftest (name, fun) {
28-
it(`${name}: ${code}`, function () {
28+
it(`${name}: ${code}`, () => {
2929
const ast = createFixture({ code, postlude, prelude });
3030
const modifiedAst = fun(ast);
3131
const actual = generate(modifiedAst);
@@ -50,7 +50,7 @@ function testWithFixture (fixtureName, options) {
5050
const expected = readFileSync(expectedFilepath).toString();
5151

5252
function deftest (name, fun) {
53-
it(`${name}: ${fixtureName}`, function () {
53+
it(`${name}: ${fixtureName}`, () => {
5454
const ast = parseFixture(fixtureFilepath);
5555
const modifiedAst = fun(ast);
5656
const actual = generate(modifiedAst);
@@ -68,7 +68,7 @@ describe('with default options', () => {
6868
testWithFixture('assignment_singlevar');
6969
testWithFixture('non_block_statement');
7070

71-
describe('removal of ESM imports', function () {
71+
describe('removal of ESM imports', () => {
7272
testESM("import assert from 'assert';");
7373
testESM("import assert from 'node:assert';");
7474
testESM("import assert from 'node:assert/strict';");
@@ -83,7 +83,7 @@ describe('with default options', () => {
8383
testESM("import { default as assert } from 'node:assert';");
8484
});
8585

86-
describe('removal of CJS requires', function () {
86+
describe('removal of CJS requires', () => {
8787
testCJS("const assert = require('assert');");
8888
testCJS("const assert = require('assert').strict;");
8989
testCJS("const assert = require('assert/strict');");
@@ -97,17 +97,13 @@ describe('with default options', () => {
9797

9898
describe('with custom options', () => {
9999
testWithFixture('custom_modules_cjs', {
100-
variables: [
101-
],
102100
modules: [
103101
'http-assert',
104102
'node:assert'
105103
]
106104
});
107105

108106
testWithFixture('custom_modules_mjs', {
109-
variables: [
110-
],
111107
modules: [
112108
'node:assert',
113109
'node:assert/strict',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy