Skip to content

Commit

Permalink
chore(docs/test): fix code style, remove commented code and replace `…
Browse files Browse the repository at this point in the history
…var` to `const` (#1874)
  • Loading branch information
那里好脏不可以 authored May 3, 2022
1 parent 4155b51 commit 24218bd
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 51 deletions.
40 changes: 20 additions & 20 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -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
}
]
]
}
}
}
2 changes: 1 addition & 1 deletion docs/en/I18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
```

Expand Down
2 changes: 1 addition & 1 deletion docs/es-es/I18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
```

Expand Down
2 changes: 1 addition & 1 deletion docs/ja/I18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
```

Expand Down
2 changes: 1 addition & 1 deletion docs/ko/I18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
```

Expand Down
2 changes: 1 addition & 1 deletion docs/pt-br/I18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
```

Expand Down
2 changes: 1 addition & 1 deletion docs/zh-cn/I18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
```

Expand Down
11 changes: 5 additions & 6 deletions karma.sauce.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = function (config) {

var batches = [
const batches = [
{
sl_chrome_26: {
base: 'SauceLabs',
Expand Down Expand Up @@ -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'],
Expand All @@ -97,5 +96,5 @@ module.exports = function (config) {
customLaunchers: batch,
browsers: Object.keys(batch),
singleRun: true
});
};
})
}
23 changes: 4 additions & 19 deletions test/plugin/preParsePostFormat.test.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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}`)
}
}
}
Expand Down

0 comments on commit 24218bd

Please sign in to comment.