diff --git a/lib/AliasFieldPlugin.js b/lib/AliasFieldPlugin.js index 90b2a08..836487b 100644 --- a/lib/AliasFieldPlugin.js +++ b/lib/AliasFieldPlugin.js @@ -44,9 +44,7 @@ module.exports = class AliasFieldPlugin { if (fieldData === null || typeof fieldData !== "object") { if (resolveContext.log) { resolveContext.log( - `Field '${ - this.field - }' doesn't contain a valid alias configuration`, + `Field '${this.field}' doesn't contain a valid alias configuration`, ); } return callback(); diff --git a/lib/AliasPlugin.js b/lib/AliasPlugin.js index aed64ed..a437266 100644 --- a/lib/AliasPlugin.js +++ b/lib/AliasPlugin.js @@ -131,9 +131,7 @@ module.exports = class AliasPlugin { return resolver.doResolve( target, obj, - `aliased with mapping '${item.name}': '${alias}' to '${ - newRequestStr - }'`, + `aliased with mapping '${item.name}': '${alias}' to '${newRequestStr}'`, resolveContext, (err, result) => { if (err) return callback(err); diff --git a/lib/DescriptionFilePlugin.js b/lib/DescriptionFilePlugin.js index 9fbb165..c20a0c9 100644 --- a/lib/DescriptionFilePlugin.js +++ b/lib/DescriptionFilePlugin.js @@ -66,7 +66,9 @@ module.exports = class DescriptionFilePlugin { } return callback(); } - const relativePath = `.${path.slice(result.directory.length).replace(/\\/g, "/")}`; + const relativePath = `.${path + .slice(result.directory.length) + .replace(/\\/g, "/")}`; /** @type {ResolveRequest} */ const obj = { ...request, @@ -78,9 +80,7 @@ module.exports = class DescriptionFilePlugin { resolver.doResolve( target, obj, - `using description file: ${result.path} (relative path: ${ - relativePath - })`, + `using description file: ${result.path} (relative path: ${relativePath})`, resolveContext, (err, result) => { if (err) return callback(err); diff --git a/lib/DescriptionFileUtils.js b/lib/DescriptionFileUtils.js index 48269aa..6ce3fbc 100644 --- a/lib/DescriptionFileUtils.js +++ b/lib/DescriptionFileUtils.js @@ -185,7 +185,10 @@ function getField(content, field) { current = null; break; } - current = /** @type {JsonObject} */ (current)[field[j]]; + current = /** @type {JsonValue} */ ( + /** @type {JsonObject} */ + (current)[field[j]] + ); } return current; } diff --git a/lib/LogInfoPlugin.js b/lib/LogInfoPlugin.js index 94aecc1..5dbb688 100644 --- a/lib/LogInfoPlugin.js +++ b/lib/LogInfoPlugin.js @@ -49,9 +49,7 @@ module.exports = class LogInfoPlugin { } if (request.relativePath) { log( - `${prefix}Relative path from description file is: ${ - request.relativePath - }`, + `${prefix}Relative path from description file is: ${request.relativePath}`, ); } callback(); diff --git a/lib/Resolver.js b/lib/Resolver.js index 5fc3344..e0445c0 100644 --- a/lib/Resolver.js +++ b/lib/Resolver.js @@ -289,7 +289,7 @@ const { /** @typedef {string | number | boolean | null} JsonPrimitive */ /** @typedef {JsonValue[]} JsonArray */ /** @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue */ -/** @typedef {{[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined}} JsonObject */ +/** @typedef {{ [Key in string]?: JsonValue | undefined }} JsonObject */ // eslint-disable-next-line jsdoc/require-property /** @typedef {object} Context */ @@ -365,9 +365,9 @@ class Resolver { static createStackEntry(hook, request) { return `${hook.name}: (${request.path}) ${request.request || ""}${ request.query || "" - }${request.fragment || ""}${ - request.directory ? " directory" : "" - }${request.module ? " module" : ""}`; + }${request.fragment || ""}${request.directory ? " directory" : ""}${ + request.module ? " module" : "" + }`; } /** diff --git a/package.json b/package.json index 61f3ca4..de3fd7f 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "homepage": "http://github.com/webpack/enhanced-resolve", "scripts": { "prepare": "husky install", - "lint": "yarn lint:code && yarn lint:types && yarn lint:types-test && yarn lint:special && yarn lint:spellcheck", + "lint": "yarn lint:code && yarn lint:types && yarn lint:types-test && yarn lint:special && yarn fmt:check && yarn lint:spellcheck", "lint:code": "eslint --cache .", "lint:special": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-file-header && node node_modules/tooling/generate-types", "lint:types": "tsc", @@ -60,12 +60,12 @@ "lint:spellcheck": "cspell --no-must-find-files \"**/*.*\"", "fmt": "yarn fmt:base --loglevel warn --write", "fmt:check": "yarn fmt:base --check", - "fmt:base": "prettier --cache --ignore-unknown .", + "fmt:base": "node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .", "fix": "yarn fix:code && yarn fix:special", "fix:code": "yarn lint:code --fix", "fix:special": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/generate-types --write", "type-report": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html", - "pretest": "yarn lintqqq", + "pretest": "yarn lint", "test": "yarn test:coverage", "test:only": "jest", "test:watch": "yarn test:only --watch", diff --git a/test/missing.test.js b/test/missing.test.js index 6d93d7d..9a783b6 100644 --- a/test/missing.test.js +++ b/test/missing.test.js @@ -87,9 +87,7 @@ describe("missing", () => { resolve(testCase[0], testCase[1], { missingDependencies }, callback); }); - it(`should report error details exactly once when trying to resolve ${ - testCase[1] - }`, (done) => { + it(`should report error details exactly once when trying to resolve ${testCase[1]}`, (done) => { /** * @param {Error & { details: string } | null} err err * @param {string} _filename _filename diff --git a/types.d.ts b/types.d.ts index 464df97..6953b2c 100644 --- a/types.d.ts +++ b/types.d.ts @@ -542,7 +542,7 @@ declare interface Iterator { i: number, ): void; } -type JsonObject = { [index: string]: JsonValue } & { +declare interface JsonObject { [index: string]: | undefined | null @@ -551,7 +551,7 @@ type JsonObject = { [index: string]: JsonValue } & { | boolean | JsonObject | JsonValue[]; -}; +} type JsonValue = null | string | number | boolean | JsonObject | JsonValue[]; declare interface KnownHooks { /**