Skip to content

Commit 9cf1fbb

Browse files
committed
chore: eslint && auto fix
1 parent 76d8837 commit 9cf1fbb

File tree

210 files changed

+1200
-1196
lines changed

Some content is hidden

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

210 files changed

+1200
-1196
lines changed

.eslintignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
/src/packages/**/*.md
1+
src/sites
2+
scripts
3+
node_modules
4+
dist
5+
.idea
6+
.husky
7+
iconfont.js

.eslintrc.js

+43-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ module.exports = {
44
node: true,
55
es2021: true,
66
},
7-
extends: ['plugin:react/recommended', 'prettier'],
7+
extends: [
8+
'airbnb',
9+
'plugin:react/recommended',
10+
'plugin:react-hooks/recommended',
11+
'plugin:@typescript-eslint/recommended',
12+
'plugin:markdown/recommended',
13+
'plugin:prettier/recommended',
14+
],
815
parser: '@typescript-eslint/parser',
916
parserOptions: {
1017
ecmaFeatures: {
@@ -13,15 +20,49 @@ module.exports = {
1320
ecmaVersion: 12,
1421
sourceType: 'module',
1522
},
16-
plugins: ['react', '@typescript-eslint'],
23+
plugins: ['react', 'react-hooks', '@typescript-eslint', 'unused-imports', 'prettier', 'markdown'],
24+
overrides: [
25+
{
26+
files: ['src/packages/**/*.md'],
27+
processor: 'markdown/markdown',
28+
},
29+
{
30+
files: [
31+
'src/packages/**/*.md/*.ts',
32+
'src/packages/**/*.md/*.tsx',
33+
'src/packages/**/*.md/*.js',
34+
'src/packages/**/*.md/*.jsx',
35+
],
36+
rules: {
37+
'unused-imports/no-unused-imports': 0,
38+
},
39+
},
40+
],
1741
rules: {
42+
'unused-imports/no-unused-imports': 2,
43+
1844
'import/prefer-default-export': 0,
45+
'import/no-extraneous-dependencies': 0,
1946
'import/extensions': 0,
2047
'import/no-unresolved': 0,
2148
'no-unused-vars': 0,
2249
'no-use-before-define': 0,
2350
'no-undef': 0,
51+
'no-shadow': 0,
52+
'no-console': 0,
53+
'no-plusplus': 0,
54+
'no-script-url': 0,
55+
'no-unused-expressions': 0,
56+
'jsx-a11y/click-events-have-key-events': 0,
57+
'@typescript-eslint/no-empty-function': 0,
58+
'@typescript-eslint/no-unused-vars': 0,
59+
'@typescript-eslint/no-var-requires': 0,
2460
'react/prop-types': 0,
61+
'react/no-array-index-key': 0,
62+
'react/static-property-placement': 0,
63+
'react/destructuring-assignment': 0,
2564
'react/jsx-filename-extension': 0,
65+
'react/jsx-props-no-spreading': 0,
66+
'jsx-a11y/no-static-element-interactions': 0,
2667
},
2768
}

commitlint.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = { extends: ['@commitlint/config-conventional'] };
1+
module.exports = { extends: ['@commitlint/config-conventional'] }

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
"build:es": "npx rollup -c rollup.config.es.js",
5252
"build": "npm run checked && vite build --config vite.config.build.ts && npm run build:es && npm run build:css && npm run build:loader-style && npm run build:types ",
5353
"build:site": "npm run checked && vite build --config vite.config.build.site.ts",
54+
"lint": "eslint .",
55+
"lint:fix": "eslint --fix .",
5456
"publish:beta": "npm publish --tag beta",
5557
"prepare": "husky install"
5658
},
@@ -101,8 +103,11 @@
101103
"eslint-config-prettier": "^8.3.0",
102104
"eslint-plugin-import": "^2.23.2",
103105
"eslint-plugin-jsx-a11y": "^6.4.1",
106+
"eslint-plugin-markdown": "^2.2.1",
107+
"eslint-plugin-prettier": "^4.0.0",
104108
"eslint-plugin-react": "^7.23.2",
105109
"eslint-plugin-react-hooks": "^4.2.0",
110+
"eslint-plugin-unused-imports": "^2.0.0",
106111
"fs-extra": "^10.0.0",
107112
"glob": "^7.2.0",
108113
"husky": "^6.0.0",

rollup.config.es.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import { getBabelOutputPlugin } from '@rollup/plugin-babel'
44

55
const path = require('path')
66
const config = require('./src/config.json')
7+
78
const entries = { 'nutui-react.es': path.join(__dirname, `./src/packages/nutui.react.build.ts`) }
89
const outputEntries = {}
910

