Skip to content

Commit 50644d5

Browse files
committed
build: update eslint config and fix eslint error
1 parent ecbd0fc commit 50644d5

File tree

5 files changed

+250
-95
lines changed

5 files changed

+250
-95
lines changed

.eslintrc.json

Lines changed: 86 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,89 @@
11
{
2-
"parser": "@typescript-eslint/parser",
3-
"parserOptions": {
4-
"ecmaVersion": 8,
5-
"sourceType": "module",
6-
"project": "./tsconfig.json"
7-
},
8-
"extends":[
9-
"standard",
10-
"plugin:react/recommended",
11-
"plugin:@typescript-eslint/recommended"
2+
"parser": "@typescript-eslint/parser",
3+
"parserOptions": {
4+
"ecmaVersion": 8,
5+
"sourceType": "module",
6+
"project": "./tsconfig.json"
7+
},
8+
"extends": [
9+
"standard",
10+
"plugin:react/recommended",
11+
"plugin:@typescript-eslint/recommended",
12+
"eslint-config-prettier",
13+
"eslint-config-prettier/react",
14+
"eslint-config-prettier/@typescript-eslint"
15+
],
16+
"plugins": ["import", "react", "jsx-a11y", "@typescript-eslint", "unicorn"],
17+
"settings": {
18+
"react": {
19+
"pragma": "React",
20+
"version": "16.6.3"
21+
}
22+
},
23+
"env": {
24+
"browser": true,
25+
"node": true,
26+
"es6": true
27+
},
28+
"globals": {
29+
"expect": true,
30+
"test": true,
31+
"describe": true,
32+
"beforeEach": true,
33+
"afterEach": true,
34+
"jest": true,
35+
"it": true
36+
},
37+
"rules": {
38+
"semi": 0,
39+
"strict": 0,
40+
"indent": [2, 4, { "SwitchCase": 1 }],
41+
"arrow-body-style": 0,
42+
"no-return-assign": 0,
43+
"no-useless-constructor": 0,
44+
"eqeqeq": 0,
45+
"no-console": 0,
46+
"no-param-reassign": 0,
47+
"@typescript-eslint/no-unused-vars": [
48+
"error",
49+
{ "vars": "all", "args": "none", "ignoreRestSiblings": false }
1250
],
13-
"plugins": [
14-
"import",
15-
"react",
16-
"jsx-a11y"
51+
"import/no-extraneous-dependencies": [
52+
"error",
53+
{
54+
"devDependencies": true,
55+
"optionalDependencies": false,
56+
"peerDependencies": false
57+
}
1758
],
18-
"settings": {
19-
"react": {
20-
"pragma": "React",
21-
"version": "16.6.3"
22-
}
23-
},
24-
"env": {
25-
"browser": true,
26-
"node": true,
27-
"es6": true
28-
},
29-
"globals": {
30-
"expect": true,
31-
"test": true,
32-
"describe": true,
33-
"beforeEach": true,
34-
"afterEach": true,
35-
"jest": true,
36-
"it": true
37-
},
38-
"rules": {
39-
"semi": 0,
40-
"strict": 0,
41-
"indent": [2, 4, { "SwitchCase": 1 }],
42-
"arrow-body-style": 0,
43-
"no-return-assign": 0,
44-
"no-useless-constructor": 0,
45-
"eqeqeq": 0,
46-
"no-console": 0,
47-
"no-param-reassign": 0,
48-
"@typescript-eslint/no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": false }],
49-
"import/no-extraneous-dependencies": ["error", {"devDependencies": true, "optionalDependencies": false, "peerDependencies": false}],
50-
"react/display-name":[0],
51-
"react/sort-comp": 0,
52-
"react/jsx-uses-react": 1,
53-
"react/prefer-stateless-function": 0,
54-
"react/jsx-closing-bracket-location": 0,
55-
"jsx-a11y/no-static-element-interactions": 0,
56-
"react/prop-types": [0, {"ignore": ["children"]}],
57-
"react/jsx-filename-extension": [1, { "extensions": [".tsx", ".js", ".jsx"] }],
58-
"react/react-in-jsx-scope": 0,
59-
"@typescript-eslint/no-explicit-any": 0,
60-
"@typescript-eslint/explicit-member-accessibility": 0,
61-
"@typescript-eslint/explicit-function-return-type": 0,
62-
"@typescript-eslint/no-use-before-define": 0,
63-
"@typescript-eslint/no-var-requires": 0,
64-
"@typescript-eslint/interface-name-prefix":0,
65-
"@typescript-eslint/no-empty-interface":0,
66-
"@typescript-eslint/no-this-alias": [
67-
"error",
68-
{
69-
"allowDestructuring": true, // Allow `const { props, state } = this`; false by default
70-
"allowedNames": ["that"] // Allow `const self = this`; `[]` by default
71-
}
72-
],
73-
"prefer-const": 0,
74-
"no-var": 0,
75-
"prefer-rest-params": 0
76-
}
77-
}
59+
"react/display-name": [0],
60+
"react/sort-comp": 0,
61+
"react/jsx-uses-react": 1,
62+
"react/prefer-stateless-function": 0,
63+
"react/jsx-closing-bracket-location": 0,
64+
"jsx-a11y/no-static-element-interactions": 0,
65+
"react/prop-types": [0, { "ignore": ["children"] }],
66+
"react/jsx-filename-extension": [
67+
1,
68+
{ "extensions": [".tsx", ".js", ".jsx"] }
69+
],
70+
"react/react-in-jsx-scope": 0,
71+
"@typescript-eslint/no-explicit-any": 0,
72+
"@typescript-eslint/explicit-member-accessibility": 0,
73+
"@typescript-eslint/explicit-function-return-type": 0,
74+
"@typescript-eslint/no-use-before-define": 0,
75+
"@typescript-eslint/no-var-requires": 0,
76+
"@typescript-eslint/interface-name-prefix": 0,
77+
"@typescript-eslint/no-empty-interface": 0,
78+
"@typescript-eslint/no-this-alias": [
79+
"error",
80+
{
81+
"allowDestructuring": true, // Allow `const { props, state } = this`; false by default
82+
"allowedNames": ["that"] // Allow `const self = this`; `[]` by default
83+
}
84+
],
85+
"prefer-const": 0,
86+
"no-var": 0,
87+
"prefer-rest-params": 0
88+
}
89+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@
9999
"enzyme": "^3.11.0",
100100
"enzyme-adapter-react-16": "^1.15.2",
101101
"eslint": "^5.16.0",
102+
"eslint-config-prettier": "^6.11.0",
102103
"eslint-config-standard": "^12.0.0",
104+
"eslint-formatter-pretty": "^4.0.0",
103105
"eslint-loader": "^1.7.1",
104106
"eslint-plugin-import": "^2.14.0",
105107
"eslint-plugin-jest": "^22.14.0",
@@ -109,6 +111,7 @@
109111
"eslint-plugin-react": "^7.11.1",
110112
"eslint-plugin-sort-requires": "^2.1.0",
111113
"eslint-plugin-standard": "^4.0.0",
114+
"eslint-plugin-unicorn": "^21.0.0",
112115
"file-loader": "^6.0.0",
113116
"husky": "^1.2.0",
114117
"increase-memory-limit": "^1.0.7",

