-
Set up
.gitignore
:- Copy from here.
-
Install
nodenv
:brew install nodenv nodenv install 14.4.0 nodenv local 14.4.0
-
Set up
package.json
:npm init
-
Set up types:
npm install --save-dev @types/node
-
Set up and configure TypeScript:
npm install --save-dev typescript npx tsc --init
- Required TS config settings:
{ "compilerOptions": { "module": "ESNext" }, "rules": { "no-unused-vars": "off", "@typescript-eslint/no-unused-vars": "error" } }
- All config options
- Helpful setup guide
@typescript-eslint/no-unused-vars
fixesno-unused-vars
firing on TS types. (Link)
-
Set up and configure ESLint:
npm install --save-dev eslint npx eslint --init
(Using Airbnb + TypeScript)
In
.eslintrc
:{ "import/extensions": [ "error", "ignorePackages", { "js": "never", "jsx": "never", "ts": "never", "tsx": "never" } ] }
-
Set up and configure eslint-import-resolver-typescript:
npm install --save-dev eslint-import-resolver-typescript
in
.eslintrc
:{ "settings": { "import/resolver": { "typescript": {} } } }
-
Set up Prettier:
npm install --save-dev prettier
-
Set up eslint-config-prettier:
npm install --save-dev eslint-config-prettier
- Extend
.eslintrc
witheslint-config-prettier
.
- Extend
-
Set up lint-staged:
npx mrm lint-staged
-
Create an
index.ts
file:touch index.ts echo 'console.log("Hello, World!")' >> index.ts npx tsc node index.js
- Install the JetBrains plugin for Node.js.
- Ensure you are on Node >= 13 for ES6 module support (StackOverflow).
- Enable
"sourceMap": true
intsconfig.json
. - Set up a Run/Debug Configuration for Node.js.
- In the "Before launch" section, add the action "Compile TypeScript".
- If you're using ES6 modules (experimental) instead of CommonJS modules (default):
- Add
"type": "module"
topackage.json
. - Rename
.eslintrc.js
to.eslintrc.cjs
.
- Add
- Follow this guide.
npm install --save discord.js
- Install the Discord bot framework of your choice.
- This article comparing frameworks seems useful?
npm install --save discordjs/Commando
- Create a bot user + token and save it to the
CAP_DISCORD_BOT_TOKEN
environmental variable. - Run
npm start
.