Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"editor.wordWrapColumn": 100,
"[markdown]": {
"editor.wordWrap": "off"
}
},
"typescript.experimental.useTsgo": true
}
11 changes: 8 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Each codemod resides in its own directory under `recipes/` and should include:
**`src/workflow.ts` example:**
```ts
import type { SgRoot, Edit } from "@codemod.com/jssg-types/main";
import type JS from "@codemod.com/jssg-types/langs/javascript";

/**
* Transform function that converts deprecated api.fn calls
* to the new api.fn syntax.
Expand All @@ -49,12 +51,15 @@ import type { SgRoot, Edit } from "@codemod.com/jssg-types/main";
* 2. api.fn(<args>, { recursive: true })
* ...
*/
export default function transform(root: SgRoot): string | null {
export default function transform(root: SgRoot<JS>): string | null {
const rootNode = root.root();
let hasChanges = false;
const edits: Edit[] = [];

// do some transformation
if (!hasChanges) return null;
edits.push(...);

if (edits.length === 0) return null;

return rootNode.commitEdits(edits);
}
```
Expand Down
213 changes: 158 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"pre-commit": "node --run lint:fix; node --run type-check; node --run test",
"test": "npm run test --workspaces --if-present",
"test-legacy": "npm run test-legacy --workspaces --if-present",
"type-check": "tsc"
"type-check": "tsgo --noEmit"
},
"repository": {
"type": "git",
Expand All @@ -27,9 +27,9 @@
},
"homepage": "https://nodejs.org/learn/userland-migrations",
"devDependencies": {
"@biomejs/biome": "2.2.4",
"@types/node": "^24.5.0",
"typescript": "^5.9.2"
"@biomejs/biome": "2.1.4",
"@types/node": "^24.2.1",
"@typescript/native-preview": "^7.0.0-dev.20250916.1"
},
"workspaces": [
"./recipes/*",
Expand Down
3 changes: 2 additions & 1 deletion recipes/create-require-from-path/src/workflow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getNodeImportStatements } from "@nodejs/codemod-utils/ast-grep/import-statement";
import { getNodeRequireCalls } from "@nodejs/codemod-utils/ast-grep/require-call";
import type { SgRoot, Edit } from "@codemod.com/jssg-types/main";
import type JS from "@codemod.com/jssg-types/langs/javascript";

/**
* Transform function that updates code to replace deprecated `createRequireFromPath` usage
Expand All @@ -20,7 +21,7 @@ import type { SgRoot, Edit } from "@codemod.com/jssg-types/main";
*
* 3. Preserves original variable names and declaration types.
*/
export default function transform(root: SgRoot): string | null {
export default function transform(root: SgRoot<JS>): string | null {
const rootNode = root.root();
const edits: Edit[] = [];
let hasChanges = false;
Expand Down
2 changes: 0 additions & 2 deletions recipes/fs-access-mode-constants/src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default function tranform(root: SgRoot<Js>): string | null {
const edits: Edit[] = [];
const patterns = ['F_OK', 'R_OK', 'W_OK', 'X_OK'];

// @ts-expect-error - ast-grep types are not fully compatible with JSSG types
const requireStatements = getNodeRequireCalls(root, 'fs');

for (const statement of requireStatements) {
Expand All @@ -30,7 +29,6 @@ export default function tranform(root: SgRoot<Js>): string | null {
}
}

// @ts-expect-error - ast-grep types are not fully compatible with JSSG types
const importStatements = getNodeImportStatements(root, 'fs');
let promisesImportName = '';

Expand Down
Loading
Loading