chore(docs/test): fix code style, remove commented code and replace `var` to `const` (#1874)

pull/1882/head
那里好脏不可以 2 years ago committed by GitHub
parent 4155b51107
commit 24218bda05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,20 +1,20 @@
module.exports = {
"env": {
"test": {
"presets": [
"@babel/preset-env"
]
},
"build": {
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"loose": true
}
]
]
}
}
};
module.exports = {
env: {
test: {
presets: [
'@babel/preset-env'
]
},
build: {
presets: [
[
'@babel/preset-env',
{
modules: false,
loose: true
}
]
]
}
}
}

@ -90,7 +90,7 @@ dayjs()
.locale('zh-cn')
.format()
// get locale object
var customLocale = window.dayjs_locale_zh_cn // zh-cn -> zh_cn
const customLocale = window.dayjs_locale_zh_cn // zh-cn -> zh_cn
</script>
```

@ -94,7 +94,7 @@ dayjs()
.locale('zh-cn')
.format()
// get locale object
var customLocale = window.dayjs_locale_zh_cn // zh-cn -> zh_cn
const customLocale = window.dayjs_locale_zh_cn // zh-cn -> zh_cn
</script>
```

@ -90,7 +90,7 @@ dayjs()
.locale('zh-cn')
.format()
// ロケールオブジェクトを取得
var customLocale = window.dayjs_locale_zh_cn // zh-cn -> zh_cn
const customLocale = window.dayjs_locale_zh_cn // zh-cn -> zh_cn
</script>
```

@ -90,7 +90,7 @@ dayjs()
.locale('zh-cn')
.format()
// get locale object
var customLocale = window.dayjs_locale_zh_cn // zh-cn -> zh_cn
const customLocale = window.dayjs_locale_zh_cn // zh-cn -> zh_cn
</script>
```

@ -90,7 +90,7 @@ dayjs()
.locale('pt-br')
.format()
// obtém o objeto de localidade
var customLocale = window.dayjs_locale_zh_cn // pt-br -> pt-br
const customLocale = window.dayjs_locale_zh_cn // pt-br -> pt-br
</script>
```

@ -90,7 +90,7 @@ dayjs()
.locale('zh-cn')
.format()
// 获取语言配置对象
var customLocale = window.dayjs_locale_zh_cn // zh-cn -> zh_cn
const customLocale = window.dayjs_locale_zh_cn // zh-cn -> zh_cn
</script>
```

@ -1,6 +1,5 @@
module.exports = function (config) {
var batches = [
const batches = [
{
sl_chrome_26: {
base: 'SauceLabs',
@ -75,9 +74,9 @@ module.exports = function (config) {
browserName: 'android'
}
}
];
]
var batch = batches[process.argv[4] || 0]
const batch = batches[process.argv[4] || 0]
config.set({
basePath: '',
frameworks: ['jasmine'],
@ -97,5 +96,5 @@ module.exports = function (config) {
customLaunchers: batch,
browsers: Object.keys(batch),
singleRun: true
});
};
})
}

@ -1,5 +1,4 @@
import MockDate from 'mockdate'
// import moment from 'moment'
import dayjs from '../../src'
import preParsePostFormat from '../../src/plugin/preParsePostFormat'
import localeData from '../../src/plugin/localeData'
@ -51,36 +50,22 @@ const localeCustomizations = {
...en,
preparse(string) {
if (typeof string !== 'string') {
// console.error('preparse - Expected string, got', {
// string
// })
throw new Error(`preparse - Expected string, got ${typeof string}`)
}
try {
const res = string.replace(/[!@#$%^&*()]/g, match => numberMap[match])
// console.log('Called custom preparse', { string, res })
return res
return string.replace(/[!@#$%^&*()]/g, match => numberMap[match])
} catch (error) {
const errorMsg = `Unexpected error during preparse of '${string}' - ${error}`
// console.error(errorMsg)
throw new Error(errorMsg)
throw new Error(`Unexpected error during preparse of '${string}' - ${error}`)
}
},
postformat(string) {
if (typeof string !== 'string') {
// console.error('postformat - Expected string, got', {
// string
// })
throw new Error(`postformat - Expected string, got ${typeof string}`)
}
try {
const res = string.replace(/\d/g, match => symbolMap[match])
// console.log('Called custom postformat', { string, res })
return res
return string.replace(/\d/g, match => symbolMap[match])
} catch (error) {
const errorMsg = `Unexpected error during postFormat of '${string}' - ${error}`
// console.error(errorMsg)
throw new Error(errorMsg)
throw new Error(`Unexpected error during postFormat of '${string}' - ${error}`)
}
}
}

Loading…
Cancel
Save