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

feat: Add preamble-future-date lint for last-call-deadline validation #120

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

apeaircreative
Copy link

Adds a new preamble-future-date lint that validates the last-call-deadline field in EIP preambles. According to EIP-1, this field must be today or a future date when status is "Last Call", using ISO 8601 format (YYYY-MM-DD). The lint includes comprehensive tests and clear error messages. Fixes #21.

This commit adds a new lint that validates that the last-call-deadline
field in EIP preambles is set to a future date when the EIP status is
'Last Call'. The lint:

- Only checks if status is 'Last Call'
- Compares the deadline date with today's date
- Reports an error if the deadline is not in the future
- Includes helpful error messages

This helps ensure that Last Call deadlines are always set to future dates,
making the EIP process more robust.
Adds validation for last-call-deadline to ensure it is set to a future date when EIP status is Last Call. Updates include:
- Added FutureDate lint to default lints
- Fixed serialization format for better compatibility
- Added comprehensive tests for past, future, and non-Last Call cases
Adds comprehensive documentation explaining the purpose,
behavior, and usage of the FutureDate lint.
According to EIP-1, last-call-deadline represents when the
last call period ends, so today's date should be valid.
Also improved error messages to be clearer about this.
Updated test assertions to match the new error messages
that allow today's date as valid for last-call-deadline.
@apeaircreative
Copy link
Author

apeaircreative commented Jan 3, 2025

Hey @SamWilsn I have some updates.

I've added more test cases inspired by #93, covering:

  • Image alt text handling
  • Self-references
  • Mixed contexts (code with EIP references)

Not sure how to merge but the solution is on #121

All tests are passing.
Can you let me know if things look good?

* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
Copy link
Contributor

Choose a reason for hiding this comment

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

eipw is released under the MPL, not apache.


fn lint<'a>(&self, slug: &'a str, ctx: &Context<'a, '_>) -> Result<(), Error> {
// Only check if status is "Last Call"
let status = match ctx.preamble().by_name("status") {
Copy link
Contributor

Choose a reason for hiding this comment

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

When possible, I prefer keeping lints small and single purpose. Here, I think it would be simpler if—instead of checking for a particular status—you only enforce that the date is in the future if and only if the field is present.

Then preamble-req-last-call-deadline, preamble-date-last-call-deadline, and this lint will all work together.

};

// Get today's date
let today = Utc::now().date_naive();
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be overly strict. If someone in, for example, Eastern Time (so UTC-5) submits near midnight, this would annoyingly fail for them. Can we do like... UTC-12 or something? I'm not 100% sure how timezones work.

async fn future_date() {
let src = r#"---
status: Last Call
last-call-deadline: 2025-12-12
Copy link
Contributor

Choose a reason for hiding this comment

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

This will fail while I am alive. Can we do like 3000-12-12?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preamble lint to ensure last-call-deadline is not in the past
2 participants