Catalog npm
PACKAGE EXPLORERView in registry

5to6-codemod

npm

A collection of codemods that allow you to transform your js code from ES5 to ES6.

Versions collected14
Direct dependencies5From release 1.8.0
Last observed20 Oct, 20:40 UTC

README

Current package documentation

Build Status GitHub version NPM version Downloads

5to6-codemod

A collection of codemods that allow you to transform your JavaScript code from ES5 to ES6 using jscodeshift.

Usage

  1. npm install -g jscodeshift
  2. npm install 5to6-codemod
  3. jscodeshift -t node_modules/5to6-codemod/transforms/[transform].js [files]
  4. Review changes via git diff. Keep what you want, throw it out if you don't. Magic!

Option flags

When executing codemods, you can configure options like so:

jscodeshift -t node_modules/5to6-codemod/transforms/[transform].js [files] --key=value

Recast options

Our transforms will automatically distinguish and pass through Recast config keys via jscodeshift. Official documentation for Recast's configuration can be found here. We currently support the following Recast keys:

  • esprima
  • inputSourceMap
  • lineTerminator
  • quote
  • range
  • reuseWhitespace
  • sourceFileName
  • sourceMapName
  • sourceRoot
  • tabWidth
  • tolerant
  • trailingComma
  • useTabs
  • wrapColumn

Transforms

  • amd - Transforms AMD style modules to ES6 import/export
  • cjs - Transforms CommonJS style require() calls to ES6 import statements
    • This transformation accepts the following option flags:
      • hoist: Enables hoisting require statements to the top
  • no-strict - Removes "use strict" statements
  • exports - Move CommonJS style module.exports statements to ES6 export statements
  • named-export-generation - Adds named exports corresponding to default export object keys. Only valid for ES6 modules exporting an object as the default export.
  • let - Replace all var calls to use let
  • simple-arrow - Replace all function expressions with a body of a sole return statement into arrow functions

Known issues

  • Can't automagically figure out when you want to use import * as varName.
  • End-of-line comments also missing in many situations
  • simple-arrow loses comments in the function expression body

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 14

Collected releases
VersionPublishedDirect dependenciesOpen version
1.8.0Registry latest1 Apr 20195
1.7.116 Jun 20175
1.6.022 May 20175
1.5.017 Mar 20174
1.4.08 Mar 20174
1.3.07 Mar 20174
1.2.04 Mar 20174
1.1.47 Feb 20174
1.1.319 Nov 20164
1.1.220 Sept 20164
1.1.120 Sept 20164
1.1.03 Jun 20164
1.0.118 May 20164
1.0.02 Jan 20164

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
5to6/codemod

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:40 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:b8291238d53199187ae14646743b8f376a270bb42413ad0f276f086f6a05dd7b