From a2aabd09be97ad9532f9c2294cf245341268907a Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Mon, 23 Sep 2019 16:05:05 -0700 Subject: [PATCH 01/16] Consolidate descriptions linter functions into one --- test/linter/test-descriptions.js | 76 ++++++++++---------------------- 1 file changed, 24 insertions(+), 52 deletions(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index e9acd5262d7449..880fb1504d5277 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -5,63 +5,38 @@ const chalk = require('chalk'); * @param {String} apiName * @param {import('../utils').Logger} logger */ -function hasValidConstrutorDescription(apiData, apiName, logger) { - const constructor = apiData[apiName]; - if (constructor && constructor.__compat.description !== `${apiName}() constructor`) { - logger.error(chalk`{red Incorrect constructor description for {bold ${apiName}()} - Actual: {yellow "${constructor.__compat.description || ""}"} - Expected: {green "${apiName}() constructor"}}`); - } -} - -/** - * @param {Identifier} apiData - * @param {String} apiName - * @param {import('../utils').Logger} logger - */ -function hasCorrectDOMEventsDescription(apiData, apiName, logger) { +function processData(apiData, apiName, logger) { for (let methodName in apiData) { - if (methodName.endsWith("_event")) { - const event = apiData[methodName]; + const method = apiData[methodName]; + if (methodName == apiName) { + if (method.__compat.description !== `${apiName}() constructor`) { + logger.error(chalk`{red Incorrect constructor description for {bold ${apiName}()} + Actual: {yellow "${method.__compat.description || ""}"} + Expected: {green "${apiName}() constructor"}}`); + } + } else if (methodName.endsWith("_event")) { const eventName = methodName.replace("_event", ""); - if (event.__compat.description !== `${eventName} event`) { - logger.error(chalk`{red Incorrect event description for {bold ${apiName}#${methodName}} - Actual: {yellow "${event.__compat.description || ""}"} + if (method.__compat.description !== `${eventName} event`) { + logger.error(chalk`{red Incorrect event description for {bold ${apiName}.${methodName}} + Actual: {yellow "${method.__compat.description || ""}"} Expected: {green "${eventName} event"}}`); } - } - } -} - -/** - * @param {Identifier} apiData - * @param {String} apiName - * @param {import('../utils').Logger} logger - */ -function hasCorrectSecureContextRequiredDescription(apiData, apiName, logger) { - const secureContext = apiData.secure_context_required; - if (secureContext && secureContext.__compat.description !== `Secure context required`) { - logger.error(chalk`{red Incorrect secure context required description for {bold ${apiName}()} - Actual: {yellow "${secureContext.__compat.description || ""}"} + } else if (methodName == 'secure_context_required') { + if (method.__compat.description !== `Secure context required`) { + logger.error(chalk`{red Incorrect secure context required description for {bold ${apiName}()} + Actual: {yellow "${method.__compat.description || ""}"} Expected: {green "Secure context required"}}`); - } -} - -/** - * @param {Identifier} apiData - * @param {String} apiName - * @param {import('../utils').Logger} logger - */ -function hasCorrectWebWorkersDescription(apiData, apiName, logger) { - const workerSupport = apiData.worker_support; - if (workerSupport && workerSupport.__compat.description !== `Available in workers`) { - logger.error(chalk`{red Incorrect worker support description for {bold ${apiName}()} - Actual: {yellow "${workerSupport.__compat.description || ""}"} + } + } else if (methodName == 'worker_support') { + if (method.__compat.description !== `Available in workers`) { + logger.error(chalk`{red Incorrect worker support description for {bold ${apiName}()} + Actual: {yellow "${method.__compat.description || ""}"} Expected: {green "Available in workers"}}`); + } + } } } - /** * @param {string} filename */ @@ -81,10 +56,7 @@ function testDescriptions(filename) { if (data.api) { for (let apiName in data.api) { const apiData = data.api[apiName]; - hasValidConstrutorDescription(apiData, apiName, logger); - hasCorrectDOMEventsDescription(apiData, apiName, logger); - hasCorrectSecureContextRequiredDescription(apiData, apiName, logger); - hasCorrectWebWorkersDescription(apiData, apiName, logger); + processData(apiData, apiName, logger); } } From b77507afbb81627271072103598b70e72b737bf6 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Fri, 25 Oct 2019 11:57:50 -0700 Subject: [PATCH 02/16] Create checkError function --- test/linter/test-descriptions.js | 44 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index 1f608440fab0de..921bc2e8266ad0 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -1,5 +1,24 @@ const chalk = require('chalk'); +/** + * @param {String} error_type + * @param {String} name + * @param {Identifier} method + * @param {String} expected + * @param {import('../utils').Logger} logger + */ +function checkError(error_type, name, method, expected, logger) { + const actual = method.__compat.description || ""; + if (actual != expected) { + logger.error(chalk`{red Incorrect ${error_type} description for {bold ${name}} + Actual: {yellow "${actual}"} + Expected: {green "${expected}"}}`); + return true; + } + + return false; +} + /** * @param {Identifier} apiData * @param {String} apiName @@ -9,30 +28,13 @@ function processData(apiData, apiName, logger) { for (let methodName in apiData) { const method = apiData[methodName]; if (methodName == apiName) { - if (method.__compat.description !== `${apiName}() constructor`) { - logger.error(chalk`{red Incorrect constructor description for {bold ${apiName}()} - Actual: {yellow "${method.__compat.description || ""}"} - Expected: {green "${apiName}() constructor"}}`); - } + checkError("constructor", `${apiName}()`, method, `${apiName}() constructor`, logger); } else if (methodName.endsWith("_event")) { - const eventName = methodName.replace("_event", ""); - if (method.__compat.description !== `${eventName} event`) { - logger.error(chalk`{red Incorrect event description for {bold ${apiName}.${methodName}} - Actual: {yellow "${method.__compat.description || ""}"} - Expected: {green "${eventName} event"}}`); - } + checkError("event", `${apiName}.${methodName}`, method, `${methodName.replace("_event", "")} event`, logger); } else if (methodName == 'secure_context_required') { - if (method.__compat.description !== `Secure context required`) { - logger.error(chalk`{red Incorrect secure context required description for {bold ${apiName}()} - Actual: {yellow "${method.__compat.description || ""}"} - Expected: {green "Secure context required"}}`); - } + checkError("secure context required", `${apiName}()`, method, "Secure context required", logger); } else if (methodName == 'worker_support') { - if (method.__compat.description !== `Available in workers`) { - logger.error(chalk`{red Incorrect worker support description for {bold ${apiName}()} - Actual: {yellow "${method.__compat.description || ""}"} - Expected: {green "Available in workers"}}`); - } + checkError("worker", `${apiName}()`, method, "Available in workers", logger); } } } From 66a69f6c54ed5e982ac23ca292e45abb01d63748 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Fri, 25 Oct 2019 11:58:10 -0700 Subject: [PATCH 03/16] Standardize output --- test/linter/test-descriptions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index 921bc2e8266ad0..6323c5edfd9f97 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -10,7 +10,7 @@ const chalk = require('chalk'); function checkError(error_type, name, method, expected, logger) { const actual = method.__compat.description || ""; if (actual != expected) { - logger.error(chalk`{red Incorrect ${error_type} description for {bold ${name}} + logger.error(chalk`{red → Incorrect ${error_type} description for {bold ${name}} Actual: {yellow "${actual}"} Expected: {green "${expected}"}}`); return true; @@ -65,7 +65,7 @@ function testDescriptions(filename) { if (errors.length) { console.error(chalk`{red Descriptions – {bold ${errors.length}} ${errors.length === 1 ? 'error' : 'errors'}:}`); for (const error of errors) { - console.error(` ${error}`); + console.error(` ${error}`); } return true; } From d2cad507c03d163bc133cd9fa1677844f9520dbd Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Mon, 9 Dec 2019 05:56:12 -0800 Subject: [PATCH 04/16] Run Prettier on file --- test/linter/test-descriptions.js | 36 ++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index 25b983b0840910..e909c648f9f52f 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -13,7 +13,7 @@ const chalk = require('chalk'); * @param {Logger} logger */ function checkError(error_type, name, method, expected, logger) { - const actual = method.__compat.description || ""; + const actual = method.__compat.description || ''; if (actual != expected) { logger.error(chalk`{red → Incorrect ${error_type} description for {bold ${name}} Actual: {yellow "${actual}"} @@ -31,13 +31,37 @@ function processData(apiData, apiName, logger) { for (let methodName in apiData) { const method = apiData[methodName]; if (methodName == apiName) { - checkError("constructor", `${apiName}()`, method, `${apiName}() constructor`, logger); - } else if (methodName.endsWith("_event")) { - checkError("event", `${apiName}.${methodName}`, method, `${methodName.replace("_event", "")} event`, logger); + checkError( + 'constructor', + `${apiName}()`, + method, + `${apiName}() constructor`, + logger, + ); + } else if (methodName.endsWith('_event')) { + checkError( + 'event', + `${apiName}.${methodName}`, + method, + `${methodName.replace('_event', '')} event`, + logger, + ); } else if (methodName == 'secure_context_required') { - checkError("secure context required", `${apiName}()`, method, "Secure context required", logger); + checkError( + 'secure context required', + `${apiName}()`, + method, + 'Secure context required', + logger, + ); } else if (methodName == 'worker_support') { - checkError("worker", `${apiName}()`, method, "Available in workers", logger); + checkError( + 'worker', + `${apiName}()`, + method, + 'Available in workers', + logger, + ); } } } From 22f78f8e3a08f1c64f9a4ca8aafc88d3a021df09 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Sun, 2 Feb 2020 20:16:08 +0100 Subject: [PATCH 05/16] Use arrow functions --- test/linter/test-descriptions.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index e909c648f9f52f..cda55a97269e8f 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -12,7 +12,7 @@ const chalk = require('chalk'); * @param {String} expected * @param {Logger} logger */ -function checkError(error_type, name, method, expected, logger) { +const checkError = (error_type, name, method, expected, logger) => { const actual = method.__compat.description || ''; if (actual != expected) { logger.error(chalk`{red → Incorrect ${error_type} description for {bold ${name}} @@ -20,14 +20,14 @@ function checkError(error_type, name, method, expected, logger) { Expected: {green "${expected}"}}`); return true; } -} +}; /** * @param {Identifier} apiData * @param {String} apiName * @param {Logger} logger */ -function processData(apiData, apiName, logger) { +const processData = (apiData, apiName, logger) => { for (let methodName in apiData) { const method = apiData[methodName]; if (methodName == apiName) { @@ -64,12 +64,12 @@ function processData(apiData, apiName, logger) { ); } } -} +}; /** * @param {string} filename */ -function testDescriptions(filename) { +const testDescriptions = filename => { /** @type {Identifier} */ const data = require(filename); @@ -101,6 +101,6 @@ function testDescriptions(filename) { return true; } return false; -} +}; module.exports = testDescriptions; From 0c702f2dceb94ea49c15bba49f3d6bffceb80d69 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Sun, 2 Feb 2020 21:58:15 +0100 Subject: [PATCH 06/16] Remove redundant return --- test/linter/test-descriptions.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index cda55a97269e8f..abf672e317204e 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -18,7 +18,6 @@ const checkError = (error_type, name, method, expected, logger) => { logger.error(chalk`{red → Incorrect ${error_type} description for {bold ${name}} Actual: {yellow "${actual}"} Expected: {green "${expected}"}}`); - return true; } }; From c5576e0029d358632866cff7ccc6938e38247bf4 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Sun, 2 Feb 2020 22:02:09 +0100 Subject: [PATCH 07/16] Update JSDoc comments --- test/linter/test-descriptions.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index abf672e317204e..f2ceab48b80275 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -6,11 +6,14 @@ const chalk = require('chalk'); */ /** - * @param {String} error_type - * @param {String} name - * @param {Identifier} method - * @param {String} expected - * @param {Logger} logger + * Check for errors in the description of a specified statement's description and return whether there's an error and log as such + * + * @param {String} error_type The name of the error + * @param {String} name The name of the API method + * @param {Identifier} method The method's compat data + * @param {String} expected Expected description + * @param {Logger} logger The logger to output errors to + * @returns {void} */ const checkError = (error_type, name, method, expected, logger) => { const actual = method.__compat.description || ''; @@ -22,9 +25,12 @@ const checkError = (error_type, name, method, expected, logger) => { }; /** - * @param {Identifier} apiData - * @param {String} apiName - * @param {Logger} logger + * Process data and check for any incorrect descriptions in said data, logging any errors + * + * @param {Identifier} apiData The compat data to check through + * @param {String} apiName The name of the API + * @param {Logger} logger The logger to output errors to + * @returns {void} */ const processData = (apiData, apiName, logger) => { for (let methodName in apiData) { @@ -66,7 +72,10 @@ const processData = (apiData, apiName, logger) => { }; /** - * @param {string} filename + * Test all of the descriptions through the data in a given filename. This test only functions with files with API data; all other files are silently ignored + * + * @param {string} filename The file to test + * @returns {boolean} Whether the file has errors */ const testDescriptions = filename => { /** @type {Identifier} */ From 793d4d2f71d645da86fed5901a6d2ffc11665ebb Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 5 Feb 2020 01:41:02 +0100 Subject: [PATCH 08/16] Update JSDocs --- test/linter/test-descriptions.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index f2ceab48b80275..6b07666b5bf16a 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -8,10 +8,10 @@ const chalk = require('chalk'); /** * Check for errors in the description of a specified statement's description and return whether there's an error and log as such * - * @param {String} error_type The name of the error - * @param {String} name The name of the API method + * @param {string} error_type The name of the error + * @param {string} name The name of the API method * @param {Identifier} method The method's compat data - * @param {String} expected Expected description + * @param {string} expected Expected description * @param {Logger} logger The logger to output errors to * @returns {void} */ @@ -27,8 +27,8 @@ const checkError = (error_type, name, method, expected, logger) => { /** * Process data and check for any incorrect descriptions in said data, logging any errors * - * @param {Identifier} apiData The compat data to check through - * @param {String} apiName The name of the API + * @param {Identifier} apiData The data to test + * @param {string} apiName The name of the API * @param {Logger} logger The logger to output errors to * @returns {void} */ @@ -84,7 +84,11 @@ const testDescriptions = filename => { /** @type {string[]} */ const errors = []; const logger = { - /** @param {...unknown} message */ + /** + * logger.error + * + * @param {...*} message Messages to add to errors + */ error: (...message) => { errors.push(message.join(' ')); }, From b568e5c681479462f04eef76fefe259dd7219a82 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 5 Feb 2020 10:32:12 +0100 Subject: [PATCH 09/16] Add copyright notice --- test/linter/test-descriptions.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index 6b07666b5bf16a..6d4f0455d3f98d 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -1,3 +1,7 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +'use strict'; const chalk = require('chalk'); /** From 6d1a6892f6d93b319ac04182a838a2b53c54edab Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Mon, 6 Apr 2020 07:54:57 -0700 Subject: [PATCH 10/16] Create processApiData and move API check to processData --- test/linter/test-descriptions.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index 6d4f0455d3f98d..15d9e7ac9ccce6 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -29,14 +29,14 @@ const checkError = (error_type, name, method, expected, logger) => { }; /** - * Process data and check for any incorrect descriptions in said data, logging any errors + * Process API data and check for any incorrect descriptions in said data, logging any errors * * @param {Identifier} apiData The data to test * @param {string} apiName The name of the API * @param {Logger} logger The logger to output errors to * @returns {void} */ -const processData = (apiData, apiName, logger) => { +const processApiData = (apiData, apiName, logger) => { for (let methodName in apiData) { const method = apiData[methodName]; if (methodName == apiName) { @@ -75,6 +75,22 @@ const processData = (apiData, apiName, logger) => { } }; +/** + * Process data and check for any incorrect descriptions in said data, logging any errors + * + * @param {Identifier} data The data to test + * @param {Logger} logger The logger to output errors to + * @returns {void} + */ +const processData = (data, logger) => { + if (data.api) { + for (const apiName in data.api) { + const apiData = data.api[apiName]; + processApiData(apiData, apiName, logger); + } + } +}; + /** * Test all of the descriptions through the data in a given filename. This test only functions with files with API data; all other files are silently ignored * @@ -98,12 +114,7 @@ const testDescriptions = filename => { }, }; - if (data.api) { - for (const apiName in data.api) { - const apiData = data.api[apiName]; - processData(apiData, apiName, logger); - } - } + processData(data, logger); if (errors.length) { console.error( From dbae9d5aad4b2f065e08458bbdeb75b95486d2bc Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Sat, 30 May 2020 19:27:41 -0700 Subject: [PATCH 11/16] Fix bad merge --- test/linter/test-descriptions.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index 8ef9493e4062a1..fba5a33d16ee4e 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -124,13 +124,6 @@ const testDescriptions = filename => { processData(data, logger); - if (data.api && data.api.Permissions) { - for (const permissionKey in data.api.Permissions) { - const apiData = data.api.Permissions[permissionKey]; - hasCorrectPermissionDescription(apiData, permissionKey, logger); - } - } - if (errors.length) { console.error( chalk`{red Descriptions – {bold ${errors.length}} ${ From f2d7957697d3d29b1bb5bda9c74eab22d4e0f353 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Thu, 8 Oct 2020 15:27:02 -0700 Subject: [PATCH 12/16] Fix Prettier issues --- test/linter/test-descriptions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index c1f7049245109b..8766b02c00d847 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -115,6 +115,6 @@ const testDescriptions = filename => { logger.emit(); return logger.hasErrors(); -} +}; module.exports = testDescriptions; From 5d4063c92d86b3fd06bcbd437ea175ea80b94eaf Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Wed, 4 May 2022 02:34:02 -0700 Subject: [PATCH 13/16] Revert out-of-scope changes --- test/linter/test-descriptions.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index 8766b02c00d847..075a315e07fd97 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -1,7 +1,3 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -'use strict'; const chalk = require('chalk'); const { Logger } = require('./utils.js'); @@ -19,14 +15,14 @@ const { Logger } = require('./utils.js'); * @param {Logger} logger The logger to output errors to * @returns {void} */ -const checkError = (error_type, name, method, expected, logger) => { +function checkError(error_type, name, method, expected, logger) { const actual = method.__compat.description || ''; if (actual != expected) { logger.error(chalk`{red → Incorrect ${error_type} description for {bold ${name}} Actual: {yellow "${actual}"} Expected: {green "${expected}"}}`); } -}; +} /** * Process API data and check for any incorrect descriptions in said data, logging any errors @@ -36,7 +32,7 @@ const checkError = (error_type, name, method, expected, logger) => { * @param {Logger} logger The logger to output errors to * @returns {void} */ -const processApiData = (apiData, apiName, logger) => { +function processApiData(apiData, apiName, logger) { for (let methodName in apiData) { const method = apiData[methodName]; if (methodName == apiName) { @@ -81,7 +77,7 @@ const processApiData = (apiData, apiName, logger) => { ); } } -}; +} /** * Process data and check for any incorrect descriptions in said data, logging any errors @@ -90,14 +86,14 @@ const processApiData = (apiData, apiName, logger) => { * @param {Logger} logger The logger to output errors to * @returns {void} */ -const processData = (data, logger) => { +function processData(data, logger) { if (data.api) { for (const apiName in data.api) { const apiData = data.api[apiName]; processApiData(apiData, apiName, logger); } } -}; +} /** * Test all of the descriptions through the data in a given filename. This test only functions with files with API data; all other files are silently ignored @@ -105,7 +101,7 @@ const processData = (data, logger) => { * @param {string} filename The file to test * @returns {boolean} Whether the file has errors */ -const testDescriptions = filename => { +function testDescriptions(filename) { /** @type {Identifier} */ const data = require(filename); @@ -115,6 +111,6 @@ const testDescriptions = filename => { logger.emit(); return logger.hasErrors(); -}; +} module.exports = testDescriptions; From 983feaada7b7874343ab5272044443eb89736a62 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 12 May 2022 12:44:02 -0700 Subject: [PATCH 14/16] Update test/linter/test-descriptions.js Co-authored-by: Claas Augner --- test/linter/test-descriptions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index 075a315e07fd97..6b2b10c097ccf2 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -33,7 +33,7 @@ function checkError(error_type, name, method, expected, logger) { * @returns {void} */ function processApiData(apiData, apiName, logger) { - for (let methodName in apiData) { + for (const methodName in apiData) { const method = apiData[methodName]; if (methodName == apiName) { checkError( From 9acc96db00a01aa9d99ea82434d2192a40c48882 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 12 May 2022 13:38:17 -0700 Subject: [PATCH 15/16] Update method/variable names --- test/linter/test-descriptions.js | 48 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index 6b2b10c097ccf2..5b49ca1993d9be 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -8,17 +8,17 @@ const { Logger } = require('./utils.js'); /** * Check for errors in the description of a specified statement's description and return whether there's an error and log as such * - * @param {string} error_type The name of the error + * @param {string} ruleName The name of the error * @param {string} name The name of the API method * @param {Identifier} method The method's compat data * @param {string} expected Expected description * @param {Logger} logger The logger to output errors to * @returns {void} */ -function checkError(error_type, name, method, expected, logger) { +function checkDescription(ruleName, name, method, expected, logger) { const actual = method.__compat.description || ''; if (actual != expected) { - logger.error(chalk`{red → Incorrect ${error_type} description for {bold ${name}} + logger.error(chalk`{red → Incorrect ${ruleName} description for {bold ${name}} Actual: {yellow "${actual}"} Expected: {green "${expected}"}}`); } @@ -33,45 +33,45 @@ function checkError(error_type, name, method, expected, logger) { * @returns {void} */ function processApiData(apiData, apiName, logger) { - for (const methodName in apiData) { - const method = apiData[methodName]; - if (methodName == apiName) { - checkError( + for (const featureName in apiData) { + const feature = apiData[featureName]; + if (featureName == apiName) { + checkDescription( 'constructor', `${apiName}()`, - method, + feature, `${apiName}() constructor`, logger, ); - } else if (methodName.endsWith('_event')) { - checkError( + } else if (featureName.endsWith('_event')) { + checkDescription( 'event', - `${apiName}.${methodName}`, - method, - `${methodName.replace('_event', '')} event`, + `${apiName}.${featureName}`, + feature, + `${featureName.replace('_event', '')} event`, logger, ); - } else if (methodName.endsWith('_permission')) { - checkError( + } else if (featureName.endsWith('_permission')) { + checkDescription( 'permission', - `${apiName}.${methodName}`, - method, - `${methodName.replace('_permission', '')} permission`, + `${apiName}.${featureName}`, + feature, + `${featureName.replace('_permission', '')} permission`, logger, ); - } else if (methodName == 'secure_context_required') { - checkError( + } else if (featureName == 'secure_context_required') { + checkDescription( 'secure context required', `${apiName}()`, - method, + feature, 'Secure context required', logger, ); - } else if (methodName == 'worker_support') { - checkError( + } else if (featureName == 'worker_support') { + checkDescription( 'worker', `${apiName}()`, - method, + feature, 'Available in workers', logger, ); From 0c2b9c665e4c810ca6584eee31bb4254c9296b27 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 13 May 2022 13:37:06 -0700 Subject: [PATCH 16/16] Update test/linter/test-descriptions.js Co-authored-by: Claas Augner --- test/linter/test-descriptions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/linter/test-descriptions.js b/test/linter/test-descriptions.js index 5b49ca1993d9be..d520af44c253bf 100644 --- a/test/linter/test-descriptions.js +++ b/test/linter/test-descriptions.js @@ -10,7 +10,7 @@ const { Logger } = require('./utils.js'); * * @param {string} ruleName The name of the error * @param {string} name The name of the API method - * @param {Identifier} method The method's compat data + * @param {Identifier} feature - The feature's compat data. * @param {string} expected Expected description * @param {Logger} logger The logger to output errors to * @returns {void}