From 5fb69b1de195d61d9d564badb9b288bde5d0d93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Tue, 9 Aug 2022 00:10:06 +0200 Subject: [PATCH] Some more small code improvements --- config/jsdoc/api/template/publish.js | 4 +--- config/jsdoc/info/publish.js | 6 +----- src/ol/util.js | 8 ++------ tasks/generate-info.js | 2 +- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/config/jsdoc/api/template/publish.js b/config/jsdoc/api/template/publish.js index e5bbfe66ff..e9a479d893 100644 --- a/config/jsdoc/api/template/publish.js +++ b/config/jsdoc/api/template/publish.js @@ -110,12 +110,10 @@ function addSignatureTypes(f) { function shortenPaths(files, commonPrefix) { // always use forward slashes - const regexp = new RegExp('\\\\', 'g'); - Object.keys(files).forEach(function (file) { files[file].shortened = files[file].resolved .replace(commonPrefix, '') - .replace(regexp, '/'); + .replaceAll('\\', '/'); }); return files; diff --git a/config/jsdoc/info/publish.js b/config/jsdoc/info/publish.js index 5d1c015f1b..9597d4e217 100644 --- a/config/jsdoc/info/publish.js +++ b/config/jsdoc/info/publish.js @@ -14,11 +14,7 @@ const path = require('path'); */ exports.publish = function (data, opts) { function getTypes(data) { - const types = []; - data.forEach(function (name) { - types.push(name.replace(/^function$/, 'Function')); - }); - return types; + return data.map((name) => name.replace(/^function$/, 'Function')); } // get all doclets that have exports diff --git a/src/ol/util.js b/src/ol/util.js index 7d61ca855b..40fc489fed 100644 --- a/src/ol/util.js +++ b/src/ol/util.js @@ -3,14 +3,10 @@ */ /** - * @return {?} Any return. + * @return {never} Any return. */ export function abstract() { - return /** @type {?} */ ( - (function () { - throw new Error('Unimplemented abstract method.'); - })() - ); + throw new Error('Unimplemented abstract method.'); } /** diff --git a/tasks/generate-info.js b/tasks/generate-info.js index 3c772ccfd0..ee9660554f 100644 --- a/tasks/generate-info.js +++ b/tasks/generate-info.js @@ -69,7 +69,7 @@ function getPaths() { const walker = walk(sourceDir); walker.on('file', (root, stats, next) => { const sourcePath = path.join(root, stats.name); - if (/\.js$/.test(sourcePath)) { + if (sourcePath.endsWith('.js')) { paths.push(sourcePath); } next();