Skip to content

Commit

Permalink
chore(project): prettier all code and change style behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed May 25, 2021
1 parent af58562 commit 3792c22
Show file tree
Hide file tree
Showing 136 changed files with 1,669 additions and 1,392 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"param-case": "^3.0.4",
"prettier": "^2.2.1",
"pretty-format": "^24.0.0",
"pretty-quick": "^3.1.0",
"raw-loader": "^4.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
Expand Down Expand Up @@ -171,7 +172,7 @@
"git add"
],
"packages/!(*vue)/**/*.md": [
"prettier --write",
"pretty-quick --staged",
"git add"
]
},
Expand Down
2 changes: 1 addition & 1 deletion packages/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@typescript-eslint/array-type": 0,
"@typescript-eslint/no-object-literal-type-assertion": 0,
"@typescript-eslint/no-use-before-define": 0,
"@typescript-eslint/no-unused-vars": 0,
"@typescript-eslint/no-unused-vars": 1,
"@typescript-eslint/no-namespace": 0,
"@typescript-eslint/ban-types": 0,
"@typescript-eslint/adjacent-overload-signatures": 0,
Expand Down
6 changes: 0 additions & 6 deletions packages/antd/build-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,5 @@ import { build } from '../../scripts/build-style'
build({
esStr: 'antd/es/',
libStr: 'antd/lib/',
styleEntry: 'style.less',
allStylesOutputFile: 'dist/antd.css',
// antd/es/button/style/index ===> antd/es/button/style/css
importCssCompilerToCssTransform: (v) =>
v.replace(/'antd\/(es|lib)\/(.*)'/, (subStr) =>
subStr.replace(/\/style\/index'$/, `/style/css'`)
),
})
23 changes: 23 additions & 0 deletions packages/antd/create-style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import glob from 'glob'
import path from 'path'
import fs from 'fs-extra'

glob(
'./*/style.less',
{ cwd: path.resolve(__dirname, './src') },
(err, files) => {
if (err) return console.error(err)
fs.writeFile(
path.resolve(__dirname, './src/style.ts'),
`// auto generated code
${files
.map((path) => {
return `import '${path}'\n`
})
.join('')}
`,
'utf8'
)
}
)
5 changes: 3 additions & 2 deletions packages/antd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
},
"scripts": {
"start": "dumi dev",
"build": "rimraf -rf lib esm dist && npm run build:cjs && npm run build:esm && npm run build:umd && npm run build:style",
"build": "rimraf -rf lib esm dist && npm run create:style && npm run build:cjs && npm run build:esm && npm run build:umd && npm run build:style",
"create:style": "ts-node create-style",
"build:style": "ts-node build-style",
"build:cjs": "tsc --declaration",
"build:esm": "tsc --declaration --module es2015 --outDir esm",
Expand Down Expand Up @@ -58,4 +59,4 @@
"access": "public"
},
"gitHead": "2c44ae410a73f02735c63c6430e021a50e21f3ec"
}
}
2 changes: 1 addition & 1 deletion packages/antd/src/__builtins__/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './useClickAway'
export * from './usePrefixCls'
export * from './usePrefixCls'
2 changes: 1 addition & 1 deletion packages/antd/src/__builtins__/hooks/usePrefixCls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export const usePrefixCls = (
) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext)
return getPrefixCls(tag, props?.prefixCls)
}
}
2 changes: 1 addition & 1 deletion packages/antd/src/__builtins__/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './moment'
export * from './hooks'
export * from './hooks'
3 changes: 1 addition & 2 deletions packages/antd/src/array-base/style.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

import 'antd/lib/button/style/index'
import './style.less'
import './style.less'
2 changes: 1 addition & 1 deletion packages/antd/src/array-table/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import 'antd/lib/select/style/index'
import 'antd/lib/space/style/index'
import 'antd/lib/badge/style/index'
import 'antd/lib/pagination/style/index'
import './style.less'
import './style.less'
2 changes: 1 addition & 1 deletion packages/antd/src/cascader/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/cascader/style/index'
import 'antd/lib/cascader/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/checkbox/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/checkbox/style/index'
import 'antd/lib/checkbox/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/date-picker/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/date-picker/style/index'
import 'antd/lib/date-picker/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/form-button-group/style.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import 'antd/lib/form/style/index'
import './style.less'
import './style.less'
2 changes: 1 addition & 1 deletion packages/antd/src/form-collapse/style.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import 'antd/lib/collapse/style/index'
import 'antd/lib/badge/style/index'
import 'antd/lib/badge/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/form-grid/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import './style.less'
import './style.less'
2 changes: 1 addition & 1 deletion packages/antd/src/form-step/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/steps/style/index'
import 'antd/lib/steps/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/form-tab/style.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import 'antd/lib/tabs/style/index'
import 'antd/lib/badge/style/index'
import 'antd/lib/badge/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ export * from './upload'
export * from './preview-text'
export * from './submit'
export * from './reset'
export * from './editable'
export * from './editable'
2 changes: 1 addition & 1 deletion packages/antd/src/input/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/input/style/index'
import 'antd/lib/input/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/number-picker/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/input-number/style/index'
import 'antd/lib/input-number/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/password/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/input/style/index'
import 'antd/lib/input/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/preview-text/style.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import 'antd/lib/tag/style/index'
import './style.less'
import './style.less'
2 changes: 1 addition & 1 deletion packages/antd/src/radio/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/radio/style/index'
import 'antd/lib/radio/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/reset/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/button/style/index'
import 'antd/lib/button/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/select/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/select/style/index'
import 'antd/lib/select/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/space/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/space/style/index'
import 'antd/lib/space/style/index'
45 changes: 13 additions & 32 deletions packages/antd/src/style.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
import './input/style'
import './number-picker/style'
import './password/style'
import './preview-text/style'
import './radio/style'
import './reset/style'
import './select/style'
import './submit/style'
import './switch/style'
import './time-picker/style'
import './transfer/style'
import './tree-select/style'
import './array-base/style'
import './array-cards/style'
import './array-collapse/style'
import './array-items/style'
import './array-tabs/style'
import './array-table/style'
import './cascader/style'
import './space/style'
import './checkbox/style'
import './date-picker/style'
import './editable/style'
import './form-button-group/style'
import './form-collapse/style'
import './form-dialog/style'
import './form-drawer/style'
import './form-item/style'
import './form-step/style'
import './form-grid/style'
import './form-tab/style'
import './upload/style'
// auto generated code
import './array-base/style.less'
import './array-cards/style.less'
import './array-collapse/style.less'
import './array-items/style.less'
import './array-table/style.less'
import './editable/style.less'
import './form-button-group/style.less'
import './form-grid/style.less'
import './form-item/style.less'
import './form-layout/style.less'
import './form/style.less'
import './preview-text/style.less'
2 changes: 1 addition & 1 deletion packages/antd/src/switch/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/switch/style/index'
import 'antd/lib/switch/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/time-picker/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/time-picker/style/index'
import 'antd/lib/time-picker/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/transfer/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/transfer/style/index'
import 'antd/lib/transfer/style/index'
2 changes: 1 addition & 1 deletion packages/antd/src/tree-select/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/tree-select/style/index'
import 'antd/lib/tree-select/style/index'
34 changes: 17 additions & 17 deletions packages/antd/src/upload/placeholder.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
export const UPLOAD_PLACEHOLDER = [
{
ext: /\.docx?$/i,
icon: '//img.alicdn.com/tfs/TB1n8jfr1uSBuNjy1XcXXcYjFXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB1n8jfr1uSBuNjy1XcXXcYjFXa-200-200.png',
},
{
ext: /\.pptx?$/i,
icon: '//img.alicdn.com/tfs/TB1ItgWr_tYBeNjy1XdXXXXyVXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB1ItgWr_tYBeNjy1XdXXXXyVXa-200-200.png',
},
{
ext: /\.jpe?g$/i,
icon: '//img.alicdn.com/tfs/TB1wrT5r9BYBeNjy0FeXXbnmFXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB1wrT5r9BYBeNjy0FeXXbnmFXa-200-200.png',
},
{
ext: /\.pdf$/i,
icon: '//img.alicdn.com/tfs/TB1GwD8r9BYBeNjy0FeXXbnmFXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB1GwD8r9BYBeNjy0FeXXbnmFXa-200-200.png',
},
{
ext: /\.png$/i,
icon: '//img.alicdn.com/tfs/TB1BHT5r9BYBeNjy0FeXXbnmFXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB1BHT5r9BYBeNjy0FeXXbnmFXa-200-200.png',
},
{
ext: /\.eps$/i,
icon: '//img.alicdn.com/tfs/TB1G_iGrVOWBuNjy0FiXXXFxVXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB1G_iGrVOWBuNjy0FiXXXFxVXa-200-200.png',
},
{
ext: /\.ai$/i,
icon: '//img.alicdn.com/tfs/TB1B2cVr_tYBeNjy1XdXXXXyVXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB1B2cVr_tYBeNjy1XdXXXXyVXa-200-200.png',
},
{
ext: /\.gif$/i,
icon: '//img.alicdn.com/tfs/TB1DTiGrVOWBuNjy0FiXXXFxVXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB1DTiGrVOWBuNjy0FiXXXFxVXa-200-200.png',
},
{
ext: /\.svg$/i,
icon: '//img.alicdn.com/tfs/TB1uUm9rY9YBuNjy0FgXXcxcXXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB1uUm9rY9YBuNjy0FgXXcxcXXa-200-200.png',
},
{
ext: /\.xlsx?$/i,
icon: '//img.alicdn.com/tfs/TB1any1r1OSBuNjy0FdXXbDnVXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB1any1r1OSBuNjy0FdXXbDnVXa-200-200.png',
},
{
ext: /\.psd?$/i,
icon: '//img.alicdn.com/tfs/TB1_nu1r1OSBuNjy0FdXXbDnVXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB1_nu1r1OSBuNjy0FdXXbDnVXa-200-200.png',
},
{
ext: /\.(wav|aif|aiff|au|mp1|mp2|mp3|ra|rm|ram|mid|rmi)$/i,
icon: '//img.alicdn.com/tfs/TB1jPvwr49YBuNjy0FfXXXIsVXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB1jPvwr49YBuNjy0FfXXXIsVXa-200-200.png',
},
{
ext: /\.(avi|wmv|mpg|mpeg|vob|dat|3gp|mp4|mkv|rm|rmvb|mov|flv)$/i,
icon: '//img.alicdn.com/tfs/TB1FrT5r9BYBeNjy0FeXXbnmFXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB1FrT5r9BYBeNjy0FeXXbnmFXa-200-200.png',
},
{
ext: /\.(zip|rar|arj|z|gz|iso|jar|ace|tar|uue|dmg|pkg|lzh|cab)$/i,
icon: '//img.alicdn.com/tfs/TB10jmfr29TBuNjy0FcXXbeiFXa-200-200.png'
icon: '//img.alicdn.com/tfs/TB10jmfr29TBuNjy0FcXXbeiFXa-200-200.png',
},
{
ext: /\.[^.]+$/i,
icon: '//img.alicdn.com/tfs/TB10.R4r3mTBuNjy1XbXXaMrVXa-200-200.png'
}
]
icon: '//img.alicdn.com/tfs/TB10.R4r3mTBuNjy1XbXXaMrVXa-200-200.png',
},
]
2 changes: 1 addition & 1 deletion packages/antd/src/upload/style.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'antd/lib/upload/style/index'
import 'antd/lib/upload/style/index'
34 changes: 17 additions & 17 deletions packages/core/src/__tests__/array.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ test('array field children state exchanges', () => {
})
)
expect(array.value).toEqual([{ value: 11 }, { value: 22 }])
expect(form.query('array.0.value').get("value")).toEqual(11)
expect(form.query('array.1.value').get("value")).toEqual(22)
expect(form.query('array.0.value').get('value')).toEqual(11)
expect(form.query('array.1.value').get('value')).toEqual(22)
expect(Object.keys(form.fields).sort()).toEqual([
'array',
'array.0.value',
Expand All @@ -88,8 +88,8 @@ test('array field children state exchanges', () => {
])
array.pop()
expect(array.value).toEqual([{ value: 11 }])
expect(form.query('array.0.value').get("value")).toEqual(11)
expect(form.query('array.1.value').get("value")).toBeUndefined()
expect(form.query('array.0.value').get('value')).toEqual(11)
expect(form.query('array.1.value').get('value')).toBeUndefined()
array.unshift({ value: 33 })
attach(
form.createField({
Expand All @@ -104,12 +104,12 @@ test('array field children state exchanges', () => {
})
)
expect(array.value).toEqual([{ value: 33 }, { value: 11 }])
expect(form.query('array.0.value').get("value")).toEqual(33)
expect(form.query('array.1.value').get("value")).toEqual(11)
expect(form.query('array.0.value').get('value')).toEqual(33)
expect(form.query('array.1.value').get('value')).toEqual(11)
array.remove(1)
expect(array.value).toEqual([{ value: 33 }])
expect(form.query('array.0.value').get("value")).toEqual(33)
expect(form.query('array.1.value').get("value")).toBeUndefined()
expect(form.query('array.0.value').get('value')).toEqual(33)
expect(form.query('array.1.value').get('value')).toBeUndefined()
array.insert(1, { value: 44 }, { value: 55 })
attach(
form.createField({
Expand All @@ -124,19 +124,19 @@ test('array field children state exchanges', () => {
})
)
expect(array.value).toEqual([{ value: 33 }, { value: 44 }, { value: 55 }])
expect(form.query('array.0.value').get("value")).toEqual(33)
expect(form.query('array.1.value').get("value")).toEqual(44)
expect(form.query('array.2.value').get("value")).toEqual(55)
expect(form.query('array.0.value').get('value')).toEqual(33)
expect(form.query('array.1.value').get('value')).toEqual(44)
expect(form.query('array.2.value').get('value')).toEqual(55)
array.move(0, 2)
expect(array.value).toEqual([{ value: 44 }, { value: 55 }, { value: 33 }])
expect(form.query('array.0.value').get("value")).toEqual(44)
expect(form.query('array.1.value').get("value")).toEqual(55)
expect(form.query('array.2.value').get("value")).toEqual(33)
expect(form.query('array.0.value').get('value')).toEqual(44)
expect(form.query('array.1.value').get('value')).toEqual(55)
expect(form.query('array.2.value').get('value')).toEqual(33)
array.move(2, 0)
expect(array.value).toEqual([{ value: 33 }, { value: 44 }, { value: 55 }])
expect(form.query('array.0.value').get("value")).toEqual(33)
expect(form.query('array.1.value').get("value")).toEqual(44)
expect(form.query('array.2.value').get("value")).toEqual(55)
expect(form.query('array.0.value').get('value')).toEqual(33)
expect(form.query('array.1.value').get('value')).toEqual(44)
expect(form.query('array.2.value').get('value')).toEqual(55)
})

test('void children', () => {
Expand Down
Loading

0 comments on commit 3792c22

Please sign in to comment.