Skip to content

Commit

Permalink
Require function names (as needed)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansott committed Feb 14, 2024
1 parent fd68d14 commit c368875
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions library/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = {
"security/detect-object-injection": "off",
"no-warning-comments": "error",
"max-lines-per-function": ["error", { max: 50, skipBlankLines: true }],
"func-names": ["error", "as-needed"],
},
overrides: [
{
Expand Down
4 changes: 2 additions & 2 deletions library/src/helpers/ipAddress.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as t from "tap";
import { wrap } from "shimmer";

wrap(require("os"), "networkInterfaces", function () {
return function () {
wrap(require("os"), "networkInterfaces", function wrap() {
return function wrap() {
return {
lo: [{ address: "127.0.0.1", family: "IPv4", internal: true }],
bond0: [{ address: "10.206.52.79", family: "IPv4", internal: false }],
Expand Down
4 changes: 1 addition & 3 deletions library/src/helpers/isPlainObject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ t.test(
"should return `false` if the object is not created by the `Object` constructor.",
async (t) => {
function Foo() {
// @ts-expect-error This is magic that TypeScript doesn't understand
this.abc = {};
}

t.notOk(isPlainObject(/foo/));
t.notOk(isPlainObject(function () {}));
t.notOk(isPlainObject(function myFunc() {}));
t.notOk(isPlainObject(1));
t.notOk(isPlainObject(["foo", "bar"]));
t.notOk(isPlainObject([]));
// @ts-expect-error This is magic that TypeScript doesn't understand
t.notOk(isPlainObject(new Foo()));
t.notOk(isPlainObject(null));
}
Expand Down
8 changes: 4 additions & 4 deletions library/src/sinks/MongoDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ export class MongoDB implements Wrapper {
// @ts-expect-error This is magic that TypeScript doesn't understand
exports.Collection.prototype,
"bulkWrite",
function (original) {
return function (this: Collection) {
function wrapBulkWrite(original) {
return function protectBulkWrite(this: Collection) {
const agent = getInstance();

if (!agent) {
Expand Down Expand Up @@ -144,8 +144,8 @@ export class MongoDB implements Wrapper {
// @ts-expect-error This is magic that TypeScript doesn't understand
exports.Collection.prototype,
operation,
function (original) {
return function (this: Collection) {
function wrapOperation(original) {
return function protectQuery(this: Collection) {
const agent = getInstance();

if (!agent) {
Expand Down
4 changes: 2 additions & 2 deletions library/src/sources/Express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export class Express implements Wrapper {
exports.Route.prototype,
// @ts-expect-error This is magic that TypeScript doesn't understand
METHODS.map((method) => method.toLowerCase()),
function (original) {
return function (this: Application) {
function wrapRouteMethod(original) {
return function injectMiddleware(this: Application) {
const args = Array.from(arguments);
const handler = args.pop();
args.push(createMiddleware());
Expand Down

0 comments on commit c368875

Please sign in to comment.