1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Enforce a single boolean attr notation in JSX (#7465)

This changeset enables the ESLint rule enforcing a single notation for boolean
attributes in JSX—explictly setting the value to `true` is no longer allowed
(as it was never needed).[1]

From the docs for JSX:[2]

> If you pass no value for a prop, it defaults to `true`.

  [1]:https://github.com/yannickcr/eslint-plugin-react/blob/80935658/docs/rules/jsx-boolean-value.md
  [2]:https://reactjs.org/docs/jsx-in-depth.html#props-default-to-true

I have chosen to use this default as it the most consistent with HTML (a la
`checked` and `disabled`).
This commit is contained in:
Whymarrh Whitby 2019-11-18 19:53:41 -03:30 committed by GitHub
parent 86b165ea83
commit b0890b6b32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 35 additions and 34 deletions

View File

@ -148,6 +148,7 @@
"operator-linebreak": [2, "after", { "overrides": { "?": "ignore", ":": "ignore" } }], "operator-linebreak": [2, "after", { "overrides": { "?": "ignore", ":": "ignore" } }],
"padded-blocks": "off", "padded-blocks": "off",
"quotes": [2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}], "quotes": [2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}],
"react/jsx-boolean-value": 2,
"react/jsx-curly-brace-presence": [2, { "props": "never", "children": "never" }], "react/jsx-curly-brace-presence": [2, { "props": "never", "children": "never" }],
"react/jsx-equals-spacing": 2, "react/jsx-equals-spacing": 2,
"react/no-deprecated": 0, "react/no-deprecated": 0,

View File

@ -71,7 +71,7 @@ export default class AppHeader extends PureComponent {
<Identicon <Identicon
address={selectedAddress} address={selectedAddress}
diameter={32} diameter={32}
addBorder={true} addBorder
/> />
</div> </div>
) )
@ -92,7 +92,7 @@ export default class AppHeader extends PureComponent {
className={classnames('app-header', { 'app-header--back-drop': isUnlocked })}> className={classnames('app-header', { 'app-header--back-drop': isUnlocked })}>
<div className="app-header__contents"> <div className="app-header__contents">
<MetaFoxLogo <MetaFoxLogo
unsetIconHeight={true} unsetIconHeight
onClick={() => history.push(DEFAULT_ROUTE)} onClick={() => history.push(DEFAULT_ROUTE)}
/> />
<div className="app-header__account-menu-container"> <div className="app-header__account-menu-container">

View File

@ -11,7 +11,7 @@ describe('Dropdown Menu Components', () => {
beforeEach(() => { beforeEach(() => {
wrapper = shallow( wrapper = shallow(
<Menu className="Test Class" isShowing={true}/> <Menu className="Test Class" isShowing/>
) )
}) })

View File

@ -26,9 +26,9 @@ describe('AdvancedTabContent Component', function () {
timeRemaining="21500" timeRemaining="21500"
transactionFee="$0.25" transactionFee="$0.25"
insufficientBalance={false} insufficientBalance={false}
customPriceIsSafe={true} customPriceIsSafe
isSpeedUp={false} isSpeedUp={false}
isEthereumNetwork={true} isEthereumNetwork
/>) />)
}) })

View File

@ -23,7 +23,7 @@ export default class BasicTabContent extends Component {
{!gasPriceButtonGroupProps.loading {!gasPriceButtonGroupProps.loading
? <GasPriceButtonGroup ? <GasPriceButtonGroup
className="gas-price-button-group--alt" className="gas-price-button-group--alt"
showCheck={true} showCheck
{...gasPriceButtonGroupProps} {...gasPriceButtonGroupProps}
/> />
: <Loading /> : <Loading />

View File

@ -204,7 +204,7 @@ export default class GasModalPageContainer extends Component {
}} }}
submitText={this.context.t('save')} submitText={this.context.t('save')}
headerCloseText={this.context.t('close')} headerCloseText={this.context.t('close')}
hideCancel={true} hideCancel
/> />
</div> </div>
) )

View File

