goog-base-migrator

0.2.0 • Public • Published

goog-base-migrator

Build Status NPM version Coverage Status Code Climate
Dependency Status devDependency Status

Migration tool from goog.base to static base class methods.

Install

$ npm install -g goog-base-migrator

How to use

Find and confirm replacement with --debug option.

View demo

$ goog-base-migrator test/fixture/basic.js --debug
File: test/fixture/basic.js
before: goog.base(this, opt_domHelper)
 after: my.app.Sample.base(this, 'constructor', opt_domHelper)
before: goog.base(this, 'enterDocument')
 after: my.app.Sample.base(this, 'enterDocument')
before: goog.base(this, 'renderBefore', sibling)
 after: my.app.Sample.base(this, 'renderBefore', sibling)
before: goog.base(this, 'disposeInternal')
 after: my.app.Sample.base(this, 'disposeInternal')
Found 4 expressions.

OK, fix it with --fix-in-place option!

View demo

$ goog-base-migrator test/fixture/basic.js --fix-in-place
File: test/fixture/basic.js
Fixed 4 expressions.
$ git diff test/fixture/basic.js
diff --git a/test/fixture/basic.js b/test/fixture/basic.js
index f74e4fc..fa57b6f 100644
--- a/test/fixture/basic.js
+++ b/test/fixture/basic.js
@@ -12,7 +12,7 @@ goog.require('goog.ui.Component');
  * @extends {goog.ui.Component}
  */
 my.app.Sample = function(opt_domHelper) {
-  goog.base(this, opt_domHelper);
+  my.app.Sample.base(this, 'constructor', opt_domHelper);
 
   /**
    * @type {number}
@@ -24,16 +24,16 @@ goog.inherits(my.app.Sample, goog.ui.Component);
 
 /** @override */
 my.app.Sample.prototype.enterDocument = function() {
-  goog.base(this, 'enterDocument');
+  my.app.Sample.base(this, 'enterDocument');
 };
 
 /** @override */
 my.app.Sample.prototype.renderBefore = function(sibling) {
-  goog.base(this, 'renderBefore', sibling);
+  my.app.Sample.base(this, 'renderBefore', sibling);
 };
 
 /** @override */
 my.app.Sample.prototype.disposeInternal = function() {
-  goog.base(this, 'disposeInternal');
+  my.app.Sample.base(this, 'disposeInternal');
   delete this.number_;
 };

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • 0.2.0 (2014/11/19) Support the commented arguments.
  • 0.1.0 (2014/04/21) Support the expression to assign result of goog.base().
  • 0.0.1 (2014/04/20) Initial release.

License

Copyright (c) 2014 ama-ch
Licensed under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i goog-base-migrator

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • ama-ch