Skip to content

Commit

Permalink
upgrade: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
3axap4eHko committed Aug 9, 2023
1 parent 4eb58cc commit d9a2abf
Show file tree
Hide file tree
Showing 8 changed files with 286 additions and 217 deletions.
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"extends": [
"prettier",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"plugins": ["@typescript-eslint", "prettier"],
"rules": {
"prettier/prettier": 1,
"@typescript-eslint/ban-ts-comment": 1,
"@typescript-eslint/no-empty-interface": 1
}
Expand Down
12 changes: 10 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/usr/bin/env sh
set -e

. "$(dirname -- "$0")/_/husky.sh"

yarn pretty-quick --staged
yarn eslint
CHANGED_FILES=$(git diff --name-only --cached --diff-filter=ACMR)
STAGED_CODE=$(echo "$CHANGED_FILES" | grep -E '\.(ts|js)$' || true)

if [ -z "$STAGED_CODE" ]; then
echo "Skip code linitng"
else
yarn eslint --fix $STAGED_CODE && git add $STAGED_CODE || exit 1
fi
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,16 @@
"@swc/jest": "^0.2.26",
"@types/jest": "^29.5.2",
"@types/node": "^20.3.1",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"eslint": "^8.42.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.0.0",
"fast-glob": "^3.2.12",
"husky": "^8.0.3",
"inop": "^0.3.1",
"jest": "^29.5.0",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.3",
"prettier": "^3.0.1",
"ts-jest": "^29.1.0",
"typescript": "^5.1.3"
}
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('createQueue test suite', () => {
const queue = createQueue();
const result = queue.pull();
await expect(Promise.race([wait(1, value), result.promise])).resolves.toBe(
value
value,
);
expect(result).toBeInstanceOf(Deferred);
expect(result.status).toBe(Status.PENDING);
Expand Down
2 changes: 1 addition & 1 deletion src/combine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const combine = <T, R = unknown>(...iterables: AsyncIterable<T>[]) => {
for await (const value of iterable) {
await queue.push({ value, done: false }).promise;
}
})
}),
).then(async () => queue.done({ value: null, done: true }));

return {
Expand Down
2 changes: 1 addition & 1 deletion src/generatorify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const generatorify = <T, R>(task: Task<T, R>): AsyncIterable<T> => {
Promise.resolve(
task(async (value) => {
await queue.push({ value, done: false }).promise;
})
}),
).then(async (value) => queue.done({ value, done: true }));

return {
Expand Down
6 changes: 3 additions & 3 deletions src/queue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defer, Deferred, Status } from './defer.js';
import { defer, Deferred } from './defer.js';

export const createQueue = <T, E = Error>() => {
const pendingQueue: Deferred<T, E>[] = [];
Expand Down Expand Up @@ -42,8 +42,8 @@ export const createQueue = <T, E = Error>() => {
push(value);
return Promise.all(
[...pendingQueue, ...resolvedQueue, ...requestQueue].map(
(d) => d.promise
)
(d) => d.promise,
),
);
},
get size() {
Expand Down
Loading

0 comments on commit d9a2abf

Please sign in to comment.