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

chore(deps): update eslint #61

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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,23 +61,26 @@

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();

Check warning on line 83 in __tests__/src/middleware.spec.js

View workflow job for this annotation

GitHub Actions / Node 16.x

Unexpected console statement

Check warning on line 83 in __tests__/src/middleware.spec.js

View workflow job for this annotation

GitHub Actions / Node 18.x

Unexpected console statement
expect(console.error.mock.calls[0]).toMatchSnapshot();

Check warning on line 84 in __tests__/src/middleware.spec.js

View workflow job for this annotation

GitHub Actions / Node 16.x

Unexpected console statement

Check warning on line 84 in __tests__/src/middleware.spec.js

View workflow job for this annotation

GitHub Actions / Node 18.x

Unexpected console statement
});
});
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 @@ -16,8 +16,8 @@

export default function applyCustomMiddleware(app, pathToMiddleware) {
try {
console.log('Applying custom middleware...');

Check warning on line 19 in src/applyCustomMiddleware.js

View workflow job for this annotation

GitHub Actions / Node 16.x

Unexpected console statement

Check warning on line 19 in src/applyCustomMiddleware.js

View workflow job for this annotation

GitHub Actions / Node 18.x

Unexpected console statement
// 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 All @@ -35,7 +34,7 @@
.pipe(
await fetch(req.remoteUrl, config)
.catch((err) => {
console.error(`${chalk.red(`request to ${req.remoteUrl} failed:`)} ${err.message}`);

Check warning on line 37 in src/middleware.js

View workflow job for this annotation

GitHub Actions / Node 16.x

Unexpected console statement

Check warning on line 37 in src/middleware.js

View workflow job for this annotation

GitHub Actions / Node 18.x

Unexpected console statement
})
)
.pipe(res);
Expand Down
Loading
Loading