diff --git a/package.json b/package.json index c1baa4c9406774f39cb0f308ebd53902b99f263d..32f8a83a3ac6417849f7b08aef599225b5db6dbe 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,8 @@ "lint:fix": "eslint --fix --ext .js src mock tests && npm run lint:style", "lint-staged": "lint-staged", "lint-staged:js": "eslint --ext .js", + "tslint": "npm run tslint:fix", + "tslint:fix": "tslint --fix 'src/**/*.ts*'", "test": "umi test", "test:component": "umi test ./src/components", "test:all": "node ./tests/run-tests.js", @@ -71,6 +73,9 @@ "eslint-plugin-jsx-a11y": "^6.1.2", "eslint-plugin-markdown": "^1.0.0-beta.6", "eslint-plugin-react": "^7.11.1", + "tslint": "^5.10.0", + "tslint-config-prettier": "^1.10.0", + "tslint-react": "^3.6.0", "gh-pages": "^2.0.1", "husky": "^1.1.2", "lint-staged": "^7.2.0", diff --git a/src/components/Authorized/AuthorizedRoute.d.ts b/src/components/Authorized/AuthorizedRoute.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..912b283ab81ecddb89f05d4228095c5b05a64803 --- /dev/null +++ b/src/components/Authorized/AuthorizedRoute.d.ts @@ -0,0 +1,13 @@ +import * as React from 'react'; +import { RouteProps } from 'react-router'; + +type authorityFN = (currentAuthority?: string) => boolean; + +type authority = string | string[] | authorityFN | Promise; + +export interface IAuthorizedRouteProps extends RouteProps { + authority: authority; +} +export { authority }; + +export class AuthorizedRoute extends React.Component {} diff --git a/src/components/Authorized/index.d.ts b/src/components/Authorized/index.d.ts index ad42676d5bf5522d03dd4192c04164b0254ba0cd..b3e2f56c6c3784daa62e908286566c954db1675f 100644 --- a/src/components/Authorized/index.d.ts +++ b/src/components/Authorized/index.d.ts @@ -1,41 +1,30 @@ import * as React from 'react'; -import { RouteProps } from 'react-router'; - -type authorityFN = (currentAuthority?: string) => boolean; - -type authority = string | Array | authorityFN | Promise; - +import AuthorizedRoute, { authority } from './AuthorizedRoute'; export type IReactComponent

= | React.StatelessComponent

| React.ComponentClass

| React.ClassicComponentClass

