Skip to content

Commit 11c5c94

Browse files
committed
fix: typescript
1 parent e9b9c14 commit 11c5c94

Some content is hidden

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

48 files changed

+142
-109
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ dist/
22
demo/dist
33
webpack/
44
jest.config.js
5-
.eslintrc.js
5+
.eslintrc.js
6+
tailwind.config.js

.eslintrc.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
module.exports = {
22
root: true,
33
parser: '@typescript-eslint/parser',
4+
"parserOptions": {
5+
"ecmaVersion": 2018,
6+
"sourceType": "module"
7+
},
48
plugins: [
59
'@typescript-eslint',
610
],
@@ -9,4 +13,21 @@ module.exports = {
913
"plugin:react/recommended",
1014
'plugin:@typescript-eslint/recommended',
1115
],
16+
settings: {
17+
react: {
18+
"version": "detect"
19+
}
20+
},
21+
rules: {
22+
"@typescript-eslint/explicit-module-boundary-types": "off",
23+
"@typescript-eslint/no-explicit-any": "off"
24+
},
25+
"overrides": [
26+
{
27+
"files": ["*.js", "*.ts"],
28+
"rules": {
29+
"@typescript-eslint/explicit-module-boundary-types": "warn"
30+
}
31+
}
32+
]
1233
};

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dev:
1313
.PHONY: lint lint-fix dev
1414

1515
# Test
16-
test:
16+
test: lint-fix
1717
@echo "Running test..."
1818
@npx jest
1919
.PHONY: test

demo/src/App/AvatarEditor/SectionWrapper/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import React from 'react'
22

33
import './index.scss'
44

5-
export default function (props) {
5+
export default function sectionWrapper(props: {
6+
className?: string,
7+
children: JSX.Element,
8+
switchConfig: () => void,
9+
tip: string
10+
}): HTMLElement {
611
const { className = "", children, switchConfig, tip } = props
712
return (
813
<div

demo/src/App/AvatarList/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import React, { Component } from 'react'
22
import PropTypes from 'prop-types'
33
import { nanoid } from 'nanoid'
44

5+
import type { AvatarFullConfig } from 'react-nice-avatar/types'
6+
import type { AvatarListItem } from './types'
7+
58
import ReactNiceAvatar, { genConfig } from 'react-nice-avatar/index'
69

710
import "./index.scss"
@@ -11,7 +14,7 @@ export default class AvatarList extends Component {
1114
selectConfig: PropTypes.func.isRequired
1215
}
1316

14-
constructor (props) {
17+
constructor (props: { selectConfig: (item: AvatarFullConfig) => void }) {
1518
super(props)
1619
this.displayCount = 10
1720
this.state = {
@@ -26,10 +29,10 @@ export default class AvatarList extends Component {
2629
this.fetchListWidth()
2730
}
2831

29-
genConfigList (count: number) {
32+
genConfigList (count: number): AvatarListItem {
3033
return new Array(count)
3134
.fill(null)
32-
.map((_, idx) => ({
35+
.map(() => ({
3336
...genConfig({ isGradient: Boolean(Math.round(Math.random())) }),
3437
id: 'n_' + nanoid()
3538
}))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { AvatarFullConfig } from 'react-nice-avatar/types'
2+
3+
export interface AvatarListItem extends AvatarFullConfig {
4+
id: string
5+
}

demo/src/App/Footer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22

3-
export default function () {
3+
export default function footer(): HTMLElement {
44
return (
55
<footer className="flex items-center justify-center text-gray-400 text-sm pb-5">
66
<a

demo/src/App/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import React, { Component } from "react";
2-
import classnames from "classnames";
32
import { hot } from "react-hot-loader";
43
import domtoimage from "dom-to-image";
54
import { saveAs } from "file-saver";
65

7-
import { AvatarFullConfig } from '../../../src/types'
8-
96
import ReactNiceAvatar, { genConfig } from "react-nice-avatar/index";
107

118
import AvatarEditor from './AvatarEditor/index'
@@ -14,7 +11,7 @@ import Footer from './Footer/index'
1411

1512
require('./index.scss')
1613

17-
class App extends Component<{}, {}> {
14+
class App extends Component {
1815
constructor(props) {
1916
super(props)
2017
this.state = {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"@types/jest": "^26.0.24",
3333
"@types/react": "^17.0.14",
3434
"@types/react-dom": "^17.0.9",
35-
"@typescript-eslint/eslint-plugin": "^4.29.3",
36-
"@typescript-eslint/parser": "^4.29.3",
35+
"@typescript-eslint/eslint-plugin": "^4.31.2",
36+
"@typescript-eslint/parser": "^4.31.2",
3737
"autoprefixer": "^10.3.1",
3838
"babel-loader": "^8.2.2",
3939
"classnames": "^2.3.1",

src/ear/big.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22

3-
export default function (props: { color: string }) {
3+
export default function earBig(props: { color: string }): SVGElement {
44
const { color } = props;
55
return (
66
<svg

0 commit comments

Comments
 (0)