From ce1d69c181191a5c9c82f8dfd189c77cccae0831 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 29 Jan 2020 23:19:09 +0100 Subject: [PATCH 1/3] Add tips/hints to version test --- test/linter/test-versions.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/linter/test-versions.js b/test/linter/test-versions.js index b3f7eeecbf8f78..7f2b652d690240 100644 --- a/test/linter/test-versions.js +++ b/test/linter/test-versions.js @@ -19,6 +19,14 @@ const VERSION_RANGE_BROWSERS = { edge: ['≤18', '≤79'], }; +/** @type {Object} */ +const browserTips = { + safari_ios: + 'The version numbers for Safari for iOS are based upon the iOS version number rather than the Safari version number. Maybe you are trying to use the desktop version number?', + opera_android: + 'Blink editions of Opera Android and Opera desktop were the Chrome version number minus 13, up until Opera Android 43 when they began skipping Chrome versions. Please double-check browsers/opera_android.json to make sure you are using the correct versions.', +}; + /** @type string[] */ const FLAGLESS_BROWSERS = ['webview_android']; @@ -68,12 +76,24 @@ function checkVersions(supportData, relPath, logger) { for (const statement of supportStatements) { if (!isValidVersion(browser, statement.version_added)) { logger.error( - chalk`{red → {bold ${relPath}} - {bold version_added: "${statement.version_added}"} is {bold NOT} a valid version number for {bold ${browser}}\n Valid {bold ${browser}} versions are: ${validBrowserVersionsString}}`, + chalk`{red → {bold ${relPath}} - {bold version_added: "${ + statement.version_added + }"} is {bold NOT} a valid version number for {bold ${browser}}\n Valid {bold ${browser}} versions are: ${validBrowserVersionsString}}${ + browserTips[browser] + ? chalk`\n {blue {bold Tip:} ${browserTips[browser]}}` + : '' + }`, ); } if (!isValidVersion(browser, statement.version_removed)) { logger.error( - chalk`{red → {bold ${relPath}} - {bold version_removed: "${statement.version_removed}"} is {bold NOT} a valid version number for {bold ${browser}}\n Valid {bold ${browser}} versions are: ${validBrowserVersionsString}}`, + chalk`{red → {bold ${relPath}} - {bold version_removed: "${ + statement.version_removed + }"} is {bold NOT} a valid version number for {bold ${browser}}\n Valid {bold ${browser}} versions are: ${validBrowserVersionsString}}${ + browserTips[browser] + ? chalk`\n {blue {bold Tip:} ${browserTips[browser]}}` + : '' + }`, ); } if ('version_removed' in statement && 'version_added' in statement) { From 0850619e2607a6a5fe94026e48158cbdfa5475ed Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 13 May 2022 13:31:45 -0700 Subject: [PATCH 2/3] Update test/linter/test-versions.js Co-authored-by: Claas Augner --- test/linter/test-versions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/linter/test-versions.js b/test/linter/test-versions.js index ce9cdfc58cf129..144e14648bc123 100644 --- a/test/linter/test-versions.js +++ b/test/linter/test-versions.js @@ -28,9 +28,9 @@ const VERSION_RANGE_BROWSERS = { /** @type {Object} */ const browserTips = { safari_ios: - 'The version numbers for Safari for iOS are based upon the iOS version number rather than the Safari version number. Maybe you are trying to use the desktop version number?', + 'The version numbers for Safari for iOS are based upon the iOS version number rather than the Safari version number. Maybe you are trying to use the desktop version number?', opera_android: - 'Blink editions of Opera Android and Opera desktop were the Chrome version number minus 13, up until Opera Android 43 when they began skipping Chrome versions. Please double-check browsers/opera_android.json to make sure you are using the correct versions.', + 'Blink editions of Opera Android and Opera desktop were the Chrome version number minus 13, up until Opera Android 43 when they began skipping Chrome versions. Please double-check browsers/opera_android.json to make sure you are using the correct versions.', }; for (const browser of Object.keys(browsers)) { From 25e20b0dd1585e7c39c4447f3be350cd415f71c3 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 13 May 2022 13:34:53 -0700 Subject: [PATCH 3/3] Simplify version added/removed check --- test/linter/test-versions.js | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/test/linter/test-versions.js b/test/linter/test-versions.js index fe8bfc6d6adb50..21098f571c02e1 100644 --- a/test/linter/test-versions.js +++ b/test/linter/test-versions.js @@ -132,28 +132,20 @@ function checkVersions(supportData, relPath, logger) { let sawVersionAddedOnly = false; for (const statement of supportStatements) { - if (!isValidVersion(browser, statement.version_added)) { - logger.error( - chalk`{red → {bold ${relPath}} - {bold version_added: "${ - statement.version_added - }"} is {bold NOT} a valid version number for {bold ${browser}}\n Valid {bold ${browser}} versions are: ${validBrowserVersionsString}}${ - browserTips[browser] - ? chalk`\n {blue {bold Tip:} ${browserTips[browser]}}` - : '' - }`, - ); - } - if (!isValidVersion(browser, statement.version_removed)) { - logger.error( - chalk`{red → {bold ${relPath}} - {bold version_removed: "${ - statement.version_removed - }"} is {bold NOT} a valid version number for {bold ${browser}}\n Valid {bold ${browser}} versions are: ${validBrowserVersionsString}}${ - browserTips[browser] - ? chalk`\n {blue {bold Tip:} ${browserTips[browser]}}` - : '' - }`, - ); + for (const property of ['version_added', 'version_removed']) { + if (!isValidVersion(browser, statement[property])) { + logger.error( + chalk`{red → {bold ${relPath}} - {bold ${property}: "${ + statement[property] + }"} is {bold NOT} a valid version number for {bold ${browser}}\n Valid {bold ${browser}} versions are: ${validBrowserVersionsString}}${ + browserTips[browser] + ? chalk`\n {blue {bold Tip:} ${browserTips[browser]}}` + : '' + }`, + ); + } } + if ('version_added' in statement && 'version_removed' in statement) { if (statement.version_added === statement.version_removed) { logger.error(