Skip to content

Commit

Permalink
Merge pull request #7983 from Agoric/ta/lint-forEach
Browse files Browse the repository at this point in the history
lint forEach
  • Loading branch information
turadg authored Jun 24, 2023
2 parents 48da763 + e1667f3 commit 2baa932
Show file tree
Hide file tree
Showing 10 changed files with 338 additions and 20 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-jessie": "^0.0.6",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-github": "^4.8.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsdoc": "^40.1.0",
"eslint-plugin-prettier": "^4.2.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config/eslint-config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
'plugin:jsdoc/recommended',
'prettier',
],
plugins: ['import'],
plugins: ['import', 'github'],
rules: {
'arrow-body-style': 'off',
'arrow-parens': 'off',
Expand Down Expand Up @@ -49,6 +49,8 @@ module.exports = {
},
],

'github/array-foreach': 'warn',

// Work around https://github.com/import-js/eslint-plugin-import/issues/1810
'import/no-unresolved': ['error', { ignore: ['ava'] }],
'import/prefer-default-export': 'off',
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@typescript-eslint/parser": "^5.59.11",
"eslint": "^8.36.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-github": "^4.8.0",
"eslint-config-jessie": "^0.0.6",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.25.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/governance/src/contractGovernance/paramManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ const makeParamManagerBuilder = (publisherKit, zoe) => {
const prepared = await Promise.all(asyncResults);

// actually update
paramNames.forEach((name, i) => {
for (const [i, name] of paramNames.entries()) {
const setFn = setters[`update${name}`];
setFn(prepared[i]);
});
}
publish();
};

Expand Down
4 changes: 2 additions & 2 deletions packages/governance/src/multiCandidateVoteCounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ const makeMultiCandidateVoteCounter = (
chosenPositions.length <= maxChoices ||
Fail`The number of choices exceeds the max choices.`;

chosenPositions.forEach(position => {
for (const position of chosenPositions) {
positionIncluded(positions, position) ||
Fail`The specified choice is not a legal position: ${position}.`;
});
}

const completedBallot = harden({ chosen: chosenPositions, shares });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ const build = async (log, zoe) => {
const { voter } = E.get(E(seat).getOfferResult());

const voteMap = new Map();
choices.forEach(entry => {
const [issue, position] = entry;
for (const [issue, position] of choices) {
voteMap.set(issue.text, position);
});
}
const votingObserver = Far('voting observer', {
updateState: details => {
const choice = voteMap.get(details.issue.text);
Expand Down
4 changes: 3 additions & 1 deletion packages/inter-protocol/src/proposals/core-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export const storeInterContractStartKits = async ({
const storeAll = async (storeP, kitPs) => {
const store = await storeP;
const kits = await Promise.all(kitPs);
kits.forEach(kit => store.init(kit.instance, kit));
for (const kit of kits) {
store.init(kit.instance, kit);
}
};

await storeAll(contractKits, [
Expand Down
4 changes: 2 additions & 2 deletions packages/inter-protocol/test/test-clientSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test('Offers.auction.Bid', async t => {
{ cliArg: -0.1, offerBidScaling: makeRatio(110n, ist.brand, 100n) },
];

discounts.forEach(({ cliArg, offerBidScaling }) => {
for (const { cliArg, offerBidScaling } of discounts) {
t.log('discount', cliArg * 100, '%');
t.deepEqual(
Offers.auction.Bid(agoricNames, {
Expand All @@ -70,7 +70,7 @@ test('Offers.auction.Bid', async t => {
},
},
);
});
}

const price = 7;
const offerPrice = makeRatio(7n, ist.brand, 1n, atom.brand);
Expand Down
4 changes: 2 additions & 2 deletions packages/inter-protocol/test/test-gov-collateral.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ const makeScenario = async (t, { env = process.env } = {}) => {
return [addr, purse];
}),
);
Object.values(voterAddresses).forEach(addr => {
for (const addr of Object.values(voterAddresses)) {
const { nameHub, nameAdmin: myAddressNameAdmin } = makeNameHubKit();
const depositFacet = Far('depositFacet', {
receive: pmt => {
Expand All @@ -242,7 +242,7 @@ const makeScenario = async (t, { env = process.env } = {}) => {
});
myAddressNameAdmin.update('depositFacet', depositFacet);
nameAdmin.update(addr, nameHub, myAddressNameAdmin);
});
}
return purses;
};

Expand Down
Loading

0 comments on commit 2baa932

Please sign in to comment.