Code quality

From redis/RedisInsight · View interactive version

Code quality is an AI agent skill from the GitHub repository redis/RedisInsight. Code-quality standards for RedisInsight: TypeScript strictness, naming conventions (camelCase, PascalCase, UPPER_SNAKE_CASE), linting rules, no `any` without reason, no `!important` in styles, and constant extraction. Use when writing or refactoring any TypeScript/JavaScript code in this repo, when

How to use this skill

Skill file

Code Quality Standards

Critical Rules

TypeScript Standards

Essential Rules

Import Organization

Required Order (enforced by ESLint)

  1. External libraries (react, lodash, etc.)
  2. Built-in Node modules (path, fs - backend only)
  3. Internal modules with aliases (uiSrc/*, apiClient)
  4. Sibling/parent relative imports
  5. Style imports (ALWAYS LAST)

Module Aliases

The UI workspace must not import from the backend codebase directly. Use apiClient for types and the existing service layer (uiSrc/services) for HTTP calls.

✅ Use aliases: import { Button } from 'uiSrc/components/Button'

❌ Avoid relative: import { Button } from '../../../ui/src/components/Button'

Naming Conventions

Comments

Default to fewer comments. Clear names, small functions, and good

tests should carry the meaning. Write a comment only when the code

genuinely can't explain itself — or when the user explicitly asks for

more (for example, on a piece of complex logic).

When you do write one, keep it short and use plain words to say

what the code is doing or why it has to exist — not how it

works under the hood, and not the story of why you made the change

(that belongs in the commit message or PR description).

✅ Good — plain, names the situation:

// When switching keys, hide the previous key's loader/error/result
// until the new key is ready.
const showLoader = isArrayKeyReady && loading

❌ Avoid — long, mechanism-heavy, re-derives what the code shows:

// Gate every aggregate-slice surface (loader, error, result) on
// `isArrayKeyReady`: when the user switches keys, `keyProp` flips
// immediately but `selectedKeyData` lags by a round-trip, so the
// prior key's slice state would otherwise paint under the newly
// selected (or empty) key for one frame before the hook's reset
// effect fires.
const showLoader = isArrayKeyReady && loading

Also avoid:

SonarJS Rules

Best Practices

Vite Cache Management

When updating npm packages (especially @redis-ui/* packages):

  1. Clear Vite cache after npm install:

```bash

rm -rf node_modules/.vite

rm -rf redisinsight/ui/node_modules/.vite

```

  1. Restart dev server to rebuild dependencies
  1. This ensures new package versions are properly loaded

Pre-Commit Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.