; -interface Secured { - (authority: authority, error?: React.ReactNode): (target: T) => T; -} - -export interface AuthorizedRouteProps extends RouteProps { - authority: authority; -} -export class AuthorizedRoute extends React.Component {} +type Secured = ( + authority: authority, + error?: React.ReactNode +) => (target: T) => T; -interface check { - ( - authority: authority, - target: T, - Exception: S - ): T | S; -} +type check = ( + authority: authority, + target: T, + Exception: S +) => T | S; -export interface AuthorizedProps { +export interface IAuthorizedProps { authority: authority; noMatch?: React.ReactNode; } -export class Authorized extends React.Component { - static Secured: Secured; - static AuthorizedRoute: typeof AuthorizedRoute; - static check: check; +export class Authorized extends React.Component { + public static Secured: Secured; + public static AuthorizedRoute: typeof AuthorizedRoute; + public static check: check; } declare function renderAuthorize(currentAuthority: string): typeof Authorized; diff --git a/src/components/Charts/ChartCard/index.d.ts b/src/components/Charts/ChartCard/index.d.ts index ae25ec64c9d238b9edddaa1e0b6486069b94c50b..0437c0c857d7f1c63c506c5eb238583a251714d0 100644 --- a/src/components/Charts/ChartCard/index.d.ts +++ b/src/components/Charts/ChartCard/index.d.ts @@ -1,5 +1,5 @@ -import * as React from 'react'; import { CardProps } from 'antd/lib/card'; +import * as React from 'react'; export interface IChartCardProps extends CardProps { title: React.ReactNode; diff --git a/src/components/Login/LoginItem.d.ts b/src/components/Login/LoginItem.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..30a7a2d6a483e2a8224fd315498f35ce72958f63 --- /dev/null +++ b/src/components/Login/LoginItem.d.ts @@ -0,0 +1,11 @@ +import * as React from 'react'; +export interface ILoginItemProps { + name?: string; + rules?: any[]; + style?: React.CSSProperties; + onGetCaptcha?: () => void; + placeholder?: string; + buttonText?: React.ReactNode; +} + +export class LoginItem extends React.Component {} diff --git a/src/components/Login/Tab.d.ts b/src/components/Login/Tab.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..db651f7b40c6194d1cd0cb8430736fc4d369e34d --- /dev/null +++ b/src/components/Login/Tab.d.ts @@ -0,0 +1,7 @@ +import * as React from 'react'; + +export interface ILoginTabProps { + key?: string; + tab?: React.ReactNode; +} +export default class LoginTab extends React.Component {} diff --git a/src/components/Login/index.d.ts b/src/components/Login/index.d.ts index 9c072867710ec785c44a525e260e3d844c5f1371..6a6f67fe6b1f250bd3708d0120bea1a22026b81b 100644 --- a/src/components/Login/index.d.ts +++ b/src/components/Login/index.d.ts @@ -1,34 +1,20 @@ -import * as React from 'react'; import Button from 'antd/lib/button'; -export interface LoginProps { +import * as React from 'react'; +import LoginItem from './LoginItem'; +import LoginTab from './LoginTab'; + +export interface ILoginProps { defaultActiveKey?: string; onTabChange?: (key: string) => void; style?: React.CSSProperties; onSubmit?: (error: any, values: any) => void; } -export interface TabProps { - key?: string; - tab?: React.ReactNode; -} -export class Tab extends React.Component {} - -export interface LoginItemProps { - name?: string; - rules?: any[]; - style?: React.CSSProperties; - onGetCaptcha?: () => void; - placeholder?: string; - buttonText?: React.ReactNode; -} - -export class LoginItem extends React.Component {} - -export default class Login extends React.Component { - static Tab: typeof Tab; - static UserName: typeof LoginItem; - static Password: typeof LoginItem; - static Mobile: typeof LoginItem; - static Captcha: typeof LoginItem; - static Submit: typeof Button; +export default class Login extends React.Component { + public static Tab: typeof LoginTab; + public static UserName: typeof LoginItem; + public static Password: typeof LoginItem; + public static Mobile: typeof LoginItem; + public static Captcha: typeof LoginItem; + public static Submit: typeof Button; } diff --git a/src/components/PageHeader/breadcrumb.d.ts b/src/components/PageHeader/breadcrumb.d.ts index ce6e62442abd6cd190684e7fa53d9fbb8d8e1f4b..cfed402113aaffc2000b99712c13add232fd0b16 100644 --- a/src/components/PageHeader/breadcrumb.d.ts +++ b/src/components/PageHeader/breadcrumb.d.ts @@ -1,6 +1,6 @@ import * as React from 'react'; -import { IPageHeaderProps } from './index' +import { IPageHeaderProps } from './index'; export default class BreadcrumbView extends React.Component {} -export function getBreadcrumb(breadcrumbNameMap: Object, url: string): Object; +export function getBreadcrumb(breadcrumbNameMap: object, url: string): object; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..5be3083113eb212c29bc33d59b6e73932bbcb0f9 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,35 @@ +{ + "compilerOptions": { + "outDir": "build/dist", + "module": "esnext", + "target": "es2016", + "lib": ["es6", "dom"], + "sourceMap": true, + "baseUrl": ".", + "jsx": "react", + "allowSyntheticDefaultImports": true, + "moduleResolution": "node", + "rootDirs": ["/src", "/test", "/mock","./typings"], + "forceConsistentCasingInFileNames": true, + "noImplicitReturns": true, + "suppressImplicitAnyIndexErrors": true, + "noUnusedLocals": true, + "allowJs": true, + "experimentalDecorators": true, + "paths": { + "@/*": ["./src/*"] + } + }, + "include": ["./src"], + "exclude": [ + "node_modules", + "build", + "scripts", + "acceptance-tests", + "webpack", + "jest", + "src/setupTests.ts", + "tslint:latest", + "tslint-config-prettier" + ] +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000000000000000000000000000000000000..125e217e4b72c9deb47a954ea58cc5b252d9ca5a --- /dev/null +++ b/tslint.json @@ -0,0 +1,11 @@ +{ + "extends": ["tslint:latest", "tslint-react", "tslint-config-prettier"], + "rules": { + "no-var-requires": false, + "no-submodule-imports": false, + "object-literal-sort-keys": false, + "jsx-no-lambda": false, + "no-implicit-dependencies": false, + "no-console": false + } +}