This addresses issue #193 by adding a comprehensive cookbook section with practical, copy-pasteable examples for new users. Changes Added a new 'Cookbook: Practical Recipes for Common Tasks' section to README.md containing 7 complete recipes: 1. Changing literal values in object properties - The exact use case from issue #193 (changing to ) 2. Adding new properties to objects - Using to create new object properties 3. Renaming identifiers throughout a file - Using and for simple replacements 4. Converting CommonJS to ES modules - Replacing and 5. Wrapping function calls with higher-order functions - Adding logging/error handling patterns 6. Converting Array.indexOf() !== -1 to Array.includes() - Modern JS pattern upgrade 7. Transforming for loops to forEach - Converting classic for loop patterns Each recipe includes before/after code examples and complete transform code that can be copied directly into a transform.js file. Motivation Issue #193 described that new users find the documentation "very thin on examples" and lack simple examples for tasks like "changing the literal value of something." This cookbook directly addresses that gap by providing working, minimal examples for common codemod patterns.
Summary This PR fixes multiple code quality issues found during code review: Bug Fixes 1. *: Fixed a bug where (which is for objects) was used instead of . This caused to be , breaking the intersection logic. Also added validation for empty/null arrays input. 2. : Added try/catch around to gracefully handle missing or inaccessible ignore config files, with a warning message instead of crashing. 3. : Added try/catch around for the option to provide a helpful error message instead of crashing with a confusing JSON syntax error. 4. : Replaced in an async callback with proper error handling that calls and logs a warning. Throwing in an async callback causes uncaught errors that crash the process. Improvements 5. : Added early return for empty nodes array in . Added clarifying comments explaining the reduce() index calculation. 6. *: Added helper function to safely access default exports from Babel presets/plugins that may use either or export pattern. All changes are backward compatible and do not change the public API.
ES6 iterators support the new for..of syntax. Since a wraps an , we can lean on ECMAScript's new iterator delegation. Resolve #679 I am working on esupgrade a tool to upgrade JS/TS code to widely available ECMAScript features. It's built on this wonderful tool. I'd really love to keep esupgrade's code base up to date too, and using for..of loops and generators would help tremendously. Thanks for your consideration and for publishing this under a free license <3
Repository: facebook/jscodeshift. Description: A JavaScript codemod toolkit. Stars: 10018, Forks: 493. Primary language: JavaScript. License: MIT. Homepage: https://jscodeshift.com Open PRs: 28, open issues: 125. Last activity: 4d ago. Top contributors: fkling, dependabot[bot], cpojer, Daniel15, ElonVolo, trivikr, gkz, jbrown215, marcodejongh, sharils and others.