eipw icon indicating copy to clipboard operation
eipw copied to clipboard

Lints to ensure link text for EIPs should match the EIP's number

Open SamWilsn opened this issue 2 years ago • 12 comments

Let's create two lints:

markdown-link-eip

If the link destination matches the pattern eip-([^.]*)\.md$, trigger if the link text does not match ^(EIP|ERC)-\1$, where \1 is the proposal's number from the file name (aka capture group 1.)

For example:

  • [EIP-1](./eip-2.md)
  • [EIP-1: Foo](./eip-1.md)
  • [Another Proposal](./eip-1.md)

If the link destination matches the pattern eip-([^.]*)\.md#.+$, trigger if the link text does not match ^(EIP|ERC)-\1\s*\S+, where \1 is the proposal's number from the file name (aka capture group 1.) Note that this pattern allows trailing characters.

For example:

  • [EIP-1](./eip-1.md#motivation)
  • [EIP-2: Hello](./eip-1.md#abstract)
  • [Another Proposal](./eip-1.md#rationale)

markdown-link-other

If the link text begins with EIP or ERC, the link target must be an EIP. For example:

  • [EIP-2](../assets/eip-2/foo.txt)

SamWilsn avatar Mar 08 '23 20:03 SamWilsn

Note: if it links to a section, then this lint should be ignored, such as [EIP-721's Motivation](./eip-721.md#motivation).

Pandapip1 avatar Mar 08 '23 22:03 Pandapip1

That's a good point!

SamWilsn avatar Mar 08 '23 22:03 SamWilsn

Hi, I would like take this up with Katya

swetshaw avatar May 24 '24 12:05 swetshaw

Hi @SamWilsn, yep, we both would like to contribute into it. Please, assign us to this issue

KatyaRyazantseva avatar May 24 '24 12:05 KatyaRyazantseva

Hi @SamWilsn, taking into account @Pandapip1 's comment about sections, should all these links matching the pattern eip-([^.]*)\.md#.+$ be ignored? Those ones having the section in the link, the second part of markdown-link-eip part:

  • [EIP-1](./eip-1.md#motivation)
  • [EIP-2: Hello](./eip-1.md#abstract)
  • [Another Proposal](./eip-1.md#rationale)

KatyaRyazantseva avatar Jun 21 '24 13:06 KatyaRyazantseva

This paragraph covers those examples:

If the link destination matches the pattern eip-([^.]*)\.md#.+$, trigger if the link text does not match ^(EIP|ERC)-\1\s*\S+, where \1 is the proposal's number from the file name (aka capture group 1.) Note that this pattern allows trailing characters.

So:

  • [EIP-1](./eip-1.md#motivation) would not be allowed because it doesn't have anything in the \S+ position of the regex.
  • [EIP-2: Hello](./eip-1.md#abstract) would not be allowed because it doesn't match EIP number.
  • [Another Proposal](./eip-1.md#rationale) would not be allowed because it doesn't begin with either ERC or EIP.

However, [EIP-1: Motivation](./eip-1.md#motivation) would be allowed.

SamWilsn avatar Jun 21 '24 13:06 SamWilsn

@SamWilsn could you please explain why [EIP-1: Foo](./eip-1.md) is incorrect?

KatyaRyazantseva avatar Jun 21 '24 22:06 KatyaRyazantseva

Because it doesn't have a subsection (after the # in the link.)

SamWilsn avatar Jun 21 '24 22:06 SamWilsn

if [EIP-N] is extended with extra text like ': Foo' it means the link should have a section?

KatyaRyazantseva avatar Jun 21 '24 22:06 KatyaRyazantseva

Pretty much. So URLs with a # should have : ...

SamWilsn avatar Jun 21 '24 22:06 SamWilsn

@SamWilsn, for markdown-link-other should I check eip number match in the text and the link?

KatyaRyazantseva avatar Jun 22 '24 10:06 KatyaRyazantseva

markdown-link-other should prevent links that look like EIPs/ERCs that don't point to EIPs.

SamWilsn avatar Jun 22 '24 18:06 SamWilsn