Tooling config

Tooling config

AdonisJS relies heavily on TypeScript, Prettier, and ESLint to have consistency in code, check for errors at build time, and more importantly, have a joyful development experience.

We have abstracted all our choices inside ready-to-use configuration presets used by all the official packages and by the official starter kits.

Continue reading this guide if you want to use the same configuration presets in your Node.js applications written in TypeScript.

TSConfig

The @adonisjs/tsconfig package contains the base configuration for TypeScript projects. We set the TypeScript module system to NodeNext and use TS Node + SWC for Just-in-Time compilation.

Feel free to explore options inside the base config file, application config file, and package development config file.

You can install the package and use it as follows.

npm i -D @adonisjs/tsconfig
# Make sure also to install the following packages
npm i -D typescript ts-node @swc/core

Extend from the tsconfig.app.json file when creating an AdonisJS application. (Comes pre-configured with starter kits).

{
"extends": "@adonisjs/tsconfig/tsconfig.app.json",
"compilerOptions": {
"rootDir": "./",
"outDir": "./build"
}
}

Extend from the tsconfig.package.json file when creating a package for the AdonisJS ecosystem.

{
"extends": "@adonisjs/tsconfig/tsconfig.package.json",
"compilerOptions": {
"rootDir": "./",
"outDir": "./build"
}
}

Prettier config

The @adonisjs/prettier-config package contains the base configuration to auto-format the source code for consistent styling. Feel free to explore configuration options inside the index.json file.

You can install the package and use it as follows.

npm i -D @adonisjs/prettier-config
# Make sure also to install prettier
npm i -D prettier

Define the following property inside the package.json file.

{
"prettier": "@adonisjs/prettier-config"
}

Also, create a .prettierignore file to ignore specific files and directories.

.prettierignore
build
node_modules

ESLint config

The @adonisjs/eslint-config package contains the base configuration to apply the linting rules. Feel free to explore options inside the base config file, application config file, and package development config file.

You can install the package and use it as follows.

Our config preset uses the eslint-plugin-prettier to ensure ESLint and Prettier can work together without stepping over each other.

npm i -D @adonisjs/eslint-config
# Make sure also to install eslint
npm i -D eslint

Extend from the eslint-config/app file when creating an AdonisJS application. (Comes pre-configured with starter kits).

package.json
{
"eslintConfig": {
"extends": "@adonisjs/eslint-config/app"
}
}

Extend from the eslint-config/package file when creating a package for the AdonisJS ecosystem.

package.json
{
"eslintConfig": {
"extends": "@adonisjs/eslint-config/package"
}
}