Skip to content

Commit e168521

Browse files
foolipgsnedders
authored andcommitted
Run eslint on all code
But don't bother fixing line lengths for existing code.
1 parent 35c4b0f commit e168521

File tree

6 files changed

+155
-143
lines changed

6 files changed

+155
-143
lines changed

git-write.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable max-len */
2+
13
'use strict';
24

35
const fetch = require('node-fetch');
@@ -31,7 +33,7 @@ async function writeReportToGit(report, repo, commitMessage, tagName) {
3133
// tree is traversed depth first to write all of the trees.
3234
async function emptyTree() {
3335
const builder = await Git.Treebuilder.create(repo, null);
34-
return { builder, subtrees: new Map };
36+
return {builder, subtrees: new Map};
3537
}
3638

3739
const rootTree = await emptyTree();
@@ -58,10 +60,10 @@ async function writeReportToGit(report, repo, commitMessage, tagName) {
5860
return tree.builder.write();
5961
}
6062

61-
let blobCache = new Map;
63+
const blobCache = new Map;
6264

6365
function isJSONObject(v) {
64-
return typeof v === "object" && v !== null && !Array.isArray(v);
66+
return typeof v === 'object' && v !== null && !Array.isArray(v);
6567
}
6668

6769
// Keep only a fixed set of keys. This filters out at least:
@@ -72,9 +74,10 @@ async function writeReportToGit(report, repo, commitMessage, tagName) {
7274
// - "screenshots" which contains screenshot hashes
7375
// - "test" which is the test path, and will be represented elsewhere
7476
// Note that "" is the dummy key value for the initial object.
75-
const keepKeys = new Set(["", "name", "status", "subtests"]);
77+
const keepKeys = new Set(['', 'name', 'status', 'subtests']);
7678

7779
function replacer(key, value) {
80+
// eslint-disable-next-line no-invalid-this
7881
if (isJSONObject(this)) {
7982
if (!keepKeys.has(key)) {
8083
return undefined;

lib/browser-specific.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable max-len */
2+
13
'use strict';
24

35
/**

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ const browserSpecific = require('./browser-specific');
44
const results = require('./results');
55
const runs = require('./runs');
66

7-
module.exports = { browserSpecific, results, runs };
7+
module.exports = {browserSpecific, results, runs};

lib/results.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable max-len */
2+
13
'use strict';
24

35
/**
@@ -48,12 +50,16 @@ function oidToKey(oid) {
4850

4951
const newTreeId = (() => {
5052
let id = 0;
51-
return () => { return ++id; };
53+
return () => {
54+
return ++id;
55+
};
5256
})();
5357

5458
const newTestId = (() => {
5559
let id = 0;
56-
return () => { return ++id; };
60+
return () => {
61+
return ++id;
62+
};
5763
})();
5864

5965
async function readResults(entry) {
@@ -72,16 +78,17 @@ async function readResults(entry) {
7278
const buffer = blob.content();
7379
const results = JSON.parse(buffer);
7480

75-
if (results.id !== undefined)
81+
if (results.id !== undefined) {
7682
throw new Error('Results JSON already has an "id" field; code needs changed');
83+
}
7784
results.id = newTestId();
7885

7986
testCache[key] = results;
8087
return results;
8188
}
8289

8390
async function readTree(treeOrEntry) {
84-
let tree, entry, oid;
91+
let tree; let entry; let oid;
8592
if (treeOrEntry instanceof Git.Tree) {
8693
tree = treeOrEntry;
8794
oid = tree.id();
@@ -121,7 +128,7 @@ async function readTree(treeOrEntry) {
121128
name = decodeURIComponent(name.substr(0, name.length - 5));
122129
newTree.tests[name] = await readResults(entry);
123130
} else {
124-
throw new TypeError('y not tree or blob?')
131+
throw new TypeError('y not tree or blob?');
125132
}
126133
}
127134

@@ -157,18 +164,14 @@ async function getLocalRunIds(repo) {
157164
//
158165
// Where test_results is an object as described in the module documentation.
159166
function walkTests(tree, visitor, path='') {
160-
const subtrees = tree.trees;
161-
for (const dir in subtrees) {
162-
const subtree = subtrees[dir];
167+
for (const [dir, subtree] of Object.entries(tree.trees)) {
163168
walkTests(subtree, visitor, `${path}/${dir}`);
164169
}
165170

166-
const tests = tree.tests;
167-
for (const name in tests) {
168-
const results = tests[name];
171+
for (const [name, results] of Object.entries(tree.tests)) {
169172
visitor(path, name, results);
170173
}
171174
}
172175

173176
// treeCache, testCache exposed only for git-query.js to report memory stats.
174-
module.exports = { getGitTree, getLocalRunIds, walkTests, treeCache, testCache };
177+
module.exports = {getGitTree, getLocalRunIds, walkTests, treeCache, testCache};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"scripts": {
1111
"install": "git clone --bare https://github.com/web-platform-tests/results-analysis-cache.git && git --git-dir=results-analysis-cache.git remote set-url --push origin [email protected]:web-platform-tests/results-analysis-cache.git || git --git-dir=results-analysis-cache.git fetch --tags",
12-
"lint": "eslint browser-specific-failures.js lib/browser-specific.js lib/runs.js compat-2021/main.js interop-2022/main.js interop-scoring/main.js",
12+
"lint": "eslint .",
1313
"test": "npm run lint && npm run test-unit",
1414
"test-unit": "mocha -u bdd ./test/*.js"
1515
},

0 commit comments

Comments
 (0)