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

Commit

Permalink
Add lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sxwei123 committed Jan 12, 2021
1 parent 7e39ea7 commit 131fb8e
Show file tree
Hide file tree
Showing 6 changed files with 895 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
36 changes: 36 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
parser: "@typescript-eslint/parser"
plugins:
- "@typescript-eslint"
extends:
- "plugin:@typescript-eslint/recommended"
- eslint-config-prettier
- plugin:import/errors
- plugin:import/warnings
- plugin:import/typescript
rules:
"@typescript-eslint/no-unused-vars":
- warn
- argsIgnorePattern: "^_"
no-use-before-define:
- warn
"@typescript-eslint/no-use-before-define":
- warn
no-unused-expressions:
- error
no-underscore-dangle:
- error
- # allow couchdb stuff
allow:
- _id
- _rev
- _deleted
- __typename
allowAfterThis: true
allowAfterSuper: true
enforceInMethodNames: true
one-var:
- error
- never
class-methods-use-this:
- error
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,20 @@
"@types/jest": "^26.0.19",
"@types/node": "^14.14.11",
"@types/node-fetch": "^2.5.7",
"@typescript-eslint/eslint-plugin": "^4.13.0",
"@typescript-eslint/parser": "^4.13.0",
"eslint": "^7.17.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-import": "^2.22.1",
"jest": "^26.6.3",
"ts-jest": "^26.4.4",
"typescript": "^4.1.2"
},
"scripts": {
"build": "tsc",
"test": "jest --config jestconfig.json",
"prepublish": "tsc"
"prepublish": "tsc",
"lint": "eslint . --ext .ts"
},
"dependencies": {
"node-fetch": "^2.6.1"
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class DataCollectorClient {
*/
async send(
logType: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
logs: any[],
timeGenerated?: string
): Promise<APIResponse> {
Expand Down
11 changes: 8 additions & 3 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import { DataCollectorClient } from "../src";
describe("The data collector client", () => {
const { LOG_ANALYTICS_AGENT_KEY, LOG_ANALYTICS_WORKSPACE_ID } = process.env;

if (!LOG_ANALYTICS_AGENT_KEY || !LOG_ANALYTICS_WORKSPACE_ID) {
throw new Error(
"LOG_ANALYTICS_AGENT_KEY and LOG_ANALYTICS_WORKSPACE_ID are required"
);
}
const client = new DataCollectorClient(
LOG_ANALYTICS_WORKSPACE_ID!,
LOG_ANALYTICS_AGENT_KEY!
LOG_ANALYTICS_WORKSPACE_ID,
LOG_ANALYTICS_AGENT_KEY
);

it("is able to send logs to Azure", async () => {
Expand Down Expand Up @@ -46,7 +51,7 @@ describe("The data collector client", () => {

it("will return InvalidAuthorization error when authorization code is invalid", async () => {
const client = new DataCollectorClient(
LOG_ANALYTICS_WORKSPACE_ID!,
LOG_ANALYTICS_WORKSPACE_ID,
"X" + LOG_ANALYTICS_AGENT_KEY
);
const res = await client.send("MyLogs", [
Expand Down
Loading

0 comments on commit 131fb8e

Please sign in to comment.