Skip to content

Commit

Permalink
Merge pull request #2425 from alibaba/fix-iceworks-client-and-cli-lint
Browse files Browse the repository at this point in the history
feat: lint for iceworks-client && iceworks-cli
  • Loading branch information
Orange-C authored Jul 15, 2019
2 parents 6581d84 + 1e585b4 commit f36e49e
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 46 deletions.
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,4 @@ packages/iceworks-scaffolder

# temp ignore
tools/iceworks
tools/iceworks-cli
tools/ice-devtools
packages/iceworks-client
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const ConnectModal = ({ intl }) => {
const CONNECT_MAP = {
connect: 'iceworks.global.connect',
reconnecting: 'iceworks.global.reconnecting',
// eslint-disable-next-line @typescript-eslint/camelcase
reconnect_failed: 'iceworks.global.reconnect_failed',
disconnect: 'iceworks.global.disconnect',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const CreateProjectModal = ({ on, onCancel, onOk, isBiz }) => {
onChange={onChangeIdChange}
/>
</FormItem>,
]
]
: null}

<FormItem
Expand Down
2 changes: 1 addition & 1 deletion packages/iceworks-client/src/components/GlobalBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { ThemeContext } from '@components/ThemeProvider';
import socket from '@src/socket';
import useSocket from '@hooks/useSocket';
import useTermTheme from '@hooks/useTermTheme';
import stores from '@stores';
import showMessage from '@utils/showMessage';
import { THEMES } from '@src/appConfig';
import goldlog from '@utils/goldlog';
import stores from '@stores';
import styles from './index.module.scss';

