Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: lint and styling overhaul #77

Draft
wants to merge 87 commits into
base: staging
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
b775be2
add eslint v9/tseslint v8 - 827 errors
ExampleWasTaken May 29, 2024
0cf5021
update eslint and ts-eslint and add prettier support
ExampleWasTaken Jun 13, 2024
f082f9a
add prettier and improve eslint config
ExampleWasTaken Jun 14, 2024
0adefb7
eslint --fix including prettier write
ExampleWasTaken Jun 14, 2024
dbfee06
Revert "eslint --fix including prettier write"
ExampleWasTaken Jun 17, 2024
5e9da51
fix prettier
ExampleWasTaken Jun 17, 2024
3691161
add temporary test npm script
ExampleWasTaken Jun 17, 2024
8f16c61
add prettier scripts
ExampleWasTaken Jun 17, 2024
ad9155a
fix editorconfig and prettierrc
ExampleWasTaken Jun 17, 2024
b2d787c
fix markdown formatting
ExampleWasTaken Jun 17, 2024
fce004d
fix prettier
ExampleWasTaken Jun 17, 2024
362b6f8
add .prettierignore and improve script
ExampleWasTaken Jun 17, 2024
0c2913f
eslint --fix mk1
ExampleWasTaken Jun 17, 2024
b7bf1bc
eslint --fix mk2
ExampleWasTaken Jun 17, 2024
5c2a5cf
add proposed eslint rule additions
ExampleWasTaken Jun 18, 2024
8356dc4
improve eslint rule proposal comment
ExampleWasTaken Jun 18, 2024
9e9e3d7
fix TS build failing
ExampleWasTaken Jun 19, 2024
74dceec
temp test script
ExampleWasTaken Jun 19, 2024
2f2e5bc
fix lint deployCommands.ts
ExampleWasTaken Jun 19, 2024
fd6f39d
fix lint postBirthday.ts
ExampleWasTaken Jun 19, 2024
1b21636
fix lint autoDisableSlowMode.ts
ExampleWasTaken Jun 19, 2024
8b5fe35
fix lint infractionEmbedPagination.ts
ExampleWasTaken Jun 19, 2024
22e8d60
fix genericEmbedPagination.ts
ExampleWasTaken Jun 19, 2024
c109cf8
temp lint script
ExampleWasTaken Jun 19, 2024
630ad36
fix lint durationInEnglish.ts
ExampleWasTaken Jun 19, 2024
e8a9ec4
fix missing type update
ExampleWasTaken Jun 19, 2024
d99a59e
fix error logging
ExampleWasTaken Jun 19, 2024
cc53b03
fix error logging mk2
ExampleWasTaken Jun 19, 2024
68b212e
fix lint config.ts
ExampleWasTaken Jun 19, 2024
f1807ed
fix lint slashCommandHandler.ts
ExampleWasTaken Jun 19, 2024
f21bfae
fix lint ready.ts
ExampleWasTaken Jun 19, 2024
eb5d19d
fix lint scamLogs.ts
ExampleWasTaken Jun 19, 2024
34ec947
fix lint messageUpdate.ts
ExampleWasTaken Jun 19, 2024
83193fb
fix lint messageDelete.ts
ExampleWasTaken Jun 23, 2024
e499b94
fix lint detectBan.ts
ExampleWasTaken Jun 23, 2024
fa42392
fix lint contextInteractionHandler.ts
ExampleWasTaken Jun 23, 2024
3a59e5a
fix lint handleRoleAssignment.ts
ExampleWasTaken Jun 23, 2024
1ae0918
fix lint buttonHandler.ts
ExampleWasTaken Jun 23, 2024
ce55c1b
fix lint autocompleteHandler.ts
ExampleWasTaken Jun 23, 2024
c14e170
fix lint wolframAlpha.ts
ExampleWasTaken Jun 23, 2024
486edb9
disable eslint for vatsim commands
ExampleWasTaken Jun 24, 2024
21d7d46
bump typescript-eslint to latest rc
ExampleWasTaken Jul 14, 2024
9ffd572
bump ts-eslint
ExampleWasTaken Jul 27, 2024
069e6e3
Merge branch 'staging' into ref/lint-overhaul
ExampleWasTaken Aug 5, 2024
13a35cd
bump to typescript-eslint v8
ExampleWasTaken Aug 5, 2024
c96c2d2
pin ts
ExampleWasTaken Aug 6, 2024
cba3c09
fix prettier regressions
ExampleWasTaken Aug 6, 2024
7fbe86b
fix src/
ExampleWasTaken Aug 6, 2024
89e9fc5
update vscode settings and extension recommendations
ExampleWasTaken Aug 7, 2024
b5708a4
fix prettier (again)
ExampleWasTaken Aug 7, 2024
22279b1
Merge branch 'staging' into ref/lint-overhaul
ExampleWasTaken Aug 7, 2024
62147d3
Merge branch 'staging' into ref/lint-overhaul
ExampleWasTaken Sep 12, 2024
daee707
fix casting
ExampleWasTaken Sep 12, 2024
0fc89e3
several eslint fixes
ExampleWasTaken Sep 12, 2024
4c329da
configure prettier as default formatter for ts/js
ExampleWasTaken Sep 12, 2024
6a48522
fix prettier
ExampleWasTaken Sep 12, 2024
b37065b
fix infractionEmbedPagination.ts
ExampleWasTaken Sep 12, 2024
5444e9a
fix genericEmbedPagination.ts
ExampleWasTaken Sep 12, 2024
b91b3f7
fix github commands
ExampleWasTaken Sep 12, 2024
f7d17ef
fix birthday.ts
ExampleWasTaken Sep 12, 2024
7a115c7
remove unused imports
ExampleWasTaken Sep 12, 2024
c4ff100
fix whois
ExampleWasTaken Sep 12, 2024
72c09c5
fix slowmode
ExampleWasTaken Sep 12, 2024
2fdcfd0
partly fix infractions
ExampleWasTaken Oct 19, 2024
cbfe376
fix listInfractions.ts
ExampleWasTaken Oct 26, 2024
728689d
fix ban infraction
ExampleWasTaken Oct 26, 2024
f01d3d7
fix faqs
ExampleWasTaken Oct 26, 2024
232de8c
fix command deploy
ExampleWasTaken Oct 26, 2024
1c4feba
fix clear messages cmd
ExampleWasTaken Oct 26, 2024
e53a13b
fix cache update cmd
ExampleWasTaken Oct 26, 2024
fc3831f
fix user info context menu
ExampleWasTaken Oct 26, 2024
22fe244
Merge branch 'staging' into ref/lint-overhaul
ExampleWasTaken Oct 26, 2024
639c3ca
fix report message context menu
ExampleWasTaken Oct 27, 2024
7364a09
ignore lint error in client.ts
ExampleWasTaken Oct 27, 2024
72e1cfc
fix npm scripts
ExampleWasTaken Oct 27, 2024
0a1a256
add prettier workflow job
ExampleWasTaken Oct 27, 2024
3faf6f9
Merge branch 'staging' into ref/lint-overhaul
ExampleWasTaken Oct 29, 2024
460c1b1
bump linting packages to latest version
ExampleWasTaken Oct 29, 2024
e263d96
bump prettier to latest version
ExampleWasTaken Oct 29, 2024
8589245
bump eslint prettier config and plugin to latest version
ExampleWasTaken Oct 29, 2024
4dff288
fix prettier errors introduced in #85 (expected)
ExampleWasTaken Oct 29, 2024
3ecbac2
partial prefix cmd lint fix
ExampleWasTaken Oct 31, 2024
7927cac
refactor prefix message handler
ExampleWasTaken Oct 31, 2024
3c93ed2
fix lint issue in showContent cmd
ExampleWasTaken Oct 31, 2024
0ad6003
remove unnecessary template strings in error logs
ExampleWasTaken Oct 31, 2024
45f3b07
fix regression that wouldn't load prefix cmds on startup
ExampleWasTaken Oct 31, 2024
a48e9ba
revert schema change
ExampleWasTaken Nov 1, 2024
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
15 changes: 13 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
tab_width = 4
trim_trailing_whitespace = true

