Skip to content

Commit 7dc7ec6

Browse files
committed
fix: use object destructuring in getBundleDirFromCompiler
Fix ESLint prefer-destructuring error by using object destructuring when extracting outputFileSystem from the compiler object.
1 parent b858829 commit 7dc7ec6

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/BundleAnalyzerPlugin.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,19 @@ class BundleAnalyzerPlugin {
229229
}
230230

231231
getBundleDirFromCompiler() {
232-
const outputFileSystem =
233-
/** @type {OutputFileSystem} */
234-
(/** @type {Compiler} */ (this.compiler).outputFileSystem);
232+
const { outputFileSystem } = /** @type {Compiler} */ (this.compiler);
233+
234+
// TypeScript thinks `outputFileSystem` can be null, but in practice it's always set
235+
// when this method is called
236+
const outputFs = /** @type {OutputFileSystem} */ (outputFileSystem);
235237

236238
// Detect `memfs` (used by webpack-dev-server 4+) by checking for the `__vol` property
237239
// Related: #471
238-
if (/** @type {{ __vol?: unknown }} */ (outputFileSystem).__vol) {
240+
if (/** @type {{ __vol?: unknown }} */ (outputFs).__vol) {
239241
return null;
240242
}
241243

242-
const outputFileSystemConstructor = outputFileSystem.constructor;
244+
const outputFileSystemConstructor = outputFs.constructor;
243245

244246
if (typeof outputFileSystemConstructor === "undefined") {
245247
return /** @type {Compiler} */ (this.compiler).outputPath;

0 commit comments

Comments
 (0)