Skip to content

Commit

Permalink
style: improve
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Aug 2, 2024
1 parent 6538867 commit c802a98
Show file tree
Hide file tree
Showing 104 changed files with 259 additions and 206 deletions.
2 changes: 1 addition & 1 deletion bin/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 136,7 @@ if (!cli.installed) {
)} ${cli.package}".`
);

const question = `Do you want to install 'webpack-cli' (yes/no): `;
const question = "Do you want to install 'webpack-cli' (yes/no): ";

const questionInterface = readLine.createInterface({
input: process.stdin,
Expand Down
34 changes: 30 additions & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 5,7 @@ const jest = require("eslint-plugin-jest");
const jsdoc = require("eslint-plugin-jsdoc");
const prettierConfig = require("eslint-config-prettier");
const globals = require("globals");
const stylistic = require("@stylistic/eslint-plugin");

const nodeConfig = n.configs["flat/recommended"];
const jsdocConfig = jsdoc.configs["flat/recommended-typescript-flavor-error"];
Expand Down Expand Up @@ -200,10 201,35 @@ module.exports = [
"no-plusplus": "off",
"no-param-reassign": "off",
"no-unreachable-loop": "off",
"no-unmodified-loop-condition": "off",
"@stylistic/lines-between-class-members": "off",
"@stylistic/quotes": "off",
"@stylistic/spaced-comment": "off"
"no-unmodified-loop-condition": "off"
}
},
{
plugins: {
"@stylistic": stylistic
},
rules: {
"@stylistic/lines-between-class-members": "error",
"@stylistic/quotes": [
"error",
"double",
{ avoidEscape: true, allowTemplateLiterals: false }
],
"@stylistic/spaced-comment": [
"error",
"always",
{
line: {
markers: ["=", "!"], // Space here to support sprockets directives
exceptions: ["-", " "]
},
block: {
markers: ["=", "!"], // Space here to support sprockets directives
exceptions: ["-", " "],
balanced: true
}
}
]
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion hot/only-dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 2,7 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
/*globals __webpack_hash__ */
/* globals __webpack_hash__ */
if (module.hot) {
/** @type {undefined|string} */
var lastHash;
Expand Down
2 changes: 1 addition & 1 deletion hot/poll.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 2,7 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
/*globals __resourceQuery */
/* globals __resourceQuery */
if (module.hot) {
var hotPollInterval = __resourceQuery.slice(1) || 10 * 60 * 1000;
var log = require("./log");
Expand Down
2 changes: 1 addition & 1 deletion hot/signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 2,7 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
/*globals __resourceQuery */
/* globals __resourceQuery */
if (module.hot) {
var log = require("./log");

Expand Down
1 change: 1 addition & 0 deletions lib/APIPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 144,7 @@ class APIPlugin {
constructor(options = {}) {
this.options = options;
}

/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
Expand Down
2 changes: 1 addition & 1 deletion lib/Dependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 86,7 @@ const memoize = require("./util/memoize");
const TRANSITIVE = Symbol("transitive");

const getIgnoredModule = memoize(
() => new RawModule("/* (ignored) */", `ignored`, `(ignored)`)
() => new RawModule("/* (ignored) */", "ignored", "(ignored)")
);

class Dependency {
Expand Down
1 change: 1 addition & 0 deletions lib/DllModuleFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 17,7 @@ class DllModuleFactory extends ModuleFactory {
super();
this.hooks = Object.freeze({});
}

/**
* @param {ModuleFactoryCreateData} data data object
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
Expand Down
34 changes: 17 additions & 17 deletions lib/FileSystemInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1138,51 1138,51 @@ class FileSystemInfo {
`File info in cache: ${this._fileTimestamps.size} timestamps ${this._fileHashes.size} hashes ${this._fileTshs.size} timestamp hash combinations`
);
logWhenMessage(
`File timestamp snapshot optimization`,
"File timestamp snapshot optimization",
this._fileTimestampsOptimization.getStatisticMessage()
);
logWhenMessage(
`File hash snapshot optimization`,
"File hash snapshot optimization",
this._fileHashesOptimization.getStatisticMessage()
);
logWhenMessage(
`File timestamp hash combination snapshot optimization`,
"File timestamp hash combination snapshot optimization",
this._fileTshsOptimization.getStatisticMessage()
);
logger.log(
`Directory info in cache: ${this._contextTimestamps.size} timestamps ${this._contextHashes.size} hashes ${this._contextTshs.size} timestamp hash combinations`
);
logWhenMessage(
`Directory timestamp snapshot optimization`,
"Directory timestamp snapshot optimization",
this._contextTimestampsOptimization.getStatisticMessage()
);
logWhenMessage(
`Directory hash snapshot optimization`,
"Directory hash snapshot optimization",
this._contextHashesOptimization.getStatisticMessage()
);
logWhenMessage(
`Directory timestamp hash combination snapshot optimization`,
"Directory timestamp hash combination snapshot optimization",
this._contextTshsOptimization.getStatisticMessage()
);
logWhenMessage(
`Missing items snapshot optimization`,
"Missing items snapshot optimization",
this._missingExistenceOptimization.getStatisticMessage()
);
logger.log(`Managed items info in cache: ${this._managedItems.size} items`);
logWhenMessage(
`Managed items snapshot optimization`,
"Managed items snapshot optimization",
this._managedItemInfoOptimization.getStatisticMessage()
);
logWhenMessage(
`Managed files snapshot optimization`,
"Managed files snapshot optimization",
this._managedFilesOptimization.getStatisticMessage()
);
logWhenMessage(
`Managed contexts snapshot optimization`,
"Managed contexts snapshot optimization",
this._managedContextsOptimization.getStatisticMessage()
);
logWhenMessage(
`Managed missing snapshot optimization`,
"Managed missing snapshot optimization",
this._managedMissingOptimization.getStatisticMessage()
);
}
Expand Down Expand Up @@ -2521,7 2521,7 @@ class FileSystemInfo {
};
const invalidWithError = (path, err) => {
if (this._remainingLogs > 0) {
this._log(path, `error occurred: %s`, err);
this._log(path, "error occurred: %s", err);
}
invalid();
};
Expand All @@ -2535,7 2535,7 @@ class FileSystemInfo {
if (current !== snap) {
// If hash differ it's invalid
if (this._remainingLogs > 0) {
this._log(path, `hashes differ (%s != %s)`, current, snap);
this._log(path, "hashes differ (%s != %s)", current, snap);
}
return false;
}
Expand Down Expand Up @@ -2579,7 2579,7 @@ class FileSystemInfo {
if (log && this._remainingLogs > 0) {
this._log(
path,
`it may have changed (%d) after the start time of the snapshot (%d)`,
"it may have changed (%d) after the start time of the snapshot (%d)",
current.safeTime,
startTime
);
Expand All @@ -2595,7 2595,7 @@ class FileSystemInfo {
if (log && this._remainingLogs > 0) {
this._log(
path,
`timestamps differ (%d != %d)`,
"timestamps differ (%d != %d)",
current.timestamp,
snap.timestamp
);
Expand Down Expand Up @@ -2623,7 2623,7 @@ class FileSystemInfo {
if (log && this._remainingLogs > 0) {
this._log(
path,
`it may have changed (%d) after the start time of the snapshot (%d)`,
"it may have changed (%d) after the start time of the snapshot (%d)",
current.safeTime,
startTime
);
Expand All @@ -2639,7 2639,7 @@ class FileSystemInfo {
if (log && this._remainingLogs > 0) {
this._log(
path,
`timestamps hashes differ (%s != %s)`,
"timestamps hashes differ (%s != %s)",
current.timestampHash,
snap.timestampHash
);
Expand Down
8 changes: 4 additions & 4 deletions lib/HotModuleReplacementPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 307,7 @@ class HotModuleReplacementPlugin {
// It should not affect child compilations
if (compilation.compiler !== compiler) return;

//#region module.hot.* API
// #region module.hot.* API
compilation.dependencyFactories.set(
ModuleHotAcceptDependency,
normalModuleFactory
Expand All @@ -324,9 324,9 @@ class HotModuleReplacementPlugin {
ModuleHotDeclineDependency,
new ModuleHotDeclineDependency.Template()
);
//#endregion
// #endregion

//#region import.meta.webpackHot.* API
// #region import.meta.webpackHot.* API
compilation.dependencyFactories.set(
ImportMetaHotAcceptDependency,
normalModuleFactory
Expand All @@ -343,7 343,7 @@ class HotModuleReplacementPlugin {
ImportMetaHotDeclineDependency,
new ImportMetaHotDeclineDependency.Template()
);
//#endregion
// #endregion

let hotIndex = 0;
/** @type {Record<string, string>} */
Expand Down
1 change: 1 addition & 0 deletions lib/IgnoreWarningsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 15,7 @@ class IgnoreWarningsPlugin {
constructor(ignoreWarnings) {
this._ignoreWarnings = ignoreWarnings;
}

/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
Expand Down
2 changes: 1 addition & 1 deletion lib/LibManifestPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 67,7 @@ class LibManifestPlugin {
chunk
});
if (usedPaths.has(targetPath)) {
callback(new Error(`each chunk must have a unique path`));
callback(new Error("each chunk must have a unique path"));
return;
}
usedPaths.add(targetPath);
Expand Down
1 change: 1 addition & 0 deletions lib/ModuleInfoHeaderPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 155,7 @@ class ModuleInfoHeaderPlugin {
constructor(verbose = true) {
this._verbose = verbose;
}

/**
* @param {Compiler} compiler the compiler
* @returns {void}
Expand Down
7 changes: 4 additions & 3 deletions lib/NormalModuleFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 1069,8 @@ Add the extension to the request.`
hint = `Did you mean '${fixedRequest}'? Also note that '${match[1]}' is not in 'resolve.extensions' yet and need to be added for this to work?`;
}
} else {
hint = `Did you mean to omit the extension or to remove 'resolve.enforceExtension'?`;
hint =
"Did you mean to omit the extension or to remove 'resolve.enforceExtension'?";
}
return callback(
null,
Expand Down Expand Up @@ -1159,9 1160,9 @@ If changing the source code is not an option there is also a resolve options cal
if (!err2) {
err.message =
`${err.message}\n`
`BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.\n`
"BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.\n"
` You need to specify '${item.loader}-loader' instead of '${item.loader}',\n`
` see https://webpack.js.org/migrate/3/#automatic-loader-module-name-extension-removed`;
" see https://webpack.js.org/migrate/3/#automatic-loader-module-name-extension-removed";
}
callback(err);
}
Expand Down
1 change: 1 addition & 0 deletions lib/Template.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 109,7 @@ class Template {
.replace(IDENTIFIER_NAME_REPLACE_REGEX, "_$1")
.replace(IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX, "_");
}

/**
* @param {string} str string to be converted to commented in bundle code
* @returns {string} returns a commented version of string
Expand Down
Loading

0 comments on commit c802a98

Please sign in to comment.