Skip to content

Commit 08a9fdf

Browse files
committed
Fixes linting
1 parent f6a4015 commit 08a9fdf

File tree

6 files changed

+10
-14
lines changed

6 files changed

+10
-14
lines changed

doc/api/errors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,7 +2507,7 @@ added: REPLACEME
25072507
A package attempted to import another package that exists in the [package map][]
25082508
but is not listed in its `dependencies` array.
25092509

2510-
```js
2510+
```mjs
25112511
// package-map.json declares "app" with dependencies: ["utils"]
25122512
// but "app" tries to import "secret-lib" which exists in the map
25132513

@@ -4504,7 +4504,6 @@ An error occurred trying to allocate memory. This should never happen.
45044504
[`new URL(input)`]: url.md#new-urlinput-base
45054505
[`new URLPattern(input)`]: url.md#new-urlpatternstring-baseurl-options
45064506
[`new URLSearchParams(iterable)`]: url.md#new-urlsearchparamsiterable
4507-
[package map]: packages.md#package-maps
45084507
[`package.json`]: packages.md#nodejs-packagejson-field-definitions
45094508
[`postMessage()`]: worker_threads.md#portpostmessagevalue-transferlist
45104509
[`postMessageToThread()`]: worker_threads.md#worker_threadspostmessagetothreadthreadid-value-transferlist-timeout
@@ -4535,6 +4534,7 @@ An error occurred trying to allocate memory. This should never happen.
45354534
[domains]: domain.md
45364535
[event emitter-based]: events.md#class-eventemitter
45374536
[file descriptors]: https://en.wikipedia.org/wiki/File_descriptor
4537+
[package map]: packages.md#package-maps
45384538
[relative URL]: https://url.spec.whatwg.org/#relative-url-string
45394539
[self-reference a package using its name]: packages.md#self-referencing-a-package-using-its-name
45404540
[special scheme]: https://url.spec.whatwg.org/#special-scheme

doc/api/esm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,7 @@ resolution for ESM specifiers is [commonjs-extension-resolution-loader][].
13031303
[Loading ECMAScript modules using `require()`]: modules.md#loading-ecmascript-modules-using-require
13041304
[Module customization hooks]: module.md#customization-hooks
13051305
[Node.js Module Resolution And Loading Algorithm]: #resolution-algorithm-specification
1306+
[Package maps]: packages.md#package-maps
13061307
[Source Phase Imports]: https://github.com/tc39/proposal-source-phase-imports
13071308
[Terminology]: #terminology
13081309
[URL]: https://url.spec.whatwg.org/
@@ -1331,7 +1332,6 @@ resolution for ESM specifiers is [commonjs-extension-resolution-loader][].
13311332
[custom https loader]: module.md#import-from-https
13321333
[import.meta.resolve]: #importmetaresolvespecifier
13331334
[merve]: https://github.com/anonrig/merve/tree/v1.0.0
1334-
[Package maps]: packages.md#package-maps
13351335
[percent-encoded]: url.md#percent-encoding-in-urls
13361336
[special scheme]: https://url.spec.whatwg.org/#special-scheme
13371337
[status code]: process.md#exit-codes

doc/api/modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,7 @@ This section was moved to
12731273
[Determining module system]: packages.md#determining-module-system
12741274
[ECMAScript Modules]: esm.md
12751275
[GLOBAL_FOLDERS]: #loading-from-the-global-folders
1276+
[Package maps]: packages.md#package-maps
12761277
[`"main"`]: packages.md#main
12771278
[`"type"`]: packages.md#type
12781279
[`--experimental-package-map`]: cli.md#--experimental-package-mappath
@@ -1300,6 +1301,5 @@ This section was moved to
13001301
[module namespace object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import#module_namespace_object
13011302
[module resolution]: #all-together
13021303
[native addons]: addons.md
1303-
[Package maps]: packages.md#package-maps
13041304
[subpath exports]: packages.md#subpath-exports
13051305
[subpath imports]: packages.md#subpath-imports

lib/internal/modules/cjs/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ function trySelf(parentPath, request, conditions) {
655655
/**
656656
* Try to resolve using package map (if enabled via --experimental-package-map).
657657
* @param {string} request - The bare specifier
658-
* @param {string} parentPath - File path of the parent module
658+
* @param {Module} parent - The parent module
659659
* @param {Set<string>} conditions - Export conditions
660660
* @returns {string|undefined}
661661
*/

lib/internal/modules/package_map.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const getPackageMapPath = getLazy(() =>
1818
require('internal/options').getOptionValue('--experimental-package-map'),
1919
);
2020
const fs = require('fs');
21-
const { fileURLToPath } = require('internal/url');
2221

2322
const {
2423
ERR_PACKAGE_MAP_ACCESS_DENIED,
@@ -88,7 +87,7 @@ class PackageMap {
8887
this.#packages.set(key, {
8988
path: absolutePath,
9089
dependencies: new SafeSet(entry.dependencies ?? []),
91-
name: entry.name, // undefined for nameless packages
90+
name: entry.name, // Undefined for nameless packages
9291
});
9392

9493
// Index by name (only named packages)
@@ -114,7 +113,7 @@ class PackageMap {
114113
*/
115114
#getKeyForPath(filePath) {
116115
const cached = this.#pathToKeyCache.get(filePath);
117-
if (cached !== undefined) return cached;
116+
if (cached !== undefined) { return cached; }
118117

119118
// Walk up to find containing package
120119
let checkPath = filePath;
@@ -126,7 +125,7 @@ class PackageMap {
126125
return key;
127126
}
128127
const parent = dirname(checkPath);
129-
if (parent === checkPath) break;
128+
if (parent === checkPath) { break; }
130129
checkPath = parent;
131130
}
132131

@@ -146,7 +145,7 @@ class PackageMap {
146145
const parentKey = this.#getKeyForPath(parentPath);
147146

148147
// Parent not in map - fall back to standard resolution
149-
if (parentKey === null) return undefined;
148+
if (parentKey === null) { return undefined; }
150149

151150
// Check cache
152151
const cacheKey = `${parentKey}\0${specifier}`;
@@ -281,7 +280,7 @@ function emitExperimentalWarning() {
281280
* @returns {PackageMap|null}
282281
*/
283282
function getPackageMap() {
284-
if (packageMap !== undefined) return packageMap;
283+
if (packageMap !== undefined) { return packageMap; }
285284

286285
packageMapPath = getPackageMapPath();
287286
if (!packageMapPath) {
@@ -306,7 +305,6 @@ function hasPackageMap() {
306305
* Resolve a package specifier using the package map.
307306
* Returns the package path and subpath, or undefined if resolution should
308307
* fall back to standard resolution.
309-
*
310308
* @param {string} specifier - The bare specifier (e.g., "lodash", "react/jsx-runtime")
311309
* @param {string} parentPath - File path of the importing module
312310
* @returns {{packagePath: string, subpath: string}|undefined}

test/es-module/test-esm-package-map.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import '../common/index.mjs';
21
import { spawnPromisified } from '../common/index.mjs';
32
import * as fixtures from '../common/fixtures.mjs';
43
import assert from 'node:assert';
54
import { execPath } from 'node:process';
65
import { describe, it } from 'node:test';
76

87
const packageMapPath = fixtures.path('package-map/package-map.json');
9-
const fixturesPath = fixtures.path('package-map');
108

119
describe('ESM: --experimental-package-map', () => {
1210

0 commit comments

Comments
 (0)