Skip to content

Commit e86d6c9

Browse files
committed
upgrade eslint
1 parent 68c765f commit e86d6c9

8 files changed

Lines changed: 675 additions & 896 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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ 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
679+
680680
'<!doctype html><html><head><meta charset="utf-8">' +
681681
"</head><body></body></html>";
682682
var options = {};
@@ -869,7 +869,7 @@ describe("sinonFakeServer", function () {
869869
xhr.respond(
870870
200,
871871
{ "Content-Type": "application/json" },
872-
// eslint-disable-next-line quotes
872+
873873
'{"id":42}',
874874
);
875875
});
@@ -886,7 +886,7 @@ describe("sinonFakeServer", function () {
886886
});
887887
assert.equals(
888888
request.responseText,
889-
// eslint-disable-next-line quotes
889+
890890
'{"id":42}',
891891
);
892892
});
@@ -937,7 +937,7 @@ describe("sinonFakeServer", function () {
937937
assert(handler.calledOnce);
938938
});
939939

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

965-
// eslint-disable-next-line max-len
965+
966966
it("does not yield response to request function handler when method does not match (using url mather function)", function () {
967967
var handler = sinon.spy();
968968
this.server.respondWith("GET", equalMatcher("/hello"), handler);
@@ -1011,7 +1011,7 @@ describe("sinonFakeServer", function () {
10111011
assert(!handler.called);
10121012
});
10131013

1014-
// eslint-disable-next-line max-len
1014+
10151015
it("does not yield response to request function handler when urlMatcher function returns non Boolean truthy value", function () {
10161016
var handler = sinon.spy();
10171017
this.server.respondWith(
@@ -1030,7 +1030,7 @@ describe("sinonFakeServer", function () {
10301030
assert(!handler.called);
10311031
});
10321032

1033-
// eslint-disable-next-line max-len
1033+
10341034
it("does not yield response to request function handler when urlMatcher function returns non Boolean falsey value", function () {
10351035
var handler = sinon.spy();
10361036
this.server.respondWith(
@@ -1054,7 +1054,7 @@ describe("sinonFakeServer", function () {
10541054
xhr.respond(
10551055
200,
10561056
{ "Content-Type": "application/json" },
1057-
// eslint-disable-next-line quotes
1057+
10581058
'{"id":42}',
10591059
);
10601060
});
@@ -1071,7 +1071,7 @@ describe("sinonFakeServer", function () {
10711071
});
10721072
assert.equals(
10731073
request.responseText,
1074-
// eslint-disable-next-line quotes
1074+
10751075
'{"id":42}',
10761076
);
10771077
});

lib/fake-xhr/index.js

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

496496
Object.keys(fakeXhr.eventListeners).forEach(function (event) {
497-
/*eslint-disable no-loop-func*/
497+
498498
fakeXhr.eventListeners[event].forEach(function (handler) {
499499
xhr.addEventListener(event, handler.listener, {
500500
capture: handler.capture,
501501
once: handler.once,
502502
});
503503
});
504-
/*eslint-enable no-loop-func*/
504+
505505
});
506506

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

lib/fake-xhr/index.test.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ function fakeXhrTearDown() {
4646
function runWithWorkingXHROveride(workingXHR, test) {
4747
var original;
4848
try {
49-
// eslint-disable-line no-restricted-syntax
49+
5050
original = sinonFakeXhr.xhr.workingXHR;
5151
sinonFakeXhr.xhr.workingXHR = workingXHR;
52-
test(); // eslint-disable-line mocha/no-empty-description
52+
test();
5353
} finally {
5454
sinonFakeXhr.xhr.workingXHR = original;
5555
}
@@ -1483,13 +1483,13 @@ describe("FakeXMLHttpRequest", function () {
14831483

14841484
// eslint-disable-next-line mocha/no-setup-in-describe
14851485
assertRequestErrorSteps(function (xhr) {
1486-
// eslint-disable-next-line mocha/no-setup-in-describe
1486+
14871487
xhr.abort();
14881488
});
14891489

14901490
// eslint-disable-next-line mocha/no-setup-in-describe
14911491
assertEventOrdering("abort", 0, function (xhr) {
1492-
// eslint-disable-next-line mocha/no-setup-in-describe
1492+
14931493
xhr.abort();
14941494
});
14951495
});
@@ -1559,7 +1559,7 @@ describe("FakeXMLHttpRequest", function () {
15591559

15601560
// eslint-disable-next-line mocha/no-setup-in-describe
15611561
assertEventOrdering("error", 0, function (xhr) {
1562-
// eslint-disable-next-line mocha/no-setup-in-describe
1562+
15631563
xhr.error();
15641564
});
15651565
});
@@ -1662,13 +1662,13 @@ describe("FakeXMLHttpRequest", function () {
16621662

16631663
// eslint-disable-next-line mocha/no-setup-in-describe
16641664
assertRequestErrorSteps(function (xhr) {
1665-
// eslint-disable-next-line mocha/no-setup-in-describe
1665+
16661666
xhr.triggerTimeout();
16671667
});
16681668

16691669
// eslint-disable-next-line mocha/no-setup-in-describe
16701670
assertEventOrdering("timeout", 0, function (xhr) {
1671-
// eslint-disable-next-line mocha/no-setup-in-describe
1671+
16721672
xhr.triggerTimeout();
16731673
});
16741674
});
@@ -2080,7 +2080,7 @@ describe("FakeXMLHttpRequest", function () {
20802080
this.xhr.respond(
20812081
200,
20822082
{ "Content-Type": "application/xml" },
2083-
//eslint-disable-next-line quotes
2083+
20842084
'!!!<?xml version="1.0" encoding="UTF-8"?><broken>',
20852085
);
20862086

@@ -2372,7 +2372,7 @@ describe("FakeXMLHttpRequest", function () {
23722372

23732373
it("performs initial readystatechange on opening when filters are being used, but don't match", function () {
23742374
try {
2375-
// eslint-disable-line no-restricted-syntax
2375+
23762376
FakeXMLHttpRequest.useFilters = true;
23772377
var spy = sinonSpy();
23782378
fakeXhr.addEventListener("readystatechange", spy);
@@ -2618,37 +2618,37 @@ describe("FakeXMLHttpRequest", function () {
26182618
it("hijacks ActiveXObject", function () {
26192619
refute.same(global.ActiveXObject, globalActiveXObject);
26202620
refute.same(global.ActiveXObject, globalActiveXObject);
2621-
refute.same(ActiveXObject, globalActiveXObject); // eslint-disable-line no-undef
2621+
refute.same(ActiveXObject, globalActiveXObject);
26222622
});
26232623

26242624
it("restores global ActiveXObject", function () {
26252625
fakeXhr.restore();
26262626

26272627
assert.same(global.ActiveXObject, globalActiveXObject);
26282628
assert.same(global.ActiveXObject, globalActiveXObject);
2629-
assert.same(ActiveXObject, globalActiveXObject); // eslint-disable-line no-undef
2629+
assert.same(ActiveXObject, globalActiveXObject);
26302630
});
26312631

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

26352635
assert(xhr instanceof FakeXMLHttpRequest);
26362636
});
26372637

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

26412641
assert(xhr instanceof FakeXMLHttpRequest);
26422642
});
26432643

26442644
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
2645+
var xhr = new ActiveXObject("Msxml2.XMLHTTP.3.0");
26462646

26472647
assert(xhr instanceof FakeXMLHttpRequest);
26482648
});
26492649

26502650
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
2651+
var xhr = new ActiveXObject("Msxml2.XMLHTTP.6.0");
26522652

26532653
assert(xhr instanceof FakeXMLHttpRequest);
26542654
});
@@ -2931,7 +2931,7 @@ describe("FakeXMLHttpRequest", function () {
29312931

29322932
// eslint-disable-next-line mocha/no-setup-in-describe
29332933
assertEventOrdering("load", 100, function (xhr) {
2934-
// eslint-disable-next-line mocha/no-setup-in-describe
2934+
29352935
xhr.respond(200, {}, "");
29362936
});
29372937

0 commit comments

Comments
 (0)