Skip to content

Commit

Permalink
chore: cleanup lint warnings (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton authored Jan 13, 2023
1 parent f953fe9 commit b87d61b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 54 deletions.
18 changes: 8 additions & 10 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"no-eval": "off",
"camelcase": ["error", { "properties": "never", "allow": [ "W[0-9]+_"] }],
"import/extensions": "off",
// TODOs - Temporarily disable rules, fix this progressively
// @TODO: Fix the following rules progressively.
"arrow-body-style": "warn",
"prefer-arrow-callback": "warn",
"prefer-object-spread": "off",
Expand All @@ -53,10 +53,9 @@
"no-prototype-builtins": "off",
"no-continue": "off",
"no-shadow": "off",
// Rules up for discussion
// Rules up for discussion.
"no-multi-assign": "off",
"new-cap": "off"
// TODOs - end
},
"overrides": [
{
Expand All @@ -71,30 +70,29 @@
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/no-unused-vars": [
"warn", // @TODO: change this to "error"
"warn",
{
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": true,
"argsIgnorePattern": "^_" // tsc compatibility
"argsIgnorePattern": "^_" // For tsc compatibility.
}
],
"comma-dangle": "off",
"implicit-arrow-linebreak": "off", // conflicts with prettier
"implicit-arrow-linebreak": "off", // Conflicts with prettier.
"import/extensions": "off",
"import/prefer-default-export": "off",
"operator-linebreak": "off",
"object-curly-newline": "off",
"prefer-rest-params": "off", // we need to use params
"prefer-rest-params": "off", // We need to use params.
"prettier/prettier": "error",
// @TODO - fix files to enable rules below this line
"@typescript-eslint/no-shadow": "warn",
"@typescript-eslint/no-use-before-define": "warn",
"@typescript-eslint/no-use-before-define": ["warn", { "functions": false }],
"import/no-cycle": "warn",
"no-bitwise": "off",
"no-unsafe-finally": "warn",
"no-param-reassign": "off",
"no-shadow": "warn",
"no-shadow": "warn"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ describe('VirtualEnvironment', () => {
get() {
return blueSetValue;
},
set(v) {
set(v: any) {
blueSetValue = v;
},
configurable: true,
Expand Down Expand Up @@ -252,13 +252,13 @@ describe('VirtualEnvironment', () => {
const a = {};
const b = {};
const calledWith = [];
ve.blueGetTransferableValue = (value) => {
calledWith.push(value);
return value;
ve.blueGetTransferableValue = (target: any) => {
calledWith.push(target);
return target;
};
ve.redCallableSetPrototypeOf = (a, b) => {
expect(a).toBe(calledWith[0]);
expect(b).toBe(calledWith[1]);
ve.redCallableSetPrototypeOf = (targetPointer: any, protoPointerOrNull: any) => {
expect(targetPointer).toBe(calledWith[0]);
expect(protoPointerOrNull).toBe(calledWith[1]);
};

ve.remapProto(a, b);
Expand Down
2 changes: 1 addition & 1 deletion packages/near-membrane-base/src/intrinsics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const ESGlobalKeys = [
];

// These are foundational things that should never be wrapped but are equivalent
// TODO: revisit this list.
// @TODO: Revisit this list.
const ReflectiveIntrinsicObjectNames = [
'AggregateError',
'Array',
Expand Down
12 changes: 3 additions & 9 deletions packages/near-membrane-base/src/membrane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1775,15 +1775,6 @@ export function createMembraneMarshall(
targetFunctionName,
targetTypedArrayLength
);
// The WeakMap is populated with the original target rather then the
// distorted one while the pointer always uses the distorted one.
// TODO: This mechanism poses another issue, which is that the return
// value of selectedTarget can never be used to call across the
// membrane because that will cause a wrapping around the potential
// distorted value instead of the original value. This is not fatal,
// but implies that for every distorted value where are two proxies
// that are not ===, which is weird. Guaranteeing this is not easy
// because it means auditing the code.
proxyPointerCache.set(originalTarget, proxyPointer);
return proxyPointer;
}
Expand Down Expand Up @@ -1846,6 +1837,7 @@ export function createMembraneMarshall(
target,
[key]
),
// eslint-disable-next-line @typescript-eslint/no-use-before-define
get: getUnforgeableGlobalThisGetter!(key),
set: undefined,
}
Expand All @@ -1861,6 +1853,7 @@ export function createMembraneMarshall(
// to obscure the getter source as "[native code]".
globalThisGetter = ReflectApply(
FunctionProtoBind,
// eslint-disable-next-line @typescript-eslint/no-use-before-define
unboundGlobalThisGetter,
[]
) as GlobalThisGetter;
Expand Down Expand Up @@ -2337,6 +2330,7 @@ export function createMembraneMarshall(
foreignTargetFunctionName: string,
foreignTargetTypedArrayLength: number
): Pointer {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
const { proxy } = new BoundaryProxyHandler(
foreignTargetPointer,
foreignTargetTraits,
Expand Down
2 changes: 1 addition & 1 deletion packages/near-membrane-dom/src/browser-realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function createIframeVirtualEnvironment(
// detach the iframe only if `options.keepAlive` isn't true.
if (keepAlive) {
aliveIframes.add(iframe);
// TODO: Temporary hack to preserve the document reference in Firefox.
// @TODO: Temporary hack to preserve the document reference in Firefox.
// https://bugzilla.mozilla.org/show_bug.cgi?id=543435
const { document: redDocument } = redWindow;
ReflectApply(DocumentProtoOpen, redDocument, []);
Expand Down
14 changes: 6 additions & 8 deletions test/environment/virtualenvironment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,14 @@ describe('VirtualEnvironment', () => {

const a = {};
const b = {};

const calledWith = [];

ve.blueGetTransferableValue = (value) => {
calledWith.push(value);
return value;
ve.blueGetTransferableValue = (target) => {
calledWith.push(target);
return target;
};
ve.redCallableSetPrototypeOf = (a, b) => {
expect(a).toBe(calledWith[0]);
expect(b).toBe(calledWith[1]);
ve.redCallableSetPrototypeOf = (targetPointer, protoPointerOrNull) => {
expect(targetPointer).toBe(calledWith[0]);
expect(protoPointerOrNull).toBe(calledWith[1]);
};

ve.remapProto(a, b);
Expand Down
34 changes: 16 additions & 18 deletions test/membrane/async-await.spec.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import createVirtualEnvironment from '@locker/near-membrane-dom';

// TODO #115 - Skip Firefox and Safari until we find a solution for them
// @TODO: Skip Firefox and Safari because their intrinsic Promise of await
// is not able to be remapped.
const isFirefox = navigator.userAgent.includes('Firefox/');
const isSafari = navigator.userAgent.includes('Safari/');
const skipTests = isFirefox || isSafari;

if (!skipTests) {
describe('async/await', () => {
it('basic wrapping', (done) => {
const env = createVirtualEnvironment(window, {
endowments: Object.getOwnPropertyDescriptors({ done, expect }),
});

env.evaluate(`
async function hello() {
return await "Hello";
}
hello().then((value) => {
expect(value).toBe("Hello");
done();
});
`);
describe('async/await', () => {
(skipTests ? xit : it)('basic wrapping', (done) => {
const env = createVirtualEnvironment(window, {
endowments: Object.getOwnPropertyDescriptors({ done, expect }),
});
env.evaluate(`
async function hello() {
return await "Hello";
}
hello().then((value) => {
expect(value).toBe("Hello");
done();
});
`);
});
}
});

0 comments on commit b87d61b

Please sign in to comment.