Skip to content
New issue

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

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

Already on GitHub? # to your account

fix(ci): fix URL RXs in linters #38540

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

OnkarRuikar
Copy link
Contributor

Issues

  1. URL checker flags #stack_and_execution_contexts when ## Stack header is changed to ##Stack and execution contexts.
  2. In markdownlint search-replace the "un-clossed-md-link" rule flags valid URLs with description, e.g., [abcd efg](/en-us/abcd "desc")

Solution

  1. In log-url-issues.js file, make the fragment matching RXes closed ended with ${fragment}( "|[\)]).
  2. Update search update RX to handle [\"'][^\"']+?[\"'][^)].
    The new RX flags:
    [abcd efg](/en-us/abcd
    [abcd efg](/en-us/abcd ac
    [abcd efg](/en-us/abcd, ac
    [abcd efg](/en-us/abcd: ac
    [abcd efg](/en-us/abcd "desc" ac
    [abcd efg](/en-us/abcd"abc" ac
    
    and allows:
    [abcd efg](/en-us/abcd)
    [abcd efg](/en-us/abcd) ac
    [abcd efg](/en-us/abcd): ac
    [abcd efg](/en-us/abcd), ac
    [abcd efg](/en-us/abcd "desc") ac
    [abcd efg](/en-us/abcd 'desc') ac
    [abcd efg](/en-us/abcd "desc")
    

@OnkarRuikar OnkarRuikar requested review from a team as code owners March 9, 2025 05:44
@OnkarRuikar OnkarRuikar requested review from pepelsbey and removed request for a team March 9, 2025 05:44
@github-actions github-actions bot added system [PR only] Infrastructure and configuration for the project size/s [PR only] 6-50 LoC changed labels Mar 9, 2025
@@ -189,11 +189,13 @@ for await (const filePath of walkSync(rootDir)) {

// check broken URL fragment
for (const fragment of deletedFragmentDetails) {
const locations = getLocations(content, fragment);
const locations = getLocations(content, `${fragment}( "|[\)])`);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const locations = getLocations(content, `${fragment}( "|[\)])`);
const locations = getLocations(content, `${fragment}(?: "|\\))`);

// check fragments in the same file
const urlParts = fragment.split("#");
if (filePath.includes(`${urlParts[0]}/index.md`)) {
locations.push(...getLocations(content, `[(]#${urlParts[1]}`));
locations.push(
...getLocations(content, `[(]#${urlParts[1]}( "|[\)])`),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
...getLocations(content, `[(]#${urlParts[1]}( "|[\)])`),
...getLocations(content, `\\(#${urlParts[1]}(?: "|\\))`),

@@ -208,7 +208,7 @@
{
"name": "un-closed-md-link",
"message": "Missing closing bracket ')'",
"searchPattern": "/(\\[[^\\]]*?\\]\\(([^\\)\\n]|\\([^\\)\\n]\\)|\\s[\"'])+?)(\\n|\\s|[,:][\\s\\n])/gm",
"searchPattern": "/\\[[^\\]]*?\\]\\(([^ )\n\",:])+?([\n,:\"]| \\w| [\"'][^\"']+?[\"'][^)])/gm",
Copy link
Member

@Josh-Cena Josh-Cena Mar 9, 2025

Choose a reason for hiding this comment

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

Suggested change
"searchPattern": "/\\[[^\\]]*?\\]\\(([^ )\n\",:])+?([\n,:\"]| \\w| [\"'][^\"']+?[\"'][^)])/gm",
"searchPattern": "/\\[.*?\\]\\([^ )\\n\",:]+(?:[\\n\",:]| [^\"']| [\"'].+?[\"'][^)])/gm",

Slightly simpler ([x][^x]+?[x] is equivalent to [x].+?[x])

@pepelsbey pepelsbey removed their request for review March 9, 2025 09:27
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
size/s [PR only] 6-50 LoC changed system [PR only] Infrastructure and configuration for the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants