Skip to content

Commit eda273d

Browse files
authored
Merge pull request webpack#7236 from webpack/lint/more-strict-jsdoc
More strict linting of jsdocs
2 parents 236bbcf + f2ad440 commit eda273d

22 files changed

+78
-65
lines changed

.eslintrc.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,20 @@ module.exports = {
2929
"no-loop-func": "warn",
3030
"indent": "off",
3131
"no-console": "off",
32-
"valid-jsdoc": "error",
32+
"valid-jsdoc": ["error", {
33+
"prefer": {
34+
"return": "returns",
35+
"memberof": "DONTUSE",
36+
"class": "DONTUSE",
37+
"inheritdoc": "DONTUSE",
38+
"description": "DONTUSE",
39+
"readonly": "DONTUSE"
40+
},
41+
"preferType": {
42+
"*": "any"
43+
},
44+
"requireReturnType": true
45+
}],
3346
"node/no-unsupported-features": "error",
3447
"node/no-deprecated-api": "error",
3548
"node/no-missing-import": "error",

declarations.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,5 @@ declare const WebAssembly;
114114
declare const importScripts;
115115
declare const $crossOriginLoading$;
116116
declare const chunkId;
117+
118+
type TODO = any;

lib/ChunkGroup.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const compareLocations = require("./compareLocations");
1212
/** @typedef {import("./ModuleReason")} ModuleReason */
1313

1414
/** @typedef {{id: number}} HasId */
15-
/** @typedef {{module: Module, loc: any, request: string}} OriginRecord */
15+
/** @typedef {{module: Module, loc: TODO, request: string}} OriginRecord */
1616
/** @typedef {string|{name: string}} ChunkGroupOptions */
1717

1818
let debugId = 5000;
@@ -112,7 +112,6 @@ class ChunkGroup {
112112

113113
/**
114114
* get a uniqueId for ChunkGroup, made up of its member Chunk debugId's
115-
* @readonly
116115
* @returns {string} a unique concatenation of chunk debugId's
117116
*/
118117
get debugId() {
@@ -121,7 +120,6 @@ class ChunkGroup {
121120

122121
/**
123122
* get a unique id for ChunkGroup, made up of its member Chunk id's
124-
* @readonly
125123
* @returns {string} a unique concatenation of chunk ids
126124
*/
127125
get id() {
@@ -182,7 +180,6 @@ class ChunkGroup {
182180
}
183181

184182
/**
185-
* @description
186183
* @param {Chunk} oldChunk chunk to be replaced
187184
* @param {Chunk} newChunk New chunkt that will be replaced
188185
* @returns {boolean} rerturns true for

lib/ChunkTemplate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ const { Tapable, SyncWaterfallHook, SyncHook } = require("tapable");
1616
* @property {Chunk} chunk the chunk used to render
1717
* @property {Hash} hash
1818
* @property {string} fullHash
19-
* @property {any} outputOptions
19+
* @property {TODO} outputOptions
2020
* @property {{javascript: ModuleTemplate, webassembly: ModuleTemplate}} moduleTemplates
21-
* @property {Map} dependencyTemplates
21+
* @property {Map<TODO, TODO>} dependencyTemplates
2222
*/
2323

2424
module.exports = class ChunkTemplate extends Tapable {
@@ -48,7 +48,7 @@ module.exports = class ChunkTemplate extends Tapable {
4848
/**
4949
*
5050
* @param {RenderManifestOptions} options render manifest options
51-
* @returns {any[]} returns render manifest
51+
* @returns {TODO[]} returns render manifest
5252
*/
5353
getRenderManifest(options) {
5454
const result = [];

lib/Entrypoint.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Entrypoint extends ChunkGroup {
2727

2828
/**
2929
* isInitial will always return true for Entrypoint ChunkGroup.
30-
* @return {true} returns true as all entrypoints are initial ChunkGroups
30+
* @returns {true} returns true as all entrypoints are initial ChunkGroups
3131
*/
3232
isInitial() {
3333
return true;
@@ -36,15 +36,15 @@ class Entrypoint extends ChunkGroup {
3636
/**
3737
* Sets the runtimeChunk for an entrypoint.
3838
* @param {Chunk} chunk the chunk being set as the runtime chunk.
39-
* @return {void}
39+
* @returns {void}
4040
*/
4141
setRuntimeChunk(chunk) {
4242
this.runtimeChunk = chunk;
4343
}
4444

4545
/**
4646
* Fetches the chunk reference containing the webpack bootstrap code
47-
* @return {Chunk} returns the runtime chunk or first chunk in `this.chunks`
47+
* @returns {Chunk} returns the runtime chunk or first chunk in `this.chunks`
4848
*/
4949
getRuntimeChunk() {
5050
return this.runtimeChunk || this.chunks[0];

lib/EvalSourceMapDevToolModuleTemplatePlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class EvalSourceMapDevToolModuleTemplatePlugin {
4040
return source;
4141
}
4242

43-
/** @type {{ [key: string]: any; }} */
43+
/** @type {{ [key: string]: TODO; }} */
4444
let sourceMap;
4545
let content;
4646
if (source.sourceAndMap) {

lib/Generator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Generator {
1919
/**
2020
* @abstract
2121
* @param {Module} module module for which the code should be generated
22-
* @param {Map<Function, any>} dependencyTemplates mapping from dependencies to templates
22+
* @param {Map<Function, TODO>} dependencyTemplates mapping from dependencies to templates
2323
* @param {RuntimeTemplate} runtimeTemplate the runtime template
2424
* @param {string} type which kind of code should be generated
2525
* @returns {Source} generated code

lib/HotModuleReplacement.runtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ module.exports = function() {
362362
for (var id in hotUpdate) {
363363
if (Object.prototype.hasOwnProperty.call(hotUpdate, id)) {
364364
moduleId = toModuleId(id);
365-
/** @type {any} */
365+
/** @type {TODO} */
366366
var result;
367367
if (hotUpdate[id]) {
368368
result = getAffectedStuff(moduleId);

lib/MainTemplate.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ const Template = require("./Template");
2929
* @property {Chunk} chunk the chunk used to render
3030
* @property {Hash} hash
3131
* @property {string} fullHash
32-
* @property {any} outputOptions
32+
* @property {TODO} outputOptions
3333
* @property {{javascript: ModuleTemplate, webassembly: ModuleTemplate}} moduleTemplates
34-
* @property {Map} dependencyTemplates
34+
* @property {Map<TODO, TODO>} dependencyTemplates
3535
*/
3636

3737
// require function shortcuts:
@@ -53,14 +53,14 @@ const Template = require("./Template");
5353
module.exports = class MainTemplate extends Tapable {
5454
/**
5555
*
56-
* @param {any=} outputOptions output options for the MainTemplate
56+
* @param {TODO=} outputOptions output options for the MainTemplate
5757
*/
5858
constructor(outputOptions) {
5959
super();
60-
/** @type {any?} */
60+
/** @type {TODO?} */
6161
this.outputOptions = outputOptions || {};
6262
this.hooks = {
63-
/** @type {SyncWaterfallHook<any[], RenderManifestOptions>} */
63+
/** @type {SyncWaterfallHook<TODO[], RenderManifestOptions>} */
6464
renderManifest: new SyncWaterfallHook(["result", "options"]),
6565
modules: new SyncWaterfallHook([
6666
"modules",
@@ -322,7 +322,7 @@ module.exports = class MainTemplate extends Tapable {
322322
/**
323323
*
324324
* @param {RenderManifestOptions} options render manifest options
325-
* @returns {any[]} returns render manifest
325+
* @returns {TODO[]} returns render manifest
326326
*/
327327
getRenderManifest(options) {
328328
const result = [];
@@ -337,8 +337,8 @@ module.exports = class MainTemplate extends Tapable {
337337
* @param {string} hash hash to be used for render call
338338
* @param {Chunk} chunk Chunk instance
339339
* @param {ModuleTemplate} moduleTemplate ModuleTemplate instance for render
340-
* @param {any} dependencyTemplates DependencyTemplate[]s
341-
* @return {ConcatSource} the newly generated source from rendering
340+
* @param {TODO} dependencyTemplates DependencyTemplate[]s
341+
* @returns {ConcatSource} the newly generated source from rendering
342342
*/
343343
render(hash, chunk, moduleTemplate, dependencyTemplates) {
344344
const buf = [];
@@ -390,7 +390,7 @@ module.exports = class MainTemplate extends Tapable {
390390
* @param {string} hash hash for render fn
391391
* @param {Chunk} chunk Chunk instance for require
392392
* @param {(number|string)=} varModuleId module id
393-
* @return {any} the moduleRequire hook call return signature
393+
* @returns {TODO} the moduleRequire hook call return signature
394394
*/
395395
renderRequireFunctionForModule(hash, chunk, varModuleId) {
396396
return this.hooks.moduleRequire.call(
@@ -407,7 +407,7 @@ module.exports = class MainTemplate extends Tapable {
407407
* @param {Chunk} chunk Chunk instance for require add fn
408408
* @param {(string|number)=} varModuleId module id
409409
* @param {Module} varModule Module instance
410-
* @return {any} renderAddModule call
410+
* @returns {TODO} renderAddModule call
411411
*/
412412
renderAddModule(hash, chunk, varModuleId, varModule) {
413413
return this.hooks.addModule.call(
@@ -423,7 +423,7 @@ module.exports = class MainTemplate extends Tapable {
423423
*
424424
* @param {string} hash string hash
425425
* @param {number} length length
426-
* @return {any} call hook return
426+
* @returns {string} call hook return
427427
*/
428428
renderCurrentHashCode(hash, length) {
429429
length = length || Infinity;
@@ -436,7 +436,7 @@ module.exports = class MainTemplate extends Tapable {
436436
/**
437437
*
438438
* @param {object} options get public path options
439-
* @return {any} hook call
439+
* @returns {string} hook call
440440
*/
441441
getPublicPath(options) {
442442
return this.hooks.assetPath.call(

lib/NormalModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class NonErrorEmittedError extends WebpackError {
6464

6565
/**
6666
* @typedef {Object} CachedSourceEntry
67-
* @property {any} source the generated source
67+
* @property {TODO} source the generated source
6868
* @property {string} hash the hash value
6969
*/
7070

0 commit comments

Comments
 (0)