Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a1bb46

Browse files
committed
refactor: rename rootOption to rootProp, to be in line with the type definition in vue-next
1 parent6719d0c commit9a1bb46

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

‎generator/codemods/global-api/__tests__/global-api-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ jest.autoMockOff()
33
const{ defineTest}=require('jscodeshift/dist/testUtils')
44

55
defineTest(__dirname,'index',null,'basic')
6-
defineTest(__dirname,'index',null,'custom-root-option')
6+
defineTest(__dirname,'index',null,'custom-root-prop')
77
// defineTest(__dirname, 'index', null, 'el')
88
defineTest(__dirname,'index',null,'vue-router')
99
defineTest(__dirname,'index',null,'vuex')

‎generator/codemods/global-api/create-app-mount.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ module.exports = function createAppMount(context) {
2424
addImport(context,{imported:'createApp'},'vue')
2525

2626
mountCalls.replaceWith(({ node})=>{
27-
letoptions=node.callee.object.arguments[0]
27+
letrootProps=node.callee.object.arguments[0]
2828
constel=node.arguments[0]
2929

3030
returnj.callExpression(
3131
j.memberExpression(
32-
j.callExpression(j.identifier('createApp'),[options]),
32+
j.callExpression(j.identifier('createApp'),[rootProps]),
3333
j.identifier('mount')
3434
),
3535
[el]

‎generator/codemods/global-api/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ module.exports = function(fileInfo, api) {
55
constcontext={ j, root}
66

77
require('./create-app-mount')(context)
8-
require('./root-option-to-use')(context,'store')
9-
require('./root-option-to-use')(context,'router')
8+
require('./root-prop-to-use')(context,'store')
9+
require('./root-prop-to-use')(context,'router')
1010
require('./remove-trivial-root')(context)
1111
require('./remove-production-tip')(context)
1212
require('./remove-vue-use')(context)

‎generator/codemods/global-api/remove-trivial-root.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* It is expected to be run after the `createApp` transformataion
3-
* if a root component is trivial, that is, it contains only one simpleoption,
3+
* if a root component is trivial, that is, it contains only one simpleprop,
44
* like `{ render: h => h(App) }`, then just use the `App` variable
55
*
66
* TODO: implement `remove-trivial-render`,

‎generator/codemods/global-api/remove-vue-use.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* But in library implementations like `vue-router` and `vuex`,
55
* the new `app.use` does not reuse the same argument passed to `Vue.use()`,
66
* but expects instantiated instances that are used to pass to the root components instead.
7-
* So we now expect the migration to be done in the `root-option-to-use` transformation,
7+
* So we now expect the migration to be done in the `root-prop-to-use` transformation,
88
* and the `Vue.use` statements can be just abandoned.
99
*@param {Object} context
1010
*@param {import('jscodeshift').JSCodeshift} context.j

‎generator/codemods/global-api/root-option-to-use.jsrenamed to‎generator/codemods/global-api/root-prop-to-use.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@
55
*@param {import('jscodeshift').JSCodeshift} context.j
66
*@param {ReturnType<import('jscodeshift').Core>} context.root
77
*/
8-
module.exports=functionrootOptionToUse(context,rootOptionName){
8+
module.exports=functionrootPropToUse(context,rootPropName){
99
const{ j, root}=context
1010

1111
constappRoots=root.find(j.CallExpression,{
1212
callee:{name:'createApp'},
1313
arguments:args=>
1414
args.length===1&&
1515
args[0].type==='ObjectExpression'&&
16-
args[0].properties.find(p=>p.key.name===rootOptionName)
16+
args[0].properties.find(p=>p.key.name===rootPropName)
1717
})
1818

1919
appRoots.replaceWith(({node:createAppCall})=>{
20-
constrootOptions=createAppCall.arguments[0]
21-
constpropertyIndex=rootOptions.properties.findIndex(
22-
p=>p.key.name===rootOptionName
20+
constrootProps=createAppCall.arguments[0]
21+
constpropertyIndex=rootProps.properties.findIndex(
22+
p=>p.key.name===rootPropName
2323
)
24-
const[{value:pluginInstance}]=rootOptions.properties.splice(
24+
const[{value:pluginInstance}]=rootProps.properties.splice(
2525
propertyIndex,
2626
1
2727
)
2828

2929
returnj.callExpression(
3030
j.memberExpression(
31-
j.callExpression(j.identifier('createApp'),[rootOptions]),
31+
j.callExpression(j.identifier('createApp'),[rootProps]),
3232
j.identifier('use')
3333
),
3434
[pluginInstance]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp