8000 Run prettier through the codebase · saknarak/nativescript-vue@a69a582 · GitHub
[go: up one dir, main page]

Skip to content {"props":{"docsUrl":"https://docs.github.com/get-started/accessibility/keyboard-shortcuts"}}

Commit a69a582

Browse files
committed
Run prettier through the codebase
1 parent ec63410 commit a69a582

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1528
-1480
lines changed

__test__/renderer/ViewNode.test.js

Lines changed: 193 additions & 190 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"tdd": "jest --watch",
99
"dev": "rollup -c -w",
1010
"build": "rollup -c",
11-
"prettier": "prettier --no-semi --single-quote --write \"{{platform,__test__}/**/*.js,samples/app*.js}\""
11+
"prettier": "prettier --no-semi --single-quote --write \"{{platform,__test__}/**/*.js,samples/app/*.js}\""
1212
},
1313
"repository": {
1414
"type": "git",

platform/nativescript/compiler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export {parseComponent} from 'sfc/parser'
2-
export {compile, compileToFunctions} from './compiler/index'
1+
export { parseComponent } from 'sfc/parser'
2+
export { compile, compileToFunctions } from './compiler/index'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import model from './model'
22

33
export default {
4-
model
5-
}
4+
model
5+
}
Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
import {addHandler, addAttr} from 'compiler/helpers'
2-
import {genComponentModel, genAssignmentCode} from 'compiler/directives/model'
3-
import {getViewMeta} from '../../element-registry'
1+
import { addHandler, addAttr } from 'compiler/helpers'
2+
import { genComponentModel, genAssignmentCode } from 'compiler/directives/model'
3+
import { getViewMeta } from '../../element-registry'
44

55
const valueTypes = ['text', 'value', 'checked', 'date', 'selectedIndex', 'time']
66

77
export default function model(el, dir, _warn) {
8-
if (el.type === 1) {
9-
genDefaultModel(el, dir.value, dir.modifiers)
10-
} else {
11-
genComponentModel(el, dir.value, dir.modifiers)
12-
}
8+
if (el.type === 1) {
9+
genDefaultModel(el, dir.value, dir.modifiers)
10+
} else {
11+
genComponentModel(el, dir.value, dir.modifiers)
12+
}
1313
}
1414

1515
function genDefaultModel(el, value, modifiers) {
16-
const {trim, number} = modifiers || {}
17-
const {prop, event} = getViewMeta(el.tag).model
16+
const { trim, number } = modifiers || {}
17+
const { prop, event } = getViewMeta(el.tag).model
1818

19+
let valueExpression = `$event.value${trim ? '.trim()' : ''}`
1920

20-
let valueExpression = `$event.value${trim ? '.trim()' : ''}`
21+
if (number) {
22+
valueExpression = `_n(${valueExpression})`
23+
}
2124

22-
if (number) {
23-
valueExpression = `_n(${valueExpression})`
24-
}
25+
const code = genAssignmentCode(value, valueExpression)
2526

26-
const code = genAssignmentCode(value, valueExpression)
27-
28-
addAttr(el, prop, `(${value})`)
29-
addHandler(el, event, code, null, true)
30-
}
27+
addAttr(el, prop, `(${value})`)
28+
addHandler(el, event, code, null, true)
29+
}
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import {genStaticKeys} from 'shared/util'
2-
import {createCompiler} from 'compiler/index'
1+
import { genStaticKeys } from 'shared/util'
2+
import { createCompiler } from 'compiler/index'
33

44
import modules from './modules/index'
55
import directives from './directives/index'
66

77
import {
8-
isUnaryTag,
9-
mustUseProp,
10-
isReservedTag,
11-
canBeLeftOpenTag,
12-
getTagNamespace
8+
isUnaryTag,
9+
mustUseProp,
10+
isReservedTag,
11+
canBeLeftOpenTag,
12+
getTagNamespace
1313
} from '../util/index'
1414

1515
export const baseOptions = {
16-
modules,
17-
directives,
18-
isUnaryTag,
19-
mustUseProp,
20-
canBeLeftOpenTag,
21< 2851 /td>-
isReservedTag,
22-
getTagNamespace,
23-
preserveWhitespace: false,
24-
staticKeys: genStaticKeys(modules)
16+
modules,
17+
directives,
18+
isUnaryTag,
19+
mustUseProp,
20+
canBeLeftOpenTag,
21+
isReservedTag,
22+
getTagNamespace,
23+
preserveWhitespace: false,
24+
staticKeys: genStaticKeys(modules)
2525
}
2626

27-
const {compile, compileToFunctions} = createCompiler(baseOptions)
28-
export {compile, compileToFunctions}
27+
const { compile, compileToFunctions } = createCompiler(baseOptions)
28+
export { compile, compileToFunctions }
Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,42 @@
1-
import {parseText} from 'compiler/parser/text-parser'
2-
import {
3-
getAndRemoveAttr,
4-
getBindingAttr,
5-
baseWarn
6-
} from 'compiler/helpers'
1+
import { parseText } from 'compiler/parser/text-parser'
2+
import { getAndRemoveAttr, getBindingAttr, baseWarn } from 'compiler/helpers'
73

84
function transformNode(el, options) {
9-
const warn = options.warn || baseWarn
10-
const staticClass = getAndRemoveAttr(el, 'class')
11-
if (process.env.NODE_ENV !== 'production' && staticClass) {
12-
const expression = parseText(staticClass, options.delimiters)
13-
if (expression) {
14-
warn(
15-
`class="${staticClass}": ` +
16-
'Interpolation inside attributes has been removed. ' +
17-
'Use v-bind or the colon shorthand instead. For example, ' +
18-
'instead of <div class="{{ val }}">, use <div :class="val">.'
19-
)
20-
}
21-
}
22-
if (staticClass) {
23-
el.staticClass = JSON.stringify(staticClass)
24-
}
25-
const classBinding = getBindingAttr(el, 'class', false /* getStatic */)
26-
if (classBinding) {
27-
el.classBinding = classBinding
5+
const warn = options.warn || baseWarn
6+
const staticClass = getAndRemoveAttr(el, 'class')
7+
if (process.env.NODE_ENV !== 'production' && staticClass) {
8+
const expression = parseText(staticClass, options.delimiters)
9+
if (expression) {
10+
warn(
11+
`class="${staticClass}": ` +
12+
'Interpolation inside attributes has been removed. ' +
13+
'Use v-bind or the colon shorthand instead. For example, ' +
14+
'instead of <div class="{{ val }}">, use <div :class="val">.'
15+
)
2816
}
17+
}
18+
if (staticClass) {
19+
el.staticClass = JSON.stringify(staticClass)
20+
}
21+
const classBinding = getBindingAttr(el, 'class', false /* getStatic */)
22+
if (classBinding) {
23+
el.classBinding = classBinding
24+
}
2925
}
3026

3127
function genData(el) {
32-
let data = ''
33-
if (el.staticClass) {
34-
data += `staticClass:${el.staticClass},`
35-
}
36-
if (el.classBinding) {
37-
data += `class:${el.classBinding},`
38-
}
39-
return data
28+
let data = ''
29+
if (el.staticClass) {
30+
data += `staticClass:${el.staticClass},`
31+
}
32+
if (el.classBinding) {
33+
data += `class:${el.classBinding},`
34+
}
35+
return data
4036
}
4137

4238
export default {
43-
staticKeys: ['staticClass'],
44-
transformNode,
45-
genData
46-
}
39+
staticKeys: ['staticClass'],
40+
transformNode,
41+
genData
42+
}

platform/nativescript/compiler/modules/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,4 @@ import class_ from './class'
22
import style from './style'
33
import scopedSlots from './scopedSlots'
44

5-
export default [
6-
class_,
7-
style,
8-
scopedSlots
9-
]
5+
export default [class_, style, scopedSlots]
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
function preTransformNode(el, options) {
2-
if (el.tag === 'template') {
3-
let name = el.attrsMap.name
2+
if (el.tag === 'template') {
3+
let name = el.attrsMap.name
44

5-
if (name) {
6-
el.attrsMap['slot'] = name
7-
el.attrsList.push({
8-
name: 'slot',
9-
value: name
10-
})
11-
}
5+
if (name) {
6+
el.attrsMap['slot'] = name
7+
el.attrsList.push({
8+
name: 'slot',
9+
value: name
10+
})
1211
}
12+
}
1313
}
1414
export default {
15-
preTransformNode
16-
}
15+
preTransformNode
16+
}
Lines changed: 61 additions & 61 deletions
56
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
11
import { cached, camelize } from 'shared/util'
22
import { parseText } from 'compiler/parser/text-parser'
3-
import {
4-
getAndRemoveAttr,
5-
getBindingAttr,
6-
baseWarn
7-
} from 'compiler/helpers'
3+
import { getAndRemoveAttr, getBindingAttr, baseWarn } from 'compiler/helpers'
84

95
const normalize = cached(camelize)
106

11-
function transformNode (el, options) {
12-
const warn = options.warn || baseWarn
13-
const staticStyle = getAndRemoveAttr(el, 'style')
14-
const { dynamic, styleResult } = parseStaticStyle(staticStyle, options)
15-
if (process.env.NODE_ENV !== 'production' && dynamic) {
16-
warn(
17-
`style="${String(staticStyle)}": ` +
18-
'Interpolation inside attributes has been deprecated. ' +
19-
'Use v-bind or the colon shorthand instead.'
20-
)
21-
}
22-
if (!dynamic && styleResult) {
23-
el.staticStyle = styleResult
24-
}
25-
const styleBinding = getBindingAttr(el, 'style', false /* getStatic */)
26-
if (styleBinding) {
27-
el.styleBinding = styleBinding
28-
} else if (dynamic) {
29-
el.styleBinding = styleResult
30-
}
7+
function transformNode(el, options) {
8+
const warn = options.warn || baseWarn
9+
const staticStyle = getAndRemoveAttr(el, 'style')
10+
const { dynamic, styleResult } = parseStaticStyle(staticStyle, options)
11+
if (process.env.NODE_ENV !== 'production' && dynamic) {
12+
warn(
13+
`style="${String(staticStyle)}": ` +
14+
'Interpolation inside attributes has been deprecated. ' +
15+
'Use v-bind or the colon shorthand instead.'
16+
)
17+
}
18+
if (!dynamic && styleResult) {
19+
el.staticStyle = styleResult
20+
}
21+
const styleBinding = getBindingAttr(el, 'style', false /* getStatic */)
22+
if (styleBinding) {
23+
el.styleBinding = styleBinding
24+
} else if (dynamic) {
25+
el.styleBinding = styleResult
26+
}
3127
}
3228

33-
function genData (el) {
34-
let data = ''
35-
if (el.staticStyle) {
36-
data += `staticStyle:${el.staticStyle},`
37-
}
38-
if (el.styleBinding) {
39-
data += `style:${el.styleBinding},`
40-
}
41-
return data
29+
function 341A genData(el) {
30+
let data = ''
31+
if (el.staticStyle) {
32+
data += `staticStyle:${el.staticStyle},`
33+
}
34+
if (el.styleBinding) {
35+
data += `style:${el.styleBinding},`
36+
}
37+
return data
4238
}
4339

44-
function parseStaticStyle (staticStyle, options) {
45-
// "width: 200px; height: 200px;" -> {width: 200, height: 200}
46-
// "width: 200px; height: {{y}}" -> {width: 200, height: y}
47-
let dynamic = false
48-
let styleResult = ''
49-
if (staticStyle) {
50-
const styleList = staticStyle.trim().split(';').map(style => {
51-
const result = style.trim().split(':')
52-
if (result.length !== 2) {
53-
return
54-
}
55-
const key = normalize(result[0].trim())
56-
const value = result[1].trim()
57-
const dynamicValue = parseText(value, options.delimiters)
58-
if (dynamicValue) {
59-
dynamic = true
60-
return key + ':' + dynamicValue
61-
}
62-
return key + ':' + JSON.stringify(value)
63-
}).filter(result => result)
64-
if (styleList.length) {
65-
styleResult = '{' + styleList.join(',') + '}'
40+
function parseStaticStyle(staticStyle, options) {
41+
// "width: 200px; height: 200px;" -> {width: 200, height: 200}
42+
// "width: 200px; height: {{y}}" -> {width: 200, height: y}
43+
let dynamic = false
44+
let styleResult = ''
45+
if (staticStyle) {
46+
const styleList = staticStyle
47+
.trim()
48+
.split(';')
49+
.map(style => {
50+
const result = style.trim().split(':')
51+
if (result.length !== 2) {
52+
return
53+
}
54+
const key = normalize(result[0].trim())
55+
const value = result[1].trim()
+
const dynamicValue = parseText(value, options.delimiters)
57+
if (dynamicValue) {
58+
dynamic = true
59+
return key + ':' + dynamicValue
6660
}
61+
return key + ':' + JSON.stringify(value)
62+
})
63+
.filter(result => result)
64+
if (styleList.length) {
65+
styleResult = '{' + styleList.join(',') + '}'
6766
}
68-
return { dynamic, styleResult }
67+
}
68+
return { dynamic, styleResult }
6969
}
7070

7171
export default {
72-
staticKeys: ['staticStyle'],
73-
transformNode,
74-
genData
75-
}
72+
staticKeys: ['staticStyle'],
73+
transformNode,
74+
genData
75+
}

0 commit comments

Comments
 (0)
0