Package
Type-aware ESLint rules for discord.js. Aside from the two prefer-* style rules, each rule flags a payload or command definition that fails at runtime, either in discord.js validation or at the Discord API. Rules check only values known at lint time and skip dynamic ones.
pnpm add -D eslint-plugin-discordjspnpm add -D eslint-plugin-discordjsRequires ESLint 9.22.0+ flat config with typed linting (projectService), since most rules read types.
// eslint.config.js
import { defineConfig } from 'eslint/config';
import discordjs from 'eslint-plugin-discordjs';
import tseslint from 'typescript-eslint';
export default defineConfig(
// ...your existing config
{
files: ['**/*.ts'],
extends: [discordjs.configs.recommended],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname
}
}
}
);// eslint.config.js
import { defineConfig } from 'eslint/config';
import discordjs from 'eslint-plugin-discordjs';
import tseslint from 'typescript-eslint';
export default defineConfig(
// ...your existing config
{
files: ['**/*.ts'],
extends: [discordjs.configs.recommended],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname
}
}
}
);If your config already sets up typed linting, drop the languageOptions block and keep the scoped extends entry.
| Rule | Catches |
|---|---|
| no-mixed-message-format | components v2 builders mixed with content/embeds/poll/stickers, Discord rejects the payload |
| require-components-v2-flag | v2 components without MessageFlags.IsComponentsV2 |
| select-menu-min-exceeds-max | a minimum above the maximum, from setters or constructor data, the API rejects it |
| no-discord-limit-exceeded | more items than a builder's hard cap (5 row components, 25 options/fields/choices), constructor data included |
| no-conflicting-button-props | customId with url, a url or skuId on the wrong style, a Premium button with a customId, label, url, or emoji |
| require-button-props | a sealed button missing its style or its style's required props (customId, url, skuId, label/emoji) |
| no-choices-and-autocomplete | autocomplete and static choices on one slash option |
| required-option-before-optional | a required slash option after an optional one |
| valid-command-name | slash command and option names Discord rejects |
| prefer-ephemeral-flag | the deprecated ephemeral: true reply option, autofixes to MessageFlags.Ephemeral |
| prefer-v2-component | embed usage that components v2 can replace (style preference, warns) |
All rules run at error except the two prefer-* style rules, which warn.
These rules are the discord.js half of the seedcord lint setup. seedcord bots add @seedcord/eslint-plugin, whose seedcord preset layers the framework rules over this plugin's recommended.