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

chore: upgrade dlint and run prefer-primordials #11777

Merged
merged 5 commits into from Aug 19, 2021

Conversation

magurotuna
Copy link
Member

This PR upgrades third_party submodule to the latest to get dlint 0.12.0, and applies prefer-primordials to the files under runtime, ext, and core.

Comment on lines +7 to +9
"exclude": [
"no-invalid-triple-slash-reference"
]
Copy link
Member Author

Choose a reason for hiding this comment

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

If I understand correctly, no-invalid-triple-slash-reference rule is for Deno users, not for the internal code of Deno, so I added it here. Please correct me if I'm wrong.
https://lint.deno.land/#no-invalid-triple-slash-reference

Copy link
Member

Choose a reason for hiding this comment

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

That's correct

Comment on lines +232 to 233
// deno-lint-ignore prefer-primordials
Error.prepareStackTrace = prepareStackTrace;
Copy link
Member Author

Choose a reason for hiding this comment

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

In Node.js, Error.prepareStackTrace is skipped linting because of the config. But deno_lint doesn't support it right now, so just added an ignore directive here for the moment.

Comment on lines +54 to +80
async function dlintPreferPrimordials() {
const execPath = getPrebuiltToolPath("dlint");
console.log("prefer-primordials");

const sourceFiles = await getSources(ROOT_PATH, [
"runtime/**/*.js",
"ext/**/*.js",
"core/**/*.js",
":!:core/examples/**",
]);

if (!sourceFiles.length) {
return;
}

const chunks = splitToChunks(sourceFiles, `${execPath} run`.length);
for (const chunk of chunks) {
const p = Deno.run({
cmd: [execPath, "run", "--rule", "prefer-primordials", ...chunk],
});
const { success } = await p.status();
if (!success) {
throw new Error("prefer-primordials failed");
}
p.close();
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I think prefer-primordials should apply only to the code related to bootstrapping, so I created another function where only this rule is run.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, please add a comment explaining that

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 👍 0cf3bfb

Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

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

This is awesome! Well done @magurotuna.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @magurotuna this is very useful

@bartlomieju bartlomieju merged commit 4ae57d1 into denoland:main Aug 19, 2021
@magurotuna magurotuna deleted the upgrade-dlint branch August 20, 2021 15:15
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.

None yet

3 participants