Skip to content

Commit

Permalink
chore: tslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Deturium committed Feb 27, 2019
1 parent 9363517 commit a399cb5
Show file tree
Hide file tree
Showing 24 changed files with 157 additions and 211 deletions.
3 changes: 0 additions & 3 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Browsers that we support

ios 10.3
Android > 67

last 2 version
> 1% in CN

Expand Down
4 changes: 3 additions & 1 deletion config/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ module.exports = {
// workbox: https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin
new WorkboxPlugin.GenerateSW({
swDest: "service-worker.js",
clientsClaim: true,
importWorkboxFrom: 'local',
skipWaiting: true,
clientsClaim: true,
navigateFallback: '/',
}),
],
}
270 changes: 130 additions & 140 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
"@material-ui/icons": "^3.0.2",
"@material-ui/styles": "^3.0.0-alpha.10",
"@reach/router": "^1.2.1",
"@sentry/browser": "^4.6.3",
"aplayer": "^1.10.1",
"copy-to-clipboard": "^3.0.8",
"dayjs": "^1.8.7",
"dayjs": "^1.8.8",
"dplayer": "^1.25.0",
"lodash-es": "^4.17.11",
"react": "16.8.3",
Expand All @@ -37,17 +36,17 @@
"url-parse": "^1.4.4"
},
"devDependencies": {
"@babel/core": "^7.3.3",
"@babel/plugin-proposal-class-properties": "^7.3.3",
"@babel/core": "^7.3.4",
"@babel/plugin-proposal-class-properties": "^7.3.4",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.3.1",
"@babel/plugin-transform-runtime": "^7.3.4",
"@babel/preset-env": "^7.3.4",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@types/lodash-es": "^4.17.2",
"@types/node": "^11.9.5",
"@types/reach__router": "^1.2.3",
"@types/react": "^16.8.4",
"@types/react": "^16.8.5",
"@types/react-cropper": "^0.10.4",
"@types/react-dom": "^16.8.2",
"@types/styled-components": "^4.1.10",
Expand All @@ -66,7 +65,7 @@
"prettier": "^1.16.4",
"prettier-tslint": "^0.4.2",
"style-loader": "^0.23.1",
"terser-webpack-plugin": "^1.2.2",
"terser-webpack-plugin": "^1.2.3",
"tslint": "^5.13.0",
"tslint-config-airbnb": "^5.11.1",
"tslint-react": "^3.6.0",
Expand All @@ -75,7 +74,7 @@
"webpack": "^4.29.5",
"webpack-bundle-analyzer": "^3.0.4",
"webpack-cli": "^3.2.3",
"webpack-dev-server": "^3.2.0",
"webpack-dev-server": "^3.2.1",
"webpack-merge": "^4.2.1",
"workbox-webpack-plugin": "^3.6.3"
},
Expand Down
1 change: 0 additions & 1 deletion src/UBB/handlerHub/specificTagHandlers/audio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const Audio: React.FC<Props> = ({ src }) => {
const divRef = useRef<HTMLDivElement>(null)

useEffect(() => {
// tslint:disable-next-line
let aplayer: any = null
let unsubscribe: HistoryUnsubscribe | null

Expand Down
1 change: 0 additions & 1 deletion src/UBB/handlerHub/specificTagHandlers/video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const Video: React.FC<Props> = ({ src }) => {
const divRef = useRef<HTMLDivElement>(null)

useEffect(() => {
// tslint:disable-next-line
let dplayer: any = null
let unsubscribe: HistoryUnsubscribe | null

Expand Down
1 change: 0 additions & 1 deletion src/components/DrawerMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ interface ItemProps {
/**
* 图标
*/
// tslint:disable-next-line:no-any
icon: React.ReactElement<any>
/**
* 文字
Expand Down
1 change: 0 additions & 1 deletion src/components/InfiniteList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ interface Props {
/**
* 列表底部 loading 出现的回调
*/
// tslint:disable-next-line
callback: Function
/**
* 是否翻转列表(且 Loading 将出现在上面)
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useContainer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
import { useState, useEffect } from 'react'

type Listener = () => void
Expand Down Expand Up @@ -40,6 +39,7 @@ export class Container<State extends object = {}> {
// this will prevent broadcast
if (nextState == null) {
if (callback) callback()

return Promise.resolve()
}

Expand Down
1 change: 0 additions & 1 deletion src/hooks/useFetcher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
import { useState, useEffect } from 'react'
import { Try } from '@/utils/fp/Try'
import { FetchError } from '@/utils/fetch'
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useInfList.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
import { useState, useEffect } from 'react'

import { Try } from '@/utils/fp/Try'
Expand Down
45 changes: 8 additions & 37 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,17 @@ dayjs.extend(relativeTime)
import './style.css'
import 'typeface-roboto'

// Sentry
// NOTE: 它的模块有点问题,不要用默认导入
import * as Sentry from '@sentry/browser'
import version from './version'

class ErrorBoundary extends React.Component {
// tslint:disable-next-line
componentDidCatch(err: any, info: any) {
Sentry.captureException(err)
}

render() {
return this.props.children
}
}

ReactDOM.render(
<ErrorBoundary>
<App />
</ErrorBoundary>,
document.getElementById('root')
)

if (process.env.NODE_ENV === 'production') {
Sentry.init({
dsn: 'https://[email protected]/1356614',
release: version,
})
}
ReactDOM.render(<App />, document.getElementById('root'))

// service worker
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker
.register('/service-worker.js')
.then(registration => {
// console.log('SW registered: ', registration)
})
.catch(registrationError => {
// console.log('SW registration failed: ', registrationError)
})
navigator.serviceWorker.register('/service-worker.js')
// .then(registration => {
// // console.log('SW registered: ', registration)
// })
// .catch(registrationError => {
// // console.log('SW registration failed: ', registrationError)
// })
})
}
1 change: 0 additions & 1 deletion src/pages/Editor/Editor/ToolBox/StickerBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ interface Props {
type StickerType = 'ac' | 'tb' | 'ms' | 'em'

// TODO: refactor with UBB
// tslint:disable-next-line
function getStickerReactNode(type: StickerType, handleFunc: Function) {
const stickerArr = []

Expand Down
1 change: 0 additions & 1 deletion src/pages/Editor/useInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export default function useInit(props: Props): Init | null {
const { floor, userName, time, topicId, content } = postInfo
const formatTime = dayjs(time).format('YYYY-MM-DD HH:mm')
setInitContent(
// tslint:disable-next-line
`[quote][b]以下是引用${floor}楼:用户${userName}${formatTime}的发言:[color=blue][url=/topic/${topicId}#${floor}]>>查看原帖<<[/url][/color][/b]\n${content}[/quote]\n`
)
setOk(true)
Expand Down
1 change: 0 additions & 1 deletion src/pages/Help/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import SiteInfo from './SiteInfo'
import DevTeam from './DevTeam'

interface ItemProps {
// tslint:disable-next-line:no-any
icon: React.ReactElement<any>
text: string
url: string
Expand Down
1 change: 0 additions & 1 deletion src/pages/LogIn/LogInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ const LogIn: React.FC = () => {
loading: false,
logInFail: true,
})
// tslint:disable-next-line:align
}, 2000)

loginHandler(err)
Expand Down
1 change: 0 additions & 1 deletion src/pages/UserCenter/Edit/LocalAvatarBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ interface Props {

export default ({ imgSrc, handleAvatarSubmit, handleClose, fileType }: Props) => {
const [isLoading, setIsLoading] = useState(false)
// tslint:disable
const cropRef = useRef<any>(null)

const submitHandle = () => {
Expand Down
1 change: 0 additions & 1 deletion src/router/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import Error from '@/pages/Error'
export const Route: React.FC<
RouteComponentProps & {
// @types/react 里 createElement 签名很混乱
// tslint:disable-next-line:no-any
component: any
// component: React.FC<any>
}
Expand Down
1 change: 0 additions & 1 deletion src/router/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @param func 待绑定函数
* @param href 路由
*/
// tslint:disable-next-line
export function bindURL(func: Function, href: string) {
return () => {
if (window.location.href === href) {
Expand Down
2 changes: 1 addition & 1 deletion src/services/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function getTopTopics(id: string) {
params: {
boardid: id,
},
})
}).then(res => Promise.resolve(res.map(topics => topics.reverse())))
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/utils/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
import { Try, Success, Failure } from './fp/Try'
import { getAccessToken } from './logIn'

Expand Down Expand Up @@ -42,6 +41,7 @@ async function cc98Fetch<T>(url: string, init: RequestInit): Promise<Try<T, Fetc
try {
data = await response.clone().json()
} catch {
// tslint:disable-next-line
console.warn(`FIX: ${requestURL} response.json() fail.`)
data = await response.text()
}
Expand Down
5 changes: 2 additions & 3 deletions src/utils/fp/Try.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
/**
* Functor Try
*/
Expand Down Expand Up @@ -76,9 +75,9 @@ export class Try<S, F> {
map<U>(func: (x: S) => U) {
if (this._value.constructor === Success) {
return Try.of<U, F>((this._value as Success<S>).map(func))
} else {
return Try.of<U, F>((this._value as Failure<F>).map(id => id))
}

return Try.of<U, F>((this._value as Failure<F>).map(id => id))
}

// some methods not fp but useful
Expand Down
1 change: 0 additions & 1 deletion src/utils/logIn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
import { Try, Success, Failure } from './fp/Try'
import { FetchError, encodeParams } from './fetch'
import { getLocalStorage, setLocalStorage, removeLocalStorage } from './storage'
Expand Down
4 changes: 3 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"align": [true, "elements", "members", "parameters", "statements"],
"array-type": [true, "array"],
"arrow-return-shorthand": [true, "multiline"],
"ban-types": false,
"eofline": true,
"function-name": false,
"import-name": false,
Expand All @@ -23,7 +24,7 @@
"jsx-curly-spacing": false,
"jsx-no-lambda": false,
"jsx-no-multiline-js": false,
"max-classes-per-file": [true, 1],
"max-classes-per-file": false,
"max-file-line-count": [true, 500],
"max-line-length": false,
"member-access": false,
Expand All @@ -40,6 +41,7 @@
"object-literal-sort-keys": false,
"object-shorthand-properties-first": false,
"ordered-imports": false,
"prefer-template": false,
"semicolon": false,
"ter-indent": false,
"ter-arrow-parens": [true, "as-needed"],
Expand Down

0 comments on commit a399cb5

Please sign in to comment.