Skip to content

chore: update doc linter, replace hardcoded entry list with dynamically created one #6491

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

Merged
merged 20 commits into from
Mar 24, 2025

Conversation

timreichen
Copy link
Contributor

This PR removes the hardcoded entry list. Apparently some files were accidentally excluded by not updating the list.

Copy link

codecov bot commented Mar 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.30%. Comparing base (536e858) to head (879ff92).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6491   +/-   ##
=======================================
  Coverage   95.30%   95.30%           
=======================================
  Files         575      575           
  Lines       43266    43270    +4     
  Branches     6467     6467           
=======================================
+ Hits        41234    41239    +5     
+ Misses       1993     1992    -1     
  Partials       39       39           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

Nits. This could be a little over-engineered and contains other changes that don't pertain to the main objective of the PR.

Comment on lines +45 to +72
export function isTestFile(filePath: string): boolean {
if (!filePath.endsWith("test.ts")) return false;
const source = Deno.readTextFileSync(filePath);
const sourceFile = ts.createSourceFile(
filePath,
source,
ts.ScriptTarget.Latest,
);

let result = true;

function visitNode(node: ts.Node) {
if (!result) return;
if (
ts.isExportSpecifier(node) ||
ts.isExportAssignment(node) ||
ts.isExportDeclaration(node) ||
node.kind === ts.SyntaxKind.ExportKeyword
) {
result = false;
} else {
ts.forEachChild(node, visitNode);
}
}

visitNode(sourceFile);
return result;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems extraneous. What about this?

export function isTestFile(filePath: string): boolean {
  return filePath.endsWith("test.ts");
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whole point of this function is to distinguish between test.ts which is used for testing (calling Deno.test()) and test.ts which is part of an api (like in @std/front-matter/test. This cannot be done by filename alone. I figured the best way was to check whether the file has exports or not, if so it must be part of an api.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe Deno.readTextFileSync(filePath).includes("\nDeno.test") would suffice? (leading \n ensures it's at the beginning of the line)

Copy link
Contributor Author

@timreichen timreichen Mar 19, 2025

Choose a reason for hiding this comment

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

This could lead to unintentional behaviour if Deno.test was wrapped in a function and therefore not at the beginning of the line (for example jsonc/testdata/JSONTestSuite/test.ts).
Also leads to unintentional behaviour when mentioned in a comment with unlucky line breaks:

/* bla bla bla...
Deno.test bla bla bla...
bla bla bla... */

So while this might work sometimes, it is not very robust.

@kt3k kt3k changed the title fix: replace hardcoded entry list with dynamically created one chore: update doc linter, replace hardcoded entry list with dynamically created one Mar 24, 2025
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM

@kt3k kt3k merged commit 6b74d90 into denoland:main Mar 24, 2025
18 checks passed
@timreichen timreichen deleted the tools-fix-docs-check-entries branch March 24, 2025 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants