2.2.1 • Published 7 months ago

vue-jscodeshift-adapter v2.2.1

Weekly downloads
11,491
License
MIT
Repository
github
Last release
7 months ago

vue-jscodeshift-adapter

Build Status

Run jscodeshift on Vue single file components

Install

npm install vue-jscodeshift-adapter -D

Usage

The instructions below assume you're familiar with jscodeshift.

Run a codemod on some .js and/or .vue files

When transformingfileInfo.source will be
.jsthe contents of the file
.vuethe contents of <script>

The source file will be updated appropriately based on the return value of your transform().

If .vue file doesn't have a <script>, your transform() will not be called and the source file will not be changed.

1. Create wrapped transform function

// my-transform.js
const adapt = require('vue-jscodeshift-adapter');
const someCodemod = require('some-codemod');

module.exports = adapt(someCodemod);

2. Run jscodeshift

$ jscodeshift <path> -t my-transform.js --extensions vue,js

See jscodeshift readme for more info on jscodeshift CLI.

License

MIT