Skip to content

Commit 609fd3d

Browse files
committed
Migrate to eslint-plugin-jsdoc
The deprecated valid-jsdoc rule of eslint does not support using typescript syntax for types, while it allows being more precise about types in a much more readable way than using the older jsdoc syntax with separate typedef or callback definitions. The plugin also implements more rules than what valid-jsdoc does.
1 parent e8ac09f commit 609fd3d

39 files changed

+110
-63
lines changed

.eslintrc.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
module.exports = {
1111
"root": true,
12-
"plugins": ["node", "header"],
13-
"extends": ["eslint:recommended", "plugin:node/recommended"],
12+
"plugins": ["node", "header", "jsdoc"],
13+
"extends": ["eslint:recommended", "plugin:node/recommended", "plugin:jsdoc/recommended"],
1414
"env": {
1515
"node": true,
1616
"es6": true,
@@ -49,7 +49,12 @@ module.exports = {
4949
"after": true
5050
}],
5151
"no-console": "off",
52-
"valid-jsdoc": ["error", { "requireParamDescription": false, "requireReturnDescription": false }],
52+
"jsdoc/require-jsdoc": "off",
53+
"jsdoc/require-param-description": "off",
54+
"jsdoc/require-property-description": "off",
55+
"jsdoc/require-returns-description": "off",
56+
// We use typescript-like literal `false` for some signatures, which is not yet supported natively by eslint-plugin-jsdoc
57+
"jsdoc/no-undefined-types": ["error", { definedTypes: ["false"] }],
5358
"node/no-unsupported-features": ["error", { version: 8 }],
5459
"node/no-deprecated-api": "error",
5560
"node/no-missing-import": "error",
@@ -66,6 +71,11 @@ module.exports = {
6671
"node/process-exit-as-throw": "error",
6772
"header/header": [2, "block", { "pattern": "This file is part of the Symfony Webpack Encore package" }]
6873
},
74+
"settings": {
75+
"jsdoc": {
76+
"mode": "typescript"
77+
}
78+
},
6979
"overrides": [
7080
{
7181
"files": [".eslintrc.js"],

index.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class Encore {
114114
* })
115115
* ```
116116
*
117-
* @param {function} definePluginOptionsCallback
117+
* @param {Function} definePluginOptionsCallback
118118
* @returns {Encore}
119119
*/
120120
configureDefinePlugin(definePluginOptionsCallback = () => {}) {
@@ -135,7 +135,7 @@ class Encore {
135135
* })
136136
* ```
137137
*
138-
* @param {function} friendlyErrorsPluginOptionsCallback
138+
* @param {Function} friendlyErrorsPluginOptionsCallback
139139
* @returns {Encore}
140140
*/
141141
configureFriendlyErrorsPlugin(friendlyErrorsPluginOptionsCallback = () => {}) {
@@ -156,7 +156,7 @@ class Encore {
156156
* })
157157
* ```
158158
*
159-
* @param {function} manifestPluginOptionsCallback
159+
* @param {Function} manifestPluginOptionsCallback
160160
* @returns {Encore}
161161
*/
162162
configureManifestPlugin(manifestPluginOptionsCallback = () => {}) {
@@ -182,7 +182,7 @@ class Encore {
182182
* })
183183
* ```
184184
*
185-
* @param {function} terserPluginOptionsCallback
185+
* @param {Function} terserPluginOptionsCallback
186186
* @returns {Encore}
187187
*/
188188
configureTerserPlugin(terserPluginOptionsCallback = () => {}) {
@@ -203,7 +203,7 @@ class Encore {
203203
* })
204204
* ```
205205
*
206-
* @param {function} cssMinimizerPluginOptionsCallback
206+
* @param {Function} cssMinimizerPluginOptionsCallback
207207
* @returns {Encore}
208208
*/
209209
configureCssMinimizerPlugin(cssMinimizerPluginOptionsCallback = () => {}) {
@@ -347,7 +347,7 @@ class Encore {
347347
* })
348348
* ```
349349
*
350-
* @param {Object<string, string>} aliases
350+
* @param {object<string, string>} aliases
351351
*
352352
* @returns {Encore}
353353
*/
@@ -721,7 +721,7 @@ class Encore {
721721
* This is useful for older packages, that might
722722
* expect jQuery (or something else) to be a global variable.
723723
*
724-
* @param {Object<string, string|string[]>} variables
724+
* @param {object<string, string | string[]>} variables
725725
* @returns {Encore}
726726
*/
727727
autoProvideVariables(variables) {
@@ -1031,7 +1031,7 @@ class Encore {
10311031
* ```
10321032
*
10331033
* @param {object} buildDependencies
1034-
* @param {function} cacheCallback
1034+
* @param {Function} cacheCallback
10351035
* @returns {Encore}
10361036
*/
10371037
enableBuildCache(buildDependencies, cacheCallback = (cache) => {}) {
@@ -1058,8 +1058,8 @@ class Encore {
10581058
* );
10591059
* ```
10601060
*
1061-
* @param {function} loaderOptionsCallback
1062-
* @param {function} pluginOptionsCallback
1061+
* @param {Function} loaderOptionsCallback
1062+
* @param {Function} pluginOptionsCallback
10631063
* @returns {Encore}
10641064
*/
10651065
configureMiniCssExtractPlugin(loaderOptionsCallback, pluginOptionsCallback = () => {}) {
@@ -1271,7 +1271,6 @@ class Encore {
12711271
* Supported options:
12721272
* * {boolean} lintVue (default=false)
12731273
* Configure the loader to lint `.vue` files
1274-
* ```
12751274
*
12761275
* @param {string|object|(function(object): object|void)} eslintLoaderOptionsOrCallback
12771276
* @param {{lintVue?: boolean}} encoreOptions
@@ -1349,6 +1348,7 @@ class Encore {
13491348
*
13501349
* Internally, this disables the mini-css-extract-plugin
13511350
* and uses the style-loader instead.
1351+
*
13521352
* @param {boolean} disabled
13531353
* @returns {Encore}
13541354
*/
@@ -1458,7 +1458,7 @@ class Encore {
14581458
* ```
14591459
*
14601460
* @param {object} options
1461-
* @param {string|object|function} ruleCallback
1461+
* @param {string|object|Function} ruleCallback
14621462
* @returns {Encore}
14631463
*/
14641464
configureImageRule(options = {}, ruleCallback = (rule) => {}) {
@@ -1475,7 +1475,7 @@ class Encore {
14751475
* See configureImageRule() for more details.
14761476
*
14771477
* @param {object} options
1478-
* @param {string|object|function} ruleCallback
1478+
* @param {string|object|Function} ruleCallback
14791479
* @returns {Encore}
14801480
*/
14811481
configureFontRule(options = {}, ruleCallback = (rule) => {}) {
@@ -1504,7 +1504,7 @@ class Encore {
15041504
*
15051505
* @param {string} name
15061506
* @param {function(webpack.RuleSetRule): webpack.RuleSetRule|void} callback
1507-
* @return {Encore}
1507+
* @returns {Encore}
15081508
*/
15091509
configureLoaderRule(name, callback) {
15101510
webpackConfig.configureLoaderRule(name, callback);
@@ -1700,6 +1700,7 @@ class Encore {
17001700
/**
17011701
* Proxy the API in order to prevent calls to most of its methods
17021702
* if the webpackConfig object hasn't been initialized yet.
1703+
*
17031704
* @type {Encore}
17041705
*/
17051706
module.exports = EncoreProxy.createProxy(new Encore());

lib/WebpackConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const { calculateDevServerUrl } = require('./config/path-util');
1919

2020
/**
2121
* @param {RuntimeConfig|null} runtimeConfig
22-
* @return {void}
22+
* @returns {void}
2323
*/
2424
function validateRuntimeConfig(runtimeConfig) {
2525
// if you're using the encore executable, these things should never happen
@@ -38,7 +38,7 @@ function validateRuntimeConfig(runtimeConfig) {
3838

3939
/**
4040
* @param {RuntimeConfig} runtimeConfig
41-
* @return {void}
41+
* @returns {void}
4242
*/
4343
function checkPackageJson(runtimeConfig) {
4444
// Display a warning if webpack is listed as a [dev-]dependency

lib/config-generator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ class ConfigGenerator {
619619
/**
620620
* @param {WebpackConfig} webpackConfig A configured WebpackConfig object
621621
*
622-
* @return {*} The final webpack config object
622+
* @returns {*} The final webpack config object
623623
*/
624624
module.exports = function(webpackConfig) {
625625
const generator = new ConfigGenerator(webpackConfig);

lib/config/parse-runtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const babel = require('@babel/core');
1616

1717
/**
1818
* @param {object} argv
19-
* @param {String} cwd
19+
* @param {string} cwd
2020
* @returns {RuntimeConfig}
2121
*/
2222
module.exports = function(argv, cwd) {

lib/config/path-util.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
* Determines the "contentBase" to use for the devServer.
2020
*
2121
* @param {WebpackConfig} webpackConfig
22-
* @return {String}
22+
* @returns {string}
2323
*/
2424
getContentBase(webpackConfig) {
2525
// strip trailing slash (for Unix or Windows)
@@ -59,7 +59,7 @@ module.exports = {
5959
* Returns the output path, but as a relative string (e.g. web/build)
6060
*
6161
* @param {WebpackConfig} webpackConfig
62-
* @return {String}
62+
* @returns {string}
6363
*/
6464
getRelativeOutputPath(webpackConfig) {
6565
return webpackConfig.outputPath.replace(webpackConfig.getContext() + path.sep, '');
@@ -72,7 +72,7 @@ module.exports = {
7272
* ok to use the publicPath as the manifestKeyPrefix.
7373
*
7474
* @param {WebpackConfig} webpackConfig
75-
* @return {void}
75+
* @returns {void}
7676
*/
7777
validatePublicPathAndManifestKeyPrefix(webpackConfig) {
7878
if (webpackConfig.manifestKeyPrefix !== null) {
@@ -120,7 +120,7 @@ module.exports = {
120120

121121
/**
122122
* @param {RuntimeConfig} runtimeConfig
123-
* @return {string|null|Object.public|*}
123+
* @returns {string}
124124
*/
125125
calculateDevServerUrl(runtimeConfig) {
126126
if (runtimeConfig.devServerFinalIsHttps === null) {

lib/loaders/babel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const applyOptionsCallback = require('../utils/apply-options-callback');
1616
module.exports = {
1717
/**
1818
* @param {WebpackConfig} webpackConfig
19-
* @return {Array} of loaders to use for Babel
19+
* @returns {Array} of loaders to use for Babel
2020
*/
2121
getLoaders(webpackConfig) {
2222
let babelConfig = {
@@ -106,7 +106,7 @@ module.exports = {
106106

107107
/**
108108
* @param {WebpackConfig} webpackConfig
109-
* @return {RegExp} to use for eslint-loader `test` rule
109+
* @returns {RegExp} to use for eslint-loader `test` rule
110110
*/
111111
getTest(webpackConfig) {
112112
const extensions = [

lib/loaders/css-extract.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
*
2020
* @param {WebpackConfig} webpackConfig
2121
* @param {Array} loaders An array of some style loaders
22-
* @return {Array}
22+
* @returns {Array}
2323
*/
2424
prependLoaders(webpackConfig, loaders) {
2525
if (!webpackConfig.extractCss) {

lib/loaders/css.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
/**
1818
* @param {WebpackConfig} webpackConfig
1919
* @param {boolean} useCssModules
20-
* @return {Array} of loaders to use for CSS files
20+
* @returns {Array} of loaders to use for CSS files
2121
*/
2222
getLoaders(webpackConfig, useCssModules = false) {
2323
const usePostCssLoader = webpackConfig.usePostCssLoader;

lib/loaders/eslint.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function isMissingConfigError(e) {
2424
module.exports = {
2525
/**
2626
* @param {WebpackConfig} webpackConfig
27-
* @return {Object} of options to use for eslint-loader options.
27+
* @returns {object} of options to use for eslint-loader options.
2828
*/
2929
getOptions(webpackConfig) {
3030
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('eslint');
@@ -73,7 +73,7 @@ Install ${chalk.yellow('babel-eslint')} to prevent potential parsing issues: ${p
7373

7474
/**
7575
* @param {WebpackConfig} webpackConfig
76-
* @return {RegExp} to use for eslint-loader `test` rule
76+
* @returns {RegExp} to use for eslint-loader `test` rule
7777
*/
7878
getTest(webpackConfig) {
7979
const extensions = ['jsx?'];

lib/loaders/handlebars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const applyOptionsCallback = require('../utils/apply-options-callback');
1616
module.exports = {
1717
/**
1818
* @param {WebpackConfig} webpackConfig
19-
* @return {Array} of loaders to use for Handlebars
19+
* @returns {Array} of loaders to use for Handlebars
2020
*/
2121
getLoaders(webpackConfig) {
2222
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('handlebars');

lib/loaders/less.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
/**
1919
* @param {WebpackConfig} webpackConfig
2020
* @param {boolean} useCssModules
21-
* @return {Array} of loaders to use for Less files
21+
* @returns {Array} of loaders to use for Less files
2222
*/
2323
getLoaders(webpackConfig, useCssModules = false) {
2424
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('less');

lib/loaders/sass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
/**
1919
* @param {WebpackConfig} webpackConfig
2020
* @param {boolean} useCssModules
21-
* @return {Array} of loaders to use for Sass files
21+
* @returns {Array} of loaders to use for Sass files
2222
*/
2323
getLoaders(webpackConfig, useCssModules = false) {
2424
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('sass');

lib/loaders/stylus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
/**
1919
* @param {WebpackConfig} webpackConfig
2020
* @param {boolean} useCssModules
21-
* @return {Array} of loaders to use for Stylus files
21+
* @returns {Array} of loaders to use for Stylus files
2222
*/
2323
getLoaders(webpackConfig, useCssModules = false) {
2424
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('stylus');

lib/loaders/typescript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const applyOptionsCallback = require('../utils/apply-options-callback');
1717
module.exports = {
1818
/**
1919
* @param {WebpackConfig} webpackConfig
20-
* @return {Array} of loaders to use for TypeScript
20+
* @returns {Array} of loaders to use for TypeScript
2121
*/
2222
getLoaders(webpackConfig) {
2323
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('typescript');

lib/loaders/vue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const getVueVersion = require('../utils/get-vue-version');
1717
module.exports = {
1818
/**
1919
* @param {WebpackConfig} webpackConfig
20-
* @return {Array} of loaders to use for Vue files
20+
* @returns {Array} of loaders to use for Vue files
2121
*/
2222
getLoaders(webpackConfig) {
2323
const vueVersion = getVueVersion(webpackConfig);

lib/plugins/asset-output-display.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const PluginPriorities = require('./plugin-priorities');
2121
* @param {Array} plugins
2222
* @param {WebpackConfig} webpackConfig
2323
* @param {FriendlyErrorsWebpackPlugin} friendlyErrorsPlugin
24-
* @return {void}
24+
* @returns {void}
2525
*/
2626
module.exports = function(plugins, webpackConfig, friendlyErrorsPlugin) {
2727
if (webpackConfig.useDevServer()) {

lib/plugins/clean.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const applyOptionsCallback = require('../utils/apply-options-callback');
1919
*
2020
* @param {Array} plugins to push to
2121
* @param {WebpackConfig} webpackConfig read only variable
22-
* @return {void}
22+
* @returns {void}
2323
*/
2424
module.exports = function(plugins, webpackConfig) {
2525

lib/plugins/define.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const applyOptionsCallback = require('../utils/apply-options-callback');
1717
/**
1818
* @param {Array} plugins
1919
* @param {WebpackConfig} webpackConfig
20-
* @return {void}
20+
* @returns {void}
2121
*/
2222
module.exports = function(plugins, webpackConfig) {
2323
const definePluginOptions = {

lib/plugins/delete-unused-entries.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const copyEntryTmpName = require('../utils/copyEntryTmpName');
1717
/**
1818
* @param {Array} plugins
1919
* @param {WebpackConfig} webpackConfig
20-
* @return {void}
20+
* @returns {void}
2121
*/
2222
module.exports = function(plugins, webpackConfig) {
2323
const entries = [... webpackConfig.styleEntries.keys()];

lib/plugins/entry-files-manifest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function processOutput(webpackConfig) {
8484
/**
8585
* @param {Array} plugins
8686
* @param {WebpackConfig} webpackConfig
87-
* @return {void}
87+
* @returns {void}
8888
*/
8989
module.exports = function(plugins, webpackConfig) {
9090
plugins.push({

0 commit comments

Comments
 (0)