transform.js 393 B

123456789101112131415
  1. const adapt = require('../../../src/index');
  2. const describe = require('jscodeshift-helper').describe;
  3. module.exports = adapt((fileInfo, api, options) => {
  4. const j = api.jscodeshift;
  5. return j(fileInfo.source)
  6. .find(j.Identifier)
  7. .forEach((path) => {
  8. j(path).replaceWith(
  9. j.identifier(path.node.name.split('').reverse().join(''))
  10. );
  11. })
  12. .toSource();
  13. });