Skip to content

Commit

Permalink
Add lint rule for no-loops and exclude script files #380
Browse files Browse the repository at this point in the history
  • Loading branch information
will-byrne committed Mar 17, 2021
1 parent 13b4240 commit e28f24f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Expand Up @@ -20,6 +20,7 @@ module.exports = {
'jest',
'jest-formatting',
'node',
'no-loops',
'unused-imports',
],
root: true,
Expand Down Expand Up @@ -82,6 +83,7 @@ module.exports = {
ignoreUrls: true,
}],
'no-await-in-loop': 'off',
'no-loops/no-loops': 2,
'no-restricted-syntax': ['error', ...[
'ForInStatement',
'LabeledStatement',
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -79,6 +79,7 @@
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.3.1",
"eslint-plugin-jest-formatting": "^2.0.1",
"eslint-plugin-no-loops": "^0.3.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-unused-imports": "^1.1.0",
"jest": "^26.6.3",
Expand Down
1 change: 1 addition & 0 deletions scripts/find-reviews-from-crossref-via-biorxiv.ts
@@ -1,3 +1,4 @@
/* eslint-disable no-loops/no-loops */
import axios from 'axios';

const publisherDoiPrefix = process.argv[2];
Expand Down
1 change: 1 addition & 0 deletions scripts/find-reviews-from-hypothesis.ts
Expand Up @@ -33,6 +33,7 @@ const processServer = async (server: string): Promise<void> => {

const numRequestsNeeded = Math.ceil(firstPage.total / perPage);

// eslint-disable-next-line no-loops/no-loops
for (let i = 1; i < numRequestsNeeded; i += 1) {
const { data } = await axios.get<HypothesisResponse>(`https://api.hypothes.is/api/search?group=${publisherGroupId}&uri.parts=${server}&limit=${perPage}&offset=${perPage * i}`);
data.rows.forEach(processRow(server));
Expand Down
1 change: 1 addition & 0 deletions scripts/find-reviews-from-pci.ts
Expand Up @@ -45,6 +45,7 @@ const findRecommendations = async (community: PciCommunity): Promise<Array<Recom
const { data: feed } = await fetchPage(community.url);
const doc = parser.parseFromString(feed, 'text/xml');

// eslint-disable-next-line no-loops/no-loops
for (const link of Array.from(doc.getElementsByTagName('link'))) {
const url = link.getElementsByTagName('url')[0];
const articleDoiString = link.getElementsByTagName('doi')[0]?.textContent ?? '';
Expand Down
1 change: 1 addition & 0 deletions scripts/find-reviews-from-prereview.ts
Expand Up @@ -44,6 +44,7 @@ void (async (): Promise<void> => {

let currentPage = 1;
let totalPages = NaN;
// eslint-disable-next-line no-loops/no-loops
do {
const { data } = await axios.post<PrereviewSearchResponse>(
'https://www.prereview.org/data/preprints/search',
Expand Down

0 comments on commit e28f24f

Please sign in to comment.