Eslint rule for block curlies (#3955)
* Add curly rule * Fix pre-existing issues with new rule
This commit is contained in:
@@ -173,20 +173,26 @@ export default class QueryAction extends Component {
|
||||
onQueryKeyChange = (event, index, queryKey) => {
|
||||
this.setState({
|
||||
queryKey,
|
||||
form: { valid: false, value: '' }
|
||||
form: {
|
||||
valid: false,
|
||||
value: ''
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onChange = (valid, value) => {
|
||||
this.setState({
|
||||
form: {
|
||||
valid, value
|
||||
valid,
|
||||
value
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onQuery = () => {
|
||||
if (!this.state.form.valid) return;
|
||||
if (!this.state.form.valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { queryKey, form } = this.state;
|
||||
|
||||
|
||||
@@ -128,8 +128,12 @@ export default class RegisterAction extends Component {
|
||||
renderContent () {
|
||||
const { error, complete } = this.props;
|
||||
|
||||
if (error) return this.renderError();
|
||||
if (complete) return this.renderComplete();
|
||||
if (error) {
|
||||
return this.renderError();
|
||||
} else if (complete) {
|
||||
return this.renderComplete();
|
||||
}
|
||||
|
||||
return this.renderForm();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,9 @@ export default class CustomChip extends Component {
|
||||
}
|
||||
|
||||
renderIcon (isAddress, address) {
|
||||
if (!isAddress) return;
|
||||
if (!isAddress) {
|
||||
return;
|
||||
}
|
||||
|
||||
return (
|
||||
<IdentityIcon
|
||||
|
||||
@@ -73,7 +73,9 @@ export default class InputText extends Component {
|
||||
}
|
||||
|
||||
renderLoading () {
|
||||
if (!this.state.loading) return;
|
||||
if (!this.state.loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={ styles['input-loading'] }>
|
||||
@@ -83,7 +85,9 @@ export default class InputText extends Component {
|
||||
}
|
||||
|
||||
renderIsValid () {
|
||||
if (this.state.loading || !this.state.valid) return;
|
||||
if (this.state.loading || !this.state.valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={ styles['input-icon'] }>
|
||||
@@ -120,8 +124,13 @@ export default class InputText extends Component {
|
||||
}
|
||||
|
||||
onKeyDown = (event) => {
|
||||
if (!this.props.onEnter) return;
|
||||
if (event.keyCode !== 13) return;
|
||||
if (!this.props.onEnter) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.keyCode !== 13) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.onEnter();
|
||||
}
|
||||
|
||||
@@ -71,9 +71,14 @@ const validateAddress = (address) => {
|
||||
|
||||
const validateTokenAddress = (address, contract, simple) => {
|
||||
const addressValidation = validateAddress(address);
|
||||
if (!addressValidation.valid) return addressValidation;
|
||||
|
||||
if (simple) return addressValidation;
|
||||
if (!addressValidation.valid) {
|
||||
return addressValidation;
|
||||
}
|
||||
|
||||
if (simple) {
|
||||
return addressValidation;
|
||||
}
|
||||
|
||||
return getTokenTotalSupply(address)
|
||||
.then(balance => {
|
||||
@@ -96,7 +101,10 @@ const validateTokenAddress = (address, contract, simple) => {
|
||||
});
|
||||
})
|
||||
.then((result) => {
|
||||
if (result) return result;
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return addressValidation;
|
||||
});
|
||||
};
|
||||
@@ -130,7 +138,10 @@ const validateTLA = (tla, contract, simple) => {
|
||||
}
|
||||
})
|
||||
.then((result) => {
|
||||
if (result) return result;
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return {
|
||||
value: fTLA,
|
||||
error: null,
|
||||
@@ -215,16 +226,28 @@ const validateURL = (string) => {
|
||||
};
|
||||
|
||||
export const validate = (value, type, contract) => {
|
||||
if (type === ADDRESS_TYPE) return validateAddress(value);
|
||||
if (type === TOKEN_ADDRESS_TYPE) return validateTokenAddress(value, contract);
|
||||
if (type === SIMPLE_TOKEN_ADDRESS_TYPE) return validateTokenAddress(value, contract, true);
|
||||
if (type === TLA_TYPE) return validateTLA(value, contract);
|
||||
if (type === SIMPLE_TLA_TYPE) return validateTLA(value, contract, true);
|
||||
if (type === UINT_TYPE) return validateUint(value);
|
||||
if (type === DECIMAL_TYPE) return validateDecimal(value);
|
||||
if (type === STRING_TYPE) return validateString(value);
|
||||
if (type === HEX_TYPE) return validateHex(value);
|
||||
if (type === URL_TYPE) return validateURL(value);
|
||||
|
||||
return { valid: true, error: null };
|
||||
switch (type) {
|
||||
case ADDRESS_TYPE:
|
||||
return validateAddress(value);
|
||||
case TOKEN_ADDRESS_TYPE:
|
||||
return validateTokenAddress(value, contract);
|
||||
case SIMPLE_TOKEN_ADDRESS_TYPE:
|
||||
return validateTokenAddress(value, contract, true);
|
||||
case TLA_TYPE:
|
||||
return validateTLA(value, contract);
|
||||
case SIMPLE_TLA_TYPE:
|
||||
return validateTLA(value, contract, true);
|
||||
case UINT_TYPE:
|
||||
return validateUint(value);
|
||||
case DECIMAL_TYPE:
|
||||
return validateDecimal(value);
|
||||
case STRING_TYPE:
|
||||
return validateString(value);
|
||||
case HEX_TYPE:
|
||||
return validateHex(value);
|
||||
case URL_TYPE:
|
||||
return validateURL(value);
|
||||
default:
|
||||
return { valid: true, error: null };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,7 +119,9 @@ export const subscribeEvents = () => (dispatch, getState) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!logs || logs.length === 0) return;
|
||||
if (!logs || logs.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
logs.forEach(log => {
|
||||
const event = log.event;
|
||||
|
||||
@@ -46,7 +46,9 @@ export default class AddMeta extends Component {
|
||||
state = initState;
|
||||
|
||||
render () {
|
||||
if (!this.props.isTokenOwner) return null;
|
||||
if (!this.props.isTokenOwner) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (<div className={ styles['add-meta'] }>
|
||||
<RaisedButton
|
||||
@@ -98,7 +100,10 @@ export default class AddMeta extends Component {
|
||||
renderContent () {
|
||||
const { complete } = this.state;
|
||||
|
||||
if (complete) return this.renderComplete();
|
||||
if (complete) {
|
||||
return this.renderComplete();
|
||||
}
|
||||
|
||||
return this.renderForm();
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,10 @@ export default class Token extends Component {
|
||||
}
|
||||
|
||||
renderBase (base) {
|
||||
if (!base || base < 0) return null;
|
||||
if (!base || base < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Chip
|
||||
value={ Math.log10(base).toString() }
|
||||
@@ -171,7 +174,10 @@ export default class Token extends Component {
|
||||
}
|
||||
|
||||
renderAddress (address) {
|
||||
if (!address) return null;
|
||||
if (!address) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Chip
|
||||
isAddress
|
||||
@@ -191,7 +197,9 @@ export default class Token extends Component {
|
||||
}
|
||||
|
||||
renderOwner (owner) {
|
||||
if (!owner) return null;
|
||||
if (!owner) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const ownerInfo = this.props.ownerAccountInfo;
|
||||
|
||||
@@ -258,85 +266,107 @@ export default class Token extends Component {
|
||||
}
|
||||
|
||||
if (isMetaLoading) {
|
||||
return (<div>
|
||||
<Loading size={ 0.5 } />
|
||||
</div>);
|
||||
return (
|
||||
<div>
|
||||
<Loading size={ 0.5 } />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!meta) return;
|
||||
if (!meta) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const metaData = metaDataKeys.find(m => m.value === meta.query);
|
||||
|
||||
if (!meta.value) {
|
||||
return (<div>
|
||||
<p className={ styles['meta-query'] }>
|
||||
No <span className={ styles['meta-key'] }>
|
||||
{ metaData.label.toLowerCase() }
|
||||
</span> meta-data...
|
||||
</p>
|
||||
</div>);
|
||||
return (
|
||||
<div>
|
||||
<p className={ styles['meta-query'] }>
|
||||
No <span className={ styles['meta-key'] }>
|
||||
{ metaData.label.toLowerCase() }
|
||||
</span> meta-data...
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (meta.query === 'IMG') {
|
||||
const imageHash = meta.value.replace(/^0x/, '');
|
||||
|
||||
return (<div>
|
||||
<p className={ styles['meta-query'] }>
|
||||
<span className={ styles['meta-key'] }>
|
||||
{ metaData.label }
|
||||
</span> meta-data:
|
||||
</p>
|
||||
<div className={ styles['meta-image'] }>
|
||||
<img src={ `${parityNode}/api/content/${imageHash}/` } />
|
||||
return (
|
||||
<div>
|
||||
<p className={ styles['meta-query'] }>
|
||||
<span className={ styles['meta-key'] }>
|
||||
{ metaData.label }
|
||||
</span> meta-data:
|
||||
</p>
|
||||
<div className={ styles['meta-image'] }>
|
||||
<img src={ `${parityNode}/api/content/${imageHash}/` } />
|
||||
</div>
|
||||
</div>
|
||||
</div>);
|
||||
);
|
||||
}
|
||||
|
||||
if (meta.query === 'A') {
|
||||
const address = meta.value.slice(0, 42);
|
||||
|
||||
return (<div>
|
||||
return (
|
||||
<div>
|
||||
<p className={ styles['meta-query'] }>
|
||||
<span className={ styles['meta-key'] }>
|
||||
{ metaData.label }
|
||||
</span> meta-data:
|
||||
</p>
|
||||
<p className={ styles['meta-value'] }>
|
||||
{ api.util.toChecksumAddress(address) }
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<p className={ styles['meta-query'] }>
|
||||
<span className={ styles['meta-key'] }>
|
||||
{ metaData.label }
|
||||
</span> meta-data:
|
||||
</p>
|
||||
<p className={ styles['meta-value'] }>
|
||||
{ api.util.toChecksumAddress(address) }
|
||||
</p>
|
||||
</div>);
|
||||
}
|
||||
|
||||
return (<div>
|
||||
<p className={ styles['meta-query'] }>
|
||||
<span className={ styles['meta-key'] }>
|
||||
{ metaData.label }
|
||||
</span> meta-data:
|
||||
</p>
|
||||
<p className={ styles['meta-value'] }>{ meta.value }</p>
|
||||
</div>);
|
||||
<p className={ styles['meta-value'] }>{ meta.value }</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderMetaPending () {
|
||||
const isMetaPending = this.props.metaPending;
|
||||
if (!isMetaPending) return;
|
||||
|
||||
return (<div>
|
||||
<p className={ styles['meta-info'] }>
|
||||
Meta-Data pending...
|
||||
</p>
|
||||
</div>);
|
||||
if (!isMetaPending) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<p className={ styles['meta-info'] }>
|
||||
Meta-Data pending...
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderMetaMined () {
|
||||
const isMetaMined = this.props.metaMined;
|
||||
if (!isMetaMined) return;
|
||||
|
||||
return (<div>
|
||||
<p className={ styles['meta-info'] }>
|
||||
Meta-Data saved on the blockchain!
|
||||
</p>
|
||||
</div>);
|
||||
if (!isMetaMined) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<p className={ styles['meta-info'] }>
|
||||
Meta-Data saved on the blockchain!
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
onUnregister = () => {
|
||||
|
||||
Reference in New Issue
Block a user