Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tips/hints to version test #5605

Merged
merged 6 commits into from
May 13, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions test/linter/test-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ const VERSION_RANGE_BROWSERS = {
webview_android: ['≤37'],
};

/** @type {Object<string, string>} */
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.',
};
queengooborg marked this conversation as resolved.
Show resolved Hide resolved

for (const browser of Object.keys(browsers)) {
validBrowserVersions[browser] = Object.keys(browsers[browser].releases);
if (VERSION_RANGE_BROWSERS[browser]) {
Expand Down Expand Up @@ -103,12 +111,24 @@ function checkVersions(supportData, relPath, logger) {
for (const statement of supportStatements) {
if (!isValidVersion(browser, statement.version_added)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to deduplicate these two blocks into a for ... of loop:

for (const property of ['version_added', 'version_removed']) {
  // ...
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to deduplicate these two blocks into a for ... of loop:

for (const property of ['version_added', 'version_removed']) {
  // ...
}

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_added' in statement && 'version_removed' in statement) {
Expand Down