Skip to content
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
12 changes: 5 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"sourceType": "module"
},
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended"
],
"env": {
"es6": true,
Expand All @@ -25,16 +24,15 @@
"arrow-body-style": ["error", "as-needed"],
"prefer-template": "error",
"max-len": ["warn", { "code": 120 }],
"no-unused-vars": ["warn", {
"argsIgnorePattern": "^_$|^e$|^reject$|^resolve$"
}],
"no-console": ["error", {
"allow": ["warn", "error"]
}],
"valid-jsdoc": "warn",
"semi": ["error", "always"],
"quotes": ["error", "double", { "allowTemplateLiterals": true }],
"@typescript-eslint/no-explicit-any": "off",
"header/header": [2, "block", ["", " Copyright 2021 The CloudEvents Authors"," SPDX-License-Identifier: Apache-2.0", ""], 2]
"header/header": [2, "block", ["", " Copyright 2021 The CloudEvents Authors"," SPDX-License-Identifier: Apache-2.0", ""], 2],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"]
}
}
1,401 changes: 1,015 additions & 386 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,22 @@
"@types/node": "^14.14.10",
"@types/superagent": "^4.1.10",
"@types/uuid": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^3.4.0",
"@typescript-eslint/parser": "^3.4.0",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.29.0",
"axios": "^0.21.1",
"chai": "~4.2.0",
"cucumber": "^6.0.5",
"cucumber-pretty": "^6.0.0",
"cucumber-tsflow": "^3.2.0",
"downtotemp": "^0.1.2",
"eslint": "^7.3.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-standard": "^14.1.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-promise": "^5.1.0",
"got": "^11.7.0",
"http-parser-js": "^0.5.2",
"mocha": "~8.2.0",
Expand All @@ -145,8 +146,8 @@
"remark-preset-lint-recommended": "^5.0.0",
"superagent": "^6.1.0",
"ts-node": "^8.10.2",
"typedoc": "^0.20.24",
"typescript": "^3.8.3",
"typedoc": "^0.21.5",
"typescript": "^4.3.5",
"webpack": "^5.1.1",
"webpack-cli": "^4.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions src/event/cloudevent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ export class CloudEvent implements CloudEventV1, CloudEventV03 {
delete properties.time;

this.type = properties.type;
delete properties.type;
delete (properties as any).type;

this.source = properties.source;
delete properties.source;
delete (properties as any).source;

this.specversion = (properties.specversion as Version) || Version.V1;
delete properties.specversion;
Expand Down
2 changes: 1 addition & 1 deletion src/event/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ValidationError extends TypeError {

export const isString = (v: unknown): boolean => typeof v === "string";
export const isObject = (v: unknown): boolean => typeof v === "object";
export const isDefined = (v: unknown): boolean => v && typeof v !== "undefined";
export const isDefined = (v: unknown): boolean => v !== null && typeof v !== "undefined";

export const isBoolean = (v: unknown): boolean => typeof v === "boolean";
export const isInteger = (v: unknown): boolean => Number.isInteger(v as number);
Expand Down
4 changes: 2 additions & 2 deletions src/transport/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface TransportFunction {
(message: Message, options?: Options): Promise<unknown>;
}

const emitterDefaults = { binding: HTTP, mode: Mode.BINARY };
const emitterDefaults: Options = { binding: HTTP, mode: Mode.BINARY };
/**
* Creates and returns an {@linkcode EmitterFunction} using the supplied
* {@linkcode TransportFunction}. The returned {@linkcode EmitterFunction}
Expand All @@ -55,7 +55,7 @@ export function emitterFor(fn: TransportFunction, options = emitterDefaults): Em
if (!fn) {
throw new TypeError("A TransportFunction is required");
}
const { binding, mode } = { ...emitterDefaults, ...options };
const { binding, mode }: any = { ...emitterDefaults, ...options };
return function emit(event: CloudEvent, opts?: Options): Promise<unknown> {
opts = opts || {};

Expand Down
5 changes: 1 addition & 4 deletions test/integration/emitter_factory_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function superagentEmitter(message: Message, options?: Options): Promise<unknown

function gotEmitter(message: Message, options?: Options): Promise<unknown> {
return Promise.resolve(
got.post(sink, { headers: message.headers, body: message.body as string, ...((options as unknown) as Options) }),
got.post(sink, { headers: message.headers, body: message.body as string, ...(options as Options) }),
);
}

Expand Down Expand Up @@ -90,9 +90,6 @@ describe("emitterFor() defaults", () => {
expect(body.id).to.equal("1234");
return Promise.resolve();
}
// Ignore the next line to ensure that HTTP transport is still the default.
// Otherwise, tslint would complain that the param did not have `binding: <val>`
/* @ts-ignore */
const emitter = emitterFor(transport, { mode: Mode.STRUCTURED });
emitter(
new CloudEvent({
Expand Down
8 changes: 4 additions & 4 deletions test/integration/spec_03_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe("CloudEvents Spec v0.3", () => {
describe("'id'", () => {
it("should throw an error when trying to remove", () => {
expect(() => {
delete cloudevent.id;
delete (cloudevent as any).id;
}).to.throw(TypeError);
});

Expand All @@ -103,23 +103,23 @@ describe("CloudEvents Spec v0.3", () => {
describe("'source'", () => {
it("should throw an error when trying to remove", () => {
expect(() => {
delete cloudevent.source;
delete (cloudevent as any).source;
}).to.throw(TypeError);
});
});

describe("'specversion'", () => {
it("should throw an error when trying to remove", () => {
expect(() => {
delete cloudevent.specversion;
delete (cloudevent as any).specversion;
}).to.throw(TypeError);
});
});

describe("'type'", () => {
it("should throw an error when trying to remove", () => {
expect(() => {
delete cloudevent.type;
delete (cloudevent as any).type;
}).to.throw(TypeError);
});

Expand Down
8 changes: 4 additions & 4 deletions test/integration/spec_1_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe("CloudEvents Spec v1.0", () => {
describe("'id'", () => {
it("should throw an error when trying to remove", () => {
expect(() => {
delete cloudevent.id;
delete (cloudevent as any).id;
}).to.throw(TypeError);
});

Expand All @@ -118,23 +118,23 @@ describe("CloudEvents Spec v1.0", () => {
describe("'source'", () => {
it("should throw an error when trying to remove", () => {
expect(() => {
delete cloudevent.source;
delete (cloudevent as any).source;
}).to.throw(TypeError);
});
});

describe("'specversion'", () => {
it("should throw an error when trying to remove", () => {
expect(() => {
delete cloudevent.specversion;
delete (cloudevent as any).specversion;
}).to.throw(TypeError);
});
});

describe("'type'", () => {
it("should throw an error when trying to remove", () => {
expect(() => {
delete cloudevent.type;
delete (cloudevent as any).type;
}).to.throw(TypeError);
});
});
Expand Down