Skip to content

Commit facad37

Browse files
committed
fixup! Update to eslint9 with xo config
1 parent eff9a0e commit facad37

File tree

8 files changed

+311
-315
lines changed

8 files changed

+311
-315
lines changed

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// https://jestjs.io/docs/en/configuration.html
22
module.exports = {
33
clearMocks: true,
4-
coverageDirectory: "coverage",
5-
testEnvironment: "node",
4+
coverageDirectory: 'coverage',
5+
testEnvironment: 'node',
66
};

prettier.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ module.exports = {
2424
},
2525
},
2626
],
27-
}
27+
};

src/ValidationError.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class ValidationError {
2-
32
constructor(data, payload) {
43
switch (true) {
54
case !data:
@@ -25,10 +24,9 @@ class ValidationError {
2524
throw new Error('The payload must be an object.');
2625
}
2726

28-
this.payload = Object.assign({}, payload);
27+
this.payload = {...payload};
2928
}
3029
}
31-
3230
}
3331

3432
module.exports = ValidationError;

src/ValidationError.test.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1+
import {describe, expect, it} from '@jest/globals';
12
const ValidationError = require('./ValidationError');
23
const MESSAGES = require('./constants/messages');
34

4-
describe('The validation error', () => {
5-
5+
describe('the validation error', () => {
66
describe('constructor', () => {
7-
87
it('should throw when not passing data', () => {
98
expect(() => new ValidationError())
109
.toThrow(new Error('Missing data.'));
1110
});
1211

1312
it('should throw when not passing a line', () => {
1413
const data = {};
14+
1515
expect(() => new ValidationError(data))
1616
.toThrow(new Error('Missing linenumber in data.'));
1717
});
@@ -20,6 +20,7 @@ describe('The validation error', () => {
2020
const data = {
2121
line: 42,
2222
};
23+
2324
expect(() => new ValidationError(data))
2425
.toThrow(new Error('Missing errorcode in data.'));
2526
});
@@ -29,6 +30,7 @@ describe('The validation error', () => {
2930
line: 42,
3031
code: MESSAGES.INDENTATION_TABS.code,
3132
};
33+
3234
expect(() => new ValidationError(data))
3335
.toThrow(new Error('Missing errortype in data.'));
3436
});
@@ -39,6 +41,7 @@ describe('The validation error', () => {
3941
code: MESSAGES.INDENTATION_TABS.code,
4042
type: MESSAGES.INDENTATION_TABS.type,
4143
};
44+
4245
expect(() => new ValidationError(data))
4346
.toThrow(new Error('Missing errormessage in data.'));
4447
});
@@ -51,6 +54,7 @@ describe('The validation error', () => {
5154
message: MESSAGES.INDENTATION_TABS.message,
5255
};
5356
const error = new ValidationError(data);
57+
5458
expect(error).toEqual(expect.objectContaining({
5559
line: 42,
5660
code: MESSAGES.INDENTATION_TABS.code,
@@ -70,12 +74,13 @@ describe('The validation error', () => {
7074
foo: true,
7175
};
7276
const error = new ValidationError(data, payload);
77+
7378
expect(error).toEqual(expect.objectContaining({
7479
line: 42,
7580
code: MESSAGES.INDENTATION_TABS.code,
7681
type: MESSAGES.INDENTATION_TABS.type,
7782
message: MESSAGES.INDENTATION_TABS.message,
78-
payload: payload,
83+
payload,
7984
}));
8085
expect(error.payload).not.toBe(payload);
8186
expect(error.payload).toEqual(payload);
@@ -88,7 +93,8 @@ describe('The validation error', () => {
8893
type: MESSAGES.INDENTATION_TABS.type,
8994
message: MESSAGES.INDENTATION_TABS.message,
9095
};
91-
const payload = 'This is a payload'
96+
const payload = 'This is a payload';
97+
9298
expect(() => new ValidationError(data, payload))
9399
.toThrow(new Error('The payload must be an object.'));
94100
});
@@ -101,10 +107,9 @@ describe('The validation error', () => {
101107
message: MESSAGES.INDENTATION_TABS.message,
102108
};
103109
const payload = ['This is a payload'];
110+
104111
expect(() => new ValidationError(data, payload))
105112
.toThrow(new Error('The payload must be an object.'));
106113
});
107-
108114
});
109-
110115
});

0 commit comments

Comments
 (0)