-
Notifications
You must be signed in to change notification settings - Fork 19
Migrated scripts to typescript #144
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
base: main
Are you sure you want to change the base?
Conversation
@microsoft-github-policy-service agree company="Microsoft" |
@microsoft-github-policy-service agree |
@@ -45,14 +53,15 @@ function transformer(file, api, options) { | |||
// Manually sort the export statements alphabetically | |||
const sortedExports = updatedExportStatements | |||
.nodes() | |||
.map(node => { | |||
|
|||
.map((node: any) => { |
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.
Let's avoid 'any' and use the types. import { TSESTree } from "@typescript-eslint/utils";
that package should have the right types.
|
||
let changesMade = 0; | ||
|
||
// Step 1: Add rule to the `rules` object (without parentheses) | ||
root.find(j.Property, { key: { name: "rules" } }) | ||
.at(0) | ||
.forEach(path => { | ||
.forEach((path: any) => { |
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.
Any in this file too
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.
Did you test this script with the repo create
command? I think you need to update the package.json script to run ts-node
instead of node
since node doesn't natively work with TypeScript (at least with the versions we're using).
ex. npm run create -- rule-name
} | ||
}) | ||
.demandCommand(1, "You must provide the rule name.").argv; // Make the rule name (positional) | ||
.demandCommand(1, "You must provide the rule name.").argv as any; // Type assertion for yargs |
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.
Per Aubrey's other comments, any
usage should be avoided.
See the yargs docs for how to avoid this casting. Since there's no async processes occurring, you can replace argv
with parseSync()
. https://github.com/yargs/yargs/blob/HEAD/docs/typescript.md#typescript-usage-examples
6cc7f31
to
01930e9
Compare
Migrated files under scripts folder.