Skip to content

Commit

Permalink
Add ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
mryhryki committed Aug 5, 2023
1 parent 9bf57bf commit 5f7c1d4
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 10 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"root": true
}
16 changes: 12 additions & 4 deletions .github/workflows/check_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Show environment
run: set -x; pwd; ls -la; node -v; npm -v;
- name: Install dependencies
run: npm install

# TODO: Remove next step
- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Show environment
run: set -x; pwd; ls -la; deno --version;

- name: Test
run: deno test ./src/
- name: Check
run: deno check ./src/test/index.ts
- name: Format
run: deno fmt ./src/
- name: Lint
run: npm run lint
2 changes: 1 addition & 1 deletion .github/workflows/publish_to_npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/setup-node@v3
- name: Show environment
run: set -x; pwd; ls -la; node -v; npm -v;
- name: Run npm install
- name: Install dependencies
run: npm install
- name: Configure git
run: |
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@
"scripts": {
"build": "esbuild --bundle --platform=neutral --outfile=./dist/index.js ./src/index.ts",
"check": "deno check ./src/test/index.ts",
"fmt": "deno fmt ./src/",
"lint": "eslint ./src/",
"lint:fix": "eslint --fix ./src/",
"prepare": "npm run build",
"test": "deno test ./src/"
},
"devDependencies": {
"esbuild": "^0.18.15"
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"esbuild": "^0.18.15",
"eslint": "^8.46.0",
"typescript": "^5.1.6"
}
}
6 changes: 3 additions & 3 deletions src/hex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Deno.test("Hex", async (t) => {

await t.step("Hex.toBin(Not string)", () => {
try {
Hex.toBin(1234 as any);
Hex.toBin(1234 as any); // eslint-disable-line @typescript-eslint/no-explicit-any
fail("Hex.toBin() is not thrown Error");
} catch (err) {
assert(err instanceof Error);
Expand All @@ -55,11 +55,11 @@ Deno.test("Hex", async (t) => {
await t.step("Hex.fromBin(Not Uint8Array)", () => {
assertEquals(HexText, Hex.fromBin(HexBin));
try {
Hex.fromBin(new Int8Array(4) as any);
Hex.fromBin(new Int8Array(4) as any); // eslint-disable-line @typescript-eslint/no-explicit-any
fail("Hex.fromBin() is not thrown Error");
} catch (err) {
assert(err instanceof Error);
assertEquals(err.message, '"bin" is not Uint8Array');
}
});
})
});
6 changes: 6 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export namespace SimpleEncryption {
type HexString = string;
type SupportAlgorithm = "AES-GCM" | "AES-CBC";

// FIXME
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface EncryptArgs {
alg?: SupportAlgorithm | null;
iv?: HexString | null;
Expand All @@ -25,10 +27,14 @@ export namespace SimpleEncryption {
iv: HexString;
}

// FIXME
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface DecryptArgs extends EncryptedData {
key: HexString;
}

// FIXME
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface DecryptedData {
plainData: Uint8Array;
}
Expand Down

0 comments on commit 5f7c1d4

Please sign in to comment.