Read JavaScript as TypeScript without the types

Why: gtd-inbox-pull's Plan 6 runs the dryer over the swipe page's
JavaScript, and the dryer skipped .js files. This is for BJ's mirror only.

What changed: .js, .jsx, .mjs and .cjs are discovered as "javascript";
their .test and .spec forms are test files. extract.py gains a
"javascript" picker that parses with the JavaScript grammar and reuses
_typescript_nodes, since the tree is TypeScript's without type nodes.
No other code is keyed on the language name. README, pyproject, the CLI
help and the package docstring name JavaScript.

Proof: four tests written first and seen to fail on their own
assertions (language detection, test-file names, the language-set
tests with a JS pair, and the method and nested-function rule), then
the full suite passed (81 tests).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015GF1LYr5V3zY3815Nt6KwR
This commit is contained in:
bj
2026-11-15 16:45:46 +02:00
co-authored by Claude Sonnet 5.5
parent 66ff6d21a4
commit f48bd0c60f
8 changed files with 93 additions and 9 deletions
+2 -1
View File
@@ -1,6 +1,6 @@
# dryer
dryer finds candidate duplicate code in Clojure, Java, Go, TypeScript, Rust, and Python. One run detects the language of each source file, normalizes that language's forms, and reports pairs whose structure is close enough to review.
dryer finds candidate duplicate code in Clojure, Java, Go, TypeScript, JavaScript, Rust, and Python. One run detects the language of each source file, normalizes that language's forms, and reports pairs whose structure is close enough to review.
Clojure follows [dry4clj](https://github.com/unclebob/dry4clj). The other languages use the same idea on the functions and methods [crapper](https://github.com/unclebob/crapper) and [mutator](https://github.com/unclebob/mutator) already treat as one unit. A form is only compared with forms written in the same language.
@@ -99,6 +99,7 @@ DUPLICATE score=0.89
| Java | methods with a body | constructors, abstract methods, methods inside anonymous or local classes |
| Go | functions and methods with a body | function literals stay inside the enclosing function |
| TypeScript | functions, methods, and top-level arrow functions | callbacks nested inside another function |
| JavaScript | functions, methods, and top-level arrow functions | callbacks nested inside another function |
| Rust | functions and methods with a body | functions inside `mod tests`, and closures |
| Python | functions and methods | functions nested inside another function |