1011
config.nav.map((item) => {
1112
item.packages.forEach((element) => {
12-
let { name, show, type, exportEmpty } = element
13+
const { name, show, type, exportEmpty } = element
1314
if (show || exportEmpty) {
1415
outputEntries[`./${name.toLowerCase()}`] = `./${name}`
1516
entries[name] = path.join(__dirname, `./src/packages/${name.toLowerCase()}/index.ts`)
@@ -32,7 +33,7 @@ export default {
3233
dir: './dist/esm',
3334
name: '[entryName].js',
3435
paths: (id) => {
35-
return /@\/packages/.test(id) ? outputEntries[id.replace('@/packages/', './')] + '.js' : id
36+
return /@\/packages/.test(id) ? `${outputEntries[id.replace('@/packages/', './')]}.js` : id
3637
},
3738
},
3839
plugins: [

src/packages/actionsheet/actionsheet.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { FunctionComponent, useState, useEffect } from 'react'
1+
import React, { FunctionComponent } from 'react'
22
import Popup from '@/packages/popup'
33
import bem from '@/utils/bem'
44

src/packages/actionsheet/demo.tsx

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState } from 'react'
22
import { ActionSheet, ItemType } from './actionsheet'
33
import Cell from '@/packages/cell'
4+
45
interface Item {
56
name: string
67
subname?: string
@@ -67,27 +68,27 @@ const ActionSheetDemo = () => {
6768
<>
6869
<div className="demo">
6970
<h2>基本用法</h2>
70-
<Cell isLink={true} onClick={() => setIsVisible1(!isVisible1)}>
71+
<Cell isLink onClick={() => setIsVisible1(!isVisible1)}>
7172
<span>
7273
<label>基础用法</label>
7374
</span>
7475
<div className="selected-option">{val1}</div>
7576
</Cell>
76-
<Cell isLink={true} onClick={() => setIsVisible2(!isVisible2)}>
77+
<Cell isLink onClick={() => setIsVisible2(!isVisible2)}>
7778
<span>
7879
<label>展示取消按钮</label>
7980
</span>
8081
<div className="selected-option">{val2}</div>
8182
</Cell>
82-
<Cell isLink={true} onClick={() => setIsVisible3(!isVisible3)}>
83+
<Cell isLink onClick={() => setIsVisible3(!isVisible3)}>
8384
<span>
8485
<label>展示描述信息</label>
8586
</span>
8687
<div className="selected-option">{val3}</div>
8788
</Cell>
8889
<h2>选项状态</h2>
8990

90-
<Cell isLink={true} onClick={() => setIsVisible4(!isVisible4)}>
91+
<Cell isLink onClick={() => setIsVisible4(!isVisible4)}>
9192
<span>
9293
<label>选项状态</label>
9394
</span>
@@ -99,15 +100,15 @@ const ActionSheetDemo = () => {
99100
menuItems={menuItemsOne}
100101
choose={chooseItem}
101102
cancel={() => setIsVisible1(false)}
102-
></ActionSheet>
103+
/>
103104
{/* demo(带取消按钮) */}
104105
<ActionSheet
105106
visible={isVisible2}
106107
cancelTxt="取消"
107108
menuItems={menuItemsOne}
108109
choose={chooseItemTwo}
109110
cancel={() => setIsVisible2(false)}
110-
></ActionSheet>
111+
/>
111112
{/* 展示描述信息 */}
112113
<ActionSheet
113114
visible={isVisible3}
@@ -116,7 +117,7 @@ const ActionSheetDemo = () => {
116117
choose={chooseItemThree}
117118
cancelTxt="取消"
118119
cancel={() => setIsVisible3(false)}
119-
></ActionSheet>
120+
/>
120121
{/* demo 选项状态 */}
121122
<ActionSheet
122123
visible={isVisible4}
@@ -127,7 +128,7 @@ const ActionSheetDemo = () => {
127128
choose={() => {
128129
setIsVisible4(false)
129130
}}
130-
></ActionSheet>
131+
/>
131132
</div>
132133
</>
133134
)

src/packages/actionsheet/doc.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { ActionSheet } from '@nutui/nutui-react';
1919
```tsx
2020
import React, { useState } from "react";
2121
import { ActionSheet,Cell } from '@nutui/nutui-react';
22+
2223
interface Item {
2324
name: string
2425
subname?: string
@@ -46,7 +47,7 @@ const App = () => {
4647

4748
return (
4849
<>
49-
<Cell isLink={true} onClick={() => setIsVisible1(!isVisible1)}>
50+
<Cell isLink onClick={() => setIsVisible1(!isVisible1)}>
5051
<span>
5152
<label>基础用法</label>
5253
</span>
@@ -58,7 +59,7 @@ const App = () => {
5859
menuItems={menuItemsOne}
5960
choose={chooseItem}
6061
cancel={() => setIsVisible1(false)}
61-
></ActionSheet>
62+
/>
6263
</>
6364
);
6465
};
@@ -93,7 +94,7 @@ const App = () => {
9394
}
9495
return (
9596
<>
96-
<Cell isLink={true} onClick={() => setIsVisible2(!isVisible2)}>
97+
<Cell isLink onClick={() => setIsVisible2(!isVisible2)}>
9798
<span>
9899
<label>展示取消按钮</label>
99100
</span>
@@ -106,7 +107,7 @@ const App = () => {
106107
menuItems={menuItemsOne}
107108
choose={chooseItemTwo}
108109
cancel={() => setIsVisible2(false)}
109-
></ActionSheet>
110+
/>
110111
</>
111112
);
112113
};
@@ -142,7 +143,7 @@ const App = () => {
142143
}
143144
return (
144145
<>
145-
<Cell isLink={true} onClick={() => setIsVisible3(!isVisible3)}>
146+
<Cell isLink onClick={() => setIsVisible3(!isVisible3)}>
146147
<span>
147148
<label>展示描述信息</label>
148149
</span>
@@ -155,7 +156,7 @@ const App = () => {
155156
choose={chooseItemThree}
156157
cancelTxt="取消"
157158
cancel={() => setIsVisible3(false)}
158-
></ActionSheet>
159+
/>
159160
</>
160161
);
161162
};
@@ -183,7 +184,7 @@ const App = () => {
183184
]
184185
return (
185186
<>
186-
<Cell isLink={true} onClick={() => setIsVisible4(!isVisible4)}>
187+
<Cell isLink onClick={() => setIsVisible4(!isVisible4)}>
187188
<span>
188189
<label>选项状态</label>
189190
</span>
@@ -197,7 +198,7 @@ const App = () => {
197198
choose={() => {
198199
setIsVisible4(false)
199200
}}
200-
></ActionSheet>
201+
/>
201202
</>
202203
);
203204
};

src/packages/actionsheet/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import { ActionSheet } from './actionsheet'
2+
23
export default ActionSheet

src/packages/address/address.tsx

+13-17
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export interface AddressProps {
4242
city: RegionData[]
4343
country: RegionData[]
4444
town: RegionData[]
45-
isShowCustomAddress: Boolean
45+
isShowCustomAddress: boolean
4646
existAddress: AddressList[]
4747
existAddressTitle: string
4848
customAndExistTitle: string
@@ -117,9 +117,9 @@ export const Address: FunctionComponent<
117117
city: { name: '' },
118118
country: { name: '' },
119119
town: { name: '' },
120-
}) //已选择的 省、市、县、镇
120+
}) // 已选择的 省、市、县、镇
121121

122-
let [selectedExistAddress, setSelectedExistAddress] = useState({}) // 当前选择的地址
122+
const [selectedExistAddress, setSelectedExistAddress] = useState({}) // 当前选择的地址
123123

124124
const [closeWay, setCloseWay] = useState('self')
125125

@@ -177,13 +177,11 @@ export const Address: FunctionComponent<
177177
}
178178
// 关闭
179179
const closeFun = () => {
180-
const resCopy = Object.assign(
181-
{
182-
addressIdStr: '',
183-
addressStr: '',
184-
},
185-
selectedRegion
186-
)
180+
const resCopy = {
181+
addressIdStr: '',
182+
addressStr: '',
183+
...selectedRegion,
184+
}
187185
const res: CloseRes = {
188186
data: {},
189187
type: privateType,
@@ -226,17 +224,15 @@ export const Address: FunctionComponent<
226224
return (
227225
<div className={b('header')}>
228226
<div className="arrow-back" onClick={onSwitchModule}>
229-
{privateType === 'custom' && backBtnIcon && (
230-
<Icon name={backBtnIcon} color="#cccccc"></Icon>
231-
)}
227+
{privateType === 'custom' && backBtnIcon && <Icon name={backBtnIcon} color="#cccccc" />}
232228
</div>
233229

234230
<div className={b('header__title')}>
235231
{privateType === 'custom' ? customAddressTitle : existAddressTitle}
236232
</div>
237233

238234
<div onClick={() => handClose('cross')}>
239-
{closeBtnIcon && <Icon name={closeBtnIcon} color="#cccccc" size="18px"></Icon>}
235+
{closeBtnIcon && <Icon name={closeBtnIcon} color="#cccccc" size="18px" />}
240236
</div>
241237
</div>
242238
)
@@ -266,7 +262,7 @@ export const Address: FunctionComponent<
266262
closeFun()
267263
}}
268264
>
269-
<div className={`${b()} ${className ? className : ''}`} style={{ ...style }} {...rest}>
265+
<div className={`${b()} ${className || ''}`} style={{ ...style }} {...rest}>
270266
{headerRender()}
271267
{(privateType === 'custom' || privateType === 'custom2') && (
272268
<CustomRender
@@ -280,7 +276,7 @@ export const Address: FunctionComponent<
280276
nextAreaList && nextAreaList(cal)
281277
}}
282278
onClose={handClose}
283-
></CustomRender>
279+
/>
284280
)}
285281
{privateType === 'exist' && (
286282
<ExistRender
@@ -292,7 +288,7 @@ export const Address: FunctionComponent<
292288
customAndExistTitle={customAndExistTitle}
293289
onSelected={selectedExist}
294290
onSwitchModule={onSwitchModule}
295-
></ExistRender>
291+
/>
296292
)}
297293
</div>
298294
</Popup>

0 commit comments

Comments
 (0)