Skip to content

Commit 561a1ee

Browse files
author
David Reed
committed
run ESLint
Several bugs were found (and fixed): src/client/index.js:71 the following if() was equivalent to if (false in obj) src/client/dom/element.js:207 the following if() was equivalent to if (!element || false in element) src/client/rewrite/html.js:179 an undefined iterate() was referenced
1 parent f0611a9 commit 561a1ee

19 files changed

+161
-220
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

.eslintrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"worker": true,
5+
"serviceworker": true,
6+
"es6": true,
7+
"node": true
8+
},
9+
"globals": { "globalThis": true, "importScripts": true },
10+
"parserOptions": { "sourceType": "module", "ecmaVersion": "latest" },
11+
"extends": ["eslint:recommended"]
12+
}

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

package-lock.json

Lines changed: 76 additions & 137 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"devDependencies": {
3333
"copy-webpack-plugin": "^11.0.0",
3434
"cross-env": "^7.0.3",
35-
"eslint": "^8.8.0",
35+
"eslint": "^8.28.0",
3636
"prettier": "^2.7.1",
3737
"terser-webpack-plugin": "^5.3.6",
3838
"webpack": "^5.74.0",

src/client/dom/document.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,21 +193,6 @@ class DocumentHook extends EventEmitter {
193193
},
194194
});
195195
}
196-
overrideReferrer() {
197-
this.ctx.overrideDescriptor(this.docProto, 'referrer', {
198-
get: (target, that) => {
199-
const event = new HookEvent(
200-
{ value: target.call(that) },
201-
target,
202-
that
203-
);
204-
this.emit('referrer', event);
205-
206-
if (event.intercepted) return event.returnValue;
207-
return event.data.value;
208-
},
209-
});
210-
}
211196
overrideCookie() {
212197
this.ctx.overrideDescriptor(this.docProto, 'cookie', {
213198
get: (target, that) => {

src/client/dom/element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class ElementApi extends EventEmitter {
204204
);
205205
}
206206
hookProperty(element, prop, handler) {
207-
if (!element || !prop in element) return false;
207+
if (!element || !(prop in element)) return false;
208208

209209
if (this.ctx.nativeMethods.isArray(element)) {
210210
for (const elem of element) {

src/client/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class UVClient extends EventEmitter {
6868
);
6969
}
7070
override(obj, prop, wrapper, construct) {
71-
if (!prop in obj) return false;
71+
if (!(prop in obj)) return false;
7272
const wrapped = this.wrap(obj, prop, wrapper, construct);
7373
return (obj[prop] = wrapped);
7474
}
@@ -92,7 +92,7 @@ class UVClient extends EventEmitter {
9292
},
9393
}.attach;
9494

95-
if (!!construct) {
95+
if (construct) {
9696
wrapped.prototype = fn.prototype;
9797
wrapped.prototype.constructor = wrapped;
9898
}

src/client/location.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class LocationApi extends EventEmitter {
3737

3838
for (const key of this.keys) {
3939
this.ctx.overrideDescriptor(this.workerLocProto, key, {
40-
get: (target, that) => {
40+
get: () => {
4141
return parse(uv.href.get.call(this.location))[key];
4242
},
4343
});
@@ -78,9 +78,12 @@ class LocationApi extends EventEmitter {
7878
);
7979
break;
8080
default:
81-
const url = new URL(emulation.href);
82-
url[key] = val;
83-
that.location.href = wrap(url.href);
81+
{
82+
const url = new URL(emulation.href);
83+
url[key] = val;
84+
that.location.href = wrap(url.href);
85+
}
86+
break;
8487
}
8588
}
8689
: undefined,

src/rewrite/cookie.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function validateCookie(cookie, meta, js = false) {
2121

2222
async function db(openDB) {
2323
const db = await openDB('__op', 1, {
24-
upgrade(db, oldVersion, newVersion, transaction) {
24+
upgrade(db) {
2525
const store = db.createObjectStore('cookies', {
2626
keyPath: 'id',
2727
});

0 commit comments

Comments
 (0)