@ -200,7 +200,7 @@ describe('GasModalPageContainer Component', function () {
customGasLimitInHex="mockCustomGasLimitInHex" customGasLimitInHex="mockCustomGasLimitInHex"
insufficientBalance={false} insufficientBalance={false}
disableSave={false} disableSave={false}
hideBasic={true} hideBasic
/>) />)
const renderTabsResult = wrapper.instance().renderTabs() const renderTabsResult = wrapper.instance().renderTabs()

View File

@ -110,7 +110,7 @@ describe('Modal Component', () => {
cancelText="Cancel" cancelText="Cancel"
onSubmit={handleSubmit} onSubmit={handleSubmit}
submitText="Submit" submitText="Submit"
submitDisabled={true} submitDisabled
headerText="My Header" headerText="My Header"
onClose={handleCancel} onClose={handleCancel}
/> />

View File

@ -90,7 +90,7 @@ describe('TransactionActivityLog Component', () => {
onCancel={() => {}} onCancel={() => {}}
onRetry={() => {}} onRetry={() => {}}
primaryTransactionStatus="pending" primaryTransactionStatus="pending"
isEarliestNonce={true} isEarliestNonce
/>, />,
{ context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } } { context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } }
) )

View File

@ -70,7 +70,7 @@ describe('TransactionListItemDetails Component', () => {
const wrapper = shallow( const wrapper = shallow(
<TransactionListItemDetails <TransactionListItemDetails
transactionGroup={transactionGroup} transactionGroup={transactionGroup}
showSpeedUp={true} showSpeedUp
/>, />,
{ context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } } { context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } }
) )

View File

@ -53,7 +53,7 @@ export default class TransactionViewBalance extends PureComponent {
value={balance} value={balance}
type={PRIMARY} type={PRIMARY}
ethNumberOfDecimals={4} ethNumberOfDecimals={4}
hideTitle={true} hideTitle
/> />
{ {
balanceIsCached ? <span className="transaction-view-balance__cached-star">*</span> : null balanceIsCached ? <span className="transaction-view-balance__cached-star">*</span> : null
@ -69,7 +69,7 @@ export default class TransactionViewBalance extends PureComponent {
value={balance} value={balance}
type={SECONDARY} type={SECONDARY}
ethNumberOfDecimals={4} ethNumberOfDecimals={4}
hideTitle={true} hideTitle
/> />
) )
} }

View File

