sinpro.dev
Docs
Team sinProject
Locales
  • Company Information
    • Portfolio
    • About
    • Services
    • Events
  • Dev Environment
    • macOS Settings
    • Chrome Extensions
    • VSCode Workspace Settings
    • VSCode Workspace Extensions
    • Global NPM Packages
    • npm-check-updates
    • SvelteKit
    • Customize Zsh
    • ChatGPT Prompts
    • Tailwind CSS
    • Warp
    • Keyboard Shortcuts
  • Assets
    • Assets
    • JPG/PNG to AVIF
    • TTF to WOFF2
  • Clean Code
    • Clean Code
    • Format
    • Quality
    • Variables
    • Functions
    • Objects and Data Structures
    • Classes
    • Concurrency
    • Error handling
    • Comments
  • Code Style
    • TypeScript Config
    • Prettier
    • ESLint
    • Stylelint
  • Testing
    • Vitest
    • Playwright
  • Git
    • Git Branches and Commits
    • Git Hooks
    • Git User Profiles
    • Git for Windows
  • GitHub
    • GitHub Issues
    • GitHub Pull Requests
    • GitHub Repository Settings
    • GitHub Branch Protection
    • GitHub Actions
  • Code Quality
    • SonarCloud Coverage
  • Server
    • SSH
    • PM2
    • Caddy
    • Updating the server
    • ngrok
  • Team sinProject
    • Our Team Policy
    • Equipment and Supplies
    • Books
    • Slack
    • Locales
    • Funny Apps
    • Docs History
  • Talk
    • Talk
    • Creating a Project
    • App Structure

Clean Code

Quality

Edit this page

Achieve exactly what is being requested

Display ‘Hello, World!’

Bad
console.log('Hello world!')
Good
console.log('Hello, World!')

Don’t commit code that cannot be executed

Bad
function foo(): void {
 console.log(`Hello`)
Good
function foo(): void {
 console.log(`Hello`)
}

Don’t allow code clones

Bad
function check_odd_or_even(input_number: number): string {
  if (input_number % 2 == 0) {
    return `${input_number} is Even`
  } else {
    return `${input_number} is Odd`
  }
}
Good
function check_odd_or_even(input_number: number): string {
  let result = input_number % 2 == 0 ? 'Even' : 'Odd'

  return `${input_number} is ${result}`
}
Format Variables
© sinProject. v0.73.0
On this page
  • Quality
  • Achieve exactly what is being requested
  • Don’t commit code that cannot be executed
  • Don’t allow code clones