Skip to content

Commit c6f9dfe

Browse files
authored
ref: Drop no-plusplus rule & refactor to use ++ / -- (#6327)
1 parent 1a9d0fc commit c6f9dfe

File tree

20 files changed

+24
-36
lines changed

20 files changed

+24
-36
lines changed

packages/browser/src/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export function shouldIgnoreOnError(): boolean {
2525
*/
2626
export function ignoreNextOnError(): void {
2727
// onerror should trigger before setTimeout
28-
ignoreOnError += 1;
28+
ignoreOnError++;
2929
setTimeout(() => {
30-
ignoreOnError -= 1;
30+
ignoreOnError--;
3131
});
3232
}
3333

packages/browser/test/integration/polyfills/promise.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@
102102
observer.observe(node, { characterData: true });
103103

104104
return function () {
105-
// eslint-disable-next-line no-plusplus
106105
node.data = iterations = ++iterations % 2;
107106
};
108107
}
@@ -468,11 +467,11 @@
468467

469468
var id = 0;
470469
function nextId() {
471-
return (id += 1);
470+
return ++id;
472471
}
473472

474473
function makePromise(promise) {
475-
promise[PROMISE_ID] = id += 1;
474+
promise[PROMISE_ID] = ++id;
476475
promise._state = undefined;
477476
promise._result = undefined;
478477
promise._subscribers = [];
@@ -535,7 +534,7 @@
535534
if (_then === then && entry._state !== PENDING) {
536535
this._settledAt(entry._state, i, entry._result);
537536
} else if (typeof _then !== 'function') {
538-
this._remaining -= 1;
537+
this._remaining--;
539538
this._result[i] = entry;
540539
} else if (c === Promise$2) {
541540
var promise = new c(noop);
@@ -562,7 +561,7 @@
562561
var promise = this.promise;
563562

564563
if (promise._state === PENDING) {
565-
this._remaining -= 1;
564+
this._remaining--;
566565

567566
if (state === REJECTED) {
568567
reject(promise, value);

packages/core/src/baseclient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,14 +714,14 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
714714
* Occupies the client with processing and event
715715
*/
716716
protected _process<T>(promise: PromiseLike<T>): void {
717-
this._numProcessing += 1;
717+
this._numProcessing++;
718718
void promise.then(
719719
value => {
720-
this._numProcessing -= 1;
720+
this._numProcessing--;
721721
return value;
722722
},
723723
reason => {
724-
this._numProcessing -= 1;
724+
this._numProcessing--;
725725
return reason;
726726
},
727727
);

packages/core/test/mocks/transport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export function makeFakeTransport(delay: number = 2000): {
1818
let sentCount = 0;
1919
const makeTransport = () =>
2020
createTransport({ recordDroppedEvent: () => undefined, textEncoder: new TextEncoder() }, () => {
21-
sendCalled += 1;
21+
sendCalled++;
2222
return new SyncPromise(async res => {
2323
await sleep(delay);
24-
sentCount += 1;
24+
sentCount++;
2525
res({});
2626
});
2727
});

packages/eslint-config-sdk/src/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,6 @@ module.exports = {
196196
],
197197

198198
rules: {
199-
// We want to prevent usage of unary operators outside of for loops
200-
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
201-
202199
// Disallow usage of console and alert
203200
'no-console': 'error',
204201
'no-alert': 'error',

packages/gatsby/test/integration.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('useEffect', () => {
2222
onClientEntry(undefined, {
2323
beforeSend: (event: any) => {
2424
expect(event).not.toBeUndefined();
25-
calls += 1;
25+
calls++;
2626

2727
return null;
2828
},

packages/integration-tests/utils/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async function getMultipleRequests(
6969
function requestHandler(request: Request): void {
7070
if (urlRgx.test(request.url())) {
7171
try {
72-
reqCount -= 1;
72+
reqCount--;
7373
requestData.push(requestParser(request));
7474

7575
if (reqCount === 0) {

packages/integration-tests/utils/web-vitals/cls.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async function moveBy(elem: HTMLParagraphElement, percent: number): Promise<void
2525
if (elem.getAttribute('id') === 'partial') {
2626
const max = Number(elem.getAttribute('max-steps'));
2727
let current = Number(elem.getAttribute('steps'));
28-
current += 1;
28+
current++;
2929
if (current > max) {
3030
return;
3131
}
@@ -52,7 +52,7 @@ function howMany(desiredCls: number): { extraSteps: number; createParagraphs: nu
5252
const extraSteps = Math.round((desiredCls - fullRuns * 0.095) / 0.005);
5353
let create = fullRuns;
5454
if (extraSteps > 0) {
55-
create += 1;
55+
create++;
5656
}
5757

5858
return { extraSteps: extraSteps, createParagraphs: create };

packages/node/src/integrations/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ function _createWrappedRequestMethodFactory(
247247

248248
const transaction = parentSpan.transaction;
249249
if (transaction) {
250-
transaction.metadata.propagations += 1;
250+
transaction.metadata.propagations++;
251251
}
252252
}
253253
}

packages/replay/.eslintrc.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ module.exports = {
6565
'@typescript-eslint/no-floating-promises': 'off',
6666
// TODO (medium-prio): Re-enable this after migration
6767
'jsdoc/require-jsdoc': 'off',
68-
// TODO: Do we even want to turn this on? Why not enable ++?
69-
'no-plusplus': 'off',
7068
},
7169
},
7270
{

packages/tracing/src/browser/request.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export function fetchCallback(
216216
options,
217217
);
218218

219-
activeTransaction.metadata.propagations += 1;
219+
activeTransaction.metadata.propagations++;
220220
}
221221
}
222222
}
@@ -351,7 +351,7 @@ export function xhrCallback(
351351
handlerData.xhr.setRequestHeader(BAGGAGE_HEADER_NAME, sentryBaggageHeader);
352352
}
353353

354-
activeTransaction.metadata.propagations += 1;
354+
activeTransaction.metadata.propagations++;
355355
} catch (_) {
356356
// Error: InvalidStateError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.
357357
}

packages/tracing/src/idletransaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export class IdleTransaction extends Transaction {
265265
const heartbeatString = Object.keys(this.activities).join('');
266266

267267
if (heartbeatString === this._prevHeartbeatString) {
268-
this._heartbeatCounter += 1;
268+
this._heartbeatCounter++;
269269
} else {
270270
this._heartbeatCounter = 1;
271271
}

packages/utils/src/browser.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export function htmlTreeAsString(elem: unknown, keyAttrs?: string[]): string {
3030
const sepLength = separator.length;
3131
let nextStr;
3232

33-
// eslint-disable-next-line no-plusplus
3433
while (currentElem && height++ < MAX_TRAVERSE_HEIGHT) {
3534
nextStr = _htmlElementAsString(currentElem, keyAttrs);
3635
// bail out if

packages/utils/src/instrument.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ function instrumentDOM(): void {
526526
originalAddEventListener.call(this, type, handler, options);
527527
}
528528

529-
handlerForType.refCount += 1;
529+
handlerForType.refCount++;
530530
} catch (e) {
531531
// Accessing dom properties is always fragile.
532532
// Also allows us to skip `addEventListenrs` calls with no proper `this` context.
@@ -554,7 +554,7 @@ function instrumentDOM(): void {
554554
const handlerForType = handlers[type];
555555

556556
if (handlerForType) {
557-
handlerForType.refCount -= 1;
557+
handlerForType.refCount--;
558558
// If there are no longer any custom handlers of the current type on this element, we can remove ours, too.
559559
if (handlerForType.refCount <= 0) {
560560
originalRemoveEventListener.call(this, type, handlerForType.handler, options);

packages/utils/src/normalize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function visit(
147147
const visitValue = visitable[visitKey];
148148
normalized[visitKey] = visit(visitKey, visitValue, depth - 1, maxProperties, memo);
149149

150-
numAdded += 1;
150+
numAdded++;
151151
}
152152

153153
// Once we've visited all the branches, remove the parent from memo storage

packages/utils/src/path.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ function normalizeArray(parts: string[], allowAboveRoot?: boolean): string[] {
1111
parts.splice(i, 1);
1212
} else if (last === '..') {
1313
parts.splice(i, 1);
14-
// eslint-disable-next-line no-plusplus
1514
up++;
1615
} else if (up) {
1716
parts.splice(i, 1);
18-
// eslint-disable-next-line no-plusplus
1917
up--;
2018
}
2119
}
2220

2321
// if the path is allowed to go above the root, restore leading ..s
2422
if (allowAboveRoot) {
25-
// eslint-disable-next-line no-plusplus
2623
for (; up--; up) {
2724
parts.unshift('..');
2825
}

packages/utils/src/promisebuffer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ export function makePromiseBuffer<T>(limit?: number): PromiseBuffer<T> {
9090
// if all promises resolve in time, cancel the timer and resolve to `true`
9191
buffer.forEach(item => {
9292
void resolvedSyncPromise(item).then(() => {
93-
// eslint-disable-next-line no-plusplus
9493
if (!--counter) {
9594
clearTimeout(capturedSetTimeout);
9695
resolve(true);

packages/utils/src/stacktrace.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ function node(getModule?: GetModuleFn): StackLineParserFn {
130130

131131
let methodStart = functionName.lastIndexOf('.');
132132
if (functionName[methodStart - 1] === '.') {
133-
// eslint-disable-next-line no-plusplus
134133
methodStart--;
135134
}
136135

packages/vue/src/components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const generateComponentTrace = (vm?: ViewModel): string => {
6161
const last = tree[tree.length - 1] as any;
6262
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
6363
if (last.constructor === vm.constructor) {
64-
currentRecursiveSequence += 1;
64+
currentRecursiveSequence++;
6565
vm = vm.$parent; // eslint-disable-line no-param-reassign
6666
continue;
6767
} else if (currentRecursiveSequence > 0) {

scripts/ensure-bundle-deps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export async function ensureBundleBuildPrereqs(options: {
7474

7575
while (retries < maxRetries && !checkForBundleDeps(packagesDir, dependencyDirs)) {
7676
console.log('Bundle dependencies not found. Trying again in 5 seconds.');
77-
retries += 1;
77+
retries++;
7878
await sleep(5000);
7979
}
8080

0 commit comments

Comments
 (0)