@ -18,7 +18,7 @@ describe('UserPreferencedCurrencyDisplay Component', () => {
it('should pass all props to the CurrencyDisplay child component', () => { it('should pass all props to the CurrencyDisplay child component', () => {
const wrapper = shallow( const wrapper = shallow(
<UserPreferencedCurrencyDisplay <UserPreferencedCurrencyDisplay
prop1={true} prop1
prop2="test" prop2="test"
prop3={1} prop3={1}
/> />

View File

@ -130,7 +130,7 @@ describe('CurrencyInput Component', () => {
fiatSuffix="USD" fiatSuffix="USD"
nativeSuffix="ETH" nativeSuffix="ETH"
useFiat useFiat
hideFiat={true} hideFiat
nativeCurrency="ETH" nativeCurrency="ETH"
currentCurrency="usd" currentCurrency="usd"
conversionRate={231.06} conversionRate={231.06}

View File

@ -16,7 +16,7 @@ describe('MetaFoxLogo', () => {
it('does not set icon height and width when unsetIconHeight is true', () => { it('does not set icon height and width when unsetIconHeight is true', () => {
const wrapper = mount( const wrapper = mount(
<MetaFoxLogo unsetIconHeight={true} /> <MetaFoxLogo unsetIconHeight />
) )
assert.equal(wrapper.find('img.app-header__metafox-logo--icon').prop('width'), null) assert.equal(wrapper.find('img.app-header__metafox-logo--icon').prop('width'), null)

View File

@ -13,7 +13,7 @@ describe('Page Container Header', () => {
onClose = sinon.spy() onClose = sinon.spy()
wrapper = shallow(<PageContainerHeader wrapper = shallow(<PageContainerHeader
showBackButton={true} showBackButton
onBackButtonClick={onBackButtonClick} onBackButtonClick={onBackButtonClick}
backButtonStyles={style} backButtonStyles={style}
title="Test Title" title="Test Title"

View File

@ -78,7 +78,7 @@ export default class ConfirmApprove extends Component {
<ConfirmTransactionBase <ConfirmTransactionBase
toAddress={toAddress} toAddress={toAddress}
identiconAddress={tokenAddress} identiconAddress={tokenAddress}
showAccountInHeader={true} showAccountInHeader
title={tokensText} title={tokensText}
contentComponent={<ConfirmApproveContent contentComponent={<ConfirmApproveContent
siteImage={siteImage} siteImage={siteImage}
@ -98,7 +98,7 @@ export default class ConfirmApprove extends Component {
ethTransactionTotal={ethTransactionTotal} ethTransactionTotal={ethTransactionTotal}
fiatTransactionTotal={fiatTransactionTotal} fiatTransactionTotal={fiatTransactionTotal}
/>} />}
hideSenderToRecipient={true} hideSenderToRecipient
customTxParamsData={customPermissionAmount customTxParamsData={customPermissionAmount
? getCustomTxParamsData(data, { customPermissionAmount, tokenAmount, decimals }) ? getCustomTxParamsData(data, { customPermissionAmount, tokenAmount, decimals })
: null : null

View File

@ -261,7 +261,7 @@ export default class ConfirmTransactionBase extends Component {
customGasPrice={customGas.gasPrice} customGasPrice={customGas.gasPrice}
customGasLimit={customGas.gasLimit} customGasLimit={customGas.gasLimit}
insufficientBalance={insufficientBalance} insufficientBalance={insufficientBalance}
customPriceIsSafe={true} customPriceIsSafe
isSpeedUp={false} isSpeedUp={false}
/> />
: null : null

View File

@ -47,17 +47,17 @@ export default class CreateAccountPage extends Component {
<div className="new-account__form"> <div className="new-account__form">
<Switch> <Switch>
<Route <Route
exact={true} exact
path={NEW_ACCOUNT_ROUTE} path={NEW_ACCOUNT_ROUTE}
component={NewAccountCreateForm} component={NewAccountCreateForm}
/> />
<Route <Route
exact={true} exact
path={IMPORT_ACCOUNT_ROUTE} path={IMPORT_ACCOUNT_ROUTE}
component={NewAccountImportForm} component={NewAccountImportForm}
/> />
<Route <Route
exact={true} exact
path={CONNECT_HARDWARE_ROUTE} path={CONNECT_HARDWARE_ROUTE}
component={ConnectHardwareForm} component={ConnectHardwareForm}
/> />

View File

@ -58,13 +58,13 @@ export default class NewAccountCreateForm extends Component {
<div className="new-account-create-form__buttons"> <div className="new-account-create-form__buttons">
<Button <Button
type="default" type="default"
large={true} large
className="new-account-create-form__button" className="new-account-create-form__button"
onClick={() => history.push(DEFAULT_ROUTE)} onClick={() => history.push(DEFAULT_ROUTE)}
>{this.context.t('cancel')}</Button> >{this.context.t('cancel')}</Button>
<Button <Button
type="secondary" type="secondary"
large={true} large
className="new-account-create-form__button" className="new-account-create-form__button"
onClick={createClick} onClick={createClick}
>{this.context.t('create')}</Button> >{this.context.t('create')}</Button>

View File

@ -83,7 +83,7 @@ export default class AccountListItem extends Component {
<UserPreferencedCurrencyDisplay <UserPreferencedCurrencyDisplay
type={PRIMARY} type={PRIMARY}
value={balance} value={balance}
hideTitle={true} hideTitle
/> />
{ {
balanceIsCached ? <span className="account-list-item__cached-star">*</span> : null balanceIsCached ? <span className="account-list-item__cached-star">*</span> : null
@ -94,7 +94,7 @@ export default class AccountListItem extends Component {
<UserPreferencedCurrencyDisplay <UserPreferencedCurrencyDisplay
type={SECONDARY} type={SECONDARY}
value={balance} value={balance}
hideTitle={true} hideTitle
/> />
) )
} }

View File

@ -130,7 +130,7 @@ export default class SendGasRow extends Component {
customGasPrice={gasPrice} customGasPrice={gasPrice}
customGasLimit={gasLimit} customGasLimit={gasLimit}
insufficientBalance={insufficientBalance} insufficientBalance={insufficientBalance}
customPriceIsSafe={true} customPriceIsSafe
isSpeedUp={false} isSpeedUp={false}
/> />
{ this.renderAdvancedOptionsButton() } { this.renderAdvancedOptionsButton() }

View File

@ -16,7 +16,7 @@ describe('SendContent Component', function () {
beforeEach(() => { beforeEach(() => {
wrapper = shallow( wrapper = shallow(
<SendContent <SendContent
showHexData={true} showHexData
/>, />,
{ context: { t: str => str + '_t' } } { context: { t: str => str + '_t' } }
) )

View File

@ -29,7 +29,7 @@ describe('SendFooter Component', function () {
addToAddressBookIfNew={propsMethodSpies.addToAddressBookIfNew} addToAddressBookIfNew={propsMethodSpies.addToAddressBookIfNew}
amount="mockAmount" amount="mockAmount"
clearSend={propsMethodSpies.clearSend} clearSend={propsMethodSpies.clearSend}
disabled={true} disabled
editingTransactionId="mockEditingTransactionId" editingTransactionId="mockEditingTransactionId"
errors={{}} errors={{}}
from={ { address: 'mockAddress', balance: 'mockBalance' } } from={ { address: 'mockAddress', balance: 'mockBalance' } }
@ -186,7 +186,7 @@ describe('SendFooter Component', function () {
addToAddressBookIfNew={propsMethodSpies.addToAddressBookIfNew} addToAddressBookIfNew={propsMethodSpies.addToAddressBookIfNew}
amount="mockAmount" amount="mockAmount"
clearSend={propsMethodSpies.clearSend} clearSend={propsMethodSpies.clearSend}
disabled={true} disabled
editingTransactionId="mockEditingTransactionId" editingTransactionId="mockEditingTransactionId"
errors={{}} errors={{}}
from={ { address: 'mockAddress', balance: 'mockBalance' } } from={ { address: 'mockAddress', balance: 'mockBalance' } }

View File

@ -58,7 +58,7 @@ describe('Send Component', function () {
recentBlocks={['mockBlock']} recentBlocks={['mockBlock']}
selectedAddress="mockSelectedAddress" selectedAddress="mockSelectedAddress"
selectedToken="mockSelectedToken" selectedToken="mockSelectedToken"
showHexData={true} showHexData
tokenBalance="mockTokenBalance" tokenBalance="mockTokenBalance"
tokenContract="mockTokenContract" tokenContract="mockTokenContract"
updateAndSetGasLimit={propsMethodSpies.updateAndSetGasLimit} updateAndSetGasLimit={propsMethodSpies.updateAndSetGasLimit}

View File

@ -61,7 +61,7 @@ export default class ToAutoComplete extends Component {
}} }}
icon={this.getListItemIcon(account.address, to)} icon={this.getListItemIcon(account.address, to)}
displayBalance={false} displayBalance={false}
displayAddress={true} displayAddress
/> />
))} ))}
</div> </div>

View File

@ -100,7 +100,7 @@ export default class EditContact extends PureComponent {
onChange={e => this.setState({ newMemo: e.target.value })} onChange={e => this.setState({ newMemo: e.target.value })}
fullWidth fullWidth
margin="dense" margin="dense"
multiline={true} multiline
rows={3} rows={3}
classes={{ classes={{
inputMultiline: 'address-book__view-contact__text-area', inputMultiline: 'address-book__view-contact__text-area',