-
Notifications
You must be signed in to change notification settings - Fork 630
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(tools): add check flag to browser_compat.ts
#4240
chore(tools): add check flag to browser_compat.ts
#4240
Conversation
_tools/check_browser_compat.ts
Outdated
const index = source.indexOf(COPYRIGHT); | ||
await Deno.writeTextFile( | ||
path, | ||
source.slice(0, index + COPYRIGHT.length) + "\n" + DECLARATION + "\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second "\n"
looks redundant to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section makes me wonder whether we should integrate both copyright and web compatibility checks. Either way, an idea for another issue/PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second
"\n"
looks redundant to me.
removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section makes me wonder whether we should integrate both copyright and web compatibility checks. Either way, an idea for another issue/PR.
I agree, this looks ugly and hacky. I had a try with the ts compiler API which would work without direct string manipulation, but the ts printer doesn't retain format and whitespaces. The same problem appeared on a draft of auto-inserting warnOnDeprecatedApi()
calls for deprecated functions. Is there a simple ts parser that also retains format and whitespaces?
import { walkSync } from "../fs/walk.ts"; | ||
|
||
import { walk } from "../fs/walk.ts"; | ||
import { COPYRIGHT } from "./check_licence.ts"; | ||
|
||
const ROOT = new URL("../", import.meta.url); | ||
const SKIP = [/(test|bench|\/_|\\_|testdata|version.ts)/]; | ||
const DECLARATION = "// This module is browser compatible."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly related to this PR, but some file (data_structures/comparators.ts
) seems having /** This module is browser compatible. */
comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I guess we should replace that with a single line comment in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea!
_tools/check_browser_compat.ts
Outdated
const index = source.indexOf(COPYRIGHT); | ||
await Deno.writeTextFile( | ||
path, | ||
source.slice(0, index + COPYRIGHT.length) + "\n" + DECLARATION + "\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section makes me wonder whether we should integrate both copyright and web compatibility checks. Either way, an idea for another issue/PR.
browser_compat.ts
browser_compat.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
browser_compat.ts
tool to check missing comments in file. It will inject missing comments if the flag is not present.This feature is borrowed from the
check_licence.ts
tool.