refactor: Enable consistent-this rule

This commit is contained in:
Joachim Van Herwegen 2024-03-12 14:51:55 +01:00
parent 5c1553bdda
commit c24e6d5a18
2 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,7 @@ module.exports = {
'arrow-body-style': [ 'error', 'as-needed', { requireReturnForObjectLiteral: false }],
'capitalized-comments': [ 'error', 'always', { ignoreConsecutiveComments: true }],
'consistent-this': 'error',
curly: [ 'error', 'all' ],
'default-case': 'error',
eqeqeq: [ 'error', 'always' ],

View File

@ -83,13 +83,13 @@ export abstract class QuotaStrategy {
*/
public async createQuotaGuard(identifier: ResourceIdentifier): Promise<Guarded<PassThrough>> {
let total = 0;
const strategy = this;
const that = this;
const { reporter } = this;
return guardStream(new PassThrough({
async transform(this, chunk: any, enc: string, done: () => void): Promise<void> {
total += await reporter.calculateChunkSize(chunk);
const availableSpace = await strategy.getAvailableSpace(identifier);
const availableSpace = await that.getAvailableSpace(identifier);
if (availableSpace.amount < total) {
this.destroy(new PayloadHttpError(
`Quota exceeded by ${total - availableSpace.amount} ${availableSpace.unit} during write`,