Skip to content

Commit 3f080f0

Browse files
authored
Enable no-unused-vars rule (#1418)
1 parent 5b6e319 commit 3f080f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+277
-355
lines changed

eslint.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ export default defineConfig([
4141
'newlines-between': 'always',
4242
},
4343
],
44+
'no-unused-vars': [
45+
'error',
46+
{
47+
argsIgnorePattern: '^_',
48+
varsIgnorePattern: '^_',
49+
caughtErrorsIgnorePattern: '^_',
50+
},
51+
],
4452
},
4553
},
4654

@@ -57,7 +65,6 @@ export default defineConfig([
5765
strict: ['error', 'safe'],
5866
'no-prototype-builtins': 'off',
5967
'no-undef': 'off',
60-
'no-unused-vars': 'off',
6168
},
6269
},
6370

src/browser/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ class Rollbar {
435435
}
436436

437437
return f._rollbar_wrapped;
438-
} catch (e) {
438+
} catch (_e) {
439439
// Return the original function if the wrap fails.
440440
return f;
441441
}

src/browser/domUtility.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function isMatchingElement(element, classes, selectors) {
161161
return true;
162162
}
163163
}
164-
} catch (e) {
164+
} catch (_e) {
165165
// ignore errors from invalid arguments
166166
}
167167
return false;

src/browser/globalSetup.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ function captureUnhandledRejections(window, handler, shim) {
6767
var reason, promise, detail;
6868
try {
6969
reason = evt.reason;
70-
} catch (e) {
70+
} catch (_e) {
7171
reason = undefined;
7272
}
7373
try {
7474
promise = evt.promise;
75-
} catch (e) {
75+
} catch (_e) {
7676
promise = '[unhandledrejection] error getting `promise` from event';
7777
}
7878
try {
@@ -81,7 +81,7 @@ function captureUnhandledRejections(window, handler, shim) {
8181
reason = detail.reason;
8282
promise = detail.promise;
8383
}
84-
} catch (e) {
84+
} catch (_e) {
8585
// Ignore
8686
}
8787
if (!reason) {

src/browser/replay/recorder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export default class Recorder {
6060
debug,
6161

6262
// disallowed rrweb options
63-
emit,
64-
checkoutEveryNms,
63+
emit: _emit,
64+
checkoutEveryNms: _checkoutEveryNms,
6565

6666
// rrweb options
6767
...rrwebOptions

src/browser/replay/replay.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export default class Replay {
231231

232232
try {
233233
await this.send(replayId);
234-
} catch (error) {
234+
} catch (_error) {
235235
this.discard(replayId);
236236
return null;
237237
}

src/browser/shim.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function _wrapInternalErr(f) {
1111
} catch (e) {
1212
try {
1313
logger.error('[Rollbar]: Internal error', e);
14-
} catch (e2) {
14+
} catch (_e2) {
1515
// Ignore
1616
}
1717
}
@@ -146,7 +146,7 @@ Shim.prototype.loadFull = function (
146146
s.onload = s.onreadystatechange = null;
147147
try {
148148
parentNode.removeChild(s);
149-
} catch (e) {
149+
} catch (_e) {
150150
// pass
151151
}
152152
done = true;
@@ -210,7 +210,7 @@ Shim.prototype.wrap = function (f, context, _before) {
210210
}
211211

212212
return f._rollbar_wrapped;
213-
} catch (e) {
213+
} catch (_e) {
214214
// Return the original function if the wrap fails.
215215
return f;
216216
}

src/browser/telemetry.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ class Instrumenter {
328328
headers[h] = xhr.getResponseHeader(h);
329329
}
330330
}
331-
} catch (e) {
331+
} catch (_e) {
332332
/* we ignore the errors here that could come from different
333333
* browser issues with the xhr methods */
334334
}
@@ -337,7 +337,7 @@ class Instrumenter {
337337
if (self.autoInstrument.networkResponseBody) {
338338
try {
339339
body = xhr.responseText;
340-
} catch (e) {
340+
} catch (_e) {
341341
/* ignore errors from reading responseText */
342342
}
343343
}
@@ -374,7 +374,7 @@ class Instrumenter {
374374
xhr.__rollbar_event.level =
375375
self.telemeter.levelFromStatus(code);
376376
self.errorOnHttpStatus(xhr.__rollbar_xhr);
377-
} catch (e) {
377+
} catch (_e) {
378378
/* ignore possible exception from xhr.status */
379379
}
380380
}
@@ -415,7 +415,7 @@ class Instrumenter {
415415
this._window,
416416
'fetch',
417417
function (orig) {
418-
return function (fn, t) {
418+
return function (_fn, _t) {
419419
const args = [...arguments];
420420
const input = args[0];
421421
let method = 'GET';
@@ -586,7 +586,7 @@ class Instrumenter {
586586
outHeaders[h] = inHeaders.get(h);
587587
}
588588
}
589-
} catch (e) {
589+
} catch (_e) {
590590
/* ignore probable IE errors */
591591
}
592592
return outHeaders;
@@ -662,7 +662,6 @@ class Instrumenter {
662662
}
663663

664664
instrumentDom() {
665-
const self = this;
666665
this.addListener(
667666
'dom',
668667
this._window,
@@ -708,8 +707,8 @@ class Instrumenter {
708707
}
709708
}
710709

711-
handleContentLoaded(evt) {
712-
const replayId = this.rollbar.triggerReplay({
710+
handleContentLoaded(_evt) {
711+
this.rollbar.triggerReplay({
713712
type: 'navigation',
714713
path: new URL(this._location.href).pathname,
715714
});
@@ -741,12 +740,12 @@ class Instrumenter {
741740
});
742741
}
743742

744-
handleForm(evt) {
743+
handleForm(_evt) {
745744
// TODO: implement form event handling
746-
const type = evt.type;
747-
const elementString = evt.target?.window
748-
? 'window'
749-
: domUtil.elementString(evt.target);
745+
//const type = evt.type;
746+
//const elementString = evt.target?.window
747+
// ? 'window'
748+
// : domUtil.elementString(evt.target);
750749
}
751750

752751
handleResize(evt) {
@@ -958,7 +957,7 @@ class Instrumenter {
958957
from = parsedFrom.path + (parsedFrom.hash || '');
959958
}
960959
this.telemeter.captureNavigation(from, to, null, _.now());
961-
const replayId = this.rollbar.triggerReplay({
960+
this.rollbar.triggerReplay({
962961
type: 'navigation',
963962
path: to,
964963
});

src/browser/transport/xhr.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function makeXhrRequest({
9797

9898
request.onreadystatechange = onreadystatechange;
9999
request.send(payload);
100-
} catch (e1) {
100+
} catch (_e1) {
101101
// Sending using the normal xmlhttprequest object didn't work, try XDomainRequest
102102
if (typeof XDomainRequest !== 'undefined') {
103103
// Assume we are in a really old browser which has a bunch of limitations:
@@ -169,7 +169,7 @@ function _createXMLHTTPObject() {
169169
try {
170170
xmlhttp = factories[i]();
171171
break;
172-
} catch (e) {
172+
} catch (_e) {
173173
// pass
174174
}
175175
}

src/errorParser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function Stack(exception, skip) {
3737

3838
try {
3939
parserStack = parseErrorStack(exception);
40-
} catch (e) {
40+
} catch (_e) {
4141
parserStack = [];
4242
}
4343

0 commit comments

Comments
 (0)