LogoRobo.js

Linting

Code quality and style with ESLint and Prettier.

Linting catches syntax and style issues early, keeping your codebase consistent and reducing bugs. The create-robo CLI can set up linting automatically during project creation. See Create Robo for details.

ESLint

ESLint identifies and fixes JavaScript and TypeScript errors. It enforces code quality rules and catches potential bugs before they reach production.

To set up ESLint manually, follow the ESLint Getting Started guide. If you used create-robo, select ESLint during setup and it will be configured automatically.

Create a .eslintrc.json file in your project root:

{
	"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
	"env": {
		"node": true
	},
	"parser": "@typescript-eslint/parser",
	"plugins": ["@typescript-eslint"],
	"root": true,
	"rules": {}
}

Create an .eslintignore file to exclude directories that should not be linted:

node_modules
.config
.robo

Prettier

Prettier handles code formatting automatically, ensuring a consistent style across the project. It eliminates formatting debates and keeps code readable.

To set up Prettier, follow the Prettier Installation guide, or select it during create-robo setup.

Create a prettier.config.js file in your project root:

module.exports = {
	printWidth: 120,
	semi: false,
	singleQuote: true,
	trailingComma: 'none',
	tabWidth: 2,
	useTabs: true
}

Running Linters

If your project was created with create-robo, run both ESLint and Prettier with a single command:

npm run lint

Most editors also support real-time linting. For VS Code, install the ESLint extension and the Prettier extension for inline feedback as you type.

Next Steps

On this page