Commit 84b5e90c authored by duanledexianxianxian's avatar duanledexianxianxian

fix eslint prettier config

parents 804969cf 49e1da77
const fabric = require('@umijs/fabric');
const fabric = require('@duanledexian/umi-config');
module.exports = {
...fabric.default,
rules: {
...fabric.default.rules,
'import/no-extraneous-dependencies': [
2,
{
optionalDependencies: true,
devDependencies: ['**/tests/**.js', '/mock/**/**.js', '**/**.test.js', '**/**._mock.js'],
},
],
},
globals: {
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true,
......
puppeteer_download_host = https://npm.taobao.org/mirrors
\ No newline at end of file
const fabric = require('@umijs/fabric');
const fabric = require('@duanledexian/umi-config');
module.exports = {
...fabric.prettier,
......
const fabric = require('@umijs/fabric');
const fabric = require('@duanledexian/umi-config');
module.exports = {
...fabric.stylelint,
......
import { IConfig, IPlugin } from 'umi-types';
import defaultSettings from './defaultSettings'; // https://umijs.org/config/
import os from 'os';
import slash from 'slash2';
import webpackPlugin from './plugin.config';
const { pwa, primaryColor } = defaultSettings; // preview.pro.ant.design only do not use in your production ;
// preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION } = process.env;
const isAntDesignProPreview = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site';
const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, TEST, NODE_ENV } = process.env;
const plugins: IPlugin[] = [
[
'umi-plugin-react',
......@@ -37,15 +37,10 @@ const plugins: IPlugin[] = [
},
}
: false,
...(!TEST && os.platform() === 'darwin'
? {
dll: {
include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
exclude: ['@babel/runtime', 'netlify-lambda'],
},
hardSource: false,
}
: {}),
dll: {
include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
exclude: ['@babel/runtime', 'netlify-lambda'],
},
},
],
[
......@@ -57,10 +52,10 @@ const plugins: IPlugin[] = [
autoAddMenu: true,
},
],
]; // 针对 preview.pro.ant.design 的 GA 统计代码
// preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
];
if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
// 针对 preview.pro.ant.design 的 GA 统计代码
if (isAntDesignProPreview) {
plugins.push([
'umi-plugin-ga',
{
......@@ -69,34 +64,17 @@ if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
]);
}
const uglifyJSOptions =
NODE_ENV === 'production'
? {
uglifyOptions: {
// remove console.* except console.error
compress: {
drop_console: true,
pure_funcs: ['console.error'],
},
},
}
: {};
export default {
// add for transfer to umi
plugins,
define: {
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION || '', // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
},
block: {
defaultGitUrl: 'https://github.com/ant-design/pro-blocks',
},
treeShaking: true,
hash: true,
targets: {
ie: 11,
},
devtool: ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION ? 'source-map' : false,
// 路由配置
devtool: isAntDesignProPreview ? 'source-map' : false,
// umi routes: https://umijs.org/zh/guide/router.html
routes: [
{
path: '/',
......@@ -327,21 +305,23 @@ export default {
},
],
},
{
component: './404',
},
],
},
{
component: './404',
},
],
// Theme for antd
// https://ant.design/docs/react/customize-theme-cn
// Theme for antd: https://ant.design/docs/react/customize-theme-cn
theme: {
'primary-color': primaryColor,
},
// proxy: {
// '/server/api/': {
// target: 'https://preview.pro.ant.design/',
// changeOrigin: true,
// pathRewrite: { '^/server': '' },
// },
// },
define: {
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION || '', // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
},
ignoreMomentLocale: true,
lessLoaderOptions: {
javascriptEnabled: true,
......@@ -353,8 +333,8 @@ export default {
context: {
resourcePath: string;
},
localIdentName: string,
localName: string
_: string,
localName: string,
) => {
if (
context.resourcePath.includes('node_modules') ||
......@@ -381,6 +361,14 @@ export default {
manifest: {
basePath: '/',
},
uglifyJSOptions,
chainWebpack: webpackPlugin,
/*
proxy: {
'/server/api/': {
target: 'https://preview.pro.ant.design/',
changeOrigin: true,
pathRewrite: { '^/server': '' },
},
},
*/
} as IConfig;
......@@ -3,6 +3,6 @@ module.exports = {
preset: 'jest-puppeteer',
extraSetupFiles: ['./tests/setupTests.js'],
globals: {
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: false, // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: false,
},
};
......@@ -41,6 +41,9 @@ const findAllInstallRouter = router => {
const filterParentRouter = (router, layout) => {
return [...router]
.map(item => {
if (!item.path && item.component === '404') {
return item;
}
if (item.routes && (!router.component || layout)) {
return { ...item, routes: filterParentRouter(item.routes, false) };
}
......@@ -94,7 +97,7 @@ const installBlock = async () => {
console.log('install ' + chalk.green(item.name) + ' to: ' + chalk.yellow(item.path));
gitFiles = gitFiles.filter(file => file.path !== gitPath);
const skipModifyRouter = item.routes ? '--skip-modify-routes' : '';
const cmd = `umi block add https://github.com/ant-design/pro-blocks/tree/master/${gitPath} --path=${item.path} ${skipModifyRouter}`;
const cmd = `umi block add https://github.com/ant-design/pro-blocks/tree/master/${gitPath} --path=${item.path} ${skipModifyRouter}`;
try {
await execCmd(cmd);
console.log(`install ${chalk.hex('#1890ff')(item.name)} success`);
......
......@@ -33,7 +33,7 @@ const onBlockCopy = (label: string) => {
const BlockCodeView: React.SFC<{
url: string;
}> = ({ url }) => {
const blockUrl = `npx umi block add ${firstUpperCase(url)} --path=${url}`;
const blockUrl = `npx umi block add ${firstUpperCase(url)} --path=${url}`;
return (
<div className={styles['copy-block-view']}>
<Typography.Paragraph
......
......@@ -19,6 +19,7 @@ export interface NoticeIconTabProps {
emptyText?: string;
clearText?: string;
viewMoreText?: string;
list: NoticeIconData[];
onViewMore?: (e: any) => void;
}
const NoticeList: React.SFC<NoticeIconTabProps> = ({
......
......@@ -117,7 +117,7 @@ export default class NoticeIcon extends Component<NoticeIconProps> {
},
);
return (
<Spin spinning={loading} delay={0}>
<Spin spinning={loading} delay={300}>
<Tabs className={styles.tabs} onChange={this.onTabChange}>
{panes}
</Tabs>
......
......@@ -7,6 +7,7 @@ import { queryNotices } from '@/services/user';
export interface NoticeItem extends NoticeIconData {
id: string;
type: string;
status: string;
}
export interface GlobalModelState {
......
import React from 'react';
import { Button } from 'antd';
import router from 'umi/router';
// 这里应该使用 antd 的 404 result 组件,
// 但是还没发布,先来个简单的。
const NoFoundPage: React.FC<{}> = () => (
<div
style={{
height: '100vh',
padding: 80,
textAlign: 'center',
}}
>
<img src="https://gw.alipayobjects.com/zos/antfincdn/wsE2Pw%243%26L/noFound.svg" alt="404" />
<br />
<br />
<h1>404</h1>
<p>Sorry, the page you visited does not exist.</p>
<Button type="primary" onClick={() => router.push('/')}>
Back Home
</Button>
</div>
);
export default NoFoundPage;
......@@ -14,7 +14,10 @@ const getRouteAuthority = (path: string, routeData: Route[]) => {
routeData.forEach(route => {
// match prefix
if (pathToRegexp(`${route.path}(.*)`).test(path)) {
authorities = route.authority || authorities;
// exact match
if (route.path === path) {
authorities = route.authority || authorities;
}
// get children authority recursively
if (route.routes) {
authorities = getRouteAuthority(path, route.routes) || authorities;
......
......@@ -24,7 +24,10 @@ const AvatarView = ({ avatar }: { avatar: string }) => (
<Upload fileList={[]}>
<div className={styles.button_view}>
<Button icon="upload">
<FormattedMessage id="account-settings.basic.change-avatar" defaultMessage="Change avatar" />
<FormattedMessage
id="account-settings.basic.change-avatar"
defaultMessage="Change avatar"
/>
</Button>
</div>
</Upload>
......@@ -207,7 +210,10 @@ class BaseView extends Component<BaseViewProps> {
})(<PhoneView />)}
</FormItem>
<Button type="primary" onClick={this.handlerSubmit}>
<FormattedMessage id="account-settings.basic.update" defaultMessage="Update Information" />
<FormattedMessage
id="account-settings.basic.update"
defaultMessage="Update Information"
/>
</Button>
</Form>
</div>
......
......@@ -17,12 +17,18 @@ class NotificationView extends Component {
return [
{
title: formatMessage({ id: 'account-settings.notification.password' }, {}),
description: formatMessage({ id: 'account-settings.notification.password-description' }, {}),
description: formatMessage(
{ id: 'account-settings.notification.password-description' },
{},
),
actions: [Action],
},
{
title: formatMessage({ id: 'account-settings.notification.messages' }, {}),
description: formatMessage({ id: 'account-settings.notification.messages-description' }, {}),
description: formatMessage(
{ id: 'account-settings.notification.messages-description' },
{},
),
actions: [Action],
},
{
......
......@@ -30,18 +30,20 @@ interface SettingsState {
@connect(({ accountSettings }: { accountSettings: { currentUser: CurrentUser } }) => ({
currentUser: accountSettings.currentUser,
}))
class Settings extends Component<
SettingsProps,
SettingsState
> {
class Settings extends Component<SettingsProps, SettingsState> {
main: HTMLDivElement | undefined = undefined;
constructor(props: SettingsProps) {
super(props);
const menuMap = {
base: <FormattedMessage id="account-settings.menuMap.basic" defaultMessage="Basic Settings" />,
base: (
<FormattedMessage id="account-settings.menuMap.basic" defaultMessage="Basic Settings" />
),
security: (
<FormattedMessage id="account-settings.menuMap.security" defaultMessage="Security Settings" />
<FormattedMessage
id="account-settings.menuMap.security"
defaultMessage="Security Settings"
/>
),
binding: (
<FormattedMessage id="account-settings.menuMap.binding" defaultMessage="Account Binding" />
......
......@@ -24,12 +24,18 @@ const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: Vis
<ChartCard
bordered={false}
title={
<FormattedMessage id="dashboard-analysis.analysis.total-sales" defaultMessage="Total Sales" />
<FormattedMessage
id="dashboard-analysis.analysis.total-sales"
defaultMessage="Total Sales"
/>
}
action={
<Tooltip
title={
<FormattedMessage id="dashboard-analysis.analysis.introduce" defaultMessage="Introduce" />
<FormattedMessage
id="dashboard-analysis.analysis.introduce"
defaultMessage="Introduce"
/>
}
>
<Icon type="info-circle-o" />
......@@ -40,7 +46,10 @@ const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: Vis
footer={
<Field
label={
<FormattedMessage id="dashboard-analysis.analysis.day-sales" defaultMessage="Daily Sales" />
<FormattedMessage
id="dashboard-analysis.analysis.day-sales"
defaultMessage="Daily Sales"
/>
}
value={`¥${numeral(12423).format('0,0')}`}
/>
......@@ -66,7 +75,10 @@ const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: Vis
action={
<Tooltip
title={
<FormattedMessage id="dashboard-analysis.analysis.introduce" defaultMessage="Introduce" />
<FormattedMessage
id="dashboard-analysis.analysis.introduce"
defaultMessage="Introduce"
/>
}
>
<Icon type="info-circle-o" />
......@@ -76,7 +88,10 @@ const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: Vis
footer={
<Field
label={
<FormattedMessage id="dashboard-analysis.analysis.day-visits" defaultMessage="Daily Visits" />
<FormattedMessage
id="dashboard-analysis.analysis.day-visits"
defaultMessage="Daily Visits"
/>
}
value={numeral(1234).format('0,0')}
/>
......@@ -90,11 +105,16 @@ const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: Vis
<ChartCard
bordered={false}
loading={loading}
title={<FormattedMessage id="dashboard-analysis.analysis.payments" defaultMessage="Payments" />}
title={
<FormattedMessage id="dashboard-analysis.analysis.payments" defaultMessage="Payments" />
}
action={
<Tooltip
title={
<FormattedMessage id="dashboard-analysis.analysis.introduce" defaultMessage="Introduce" />
<FormattedMessage
id="dashboard-analysis.analysis.introduce"
defaultMessage="Introduce"
/>
}
>
<Icon type="info-circle-o" />
......@@ -130,7 +150,10 @@ const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: Vis
action={
<Tooltip
title={
<FormattedMessage id="dashboard-analysis.analysis.introduce" defaultMessage="Introduce" />
<FormattedMessage
id="dashboard-analysis.analysis.introduce"
defaultMessage="Introduce"
/>
}
>
<Icon type="info-circle-o" />
......@@ -140,11 +163,17 @@ const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: Vis
footer={
<div style={{ whiteSpace: 'nowrap', overflow: 'hidden' }}>
<Trend flag="up" style={{ marginRight: 16 }}>
<FormattedMessage id="dashboard-analysis.analysis.week" defaultMessage="Weekly Changes" />
<FormattedMessage
id="dashboard-analysis.analysis.week"
defaultMessage="Weekly Changes"
/>
<span className={styles.trendText}>12%</span>
</Trend>
<Trend flag="down">
<FormattedMessage id="dashboard-analysis.analysis.day" defaultMessage="Weekly Changes" />
<FormattedMessage
id="dashboard-analysis.analysis.day"
defaultMessage="Weekly Changes"
/>
<span className={styles.trendText}>11%</span>
</Trend>
</div>
......
......@@ -59,7 +59,9 @@ const ProportionSales = ({
</h4>
<Pie
hasLegend
subTitle={<FormattedMessage id="dashboard-analysis.analysis.sales" defaultMessage="Sales" />}
subTitle={
<FormattedMessage id="dashboard-analysis.analysis.sales" defaultMessage="Sales" />
}
total={() => <Yuan>{salesPieData.reduce((pre, now) => now.y + pre, 0)}</Yuan>}
data={salesPieData}
valueFormat={value => <Yuan>{value}</Yuan>}
......
......@@ -41,16 +41,28 @@ const SalesCard = ({
<div className={styles.salesExtraWrap}>
<div className={styles.salesExtra}>
<a className={isActive('today')} onClick={() => selectDate('today')}>
<FormattedMessage id="dashboard-analysis.analysis.all-day" defaultMessage="All Day" />
<FormattedMessage
id="dashboard-analysis.analysis.all-day"
defaultMessage="All Day"
/>
</a>
<a className={isActive('week')} onClick={() => selectDate('week')}>
<FormattedMessage id="dashboard-analysis.analysis.all-week" defaultMessage="All Week" />
<FormattedMessage
id="dashboard-analysis.analysis.all-week"
defaultMessage="All Week"
/>
</a>
<a className={isActive('month')} onClick={() => selectDate('month')}>
<FormattedMessage id="dashboard-analysis.analysis.all-month" defaultMessage="All Month" />
<FormattedMessage
id="dashboard-analysis.analysis.all-month"
defaultMessage="All Month"
/>
</a>
<a className={isActive('year')} onClick={() => selectDate('year')}>
<FormattedMessage id="dashboard-analysis.analysis.all-year" defaultMessage="All Year" />
<FormattedMessage
id="dashboard-analysis.analysis.all-year"
defaultMessage="All Year"
/>
</a>
</div>
<RangePicker
......
......@@ -17,7 +17,10 @@ const columns = [
},
{
title: (
<FormattedMessage id="dashboard-analysis.table.search-keyword" defaultMessage="Search keyword" />
<FormattedMessage
id="dashboard-analysis.table.search-keyword"
defaultMessage="Search keyword"
/>
),
dataIndex: 'keyword',
key: 'keyword',
......@@ -31,7 +34,9 @@ const columns = [
className: styles.alignRight,
},
{
title: <FormattedMessage id="dashboard-analysis.table.weekly-range" defaultMessage="Weekly Range" />,
title: (
<FormattedMessage id="dashboard-analysis.table.weekly-range" defaultMessage="Weekly Range" />
),
dataIndex: 'range',
key: 'range',
sorter: (a: { range: number }, b: { range: number }) => a.range - b.range,
......@@ -79,7 +84,10 @@ const TopSearch = ({
/>
<Tooltip
title={
<FormattedMessage id="dashboard-analysis.analysis.introduce" defaultMessage="introduce" />
<FormattedMessage
id="dashboard-analysis.analysis.introduce"
defaultMessage="introduce"
/>
}
>
<Icon style={{ marginLeft: 8 }} type="info-circle-o" />
......@@ -103,7 +111,10 @@ const TopSearch = ({
/>
<Tooltip
title={
<FormattedMessage id="dashboard-analysis.analysis.introduce" defaultMessage="introduce" />
<FormattedMessage
id="dashboard-analysis.analysis.introduce"
defaultMessage="introduce"
/>
}
>
<Icon style={{ marginLeft: 8 }} type="info-circle-o" />
......
......@@ -71,7 +71,10 @@ class BasicForm extends Component<BasicFormProps> {
<PageHeaderWrapper content={<FormattedMessage id="form-basic-form.basic.description" />}>
<Card bordered={false}>
<Form onSubmit={this.handleSubmit} hideRequiredMark style={{ marginTop: 8 }}>
<FormItem {...formItemLayout} label={<FormattedMessage id="form-basic-form.title.label" />}>
<FormItem
{...formItemLayout}
label={<FormattedMessage id="form-basic-form.title.label" />}
>
{getFieldDecorator('title', {
rules: [
{
......@@ -79,9 +82,14 @@ class BasicForm extends Component<BasicFormProps> {
message: formatMessage({ id: 'form-basic-form.title.required' }),
},
],
})(<Input placeholder={formatMessage({ id: 'form-basic-form.title.placeholder' })} />)}
})(
<Input placeholder={formatMessage({ id: 'form-basic-form.title.placeholder' })} />,
)}
</FormItem>
<FormItem {...formItemLayout} label={<FormattedMessage id="form-basic-form.date.label" />}>
<FormItem
{...formItemLayout}
label={<FormattedMessage id="form-basic-form.date.label" />}
>
{getFieldDecorator('date', {
rules: [
{
......@@ -99,7 +107,10 @@ class BasicForm extends Component<BasicFormProps> {
/>,
)}
</FormItem>
<FormItem {...formItemLayout} label={<FormattedMessage id="form-basic-form.goal.label" />}>
<FormItem
{...formItemLayout}
label={<FormattedMessage id="form-basic-form.goal.label" />}
>
{getFieldDecorator('goal', {
rules: [
{
......@@ -164,7 +175,9 @@ class BasicForm extends Component<BasicFormProps> {
}
>
{getFieldDecorator('invites')(
<Input placeholder={formatMessage({ id: 'form-basic-form.invites.placeholder' })} />,
<Input
placeholder={formatMessage({ id: 'form-basic-form.invites.placeholder' })}
/>,
)}
</FormItem>
<FormItem
......
......@@ -59,10 +59,7 @@ interface BasicListState {
loading: loading.models.listBasicList,
}),
)
class BasicList extends Component<
BasicListProps,
BasicListState
> {
class BasicList extends Component<BasicListProps, BasicListState> {
state: BasicListState = { visible: false, done: false, current: undefined };
formLayout = {
......
......@@ -35,10 +35,7 @@ interface CardListState {
loading: loading.models.list,
}),
)
class CardList extends Component<
CardListProps,
CardListState
> {
class CardList extends Component<CardListProps, CardListState> {
componentDidMount() {
const { dispatch } = this.props;
dispatch({
......
......@@ -28,12 +28,10 @@ for (let i = 0; i < 8; i += 1) {
function getRule(
req: { url: any },
res: {
json: (
arg0: {
list: TableListItem[];
pagination: { total: number; pageSize: number; current: number };
},
) => void;
json: (arg0: {
list: TableListItem[];
pagination: { total: number; pageSize: number; current: number };
}) => void;
},
u: any,
) {
......
......@@ -7,11 +7,7 @@ const FormItem = Form.Item;
interface CreateFormProps extends FormComponentProps {
modalVisible: boolean;
handleAdd: (
fieldsValue: {
desc: string;
},
) => void;
handleAdd: (fieldsValue: { desc: string }) => void;
handleModalVisible: () => void;
}
const CreateForm: React.SFC<CreateFormProps> = props => {
......
......@@ -65,10 +65,7 @@ interface BasicState {
loading: loading.effects['profileBasic/fetchBasic'],
}),
)
class Basic extends Component<
BasicProps,
BasicState
> {
class Basic extends Component<BasicProps, BasicState> {
componentDidMount() {
const { dispatch } = this.props;
dispatch({
......
......@@ -64,7 +64,10 @@ const extra = (
<Step
title={
<span style={{ fontSize: 14 }}>
<FormattedMessage id="result-success.success.step1-title" defaultMessage="Create project" />
<FormattedMessage
id="result-success.success.step1-title"
defaultMessage="Create project"
/>
</span>
}
description={desc1}
......
......@@ -45,10 +45,7 @@ export interface FromDataType {
submitting: loading.effects['userLogin/login'],
}),
)
class Login extends Component<
LoginProps,
LoginState
> {
class Login extends Component<LoginProps, LoginState> {
loginForm: FormComponentProps['form'] | undefined | null = undefined;
state: LoginState = {
......
......@@ -21,6 +21,13 @@ declare module 'nzh/cn';
declare module 'webpack-theme-color-replacer';
declare module 'webpack-theme-color-replacer/client';
// src/typings.d.ts
declare module 'umi-plugin-react/locale' {
export default interface MessageDescriptor {
id: string;
} /* eslint-disable-line */
}
declare let ga: Function;
// preview.pro.ant.design only do not use in your production ;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment