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

fix include linter #478

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion server/remark-includes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ export default function remarkIncludes({
vfile,
startIndex: lastErrorIndex,
ruleId: "includes",
source: "remark-lint",
Copy link
Contributor

Choose a reason for hiding this comment

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

Does naming the source to something beside remark-lint also work? I'm curious about which code reads the source field.

From a quick browse, it looks like the remark-message-control plugin uses it to allow for disabling/enabling linters via comments (this is used by remark-lint). I'm not sure what else uses it.

@iAdramelk, I'm not sure if you're available to answer questions about the update-vfile-messages.ts code—if you are, could you provide some context on what this code does? Thanks!

Copy link
Author

@GavinFrazar GavinFrazar Jun 25, 2024

Choose a reason for hiding this comment

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

Does naming the source to something beside remark-lint also work? I'm curious about which code reads the source field.

I tried changing it to "something" and that didn't fix it for the include link in the redshift guide.

It does affect the example in the 14.x reference that has an ignore comment - if I change source to "something" then it's not ignored and I get:

content/14.x/docs/pages/contributing/documentation/reference.mdx
    450:1-454:4  error    Wrong import path docs/pages/includes/include.mdx in file content/14.x/docs/pages/contributing/documentation/reference.mdx

Otherwise it ignores it correctly.

Having now learned what it's for, I tried this in the redshift serverless file:

## Step 3/4. Install and start the Teleport Database Service

{/*lint enable includes*/} 

(!docs/pages/includes/database-access/token.mdx!)

But it still doesn't detect the error.

Some more info I learned: in general, if a broken include path is followed by another include path that's valid, and remark-lint is in the source, then it doesn't throw an error, e.g.:


(!docs/pages/includes/bad.mdx!)

(!docs/pages/includes/good.mdx!)

Inserting text after bad.mdx above will catch the invalid include path.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ptgott AFAIR source is only used in reporting. See the right side of this screenshot for example: https://github.com/remarkjs/remark-lint/raw/main/screenshot.png

For my knowledge it should not affect actual linter results in any way.

});
};
}
1 change: 0 additions & 1 deletion server/remark-variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ export default function remarkVariables({
vfile,
startIndex: lastErrorIndex,
ruleId: "variables",
source: "remark-lint",
});
};
}
3 changes: 0 additions & 3 deletions server/update-vfile-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ interface UpdateMessagesOptions {
vfile: VFile;
startIndex: number;
ruleId: string;
source: string;
}

export default function updateMessages({
vfile,
startIndex,
ruleId,
source,
}: UpdateMessagesOptions) {
let index = startIndex;

while (index < vfile.messages.length) {
const message = vfile.messages[index];

message.ruleId = ruleId;
message.source = source;
message.fatal = true;

index++;
Expand Down
Loading