[*.{js,jsx,ts,tsx}]
indent_size = 2
insert_final_newline = true
tab_width = 2

# YAML is usually 2 spaces
# Markdown will cause weird formating with 4 spaces
[*.{md,yml,yaml}]
indent_size = 2
tab_width = 2
38 changes: 0 additions & 38 deletions .eslintrc.json

This file was deleted.

18 changes: 9 additions & 9 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
## Changelog

Update <small>_ October 2024</small>
Update <small>\_ October 2024</small>

- feat: Prefix Command Management (28/10/2024)
- fix: role assignment typo for server announcements (22/10/2024)

Update <small>_ August 2024</small>
Update <small>\_ August 2024</small>

- feat: add runway information to simbriefdata (08/08/2024)
- chore: add vscode editor settings (08/08/2024)
- fix: temporarily pin typescript version to v5.4.x (see https://github.com/flybywiresim/discord-bot-utils/issues/78) (07/10/2024)

Update <small>_ July 2024</small>
Update <small>\_ July 2024</small>

- fix: resolve security vulnerabilities in 3rd-party packages (27/07/2024)
- fix: corrected typo in the embed for simbrief-data support-request (27/07/2024)
- docs: updated the Ground Rules on the Contributing guide page (27/07/2024)
- feat: add optional description to `/locate` panels. (27/07/2024)

Update <small>_ May 2024</small>
Update <small>\_ May 2024</small>

- fix: keep footer on embed expire (29/05/2024)
- feat: /clear-messages command (29/05/2024)
Expand All @@ -34,20 +34,20 @@ Update <small>_ May 2024</small>
- fix: lint workflow failing silently (18/05/2024)
- chore: fix eol issues on Windows (17/05/2024)

Update <small>_ April 2024</small>
Update <small>\_ April 2024</small>

- fix: clarify errors in timeout command (30/04/2024)
- fix: adds mod alerts to the config requirements (30/04/2024)

Update <small>_ March 2024</small>
Update <small>\_ March 2024</small>

- fix: birthday handler user caching issue (23/03/2024)
- feat: adds github issue command (18/03/2024)
- fix: content change in welcome command (18/03/2024)
- fix: multiple plus symbols in zulu command (18/03/2024)
- feat: add infractions counts to buttons in list infractions command (18/03/2024)

Update <small>_ February 2024</small>
Update <small>\_ February 2024</small>

- fix: report message logging bug (18/02/2024)
- feat: command to list users in a role (18/02/2024)
Expand All @@ -58,7 +58,7 @@ Update <small>_ February 2024</small>
- fix: message edit and delete crash (01/02/2024)
- feat: add heartbeat mechanism for monitoring (01/02/2024)

Update <small>_ January 2024</small>
Update <small>\_ January 2024</small>

- fix: defer interaction for cache update (28/01/2024)
- fix: defer interaction on birthday list command (28/01/2024)
Expand All @@ -68,7 +68,7 @@ Update <small>_ January 2024</small>
- fix: ScamLog - Ignore messages entirely unless it has everyone (28/01/2024)
- fix: command names (28/01/2024)
- fix: ignore Dyno bot (27/01/2024)
- fix: use - instead of _ in command names (27/01/2024)
- fix: use - instead of \_ in command names (27/01/2024)
- feat: auto-generation of the command table (24/01/2024)
- feat: migrate reportedIssues command (22/01/2024)
- feat: docSearch command (22/01/2024)
Expand Down
59 changes: 33 additions & 26 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Some commands may require additional tokens. If you would like to test them out

## Adding a New Command

>Please note, this will only show the basics of adding a command.
> Please note, this will only show the basics of adding a command.

1. Create a new file in the relevant folder within `src/commands/` and name it appropriately. `yourcommand.ts`.
2. Create your command.
Expand Down Expand Up @@ -224,42 +224,49 @@ import { ApplicationCommandOptionType, ApplicationCommandType } from 'discord.js
import { slashCommand, slashCommandStructure, AutocompleteCallback, makeEmbed } from '../../lib';

const data = slashCommandStructure({
name: 'ping',
description: 'Ping the bot for a response.',
type: ApplicationCommandType.ChatInput,
default_member_permissions: constantsConfig.commandPermission.MANAGE_SERVER, //Optional command permission - always use MANAGE_SERVER and add a comment to specify overrides needed (roles, channels etc.)
dm_permission: false, // Optional, this sets if commands can be run in DMs (global commands only)
options: [{ // Optional, this is where you can add options to your command
name: 'message',
description: 'Provide some text to send back.',
type: ApplicationCommandOptionType.String,
max_length: 100,
required: false,
autocomplete: true, // Optional - This is only required if you plan on using autocomplete for your command.
}],
name: 'ping',
description: 'Ping the bot for a response.',
type: ApplicationCommandType.ChatInput,
default_member_permissions: constantsConfig.commandPermission.MANAGE_SERVER, //Optional command permission - always use MANAGE_SERVER and add a comment to specify overrides needed (roles, channels etc.)
dm_permission: false, // Optional, this sets if commands can be run in DMs (global commands only)
options: [
{
// Optional, this is where you can add options to your command
name: 'message',
description: 'Provide some text to send back.',
type: ApplicationCommandOptionType.String,
max_length: 100,
required: false,
autocomplete: true, // Optional - This is only required if you plan on using autocomplete for your command.
},
],
});

// Optional - This is only required if you plan on using autocomplete for your command.
const autocompleteCallback: AutocompleteCallback = ({ interaction }) => {
// Autocomplete logic goes here
const choices = [
{
name: 'Display Name',
value: 'Value that is actually sent to your bot.'
},
];

// If you can't autocomplete anything respond with an empty array.
return interaction.respond(choices);
// Autocomplete logic goes here
const choices = [
{
name: 'Display Name',
value: 'Value that is actually sent to your bot.',
},
];

// If you can't autocomplete anything respond with an empty array.
return interaction.respond(choices);
};

export default slashCommand(data, async ({ interaction }) => {
export default slashCommand(
data,
async ({ interaction }) => {
const msg = interaction.options.getString('message') ?? 'Pong 🏓';

const pongEmbed = makeEmbed({ description: msg });

return interaction.reply({ embeds: [pongEmbed] });
}, autocompleteCallback); // Optional - This is only required if you plan on using autocomplete for your command.
},
autocompleteCallback,
); // Optional - This is only required if you plan on using autocomplete for your command.
```

## Command Permissions
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report_beta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ labels: [Bug]
body:
- type: markdown
attributes:
value: "# FlyByWire Discord bot Bug Report Form"
value: '# FlyByWire Discord bot Bug Report Form'
- type: dropdown
id: type
attributes:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request_beta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ labels: [Request]
body:
- type: markdown
attributes:
value: "# FBW Discord Bot Feature Request Form"
value: '# FBW Discord Bot Feature Request Form'
- type: dropdown
id: type
attributes:
Expand Down
24 changes: 12 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
version: 2

updates:
- package-ecosystem: npm
directory: /
schedule:
interval: monthly
commit-message:
prefix: "chore"
include: scope
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-minor", "version-update:semver-patch"]
open-pull-requests-limit: 10
target-branch: staging
- package-ecosystem: npm
directory: /
schedule:
interval: monthly
commit-message:
prefix: 'chore'
include: scope
ignore:
- dependency-name: '*'
update-types: ['version-update:semver-minor', 'version-update:semver-patch']
open-pull-requests-limit: 10
target-branch: staging
40 changes: 20 additions & 20 deletions .github/workflows/cdn-upload-production.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name: CDN Upload - Production

on:
workflow_dispatch:
push:
branches:
- production
paths:
- 'assets/images**'
workflow_dispatch:
push:
branches:
- production
paths:
- 'assets/images**'

jobs:
cdn_upload:
if: github.repository_owner == 'flybywiresim' # Prevent running this on forks
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Upload to CloudFlare CDN
env:
CLOUDFLARE_CDN_URL: ${{ secrets.CLOUDFLARE_CDN_URL_PRODUCTION }}
CLOUDFLARE_ACCESS_KEY: ${{ secrets.CLOUDFLARE_ACCESS_KEY_PRODUCTION }}
run: |
./.github/workflow_scripts/cf-cdn.sh
cdn_upload:
if: github.repository_owner == 'flybywiresim' # Prevent running this on forks
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Upload to CloudFlare CDN
env:
CLOUDFLARE_CDN_URL: ${{ secrets.CLOUDFLARE_CDN_URL_PRODUCTION }}
CLOUDFLARE_ACCESS_KEY: ${{ secrets.CLOUDFLARE_ACCESS_KEY_PRODUCTION }}
run: |
./.github/workflow_scripts/cf-cdn.sh
40 changes: 20 additions & 20 deletions .github/workflows/cdn-upload-staging.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name: CDN Upload - Staging

on:
workflow_dispatch:
push:
branches:
- staging
paths:
- 'assets/images**'
workflow_dispatch:
push:
branches:
- staging
paths:
- 'assets/images**'

jobs:
cdn_upload:
if: github.repository_owner == 'flybywiresim' # Prevent running this on forks
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Upload to CloudFlare CDN
env:
CLOUDFLARE_CDN_URL: ${{ secrets.CLOUDFLARE_CDN_URL_STAGING }}
CLOUDFLARE_ACCESS_KEY: ${{ secrets.CLOUDFLARE_ACCESS_KEY_STAGING }}
run: |
./.github/workflow_scripts/cf-cdn.sh
cdn_upload:
if: github.repository_owner == 'flybywiresim' # Prevent running this on forks
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Upload to CloudFlare CDN
env:
CLOUDFLARE_CDN_URL: ${{ secrets.CLOUDFLARE_CDN_URL_STAGING }}
CLOUDFLARE_ACCESS_KEY: ${{ secrets.CLOUDFLARE_ACCESS_KEY_STAGING }}
run: |
./.github/workflow_scripts/cf-cdn.sh
Loading