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 linter for obsolete data #16429

Merged
merged 3 commits into from
Jun 4, 2022
Merged

Add linter for obsolete data #16429

merged 3 commits into from
Jun 4, 2022

Conversation

bershanskiy
Copy link
Contributor

Summary

Adds linter which checks for guideline called Removal of irrelevant features.

Test results and supporting details

It is a linter, not data.

Related issues

N/A

Please note: currently this linter checks only the original two rules:

  • a feature was never implemented in any browser and the specification has been abandoned.
  • a feature was implemented and has since been removed from all browsers dating back two or more years ago.
    I'm not sure how to interpret the third rule:
  • a feature is unsupported in all releases in the past five years.

As written, the third rule seems to imply the second rule: if a feature meets the third rule -- it hasn't been supported for 5 years -- then it seems to me it meets the second rule -- it might have been implemented but hasn't been supported for 2 years.

@github-actions github-actions bot added the linter Issues or pull requests regarding the tests / linter of the JSON files. label May 25, 2022
Copy link
Contributor

@queengooborg queengooborg left a comment

Choose a reason for hiding this comment

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

Thank you for doing this! I haven't fully reviewed this PR (I'm on my phone), but I have one comment first.

By the way, regarding that third rule, I realized the wording is confusing, it took me a while to realize what it's for. The rule is a clause for IE data: although the feature is supported in IE11, the "current" version, since IE has not gotten an update in over five years and all other browsers don't support it, we would be able to remove it based upon this clause!

new Date(
browsers[browser].releases[d.version_removed].release_date,
).getTime() >
new Date().getTime() - 2 * 365 * 24 * 60 * 60 * 1000
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we actually hard-code a date? Performing math to calculate two years difference is more than alright, but I wouldn't want to have the lint suddenly fail on main and cause test failures in others' PRs!

Copy link
Contributor Author

@bershanskiy bershanskiy May 25, 2022

Choose a reason for hiding this comment

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

That is a valid concern, I wasn't sure what I should do. I was thinking about making a chron-based CI workflow, but the current test infrastructure does not really support this. If we hard-code the date, how do we know when to update it? Also, we can use two-tier messaging: warnings for features that were obsolete for more than 2 years but less than 2.5 years and errors for features that have been obsolete for over 2.5 years. Also, I chose to define a year as 365 days entirely arbitrarily but can change it.

@bershanskiy
Copy link
Contributor Author

By the way, regarding that third rule, I realized the wording is confusing, it took me a while to realize what it's for. The rule is a clause for IE data: although the feature is supported in IE11, the "current" version, since IE has not gotten an update in over five years and all other browsers don't support it, we would be able to remove it based upon this clause!

I believe this rule was introduced in #6429, however, I still do not fully understand the clause even after reading the lined discussion. Since IE data might be deprecated soon, we probably can ignore that clause for now. I'll implement it if MDN team decides to keep IE data around.

@queengooborg
Copy link
Contributor

Warnings sound good to me! Perhaps we should get openwebdocs/project#79 implemented first in this case, though?

@bershanskiy
Copy link
Contributor Author

Warnings sound good to me!

I'll use warnings then.

Perhaps we should get openwebdocs/project#79 implemented first in this case, though?

Thanks for letting me know about this project. I don't think this particular test needs to wait for a new linter, but we will be able to migrate this test to a new linter easily.

@github-actions
Copy link

github-actions bot commented Jun 1, 2022

This pull request has merge conflicts that must be resolved before it can be merged.

@queengooborg
Copy link
Contributor

Oops, I performed a semi-merge and didn't realize until I did that this was another's PR, sorry about that!

@bershanskiy
Copy link
Contributor Author

I still need to implement this:

Also, we can use two-tier messaging: warnings for features that were obsolete for more than 2 years but less than 2.5 years and errors for features that have been obsolete for over 2.5 years.

@bershanskiy
Copy link
Contributor Author

Oops, I performed a semi-merge and didn't realize until I did that this was another's PR, sorry about that!

I just force-pushed a rebase, you rebase is available on this branch.

@queengooborg
Copy link
Contributor

Also, we can use two-tier messaging: warnings for features that were obsolete for more than 2 years but less than 2.5 years and errors for features that have been obsolete for over 2.5 years.

The next-gen linter has been implemented now, and as a part of it, I implemented issue levels, including warnings. All you need to do is call logger.warning() instead!

@queengooborg queengooborg self-requested a review June 2, 2022 12:25
@bershanskiy
Copy link
Contributor Author

Also, we can use two-tier messaging: warnings for features that were obsolete for more than 2 years but less than 2.5 years and errors for features that have been obsolete for over 2.5 years.

The next-gen linter has been implemented now, and as a part of it, I implemented issue levels, including warnings. All you need to do is call logger.warning() instead!

Done!

Copy link
Contributor

@queengooborg queengooborg left a comment

Choose a reason for hiding this comment

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

Thank you for your PR -- just got a couple of feedback points, but LGTM overall!

test/linter/test-obsolete.js Outdated Show resolved Hide resolved
test/linter/test-obsolete.js Outdated Show resolved Hide resolved
test/linter/test-obsolete.js Outdated Show resolved Hide resolved
test/linter/test-obsolete.test.js Outdated Show resolved Hide resolved
test/linter/test-obsolete.js Outdated Show resolved Hide resolved
test/linter/test-obsolete.js Show resolved Hide resolved
test/linter/test-obsolete.js Outdated Show resolved Hide resolved
test/linter/test-obsolete.js Outdated Show resolved Hide resolved
@bershanskiy
Copy link
Contributor Author

@queengooborg Thanks for the review, I think I addressed all the comments!

Copy link
Contributor

@queengooborg queengooborg left a comment

Choose a reason for hiding this comment

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

Thank you for this! I just ran some quick tests to ensure this is functioning as expected, and all is looking good to me.

For a follow-up, I think we could also enforce the third condition for irrelevant features, where it can be removed if "a feature is unsupported in all releases in the past five years" so we can track IE-only features better. Something for the future though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linter Issues or pull requests regarding the tests / linter of the JSON files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants