Skip to content

Commit bb84356

Browse files
authored
upgrade eslint (#256)
1 parent ba2eeff commit bb84356

8 files changed

Lines changed: 658 additions & 906 deletions

File tree

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

eslint.config.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"use strict";
2+
3+
const sinonConfig = require("@sinonjs/eslint-config");
4+
5+
module.exports = [
6+
{
7+
ignores: [
8+
"eslint.config.js",
9+
"coverage/**",
10+
".worktrees/**",
11+
"**/.worktrees/**",
12+
"site/**",
13+
"nise.js",
14+
],
15+
},
16+
...sinonConfig,
17+
{
18+
files: ["lib/**/*.js", "lib/**/*.test.js"],
19+
rules: {
20+
"no-unused-vars": [
21+
"error",
22+
{ vars: "all", args: "after-used", caughtErrors: "none" },
23+
],
24+
},
25+
},
26+
{
27+
files: ["lib/**/*.test.js"],
28+
rules: {
29+
"mocha/consistent-spacing-between-blocks": "off",
30+
},
31+
},
32+
{
33+
languageOptions: {
34+
globals: {
35+
BigInt: false,
36+
Int8Array: false,
37+
Int16Array: false,
38+
Int32Array: false,
39+
Promise: false,
40+
Uint8Array: false,
41+
Uint8ClampedArray: false,
42+
Uint16Array: false,
43+
Uint32Array: false,
44+
},
45+
},
46+
},
47+
];

lib/fake-server/index.test.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,6 @@ describe("sinonFakeServer", function () {
676676
// setup client
677677
// Build Android like format (manual jsdom, with window.window inset)
678678
var html =
679-
// eslint-disable-next-line quotes
680679
'<!doctype html><html><head><meta charset="utf-8">' +
681680
"</head><body></body></html>";
682681
var options = {};
@@ -869,7 +868,7 @@ describe("sinonFakeServer", function () {
869868
xhr.respond(
870869
200,
871870
{ "Content-Type": "application/json" },
872-
// eslint-disable-next-line quotes
871+
873872
'{"id":42}',
874873
);
875874
});
@@ -886,7 +885,7 @@ describe("sinonFakeServer", function () {
886885
});
887886
assert.equals(
888887
request.responseText,
889-
// eslint-disable-next-line quotes
888+
890889
'{"id":42}',
891890
);
892891
});
@@ -937,7 +936,6 @@ describe("sinonFakeServer", function () {
937936
assert(handler.calledOnce);
938937
});
939938

940-
// eslint-disable-next-line max-len
941939
it("yields response to request function handler when url is a function that returns true with no Http Method specified", function () {
942940
var handler = sinon.spy();
943941
this.server.respondWith(equalMatcher("/hello?world"), handler);
@@ -962,7 +960,6 @@ describe("sinonFakeServer", function () {
962960
assert(!handler.called);
963961
});
964962

965-
// eslint-disable-next-line max-len
966963
it("does not yield response to request function handler when method does not match (using url mather function)", function () {
967964
var handler = sinon.spy();
968965
this.server.respondWith("GET", equalMatcher("/hello"), handler);
@@ -1011,7 +1008,6 @@ describe("sinonFakeServer", function () {
10111008
assert(!handler.called);
10121009
});
10131010

1014-
// eslint-disable-next-line max-len
10151011
it("does not yield response to request function handler when urlMatcher function returns non Boolean truthy value", function () {
10161012
var handler = sinon.spy();
10171013
this.server.respondWith(
@@ -1030,7 +1026,6 @@ describe("sinonFakeServer", function () {
10301026
assert(!handler.called);
10311027
});
10321028

1033-
// eslint-disable-next-line max-len
10341029
it("does not yield response to request function handler when urlMatcher function returns non Boolean falsey value", function () {
10351030
var handler = sinon.spy();
10361031
this.server.respondWith(
@@ -1054,7 +1049,7 @@ describe("sinonFakeServer", function () {
10541049
xhr.respond(
10551050
200,
10561051
{ "Content-Type": "application/json" },
1057-
// eslint-disable-next-line quotes
1052+
10581053
'{"id":42}',
10591054
);
10601055
});
@@ -1071,7 +1066,7 @@ describe("sinonFakeServer", function () {
10711066
});
10721067
assert.equals(
10731068
request.responseText,
1074-
// eslint-disable-next-line quotes
1069+
10751070
'{"id":42}',
10761071
);
10771072
});

lib/fake-xhr/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,14 +494,12 @@ function fakeXMLHttpRequestFor(globalScope) {
494494
xhr.addEventListener("readystatechange", stateChangeStart);
495495

496496
Object.keys(fakeXhr.eventListeners).forEach(function (event) {
497-
/*eslint-disable no-loop-func*/
498497
fakeXhr.eventListeners[event].forEach(function (handler) {
499498
xhr.addEventListener(event, handler.listener, {
500499
capture: handler.capture,
501500
once: handler.once,
502501
});
503502
});
504-
/*eslint-enable no-loop-func*/
505503
});
506504

507505
xhr.addEventListener("readystatechange", stateChangeEnd);

lib/fake-xhr/index.test.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ function fakeXhrTearDown() {
4646
function runWithWorkingXHROveride(workingXHR, test) {
4747
var original;
4848
try {
49-
// eslint-disable-line no-restricted-syntax
5049
original = sinonFakeXhr.xhr.workingXHR;
5150
sinonFakeXhr.xhr.workingXHR = workingXHR;
52-
test(); // eslint-disable-line mocha/no-empty-description
51+
test();
5352
} finally {
5453
sinonFakeXhr.xhr.workingXHR = original;
5554
}
@@ -1483,13 +1482,11 @@ describe("FakeXMLHttpRequest", function () {
14831482

14841483
// eslint-disable-next-line mocha/no-setup-in-describe
14851484
assertRequestErrorSteps(function (xhr) {
1486-
// eslint-disable-next-line mocha/no-setup-in-describe
14871485
xhr.abort();
14881486
});
14891487

14901488
// eslint-disable-next-line mocha/no-setup-in-describe
14911489
assertEventOrdering("abort", 0, function (xhr) {
1492-
// eslint-disable-next-line mocha/no-setup-in-describe
14931490
xhr.abort();
14941491
});
14951492
});
@@ -1559,7 +1556,6 @@ describe("FakeXMLHttpRequest", function () {
15591556

15601557
// eslint-disable-next-line mocha/no-setup-in-describe
15611558
assertEventOrdering("error", 0, function (xhr) {
1562-
// eslint-disable-next-line mocha/no-setup-in-describe
15631559
xhr.error();
15641560
});
15651561
});
@@ -1662,13 +1658,11 @@ describe("FakeXMLHttpRequest", function () {
16621658

16631659
// eslint-disable-next-line mocha/no-setup-in-describe
16641660
assertRequestErrorSteps(function (xhr) {
1665-
// eslint-disable-next-line mocha/no-setup-in-describe
16661661
xhr.triggerTimeout();
16671662
});
16681663

16691664
// eslint-disable-next-line mocha/no-setup-in-describe
16701665
assertEventOrdering("timeout", 0, function (xhr) {
1671-
// eslint-disable-next-line mocha/no-setup-in-describe
16721666
xhr.triggerTimeout();
16731667
});
16741668
});
@@ -2080,7 +2074,7 @@ describe("FakeXMLHttpRequest", function () {
20802074
this.xhr.respond(
20812075
200,
20822076
{ "Content-Type": "application/xml" },
2083-
//eslint-disable-next-line quotes
2077+
20842078
'!!!<?xml version="1.0" encoding="UTF-8"?><broken>',
20852079
);
20862080

@@ -2372,7 +2366,6 @@ describe("FakeXMLHttpRequest", function () {
23722366

23732367
it("performs initial readystatechange on opening when filters are being used, but don't match", function () {
23742368
try {
2375-
// eslint-disable-line no-restricted-syntax
23762369
FakeXMLHttpRequest.useFilters = true;
23772370
var spy = sinonSpy();
23782371
fakeXhr.addEventListener("readystatechange", spy);
@@ -2618,37 +2611,37 @@ describe("FakeXMLHttpRequest", function () {
26182611
it("hijacks ActiveXObject", function () {
26192612
refute.same(global.ActiveXObject, globalActiveXObject);
26202613
refute.same(global.ActiveXObject, globalActiveXObject);
2621-
refute.same(ActiveXObject, globalActiveXObject); // eslint-disable-line no-undef
2614+
refute.same(ActiveXObject, globalActiveXObject);
26222615
});
26232616

26242617
it("restores global ActiveXObject", function () {
26252618
fakeXhr.restore();
26262619

26272620
assert.same(global.ActiveXObject, globalActiveXObject);
26282621
assert.same(global.ActiveXObject, globalActiveXObject);
2629-
assert.same(ActiveXObject, globalActiveXObject); // eslint-disable-line no-undef
2622+
assert.same(ActiveXObject, globalActiveXObject);
26302623
});
26312624

26322625
it("creates FakeXHR object with ActiveX Microsoft.XMLHTTP", function () {
2633-
var xhr = new ActiveXObject("Microsoft.XMLHTTP"); // eslint-disable-line no-undef
2626+
var xhr = new ActiveXObject("Microsoft.XMLHTTP");
26342627

26352628
assert(xhr instanceof FakeXMLHttpRequest);
26362629
});
26372630

26382631
it("creates FakeXHR object with ActiveX Msxml2.XMLHTTP", function () {
2639-
var xhr = new ActiveXObject("Msxml2.XMLHTTP"); // eslint-disable-line no-undef
2632+
var xhr = new ActiveXObject("Msxml2.XMLHTTP");
26402633

26412634
assert(xhr instanceof FakeXMLHttpRequest);
26422635
});
26432636

26442637
it("creates FakeXHR object with ActiveX Msxml2.XMLHTTP.3.0", function () {
2645-
var xhr = new ActiveXObject("Msxml2.XMLHTTP.3.0"); // eslint-disable-line no-undef
2638+
var xhr = new ActiveXObject("Msxml2.XMLHTTP.3.0");
26462639

26472640
assert(xhr instanceof FakeXMLHttpRequest);
26482641
});
26492642

26502643
it("creates FakeXHR object with ActiveX Msxml2.XMLHTTP.6.0", function () {
2651-
var xhr = new ActiveXObject("Msxml2.XMLHTTP.6.0"); // eslint-disable-line no-undef
2644+
var xhr = new ActiveXObject("Msxml2.XMLHTTP.6.0");
26522645

26532646
assert(xhr instanceof FakeXMLHttpRequest);
26542647
});
@@ -2931,7 +2924,6 @@ describe("FakeXMLHttpRequest", function () {
29312924

29322925
// eslint-disable-next-line mocha/no-setup-in-describe
29332926
assertEventOrdering("load", 100, function (xhr) {
2934-
// eslint-disable-next-line mocha/no-setup-in-describe
29352927
xhr.respond(200, {}, "");
29362928
});
29372929

0 commit comments

Comments
 (0)