jscodeshift

A JavaScript codemod toolkit.

MIT License

Downloads
28.3M
Stars
9.3K
Committers
121

Bot releases are hidden (Show)

jscodeshift - 17.0.0 Latest Release

Published by Daniel15 2 months ago

[17.0.0] 2024-08-06

We needed to go from v0.x to a major release, and it may as well happen now. jscodeshift has been around for nine years though, so going to v1.0.0 didn't feel quite right. I've instead promoted the minor version number to a major version number, similar to what React did when it went from 0.14 to 15.0.

Fixed

  • Node.js 16 is now explicitly specified as the minimum required version. It was already (#607, @trivikr)

Added

  • A new jscodeshift website has launched, thanks to the team at Codemod. (#592, @mohab-sameh with some tweaks by @morinokami)
  • Added collection functions for import declarations, including finding imports and inserting new imports (#617, @danieldelcore)

Changed

  • Enabled TypeScript importAttributes (#585, @benasher44) and decoratorAutoAccessors (#594, @syi0808) plugins
  • Removed or replaced various outdated and unused dependencies (#601, #605, #609, #613, @trivikr)
  • Started using Corepack to manage Yarn version (#599, @trivikr)
jscodeshift - 0.13.1

Published by mroch almost 3 years ago

Changed

  • Switched from colors to chalk to mitigate a security vulnerability in [email protected].

Full Changelog: https://github.com/facebook/jscodeshift/compare/0.13.0...0.13.1

jscodeshift - v0.7.0

Published by jbrown215 almost 5 years ago

Added

  • Added jest snapshot utils (#297, @dogoku)

Changed

  • Moved from BSD to MIT license

Fixed

  • No longer throw an error when calling jscodeshift on a non-existent path (#334, @threepointone)
  • Preserve the original file extension in remote files (#317, @samselikoff)
jscodeshift -

Published by fkling over 5 years ago

Changed

  • Allow writing tests in TypeScript (#308)
  • Better handling of .gitingore files: Ignore comments and support \r\n line breaks (#306)
jscodeshift -

Published by fkling over 5 years ago

Fixed

  • Don't throw an error when jscodeshift processes an empty set of files (#295, @skovhus).
  • renameTo should not rename class properties (#296, @henryqdineen).
  • Custom/unknown CLI parameters are parsed as JSON, just like nomnom used to do.
jscodeshift -

Published by fkling almost 6 years ago

Changed

  • @babel/register/@babel/preset-env is configured to not transpile any
    language features that the running Node process supports. That means if you use
    features in your transform code supported by the Node version you are running,
    they will be left as is. Most of ES2015 is actually supported since Node v6.
  • Do not transpile object rest/spread in transform code if supported by running
    Node version.

Fixed

  • Presets and plugins passed to @babel/register are now properly named and
    loaded.
jscodeshift -

Published by fkling almost 6 years ago

Added

  • Tranform files can be written in Typescript. If the file extension of the
    transform file is .ts or .tsx, @babel/preset-typescript is used to
    convert them. This requires the --babel option to be set (which it is by
    default). ( #287 , @brieb )

Changed

  • The preset and plugins for converting the transform file itself via babeljs
    have been updated to work with babel v7. This included removing
    babel-preset-es2015 and babel-preset-stage-1 in favor of
    @babel/preset-env. Only @babel/proposal-class-properties and
    @babel/proposal-object-rest-spread are enabled as experimental features. If
    you want to use other's in your transform file, please create a PR.

Fixed

  • Typescript parses use @babel/parser instead of Babylon ( #291, @elliottsj )

Bumped

  • micromatch => v3.1.10, which doesn't (indirectly) depend on randomatic <
    v3 anymore (see #292).
jscodeshift -

Published by fkling almost 6 years ago

A bunch of changes to get jscodeshift in a better shape. This is minor version update because important dependencies and parser configurations have changed.


New

  • New CLI option --parser-config: This option accepts a path to a JSON file and overrides the default options for flow or babylon. This allows you to tweak parser settings (e.g. legacy decorators). (46d250f)
  • New CLI option --stdin: If provided, the list of files/directories is read from stdin. This makes it easier to pass large lists of files. (b6eaa0a)
  • New API in transforms: api.report lets you print arbitrary text to stdout. Useful if another tools consumes jscodeshift's stdout. (c902a00) Example:
// In the transform
api.report('some data');

// in stdout
 REP path/to/file.js some data
  • Support for Typescript source code, via babylon ( #286 ; @brieb). Use --parser=ts or --parser=tsx.

Improvements

  • Updated babylon to v7 adding support for newer flow features (#282 , @wanderley )
  • Updated recast to v0.16, which includes a bunch of printing improvments (#289 , @majapw )
  • Enable more features in babylon and flow (#278 , @mjesun ; #281 , @jbrown215 )
  • Improve handling of large lists of files (62b12ad, 9c83c39)

Fixes

  • JSXElements's hasAttributes method understands value-less Boolean attributes (#277 , @artemruts )
  • More reliable printing to stdout (62b12ad)

Internal

  • Replaces deprecated nomnom with own implementation (a2becc5)
  • Remove direct dependency on lodash (4701096)
jscodeshift -

Published by fkling over 6 years ago

New

  • Bump recast and babylon to support JSX fragments (#239)
  • Add dynamicImport plugin to babylon parser. (#208)
  • Allow specifying a testName for inline tests (#218)
  • Add some() and every() methods for Collection (#216)

Fixed/Improved

  • Fix error handling for http (#242)
  • Perf: replace async with neo-async (#241)
  • Fix renameTo renaming React component prop name unexpectedly (#220)
  • Fix renameTo not taking property shorthands into account (#211)
jscodeshift -

Published by fkling over 7 years ago

New

@TheSavior added the possibility to define tests inline, without having to create separate files for input and output:

const transform = require('../myTransform');
defineInlineTest(transform, {}, 'input', 'expected output');

#204

jscodeshift -

Published by fkling over 7 years ago

Fixes

  • Printing issues by bumping recast and babylon versions ( #200 , #201 @xixixao)
  • Bug with template.expression when a literal with no interpolation was used ( #196, @jsnajdr)

Internally

  • Drop usage of es6-promise ( #189, @wtgtybhertgeghgtwtg)

Thank you @xixixao, @jsnajdr and @wtgtybhertgeghgtwtg for contributing!

jscodeshift -

Published by fkling almost 8 years ago

Fixes

  • Write changes to files atomically (#156, @alangpierce)
  • Fix placeholder holder associate in template builders (#163, @robz)
jscodeshift -

Published by fkling almost 8 years ago

New

  • Collections now have a .length property which is equivalent to .size() (#151, @DrewML)

  • You can now reference jscodeshift as j directly from the transform's API options. I.e. you can write

    export default function transformer(file, { j }) {
      return j(file.source).toSource();
    }
    

    instead of

    export default function transformer(file, api) {
      const j = api.jscodeshift;
    
      return j(file.source).toSource();
    }
    

    or

    export default function transformer(file, {jscodeshift: j}) {
      return j(file.source).toSource();
    }
    

    (#153, @vjeux)

Improved

  • Experimental settings have been enabled for the flow parser, so it is now be able to process files that use e.g. public class fields (a2e4a3a)
jscodeshift -

Published by fkling about 8 years ago

New

  • .editorconfig file ( #142 , @DrewML )

Changed

  • Better error message when using .get on an empty collection ( #140 , @DrewML )
  • jscodeshift now depends on recast v0.11.11 which adds better support for new flow type constructs.
jscodeshift -

Published by fkling about 8 years ago

Fixes

  • Use all CPUs if only one is available ( #137, @daedalus28 )
  • Don't error if error stack trace is not available ( #134, 20422bda773a257662d7d6b52010a31aa4e5b39f )
jscodeshift -

Published by fkling about 8 years ago

New

  • Return value of Runner.run includes elapsed time and stats collected via stats method ( #128, @iamdustan).
  • jscodeshift --version also prints the used recast version ( #131, @keyanzhang)

Fixes

  • renameTo ignores Identifiers that are not variable references ( #125, Robby Nevels)
  • Transformers / codemods can use experimental features ( >= stage 1) and flow type annotations again (28eb51508dca2aa70f9a454d3247ee2e08fcf4ae). This was a regressions.
jscodeshift -

Published by fkling over 8 years ago

Fixed

  • testUtils supports custom parsers (e5fb37d0c43475fa20181dd542a3a250680138df)
  • testUtils also passes a stub for the stats method to the transformer (e5fb37d0c43475fa20181dd542a3a250680138df)
jscodeshift -

Published by fkling over 8 years ago

Fixed

  • Fixed stats output in dry run. Thanks @gaearon for noticing.
jscodeshift -

Published by fkling over 8 years ago

Fixed

  • Fixes an issue with using jscodeshift inside jest unit tests ( #122 )
jscodeshift -

Published by fkling over 8 years ago

Fixed: jscodeshift installation

Seems like npm cannot handle local files (#120) :-/

Package Rankings
Top 0.49% on Npmjs.org
Top 3.82% on Proxy.golang.org
Badges
Extracted from project README's
Support Ukraine Build Status
Related Projects