lint command runs ESLint on your Native Desktop project to identify and fix code quality issues, enforce coding standards, and catch potential bugs before they reach production.
Prerequisites
Before running the lint command, ensure:- Your project has been created using
native-desktop create - All dependencies are installed (
npm install) - ESLint configuration exists (
.eslintrc.json)
Basic Usage
To lint your project, open the terminal in the root directory of your Native Desktop project and run:- Load ESLint configuration from
.eslintrc.json - Scan all source files in your project
- Report any code quality issues, warnings, or errors
- Exit with an appropriate status code
What Gets Linted
By default, the lint command checks:- All TypeScript files (
.ts,.tsx) - All JavaScript files (
.js,.jsx) - Files in the
src/directory - Configuration files (if specified)
.eslintignore are automatically excluded from linting.
Output Examples
Successful Lint (No Issues)
With Warnings
With Errors
ESLint Configuration
The lint command uses the.eslintrc.json file generated by native-desktop create. Here’s an example configuration:
Common Linting Rules
The Native Desktop CLI configures ESLint with recommended rules:- Code Quality
- Best Practices
- TypeScript
- Style
- no-unused-vars: Disallow unused variables
- no-undef: Disallow undeclared variables
- no-unreachable: Disallow unreachable code
- no-constant-condition: Disallow constant conditions
Fixing Issues Automatically
While thelint command reports issues, you can fix many of them automatically using the format command:
Ignoring Files
Create or edit.eslintignore to exclude files from linting:
Integration with Development Workflow
Pre-Commit Hook
Add linting to your pre-commit hooks using tools like Husky:CI/CD Pipeline
Include linting in your continuous integration:npm Scripts
Add linting to your package.json scripts:Exit Codes
The lint command uses standard exit codes for CI/CD integration:- 0: No linting errors (warnings are allowed)
- 1: Linting errors found
Common Issues
ESLint Configuration Not Found
ESLint Configuration Not Found
Error:
.eslintrc.json not foundSolution: Ensure the configuration file exists in your project root.Parsing Error
Parsing Error
Error:
Parsing error: Unexpected tokenSolution: Ensure your TypeScript parser is configured correctly.Plugin Not Found
Plugin Not Found
Error:
Failed to load plugin '@typescript-eslint'Solution: Install missing ESLint plugins.Too Many Errors
Too Many Errors
Error: Overwhelmed by linting errorsSolution: Fix errors gradually or adjust rules.
Rule Not Working
Rule Not Working
Error: Expected rule to trigger but didn’tSolution: Verify rule configuration and ESLint version.
Customizing Rules
You can customize ESLint rules in.eslintrc.json:
Rule Severity Levels
- “off” or 0: Disable the rule
- “warn” or 1: Enable as warning (doesn’t fail build)
- “error” or 2: Enable as error (fails build)
Linting Specific Files
While the CLI command lints the entire project, you can lint specific files using npx directly:Best Practices
Lint Early, Lint Often
Run linting frequently during development to catch issues early.
Consistent Rules
Keep ESLint rules consistent across your team and projects.
Address Warnings
Don’t ignore warnings—they often indicate potential issues.
Automate Linting
Integrate linting into your CI/CD pipeline and pre-commit hooks.
IDE Integration
Most modern IDEs integrate with ESLint automatically:Visual Studio Code
Install the ESLint extension:- Open VS Code
- Go to Extensions (Cmd+Shift+X / Ctrl+Shift+X)
- Search for “ESLint”
- Install the official ESLint extension
WebStorm / IntelliJ IDEA
ESLint is built-in and enabled by default. Configure in: Settings → Languages & Frameworks → JavaScript → Code Quality Tools → ESLintQuality Metrics
Track linting issues over time to improve code quality:Command Comparison
| Command | Purpose | Auto-Fix | Focus |
|---|---|---|---|
native-desktop lint | Check code quality | ❌ No | Logic, patterns, bugs |
native-desktop fmt | Format code style | ✅ Yes | Formatting, style |
native-desktop types | Check types | ❌ No | Type safety |
Use all three commands together for comprehensive code quality assurance.