src/components/slidePane/__tests__/index.test.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ describe('test SlidePane ', () => {
1212
style: { color: 'red', background: '#FF7C12' }
1313
}
1414
test('should render correct', () => {
15-
const { container, getByTestId } = render(<SlidePane
16-
children={expectValues.children}
17-
visible={expectValues.visible}
18-
style={expectValues.style}
19-
/>)
15+
const { container, getByTestId } = render(
16+
<SlidePane
17+
visible={expectValues.visible}
18+
style={expectValues.style}
19+
>
20+
{expectValues.children}
21+
</SlidePane>)
2022
expect(container.firstChild).toHaveStyle(expectValues.style);
2123
const oDiv = getByTestId('slidepane_container');
2224
expect(oDiv).not.toBeNull();
@@ -25,10 +27,10 @@ describe('test SlidePane ', () => {
2527
expect(container).toMatchSnapshot();
2628
})
2729
test('should be invisible', () => {
28-
const { getByTestId } = render(<SlidePane
29-
children={expectValues.children}
30-
visible={false}
31-
/>)
30+
const { getByTestId } = render(
31+
<SlidePane visible={false} >
32+
{expectValues.children}
33+
</SlidePane>)
3234
const oDiv = getByTestId('slidepane_container');
3335
expect(oDiv).not.toBeVisible();
3436
})

src/components/slidePane/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ export interface SlidePaneProps {
1616
}
1717

1818
class SlidePane extends React.Component<SlidePaneProps, any> {
19-
constructor (props: any) {
19+
constructor(props: any) {
2020
super(props);
2121
}
2222

23-
render () {
23+
render() {
2424
const { children, visible, style, className, onClose } = this.props
2525
const slidePrefixCls = 'dtc-slide-pane';
2626
let myStyle: any = {
@@ -34,13 +34,13 @@ class SlidePane extends React.Component<SlidePaneProps, any> {
3434
if (style) myStyle = assign(myStyle, style);
3535

3636
return (
37-
<div className={ classes } style={myStyle} >
38-
<div className={`${slidePrefixCls}-conent`}
39-
data-testid="slidepane_container"
40-
style={{ display: visible ? 'block' : 'none', height: '100%' }}>
41-
{ children }
37+
<div className={classes} style={myStyle} >
38+
<div className={`${slidePrefixCls}-conent`}
39+
data-testid="slidepane_container"
40+
style={{ display: visible ? 'block' : 'none', height: '100%' }}>
41+
{children}
4242
</div>
43-
<span className={`${slidePrefixCls}-toggle`} data-testid="slidepane_action" onClick={onClose} {...{ onClick: onClose }}>
43+
<span className={`${slidePrefixCls}-toggle`} data-testid="slidepane_action" onClick={onClose} {...{ onClick: onClose }}>
4444
<Icon type="double-right" />
4545
</span>
4646
</div>

0 commit comments

Comments
 (0)