- FAQ
- Introduction
- Comparisons
- Quick Start
- Features
- Disclaimer
- Requirements
- Event Handler
- Command Handler
- Messages
- Chats
- Groups
- Contacts
- Polls
- Channels
- Orders
- Payments
- Multi Device
- Presence and Profile
What Is WWebJS
Setup
Your Application
Components
Business Features
Advanced Topics
Contributing
In app projects, linting and formatting are reliability tools, not style accessories.
Goal
You want to achieve three outcomes:
- Catch errors early.
- Keep team conventions consistent.
- Reserve reviews for architecture and behavior.
1. Install tools
npm install --save-dev eslint prettier eslint-config-prettier2. Configure ESLint
Create eslint.config.js:
const js = require('@eslint/js')
module.exports = [
js.configs.recommended,
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'commonjs',
},
rules: {
'no-unused-vars': 'warn',
'no-console': 'off',
eqeqeq: ['error', 'always'],
},
},
]Why eqeqeq matters: implicit coercion often causes event flow bugs.
3. Add Prettier
Create .prettierrc.json:
{
"singleQuote": true,
"semi": false,
"trailingComma": "all",
"printWidth": 100
}4. Add scripts in package.json
{
"scripts": {
"lint": "eslint src",
"lint:fix": "eslint src --fix",
"format": "prettier --write src",
"format:check": "prettier --check src"
}
}5. Daily workflow
Use this sequence consistently:
- run
npm run lintbefore commit. - run
npm run formatfor file consistency. - run
npm run lintagain before push.
This lowers integration noise across branches.
6. Rule focus for app projects
Extend rules intentionally:
- warnings for unused values,
- strict equality checks,
- no silent promise failures,
- no uncontrolled global state.
Add plugins gradually as your codebase grows.
7. Editor integration
For VS Code, these settings are useful:
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}8. Add a pre commit guard
Optional but recommended:
npm install --save-dev husky
npx husky initThen configure .husky/pre-commit:
npm run lint
npm run format:checkThis prevents broken quality checks from entering the repository.