Fix no-plusplus issues (#9206)

See [`no-plusplus`](https://eslint.org/docs/rules/no-plusplus) for more information.

This change enables `no-plusplus` and fixes the issues raised by the rule.
feature/default_network_editable
Whymarrh Whitby 4 years ago committed by GitHub
parent 548b0bbbd5
commit 310b15ba4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .eslintrc.js
  2. 2
      app/scripts/controllers/transactions/index.js
  3. 1
      app/scripts/lib/random-id.js
  4. 4
      app/scripts/metamask-controller.js
  5. 2
      app/scripts/migrations/019.js
  6. 2
      development/sourcemap-validator.js
  7. 4
      test/unit/migrations/023-test.js
  8. 2
      ui/app/components/app/gas-customization/gas-price-chart/gas-price-chart.utils.js
  9. 1
      ui/app/components/app/modals/fade-modal.js
  10. 4
      ui/app/pages/mobile-sync/mobile-sync.component.js

@ -51,6 +51,7 @@ module.exports = {
'no-empty': 'error',
'no-eq-null': 'error',
'no-loop-func': 'error',
'no-plusplus': ['error', { 'allowForLoopAfterthoughts': true }],
'no-useless-catch': 'error',
'no-useless-concat': 'error',
/* End v2 rules */

@ -684,7 +684,7 @@ export default class TransactionController extends EventEmitter {
if (!('retryCount' in txMeta)) {
txMeta.retryCount = 0
}
txMeta.retryCount++
txMeta.retryCount += 1
this.txStateManager.updateTx(txMeta, 'transactions/pending-tx-tracker#event: tx:retry')
})
}

@ -3,5 +3,6 @@ const MAX = Number.MAX_SAFE_INTEGER
let idCounter = Math.round(Math.random() * MAX)
export default function createRandomId () {
idCounter = idCounter % MAX
// eslint-disable-next-line no-plusplus
return idCounter++
}

@ -1519,7 +1519,7 @@ export default class MetamaskController extends EventEmitter {
const api = this.getApi()
const dnode = Dnode(api)
// report new active controller connection
this.activeControllerConnections++
this.activeControllerConnections += 1
this.emit('controllerConnectionChanged', this.activeControllerConnections)
// connect dnode api to remote connection
pump(
@ -1528,7 +1528,7 @@ export default class MetamaskController extends EventEmitter {
outStream,
(err) => {
// report new active controller connection
this.activeControllerConnections--
this.activeControllerConnections -= 1
this.emit('controllerConnectionChanged', this.activeControllerConnections)
// report any error
if (err) {

@ -72,7 +72,7 @@ function getHighestContinuousFrom (txList, startPoint) {
let highest = startPoint
while (nonces.includes(highest)) {
highest++
highest += 1
}
return highest

@ -91,7 +91,7 @@ async function validateSourcemapForFile ({ buildName }) {
const matchesPerLine = buildLines.map((line) => indicesOf(targetString, line))
matchesPerLine.forEach((matchIndices, lineIndex) => {
matchIndices.forEach((matchColumn) => {
sampleCount++
sampleCount += 1
const position = { line: lineIndex + 1, column: matchColumn }
const result = consumer.originalPositionFor(position)
// warn if source content is missing

@ -41,7 +41,7 @@ while (transactions.length <= 100) {
// This is an old migration, let's allow it
// eslint-disable-next-line no-loop-func
if (!deletableTxStates.find((s) => s === status)) {
nonDeletableCount++
nonDeletableCount += 1
}
transactions.push({ status })
}
@ -67,7 +67,7 @@ describe('storage is migrated successfully and the proper transactions are remov
const migratedTransactions = migratedData.data.TransactionController.transactions
migratedTransactions.forEach((tx) => {
if (!deletableTxStates.find((s) => s === tx.status)) {
leftoverNonDeletableTxCount++
leftoverNonDeletableTxCount += 1
}
})
assert.equal(leftoverNonDeletableTxCount, nonDeletableCount, "migration shouldn't delete transactions we want to keep")

@ -163,7 +163,7 @@ export function setSelectedCircle ({
while (lowerX === higherX) {
higherX = getCoordinateData(`.c3-circle-${count}`).x
higherY = getCoordinateData(`.c3-circle-${count}`).y
count++
count += 1
}
}

@ -22,6 +22,7 @@ const insertRule = (css) => {
const insertKeyframesRule = (keyframes) => {
// random name
// eslint-disable-next-line no-plusplus
const name = 'anim_' + (++index) + (+new Date())
let css = `@keyframes ${name} {`

@ -173,8 +173,10 @@ export default class MobileSyncPage extends Component {
chunkString (str, size) {
const numChunks = Math.ceil(str.length / size)
const chunks = new Array(numChunks)
for (let i = 0, o = 0; i < numChunks; ++i, o += size) {
for (let i = 0, o = 0; i < numChunks;) {
chunks[i] = str.substr(o, size)
i += 1
o += size
}
return chunks
}

Loading…
Cancel
Save