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
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ assign you to the issue so you can begin working on it.
4. Install the necessary node packages and dependencies.

```sh
$ npm install
$ pnpm install
```

5. Use the [smee.io](https://smee.io/) CLI to redirect GitHub webhook payloads
Expand All @@ -81,7 +81,7 @@ assign you to the issue so you can begin working on it.
7. Run the bot to ensure that your environment was configured correctly.

```sh
$ npm start
$ pnpm start
```

If you encounter any problems during installation, let us know on the [zulipbot
Expand All @@ -98,7 +98,7 @@ chat](https://chat.zulip.org/#narrow/stream/zulipbot) and we can help you out!
3. Check if your changes and commits pass all tests:

```sh
$ npm test
$ pnpm test
```

Modify your commits accordingly if your changes don't pass all tests.
Expand Down
6 changes: 3 additions & 3 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ the **zulipbot wiki**.

## Usage

If you're using the [Zulip project configuration](../config/config-example.js)
(`./config/config-example.js`), see zulipbot's [usage
If you're using the [Zulip project configuration](../config/config-example.ts)
(`./config/config-example.ts`), see zulipbot's [usage
instructions](https://zulip.readthedocs.io/en/latest/contributing/zulipbot-usage.html)
on the Zulip documentation.

If you're using your own custom configuration (`./config/config.js` is different
If you're using your own custom configuration (`./config/config.ts` is different
from the Zulip project configuration), please visit the
[Commands](https://github.com/zulip/zulipbot/wiki/Commands) page on the
**zulipbot wiki**.
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ jobs:

steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
with:
run_install: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- run: ln -s config-example.js config/config.js
- run: npm ci
- run: npm test
cache: pnpm
- run: ln -s config-example.ts config/config.ts
- run: pnpm install --frozen-lockfile
- run: pnpm test
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.tap
node_modules
/config/config.js
/config/config.ts
/config/secrets.json
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.tap
/config/config.js
/config/config.ts
/config/secrets.json
/pnpm-lock.yaml
/pnpm-workspace.yaml
File renamed without changes.
60 changes: 35 additions & 25 deletions config/default.js → config/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
* explanations on each option.
*/

import { safeCastTo } from "ts-extras";

// Default authentication specified by environment variables
export const auth = {
oAuthToken: process.env.OAUTH_TOKEN,
webhookSecret: process.env.WEBHOOK_SECRET,
export const auth: {
oAuthToken: string | undefined;
webhookSecret: string | undefined;
username?: string;
} = {
oAuthToken: process.env["OAUTH_TOKEN"],
webhookSecret: process.env["WEBHOOK_SECRET"],
};

/**
Expand All @@ -20,27 +26,27 @@ export const auth = {
export const issues = {
commands: {
assign: {
claim: [],
abandon: [],
claim: new Array<string>(),
abandon: new Array<string>(),
limit: Number.POSITIVE_INFINITY,
newContributors: {
permission: null,
permission: safeCastTo<string | null>(null),
restricted: Number.POSITIVE_INFINITY,
},
warn: {
labels: [],
labels: new Array<string>(),
presence: false,
force: true,
},
},
label: {
add: [],
remove: [],
self: false,
add: new Array<string>(),
remove: new Array<string>(),
self: safeCastTo<boolean | { users: string[] }>(false),
},
},
area: {
labels: null,
labels: safeCastTo<Map<string, string> | null>(null),
references: false,
},
};
Expand All @@ -56,18 +62,22 @@ export const pulls = {
status: {
mergeConflicts: {
branch: "main",
label: null,
label: safeCastTo<string | null>(null),
comment: false,
},
wip: null,
wip: safeCastTo<string | null>(null),
size: {
labels: null,
exclude: [],
labels: safeCastTo<Map<string, number> | null>(null),
exclude: new Array<string>(),
},
},
references: {
required: false,
labels: false,
labels: safeCastTo<
| { include: string[]; exclude?: never }
| { include?: never; exclude: string[] }
| false
>(false),
},
};

Expand All @@ -79,25 +89,25 @@ export const pulls = {
*/

export const activity = {
inactive: null,
inactive: safeCastTo<string | null>(null),
check: {
repositories: [],
interval: null,
reminder: null,
limit: null,
repositories: new Array<string>(),
interval: safeCastTo<number | null>(null),
reminder: safeCastTo<number | null>(null),
limit: safeCastTo<number | null>(null),
},
issues: {
inProgress: null,
inProgress: safeCastTo<string | undefined>(undefined),
clearClosed: false,
},
pulls: {
autoUpdate: true,
reviewed: {
label: null,
assignee: null,
label: safeCastTo<string | null>(null),
assignee: safeCastTo<boolean | null>(null),
},
needsReview: {
label: null,
label: safeCastTo<string | null>(null),
ignore: false,
},
},
Expand Down
13 changes: 13 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from "eslint/config";
import xo from "eslint-config-xo";
import xoTypeScript from "eslint-config-xo-typescript";
import importPlugin from "eslint-plugin-import";
import prettierRecommended from "eslint-plugin-prettier/recommended";
import unicorn from "eslint-plugin-unicorn";
Expand All @@ -9,6 +10,10 @@ export default defineConfig(
ignores: ["package-lock.json"],
},
xo,
{
files: ["**/*.{cts,mts,ts}"],
extends: xoTypeScript,
},
importPlugin.flatConfigs.recommended,
unicorn.configs.recommended,
prettierRecommended,
Expand All @@ -21,6 +26,8 @@ export default defineConfig(
},
rules: {
"@stylistic/curly-newline": "off", // https://github.com/prettier/eslint-config-prettier/issues/351
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-restricted-types": "off",
"arrow-body-style": "error",
"capitalized-comments": "off",
curly: ["error", "multi-line", "consistent"],
Expand All @@ -45,8 +52,10 @@ export default defineConfig(
strict: "error",
"unicorn/no-null": "off",
"unicorn/no-process-exit": "off",
"unicorn/no-useless-undefined": "off",
"unicorn/numeric-separators-style": "off",
"unicorn/prefer-node-protocol": "off",
"unicorn/prefer-ternary": "off",
"unicorn/prevent-abbreviations": [
"error",
{ replacements: { args: false } },
Expand All @@ -61,4 +70,8 @@ export default defineConfig(
strict: "off",
},
},
{
files: ["**/tsconfig.json"],
language: "json/jsonc", // https://github.com/xojs/xo/issues/798
},
);
Loading