Skip to content

Commit

Permalink
Merge pull request #2590 from XiaoMi/hotfix/stories-code-standard
Browse files Browse the repository at this point in the history
fix: stories code standard
  • Loading branch information
solarjoker authored Sep 18, 2023
2 parents 1fbf860 + bf8818e commit 3c16b3b
Show file tree
Hide file tree
Showing 15 changed files with 143 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import EllipsisTooltip from '../src'
*/
export const MultiplyLine = () => {
const textOverview =
'【译】孔子说:“学习并且不断温习,不也很愉快吗?远方来了朋友,不也很快乐吗?人家不了解我,我也不怨恨,不也是君子吗?”,【译】孔子说:“学习并且不断温习,不也很愉快吗?远方来了朋友,不也很快乐吗?人家不了解我,我也不怨恨,不也是君子吗?”'
'【译】孔子说:“学习并且不断温习,不也很愉快吗?远方来了朋友,不也很快乐吗?人家不了解我,我也不怨恨,不也是君子吗?”,【译】孔子说:“学习并且不断温习,不也很愉快吗?远方来了朋友,不也很快乐吗?人家不了解我,我也不怨恨,不也是君子吗?”'

return (
<>
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/form/stories/cascade.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-callback-literal */
import React from 'react'
import Form, { FormHelpers } from '../src'
import Button from '@hi-ui/button'
Expand Down Expand Up @@ -201,7 +200,7 @@ export const Cascade = () => {
}}
onRemove={(file, fileList, index) => {
console.log('remove callback', file, fileList, index)
return new Promise((resolve, reject) => resolve(true))
return new Promise((resolve) => resolve(true))
}}
name={'files[]'}
defaultFileList={[
Expand Down
5 changes: 2 additions & 3 deletions packages/ui/form/stories/get-values.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-callback-literal */
import React from 'react'
import Form, { FormHelpers } from '../src'
import Input from '@hi-ui/input'
Expand Down Expand Up @@ -37,9 +36,9 @@ export const GetValues = () => {
validator: (rule, value, callback) => {
const telReg = /^[1][3|4|5|6|7|8|9][0-9]{9}$/
if (!value) {
callback('请输入手机号')
callback(new Error('请输入手机号'))
} else if (!telReg.test(value)) {
callback('请输入正确的手机号')
callback(new Error('请输入正确的手机号'))
} else {
callback()
}
Expand Down
5 changes: 2 additions & 3 deletions packages/ui/form/stories/nested-field.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-callback-literal */
import React from 'react'
import Form, { FormHelpers } from '../src'
import Input from '@hi-ui/input'
Expand Down Expand Up @@ -44,9 +43,9 @@ export const NestedField = () => {
validator: (rule, value, callback) => {
const telReg = /^[1][3|4|5|6|7|8|9][0-9]{9}$/
if (!value) {
callback('请输入手机号')
callback(new Error('请输入手机号'))
} else if (!telReg.test(value)) {
callback('请输入正确的手机号')
callback(new Error('请输入正确的手机号'))
} else {
callback()
}
Expand Down
5 changes: 2 additions & 3 deletions packages/ui/form/stories/set-values.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-callback-literal */
import React from 'react'
import Form, { FormHelpers } from '../src'
import Input from '@hi-ui/input'
Expand Down Expand Up @@ -51,9 +50,9 @@ export const SetValues = () => {
validator: (rule, value, callback) => {
const telReg = /^[1][3|4|5|6|7|8|9][0-9]{9}$/
if (!value) {
callback('请输入手机号')
callback(new Error('请输入手机号'))
} else if (!telReg.test(value)) {
callback('请输入正确的手机号')
callback(new Error('请输入正确的手机号'))
} else {
callback()
}
Expand Down
15 changes: 7 additions & 8 deletions packages/ui/form/stories/validate-field.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-callback-literal */
import React from 'react'
import Form, { FormHelpers } from '../src'
import Input from '@hi-ui/input'
Expand Down Expand Up @@ -70,9 +69,9 @@ export const ValidateField = () => {
const telReg = /^[1][3|4|5|6|7|8|9][0-9]{9}$/

if (!value) {
callback('请输入手机号')
callback(new Error('请输入手机号'))
} else if (!telReg.test(value)) {
callback('请输入正确的手机号')
callback(new Error('请输入正确的手机号'))
} else {
callback()
}
Expand All @@ -94,9 +93,9 @@ export const ValidateField = () => {
validator: (rule, value, callback) => {
const telReg = /^[0-9]{6}$/
if (!value) {
callback('请输入手机号')
callback(new Error('请输入手机号'))
} else if (!telReg.test(value)) {
callback('请输入正确的验证码')
callback(new Error('请输入正确的验证码'))
} else {
callback()
}
Expand Down Expand Up @@ -135,9 +134,9 @@ export const ValidateField = () => {
validator: (rule, value, callback) => {
const telReg = /^(?![^a-zA-Z]+$)(?!\D+$).{8,16}$/
if (!value) {
callback('请输入密码')
callback(new Error('请输入密码'))
} else if (!telReg.test(value)) {
callback('请输入包括数字和字母、长度8到16位的密码组合')
callback(new Error('请输入包括数字和字母、长度8到16位的密码组合'))
} else {
callback()
}
Expand All @@ -159,7 +158,7 @@ export const ValidateField = () => {
console.log(value, formData.password)

if (value !== formData.password) {
callback('两次密码不同')
callback(new Error('两次密码不同'))
} else {
callback()
}
Expand Down
9 changes: 3 additions & 6 deletions packages/ui/form/stories/validate.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,10 @@ export const Validate = () => {
validator: (rule, value, cb) => {
const count = +value
if (isNaN(count)) {
// eslint-disable-next-line node/no-callback-literal
cb('请输入数字')
cb(new Error('请输入数字'))
} else if (count <= 0) {
// eslint-disable-next-line node/no-callback-literal
cb('必须是正数')
cb(new Error('必须是正数'))
} else {
// eslint-disable-next-line node/no-callback-literal
cb()
}
},
Expand Down Expand Up @@ -155,7 +152,7 @@ export const Validate = () => {
<FormItem label="品类" field="category" valueType="string">
<Cascader
onChange={(id) => {
console.log('change')
console.log('change', id)
}}
data={cascaderOptions}
style={{ width: '100%' }}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/message/stories/type.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const Type = () => {
return () => {
message.open({
title: '问君能有几多愁,恰似一江春水向东流',
type: type,
type,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/scrollbar/stories/event.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const Event = () => {
<h2>x、y滚动事件</h2>
<div className="scrollbar-basic__wrap" style={{ height: 320, marginBottom: 64 }}>
<Scrollbar
onScrollX={(e) => console.log('scroll x')}
onScrollX={() => console.log('scroll x')}
onScrollY={() => console.log('scroll y')}
>
{scrollContent}
Expand Down
Loading

0 comments on commit 3c16b3b

Please sign in to comment.