Skip to content

Commit

Permalink
addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-statsig committed Jun 14, 2023
1 parent c72dc3c commit 35c7674
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 33 deletions.
53 changes: 23 additions & 30 deletions custom_eslint/public-methods-error-boundary.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,29 @@ module.exports = {
}

const statments = method.value.body.body;
if(statments.length > 1) {
context.report({
node: statments[0],
message: `All code in public method should be contained inside a single errorBoundary statment.`,
});
continue;
}
const statment = method.value.body.body[0]

const arguement = statment.argument;
const isErrorBoundaryReturnStatment =
arguement?.callee?.object?.object?.type === 'ThisExpression' &&
arguement?.callee?.object?.property?.name === 'errorBoundary'

const expression = statment.expression;
const isErrorBoundaryExpression =
expression?.type === 'CallExpression' &&
expression?.callee?.object?.object?.type === 'ThisExpression' &&
expression?.callee?.object?.property?.name === 'errorBoundary';


const isGetter =
arguement?.type === "MemberExpression" &&
arguement?.property?.type === "Identifier"

if(!isErrorBoundaryReturnStatment && !isGetter && !isErrorBoundaryExpression){
context.report({
node: method,
message: `All code in public method should be contained inside a single errorBoundary statment.`,
});
for (const statment of statments) {
const arguement = statment.argument;
const isErrorBoundaryReturnStatment =
arguement?.callee?.object?.object?.type === 'ThisExpression' &&
arguement?.callee?.object?.property?.name === 'errorBoundary'

const expression = statment.expression;
const isErrorBoundaryExpression =
expression?.type === 'CallExpression' &&
expression?.callee?.object?.object?.type === 'ThisExpression' &&
expression?.callee?.object?.property?.name === 'errorBoundary';


const isGetter =
arguement?.type === "MemberExpression" &&
arguement?.property?.type === "Identifier"

if(!isErrorBoundaryReturnStatment && !isGetter && !isErrorBoundaryExpression){
context.report({
node: statment,
message: `All code in public method should be contained inside a single errorBoundary statment.`,
});
}
}
}
},
Expand Down
7 changes: 4 additions & 3 deletions src/StatsigClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,10 @@ export default class StatsigClient implements IHasStatsigInternal, IStatsig {
}

public async updateUser(user: StatsigUser | null): Promise<boolean> {
/* eslint-disable-next-line statsig-linter/public-methods-error-boundary */
const updateStartTime = Date.now();
let fireCompletionCallback: (
// eslint-disable-next-line statsig-linter/public-methods-error-boundary
const updateStartTime = Date.now();
// eslint-disable-next-line statsig-linter/public-methods-error-boundary
let fireCompletionCallback: (
success: boolean,
error: string | null,
) => void | null;
Expand Down

0 comments on commit 35c7674

Please sign in to comment.