Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
chore(deps): update eslint (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
dogpatch626 committed Nov 7, 2023
1 parent dda545e commit 432f7b7
Show file tree
Hide file tree
Showing 7 changed files with 1,090 additions and 831 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lib

# test
test-results

.jest-cache
# OS
.DS_Store

Expand Down
10 changes: 5 additions & 5 deletions __mocks__/node-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const fetch = jest.fn((url, config) => {
instances.push(reqInstance);
return reqInstance;
});

fetch.__resetRequests = () => { // eslint-disable-line no-underscore-dangle
instances.splice(0, Infinity);
// eslint-disable-next-line no-underscore-dangle -- this is a mock
fetch.__resetRequests = () => {
instances.splice(0, Number.POSITIVE_INFINITY);
};
fetch.__getRequest = (n) => Promise.resolve(instances[n]); // eslint-disable-line no-underscore-dangle, max-len

// eslint-disable-next-line no-underscore-dangle -- this is a mock
fetch.__getRequest = (n) => Promise.resolve(instances[n]);
module.exports = fetch;
14 changes: 9 additions & 5 deletions __tests__/src/middleware.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ describe('pipe', () => {
const res = { data: 'data' };

beforeEach(() => {
fetch.__resetRequests(); // eslint-disable-line no-underscore-dangle
// eslint-disable-next-line no-underscore-dangle -- this is a mock
fetch.__resetRequests();
fetch.mockClear();
req.pipe.mockClear();
});
Expand All @@ -60,20 +61,23 @@ describe('pipe', () => {

it('should pipe request', async () => {
pipe(false)(req, res);
const reqInstance = await fetch.__getRequest(0); // eslint-disable-line no-underscore-dangle
// eslint-disable-next-line no-underscore-dangle -- this is a mock
const reqInstance = await fetch.__getRequest(0);
expect(req.pipe).toHaveBeenCalledWith(reqInstance);
});

it('should pipe response', async () => {
pipe(false)(req, res);
const reqInstance = await fetch.__getRequest(0); // eslint-disable-line no-underscore-dangle
expect(reqInstance.pipe).toBeCalledWith(res);
// eslint-disable-next-line no-underscore-dangle -- this is a mock
const reqInstance = await fetch.__getRequest(0);
expect(reqInstance.pipe).toHaveBeenCalledWith(res);
});

it('should show a message when there is a socket error', async () => {
jest.spyOn(console, 'error').mockImplementation(() => 0);
pipe(false)(req, res);
const reqInstance = await fetch.__getRequest(0); // eslint-disable-line no-underscore-dangle
// eslint-disable-next-line no-underscore-dangle -- this is a mock
const reqInstance = await fetch.__getRequest(0);
reqInstance.emit('error', new Error('test error like socket timeout'));
expect(chalk.red).toHaveBeenCalled();
expect(console.error).toHaveBeenCalled();
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"yargs": "^15.4.1"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@commitlint/cli": "^9.1.2",
"@commitlint/config-conventional": "^17.3.0",
"@semantic-release/changelog": "^6.0.0",
Expand All @@ -72,10 +73,11 @@
"@semantic-release/npm": "^9.0.2",
"@semantic-release/release-notes-generator": "^10.0.0",
"amex-jest-preset": "^7.0.0",
"@babel/cli": "^7.0.0",
"babel-preset-amex": "^4.0.0",
"eslint": "^7.32.0",
"eslint-config-amex": "^13.1.0",
"eslint": "^8.0.0",
"eslint-config-amex": "^16.0.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-jest-dom": "4.0.1",
"husky": "^3.0.9",
"jest": "^29.0.0",
"lockfile-lint": "^4.3.7",
Expand Down
2 changes: 1 addition & 1 deletion src/applyCustomMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import chalk from 'chalk';
export default function applyCustomMiddleware(app, pathToMiddleware) {
try {
console.log('Applying custom middleware...');
// eslint-disable-next-line global-require, import/no-dynamic-require
// eslint-disable-next-line global-require, import/no-dynamic-require -- dynamic require is needed here
const customMiddlewareConfig = require(pathToMiddleware);

if (typeof customMiddlewareConfig === 'function') {
Expand Down
1 change: 0 additions & 1 deletion src/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* under the License.
*/

/* eslint-disable no-param-reassign */
import fetch from 'node-fetch';
import chalk from 'chalk';

Expand Down
Loading

0 comments on commit 432f7b7

Please sign in to comment.