const GlobalBar = ({ project, intl }) => {
Expand Down
10 changes: 5 additions & 5 deletions packages/iceworks-client/src/components/Locale/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint camelcase:0 */
/* eslint @typescript-eslint/camelcase:0 */
import React, { createContext } from 'react';
import PropTypes from 'prop-types';
import { IntlProvider, addLocaleData } from 'react-intl';
Expand All @@ -13,8 +13,8 @@ import enUS from '@alifd/next/lib/locale/en-us';
import zhCN from '@alifd/next/lib/locale/zh-cn';

// 引入 locale 配置文件
import en_US from '../../locales/en-US';
import zh_CN from '../../locales/zh-CN';
import enUSLocale from '../../locales/en-US';
import zhCNLocale from '../../locales/zh-CN';

// 设置语言包
addLocaleData([...en, ...zh]);
Expand All @@ -26,13 +26,13 @@ export const localeInfos = {
[LOCAL_ZH_CN]: {
nextLocale: zhCN,
appLocale: 'zh',
appMessages: zh_CN,
appMessages: zhCNLocale,
label: '中文',
},
[LOCAL_EN_US]: {
nextLocale: enUS,
appLocale: 'en',
appMessages: en_US,
appMessages: enUSLocale,
label: 'English',
},
};
Expand Down
22 changes: 11 additions & 11 deletions packages/iceworks-client/src/components/ScaffoldCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ const ScaffoldCard = ({ dataSource, onDownload }) => {
) : null}
{dataSource.screenshots && dataSource.screenshots.length
? dataSource.screenshots.map((url, key) => {
const screenshotStyle = generateStyle(dataSource.screenshots, key);
return (
<img
alt={dataSource.title}
src={url || PLACEHOLDER_IMG}
style={screenshotStyle}
className={styles.screenshotImg}
key={key}
/>
);
})
const screenshotStyle = generateStyle(dataSource.screenshots, key);
return (
<img
alt={dataSource.title}
src={url || PLACEHOLDER_IMG}
style={screenshotStyle}
className={styles.screenshotImg}
key={key}
/>
);
})
: (
<img
alt={dataSource.title}
Expand Down
5 changes: 3 additions & 2 deletions packages/iceworks-client/src/hooks/useDependency.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import stores from '@stores';
/* eslint react-hooks/rules-of-hooks:0 */
import { useState } from 'react';
import useModal from '@hooks/useModal';
import useSocket from '@hooks/useSocket';
import { useState } from 'react';
import writeGlobalLog from '@utils/writeGlobalLog';
import showMessage from '@utils/showMessage';
import stores from '@stores';

export const STATUS_RESETING = 'reseting';

Expand Down
4 changes: 2 additions & 2 deletions packages/iceworks-client/src/hooks/useProject.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import stores from '@stores';
import useModal from '@hooks/useModal';
import { useState } from 'react';
import useModal from '@hooks/useModal';
import showMessage from '@utils/showMessage';
import logger from '@utils/logger';
import goldlog from '@utils/goldlog';
import stores from '@stores';

function useProject({ panelStores } = {}) {
const [projectsStore, projectStore, materialStore] = stores.useStores(['projects', 'project', 'material']);
Expand Down
16 changes: 7 additions & 9 deletions packages/iceworks-client/src/hooks/useTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,22 @@ const useTask = ({ type, writeLog, writeChunk }) => {
}
}

function taskEventListener(eventName) {
useSocket(eventName, (data) => {
setStatus(type, data.status);
if (writeChunk) {
writeChunk(data.chunk);
}
}, [status]);
function taskEventListener(data) {
setStatus(type, data.status);
if (writeChunk) {
writeChunk(data.chunk);
}
}

useEffect(() => {
onGetStatus();
}, []);

// listen start event handle
taskEventListener(startEventName);
useSocket(startEventName, data => taskEventListener(data), [status]);

// listen stop event handle
taskEventListener(stopEventName);
useSocket(stopEventName, data => taskEventListener(data), [status]);

return {
isWorking: status === 'working',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import Card from '@components/Card';
import TaskBar from '@components/TaskBar';
import XtermTerminal from '@components/XtermTerminal';
import { withErrorBoundary } from '@components/ErrorBoundary';
import stores from '@stores';
import termManager from '@utils/termManager';
import logger from '@utils/logger';
import stores from '@stores';
import TaskModal from '../TaskModal';
import styles from './index.module.scss';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { Button } from '@alifd/next';

import Icon from '@components/Icon';
import SubMenu from '@components/SubMenu';

Expand Down Expand Up @@ -50,7 +49,7 @@ const MaterialSubMenu = ({
);
})}
</div>
: null
: null
}
</div>
<div className={styles.opts}>
Expand Down
2 changes: 1 addition & 1 deletion packages/iceworks-client/src/pages/Material/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { Tab } from '@alifd/next';
import showMessage from '@utils/showMessage';
import stores from '@stores';
import Card from '@components/Card';
import { FormattedMessage, injectIntl } from 'react-intl';
import { forceCheck } from 'react-lazyload';
import useProject from '@hooks/useProject';
import useMaterial from '@hooks/useMaterial';
import useDependency from '@hooks/useDependency';
import CreateProjectModal from '@components/CreateProjectModal';
import stores from '@stores';
import SubMenu from './components/SubMenu';
import MaterialPanel from './components/MaterialPanel';
import InstallModal from './components/InstallModal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function Main({ dataSource, onOk }) {

const statusMap = {
conflicted: ['#FA7070', <FormattedMessage id="iceworks.project.panel.git.main.status.conflicted" />],
// eslint-disable-next-line @typescript-eslint/camelcase
not_added: ['#2ECA9C', <FormattedMessage id="iceworks.project.panel.git.main.status.not_added" />],
modified: ['#FCDA52', <FormattedMessage id="iceworks.project.panel.git.main.status.modified" />],
created: ['#5485F7', <FormattedMessage id="iceworks.project.panel.git.main.status.created" />],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Select, Input, Loading } from '@alifd/next';
import uniqBy from 'lodash.uniqby';
import cx from 'classnames';
import socket from '@src/socket';
import stores from '@stores';
import Modal from '@components/Modal';
import Icon from '@components/Icon';
import BlockCard from '@components/BlockCard';
Expand All @@ -19,6 +18,7 @@ import {
SortableHandle,
arrayMove,
} from 'react-sortable-hoc';
import stores from '@stores';
import SavePageModal from './SavePageModal';
import styles from './BuildPageModal.module.scss';

Expand Down
5 changes: 2 additions & 3 deletions packages/iceworks-client/src/pages/Project/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* eslint babel/new-cap:0, react/no-danger:0, react/self-closing-comp: 0 */
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { Button } from '@alifd/next';
import logger from '@utils/logger';
import useProject from '@hooks/useProject';
import useDependency from '@hooks/useDependency';
import useVisibilityChange from '@hooks/useVisibilityChange';
import stores from '@stores';
import ErrorBoundary from '@components/ErrorBoundary';
import Icon from '@components/Icon';
import SelectWorkFolderModal from '@components/SelectWorkFolderModal';
Expand All @@ -19,6 +17,7 @@ import {
SortableElement,
SortableHandle,
} from 'react-sortable-hoc';
import stores from '@stores';
import FallbackPanel from './components/FallbackPanel';
import SubMenu from './components/SubMenu';
import DeleteProjectModal from './components/DeleteProjectModal';
Expand Down Expand Up @@ -215,7 +214,7 @@ const Project = ({ history, intl }) => {
return (
<div className={styles.noAdapter}>
<h5><FormattedMessage id="iceworks.global.adapter.title" /></h5>
<p dangerouslySetInnerHTML={{ __html: intl.formatHTMLMessage({ id: 'iceworks.global.adapter.description' }) }}></p>
<p dangerouslySetInnerHTML={{ __html: intl.formatHTMLMessage({ id: 'iceworks.global.adapter.description' }) }} />
<div className={styles.reloadButton}>
<Button type="primary" onClick={reloadAdapter}>
<FormattedMessage id="iceworks.global.adapter.reload" />
Expand Down
9 changes: 6 additions & 3 deletions packages/iceworks-client/src/stores/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ export default {
this.dataSource = await socket.emit('home.setting.getUser');
},

// eslint-disable-next-line camelcase
async login({ workid, cname, avatar_url }) {
this.dataSource = await socket.emit('home.setting.setUser', { name: cname, workId: workid, avatarUrl: avatar_url });
async login({ workid, cname, avatar_url: avatarUrl }) {
this.dataSource = await socket.emit('home.setting.setUser', {
name: cname,
workId: workid,
avatarUrl,
});
},
};
2 changes: 1 addition & 1 deletion packages/iceworks-client/src/utils/goldlog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint no-param-reassign:0 */
import axios from 'axios';
import dateTime from 'date-time';
import browser from 'browser-detect';
Expand All @@ -7,6 +6,7 @@ import appConfig from '../appConfig';
const UA = browser();

function goldlog(data = {}) {
// eslint-disable-next-line @typescript-eslint/camelcase
data.visit_time = dateTime();
data.UA = UA;

Expand Down
5 changes: 4 additions & 1 deletion tools/iceworks-cli/bin/iceworks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env node

/* eslint quotes:0, prefer-template:0 */
const chalk = require('chalk');
const program = require('commander');
const pkgData = require('../package');
Expand All @@ -18,6 +17,7 @@ program.version(pkgData.version).usage('<command> [options]');
// output help information on unknown commands
program.arguments('<command>').action((cmd) => {
program.outputHelp();
// eslint-disable-next-line prefer-template
console.log(` ` + chalk.red(`Unknown command ${chalk.yellow(cmd)}.`));
console.log();
});
Expand All @@ -34,6 +34,7 @@ program
.action((npmName, cmd) => {
const options = cleanArgs(cmd);
options.npmName = npmName;
// eslint-disable-next-line global-require
require('../command/init')(options);
});

Expand All @@ -53,6 +54,7 @@ program
.action((npmName, cmd) => {
const options = cleanArgs(cmd);
options.npmName = npmName;
// eslint-disable-next-line global-require
require('../command/addBlock')(options);
});

Expand All @@ -73,6 +75,7 @@ program.parse(process.argv);

if (!process.argv.slice(2).length) {
// start web server for iceworks 3.0
// eslint-disable-next-line global-require
require('../command/start')(cleanArgs());
}

Expand Down

0 comments on commit f36e49e

Please # to comment.