Skip to content

Commit

Permalink
fix: Fix code erros tip by eslint
Browse files Browse the repository at this point in the history
Signed-off-by: leoliu <leoliu@yunify.com>
  • Loading branch information
leoliu committed Aug 7, 2020
1 parent 72650b4 commit 4bd5a88
Show file tree
Hide file tree
Showing 24 changed files with 47 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"test:e2e": "cypress run",
"serve": "NODE_ENV=production node server/server.js",
"lego": "webpack -p --config scripts/webpack.lego.js",
"lint": "eslint ./src",
"lint": "eslint src/**/*.jsx src/**/*.js",
"postinstall": "rimraf .cache-loader",
"prebuild": "rimraf dist",
"release": "standard-version"
Expand Down
16 changes: 8 additions & 8 deletions src/components/Base/Dragger/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,13 @@ export default class Dragger extends React.Component {

@observable
scale = 1

@observable
translateX = 30

@observable
translateY = 60

@observable
isFullscreen = false

Expand Down Expand Up @@ -168,22 +171,19 @@ export default class Dragger extends React.Component {
const contentWidth = this.content.clientWidth * this.scale
const contentHeight = this.content.clientHeight * this.scale

if (clientX < this.translateX) {
this.translateX = this.translateX
} else if (clientX > this.translateX + contentWidth) {
if (clientX > this.translateX + contentWidth) {
this.translateX =
-(deltaScale * this.content.clientWidth) + this.translateX
} else {
} else if (clientX >= this.translateX) {
this.translateX =
-(deltaScale * (clientX - this.translateX)) / this.scale +
this.translateX
}
if (clientY < this.translateY) {
this.translateY = this.translateY
} else if (clientY > this.translateY + contentHeight) {

if (clientY > this.translateY + contentHeight) {
this.translateY =
-(deltaScale * this.content.clientHeight) + this.translateY
} else {
} else if (clientY >= this.translateY) {
this.translateY =
(-deltaScale * (clientY - this.translateY)) / this.scale +
this.translateY
Expand Down
3 changes: 2 additions & 1 deletion src/components/Base/ScrollLoad/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export default class ScrollLoad extends React.Component {
loading: false,
loadMore: isRemainingData(props),
}
} else if (props.loading !== state.loading) {
}
if (props.loading !== state.loading) {
return {
loading: props.loading,
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Base/Steps/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export default class Steps extends React.Component {
const { current } = this.props
if (index === current) {
return 'current'
} else if (index < current) {
}
if (index < current) {
return 'finished'
}

Expand Down
1 change: 1 addition & 0 deletions src/components/Forms/GrayRelease/Components/Card/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default class Card extends React.PureComponent {

onSelect(component, !value)
}

renderActions() {
const { value, component, loading } = this.props

Expand Down
4 changes: 3 additions & 1 deletion src/components/Forms/ImageBuilder/B2IForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ export default class S2IForm extends React.Component {
<Form ref={formRef} data={formTemplate}>
<Form.Item
label={t('Upload Artifacts')}
rules={[{ required: true, message: t('The file has not been uploaded.') }]}
rules={[
{ required: true, message: t('The file has not been uploaded.') },
]}
>
<Uploader
name={`${this.prefix}spec.config.sourceUrl`}
Expand Down
1 change: 1 addition & 0 deletions src/components/Graph/Detail/Monitors/TrafficCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class TrafficCard extends React.Component {
static propTypes = {
metrics: PropTypes.array,
}

static defaultProps = {
metrics: [],
}
Expand Down
9 changes: 6 additions & 3 deletions src/components/Inputs/InputPassword/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,14 @@ export default class Password extends React.Component {

if (strength === -1) {
return { width: 0, backgroundColor: '#fff' }
} else if (strength >= 0 && strength < 6) {
}
if (strength >= 0 && strength < 6) {
return { width: '33%', backgroundColor: '#ca2621' }
} else if (strength >= 6 && strength < 8) {
}
if (strength >= 6 && strength < 8) {
return { width: '66%', backgroundColor: '#f5a623' }
} else if (strength >= 8) {
}
if (strength >= 8) {
return { width: '100%', backgroundColor: '#55bc8a' }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class Metadata extends React.Component {
}

onCollapsed(item) {
const data = Object.assign({}, item, { collapsed: !item.collapsed })
const data = { ...item, collapsed: !item.collapsed }
this.setState({ data })
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Form } from 'components/Base'
import { Input, Select } from '@pitrix/lego-ui'

import CustomMonitorMetircQueryInput from '../../MetircQueryInput'
import FormItemContainer from '../../Form/ItemContianer'
import FormItemContainer from '../ItemContianer'
import Field from '../Field'

import styles from './index.scss'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import React from 'react'
import { isFunction } from 'lodash'
import { Icon } from '@pitrix/lego-ui'
import { toJS } from 'mobx'
import TableColumnStyleModal from '../../../components/TableColumnStyleModal'
import TableColumnStyleModal from '../../TableColumnStyleModal'

import styles from './index.scss'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class RowTitleEditor extends React.Component {
onBlur = () => {
this.setState({ editing: false })
}

onKeyUp = e => {
const isEnter = e.keyCode === 13
isEnter && this.setState({ editing: false })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { pick } from 'lodash'
import { Modal, Form } from 'components/Base'
import { Select, Columns, Column } from '@pitrix/lego-ui'
import NumberInput from 'components/Inputs/NumberInput'
import ColorSelector from '../../components/FormInput/ColorSelector'
import ColorSelector from '../FormInput/ColorSelector'

import styles from './index.scss'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class Metadata extends React.Component {
}

onCollapsed(item) {
const data = Object.assign({}, item, { collapsed: !item.collapsed })
const data = { ...item, collapsed: !item.collapsed }
this.setState({ data })
}

Expand Down
9 changes: 4 additions & 5 deletions src/components/Tables/Ranking/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ export const THEME = {
export default class RankingTable extends React.Component {
get columns() {
const sort_metric = get(this, 'props.store.sort_metric', '')
return this.props.columns.map(column =>
Object.assign({}, column, {
className: column.sort_metric === sort_metric ? styles.rankCol : '',
})
)
return this.props.columns.map(column => ({
...column,
className: column.sort_metric === sort_metric ? styles.rankCol : '',
}))
}

render() {
Expand Down
1 change: 1 addition & 0 deletions src/components/TextPreview/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default class TextPreview extends React.Component {
hideToolbar: PropTypes.bool,
hideOverlayBtns: PropTypes.bool,
}

static defaultProps = {
files: {},
type: 'selectFiles',
Expand Down
5 changes: 4 additions & 1 deletion src/pages/appStore/components/AppPreview/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class AppPreview extends React.Component {
versionId: PropTypes.string,
currentTab: PropTypes.string,
}

static defaultProps = {
currentTab: '',
appId: '',
Expand Down Expand Up @@ -90,7 +91,9 @@ export default class AppPreview extends React.Component {
}

return (
<p className={styles.noReadme}>{t('The version has no documentation.')}</p>
<p className={styles.noReadme}>
{t('The version has no documentation.')}
</p>
)
}

Expand Down
1 change: 1 addition & 0 deletions src/pages/appStore/components/Banner/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class Banner extends React.PureComponent {
className: PropTypes.string,
children: PropTypes.node,
}

get isAppsPage() {
return location.pathname === '/apps'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class CodeStatusCard extends React.PureComponent {
value: 0,
url: '',
}

render() {
const { hasIcon, title, value, resultClass, unit, url } = this.props
const classContent = CLASSLISTS[parseInt(resultClass, 10) - 1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ export default class KubernetesDeploy extends React.Component {

@observable
dockerCredentials = [{ key: 'default' }]

@observable
isShowAdvenced = false

@observable
isShowDetail = false

Expand Down
1 change: 1 addition & 0 deletions src/pages/devops/components/Pipeline/StepsEditor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default class StepsEditor extends React.Component {

@observable
zIndex = ''

@observable
isEditMode = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default class PipelineLog extends React.Component {

@observable
activeNodeIndex = [0, 0] // lineindex, colunmIndex

@observable
refreshFlag = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class ImageRunRecords extends React.Component {
content: t('Copy Successfully'),
})
}

render() {
const {
imageName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Banner extends PureComponent {
icon: PropTypes.string,
onClickBack: PropTypes.func,
}

handleClickBack = () => {
this.props.onClickBack ? this.props.onClickBack() : history.back()
}
Expand Down

0 comments on commit 4bd5a88

Please sign in to comment.