Skip to content

Commit

Permalink
style: switch to biome
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Sep 27, 2024
1 parent f722ff9 commit 7dec6dd
Show file tree
Hide file tree
Showing 52 changed files with 303 additions and 187 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

47 changes: 0 additions & 47 deletions .eslintrc.js

This file was deleted.

5 changes: 0 additions & 5 deletions .prettierignore

This file was deleted.

7 changes: 0 additions & 7 deletions .prettierrc

This file was deleted.

5 changes: 2 additions & 3 deletions __tests__/__mocks__/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { GitHubEventWorker, IOctokitShape } from '@/queue/worker/github';

export class MockGitHubEventWorker extends GitHubEventWorker {
async createGitHubApp(botId: string): Promise<IOctokitShape | undefined> {
const appSetting = await GitHubKVManager.instance().getAppSettingById(
botId,
);
const appSetting =
await GitHubKVManager.instance().getAppSettingById(botId);

const webhooks = new Webhooks<{
secret: undefined;
Expand Down
12 changes: 6 additions & 6 deletions __tests__/fixtures/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@

import {
CommitCommentCreatedEvent,
DiscussionCreatedEvent,
DiscussionCommentCreatedEvent,
DiscussionCreatedEvent,
IssueCommentCreatedEvent,
PullRequestOpenedEvent,
PullRequestClosedEvent,
PullRequestReviewSubmittedEvent,
PullRequestReviewDismissedEvent,
PullRequestOpenedEvent,
PullRequestReviewCommentCreatedEvent,
PullRequestReviewCommentDeletedEvent,
PullRequestReviewCommentEditedEvent,
PullRequestReviewDismissedEvent,
PullRequestReviewSubmittedEvent,
} from '@octokit/webhooks-types';

import _commit_comment_611372_0_created from './commit_comment_611372_0_created.json';
import _discussion_90_0_created from './discussion_90_0_created.json';
import _discussion_comment_90_0_created from './discussion_comment_90_0_created.json';
import _issue_comment_1_0_created from './issue_comment_1_0_created.json';
import _pull_request_2_0_opened from './pull_request_2_0_opened.json';
import _pull_request_2_3_closed from './pull_request_2_3_closed.json';
import _pull_request_2_4_closed from './pull_request_2_4_closed.json';
import _pull_request_2_12_opened from './pull_request_2_12_opened.json';
import _pull_request_2_13_opened from './pull_request_2_13_opened.json';
import _pull_request_2_14_opened from './pull_request_2_14_opened.json';
import _pull_request_2_3_closed from './pull_request_2_3_closed.json';
import _pull_request_2_4_closed from './pull_request_2_4_closed.json';
import _pull_request_2_review_comment_0_created from './pull_request_2_review_comment_0_created.json';
import _pull_request_2_review_comment_1_created from './pull_request_2_review_comment_1_created.json';
import _pull_request_2_review_comment_2_created from './pull_request_2_review_comment_2_created.json';
Expand Down
8 changes: 4 additions & 4 deletions __tests__/fixtures/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
IssueCommentCreatedEvent,
IssuesOpenedEvent,
PullRequestEditedEvent,
PullRequestReviewSubmittedEvent,
PullRequestOpenedEvent,
PullRequestReviewCommentCreatedEvent,
PullRequestReviewSubmittedEvent,
ReleasePublishedEvent,
IssuesOpenedEvent,
PullRequestOpenedEvent,
IssueCommentCreatedEvent,
} from '@octokit/webhooks-types';

import _antd_mini_release_published from './antd_mini_release_published.json';
Expand Down
2 changes: 1 addition & 1 deletion __tests__/github/render.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { renderPrOrIssue, render } from '@/github/renderer';
import { render, renderPrOrIssue } from '@/github/renderer';

import { issue2045, pr2060 } from '../fixtures';

Expand Down
4 changes: 2 additions & 2 deletions __tests__/github/renderer/make-mark.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { readFile } from 'fs/promises';
import path from 'path';
import { readFile } from 'fs/promises';

import { convertToDingMarkdown } from '@/github/dingtalk';
import { replaceGitHubText } from '@/github/gfm';
import { parseMarkdown, makeMarkdown } from '@/github/renderer/make-mark';
import { makeMarkdown, parseMarkdown } from '@/github/renderer/make-mark';

describe('github renderer make-mark', () => {
it('parse and make', async () => {
Expand Down
8 changes: 4 additions & 4 deletions __tests__/github/templates/prOrIssue.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { handlePr, handleIssue } from '@/github/templates/prOrIssue';
import { handleIssue, handlePr } from '@/github/templates/prOrIssue';

import {
pull_request_2_3_closed,
issue_opened_event,
pull_request_2_0_opened,
pull_request_2_3_closed,
pull_request_2_13_opened,
pull_request_edited_wip,
pull_request_edited_base,
issue_opened_event,
pull_request_edited_wip,
} from '../../fixtures';
import { ctx } from '../ctx';

Expand Down
2 changes: 1 addition & 1 deletion __tests__/github/templates/release.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { handleRelease } from '@/github/templates/release';

import { release_published, antd_mini_release_published } from '../../fixtures';
import { antd_mini_release_published, release_published } from '../../fixtures';
import { ctx } from '../ctx';

describe('release related', () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/github/templates/review.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { writeFile } from 'fs/promises';
import path from 'path';
import { writeFile } from 'fs/promises';

import { convertToDingMarkdown } from '@/github/dingtalk';
import { handleReviewComment } from '@/github/templates/comment';
Expand Down
6 changes: 3 additions & 3 deletions __tests__/github/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { sendToDing } from '@/github/dingtalk';
import {
replaceGitHubUrlToMarkdown,
replaceGitHubText,
parseGitHubUrl,
replaceGitHubText,
replaceGitHubUrlToMarkdown,
} from '@/github/gfm';
import { standardizeMarkdown } from '@/github/renderer/make-mark';
import { handlePr } from '@/github/templates/prOrIssue';
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('github utils', () => {
const urls = [] as string[];
jest
.spyOn(DingUtils, 'send')
.mockImplementation(async (content, url): Promise<any> => {
.mockImplementation(async (_content, url): Promise<any> => {
urls.push(url);
});

Expand Down
18 changes: 9 additions & 9 deletions __tests__/queue/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ import { prepareEnv } from '../__mocks__';
import { MockMessageBatch } from '../__mocks__/queue/message';
import { MockGitHubEventWorker } from '../__mocks__/webhooks';
import {
pull_request_2_3_closed,
antd_mini_release_published,
discussion_90_0_created,
discussion_comment_90_0_created,
issue_opened_event,
pull_request_2_0_opened,
pull_request_2_3_closed,
pull_request_2_13_opened,
pull_request_edited_wip,
pull_request_edited_base,
issue_opened_event,
release_published,
antd_mini_release_published,
pull_request_2_review_comment_0_created,
pull_request_review_4_submitted_changes_requested,
pull_request_2_review_comment_1_created,
discussion_90_0_created,
discussion_comment_90_0_created,
pull_request_edited_base,
pull_request_edited_wip,
pull_request_review_4_submitted_changes_requested,
pull_request_review_submitted_approved,
release_published,
} from '../fixtures';

const botId = 'mock';
Expand Down
90 changes: 90 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": true },
"files": { "ignoreUnknown": false, "ignore": ["dist/**"] },
"formatter": {
"enabled": true,
"useEditorconfig": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80,
"attributePosition": "auto",
"bracketSpacing": true,
"ignore": ["**/index.js", "src/lib", "libs/app.js", "**/.yarn"]
},
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"complexity": { "noUselessTypeConstraint": "error" },
"correctness": {
"noUnusedVariables": "error",
"useArrayLiterals": "off"
},
"style": {
"noNamespace": "off",
"useAsConstAssertion": "error",
"useBlockStatements": "off"
},
"suspicious": {
"noExplicitAny": "warn",
"noExtraNonNullAssertion": "error",
"noMisleadingInstantiator": "error",
"noUnsafeDeclarationMerging": "error",
"useNamespaceKeyword": "error"
}
},
"ignore": ["**/index.js", "dist/**"]
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "all",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto",
"bracketSpacing": true
}
},
"overrides": [
{
"include": ["*.ts", "*.tsx", "*.mts", "*.cts"],
"linter": {
"rules": {
"correctness": {
"noConstAssign": "off",
"noGlobalObjectCalls": "off",
"noInvalidBuiltinInstantiation": "off",
"noInvalidConstructorSuper": "off",
"noNewSymbol": "off",
"noSetterReturn": "off",
"noUndeclaredVariables": "off",
"noUnreachable": "off",
"noUnreachableSuper": "off"
},
"style": {
"noArguments": "error",
"noVar": "error",
"useConst": "error"
},
"suspicious": {
"noDuplicateClassMembers": "off",
"noDuplicateObjectKeys": "off",
"noDuplicateParameters": "off",
"noFunctionAssign": "off",
"noImportAssign": "off",
"noRedeclare": "off",
"noUnsafeNegation": "off",
"useGetterReturn": "off"
}
}
}
}
]
}
4 changes: 2 additions & 2 deletions build-cfworker.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'dotenv/config';

import { context as createContext, Plugin } from 'esbuild';
import { Plugin, context as createContext } from 'esbuild';
import mri from 'mri';

import { buildParams, DEFAULT_BUILD_ARGS } from './build';
import { DEFAULT_BUILD_ARGS, buildParams } from './build';

const argv = mri(process.argv.slice(2));

Expand Down
2 changes: 1 addition & 1 deletion build-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dotenv/config';
import { context as createContext } from 'esbuild';
import mri from 'mri';

import { buildParams, DEFAULT_BUILD_ARGS } from './build';
import { DEFAULT_BUILD_ARGS, buildParams } from './build';

const argv = mri(process.argv.slice(2));

Expand Down
6 changes: 3 additions & 3 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pre-commit:
parallel: true
commands:
eslint:
lint:
glob: '*.{js,ts,jsx,tsx}'
run: yarn eslint {staged_files}
run: yarn lint {staged_files}
prettier:
glob: '*.{js,ts,jsx,tsx,css,less,scss,vue,json,gql,md}'
run: |
yarn prettier {staged_files} -w
yarn lint:fix {staged_files}
git update-index --again
commit-msg:
Expand Down
10 changes: 5 additions & 5 deletions libs/bot-commander/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('bot-commander', () => {
const center = new CommandCenter();

const deferred = new Deferred<ICommand<any>>();
center.on('test', async (ctx, command) => {
center.on('test', async (_ctx, command) => {
deferred.resolve(command);
const text = removeCommandPrefix(command.command, 'test');
console.log(`🚀 ~ center.on ~ text:`, text);
Expand All @@ -28,11 +28,11 @@ describe('bot-commander', () => {
const deferred = new Deferred<ICommand<any>>();
center.intercept(
() => {
center.on('test', async (ctx, command) => {
center.on('test', async (_ctx, command) => {
deferred.resolve(command);
});
},
async (ctx, command) => {
async (_ctx, command) => {
command.command = 'hacked';
return false;
},
Expand All @@ -42,11 +42,11 @@ describe('bot-commander', () => {
let intercepted = false;
center.intercept(
() => {
center.on('test2', async (ctx, command) => {
center.on('test2', async (_ctx, _command) => {
triggered = true;
});
},
(ctx, command) => {
(_ctx, _command) => {
intercepted = true;
return true;
},
Expand Down
Loading

0 comments on commit 7dec6dd

Please sign in to comment.