Languages and platforms
Type: Policy. Conventions for languages, runtimes, and frameworks.
Technology-specific conventions complement the shared development policies. Choose the sections relevant to your project: JavaScript and TypeScript, Node.js, Svelte, SvelteKit, web interfaces, or Python. Platform versions, startup commands, and application structure are described in the project’s own documentation.
- JavaScript and TypeScript
- Naming in JavaScript and TypeScript
- Grouping tests
- Node.js
- Svelte 5
- SvelteKit
- Web interfaces
- Python
JavaScript and TypeScript
Formatting
Handwritten TypeScript/Svelte code uses two spaces, semicolons, and single quotes in TypeScript. Configuration, declaration and generated files retain their own existing format.
For TypeScript, JavaScript, <script> and tests, the width guideline is 100 characters, including indentation. Long URLs, paths, regular expressions and string literals are not broken down into calculations or concatenations for the sake of width.
An independent instruction is written on a separate line. Do not concatenate state declarations, side effects, or assertions across multiple ;s on a line. Callback and lifecycle blocks are expanded when they contain multiple actions.
Choose braces according to context and readability. For independent data checks, error handling, and early returns, prefer an expanded form with the condition and action on separate lines. A short form without braces is acceptable for an obvious local action if it does not obscure branch boundaries. Expand multiline conditions and actions, nested branches, and chains with inconsistent formatting. Do not shorten a clear block for compactness or add braces mechanically to every condition.
else and else if start on the line after the closing brace of the preceding block, at the same indentation level.
catch starts on the line after the closing brace of its try block, at the same indentation level.
Nested try/catch statements within one function or at module scope are prohibited. Do not place an inner try in the outer statement's try, catch, or finally block. Extract an operation that needs its own error handling into a named function. Preserve exception boundaries, operation order, and resource cleanup.
Exceptions follow the general justification rule.
Whenever possible, keep a method or function signature on one line if the full signature fits within 100 characters, including indentation.
Long signatures, destructuring, objects, and calls are expanded so that each field or argument of a multiline list begins on a separate line. Short visual literals and arguments remain compact. Simple ternary expressions are allowed; complex choices should not be hidden inside a long expression.
Types and data checks
- Prefer clear types on module boundary and inference within small implementation.
- Do not add decorative type aliases that only repeat the expression.
- Use
unknownand narrowing for external input; don't replace checking unconditional cast. - Guard clause is preferable to deep nesting if it does not hide the lifecycle.
- One class is defined in one file.
- Do not change the order of side effects for the sake of visual symmetry.
The ! operator does not replace checking a result before using it.
Naming in JavaScript and TypeScript
Basic naming rules
The following rules are used in TypeScript/JavaScript code:
camelCase- variables, functions, values, exported const;PascalCase- classes, types, interfaces, enum;kebab-case— runtime names, CLI names, profile names, file names;SCREAMING_SNAKE_CASE/ALL_CAPS- prohibited for internal project identifiers.
Examples:
const maxRetryCount = 3;
const mlProfileCatalog = loadMlProfiles();
- Function
resolveMarketMlProfile. - Type
MarketMlProfile. - Interface
MarketFeatureProfile. - Class
MarketDatasetBuilder.
Prohibition ALL_CAPS / SCREAMING_SNAKE_CASE
In internal TypeScript/JavaScript code, it is prohibited to use ALL_CAPS / SCREAMING_SNAKE_CASE for TypeScript/JavaScript identifier names.
The ban applies to:
- local variables;
- exported constants;
- functions;
- classes;
- types;
- interfaces;
- enum members;
- registry/resolver/map/catalog-variables.
Prohibited:
export const ML_PROFILE_CATALOG = {};
const MAX_RETRY_COUNT = 3;
enum Status {
ACTIVE = 'active',
DISABLED = 'disabled'
}
Acceptable:
export const mlProfileCatalog = {};
const maxRetryCount = 3;
enum Status {
Active = 'active',
Disabled = 'disabled'
}
Exporting a value or keeping it immutable does not change the naming rule for internal identifiers.
Symbolic codes
SCREAMING_SNAKE_CASE is allowed for string symbolic codes if the value is stable machine code and not a variable, function, class, or runtime-name.
Acceptable cases:
- application error codes;
- scenario codes;
- machine-readable diagnostic codes;
- compatibility codes;
- external protocol/status codes;
- semi-external string contracts between application layers.
Acceptable:
export type FrameBuildErrorCode =
| 'NOT_ENOUGH_CANDLES';
const frameBuildErrorMessages: Record<FrameBuildErrorCode, string> = {
'NOT_ENOUGH_CANDLES': 'Not enough candles'
};
Acceptable:
export type ValidationErrorCode =
| 'INVALID_FIGI'
| 'INVALID_DATE_RANGE'
| 'UNSUPPORTED_INTERVAL';
Prohibited:
const NOT_ENOUGH_CANDLES = 'Not enough candles';
const FRAME_BUILD_ERROR_MESSAGES = {};
const INVALID_FIGI = 'Invalid FIGI';
If SCREAMING_SNAKE_CASE is used as a string value, it must be a consciously stable code and not a replacement for a regular name.
A good rule of thumb:
ALL_CAPS identifier -> запрещено
ALL_CAPS string code -> допустимо, если это stable symbolic code
For an object literal with symbolic code keys, it is preferable to explicitly write the keys in quotes to emphasize that this is a string contract and not an identifier naming style.
Preferred:
const frameBuildErrorMessages: Record<FrameBuildErrorCode, string> = {
'NOT_ENOUGH_CANDLES': 'Not enough candles'
};
Undesirable:
const frameBuildErrorMessages: Record<FrameBuildErrorCode, string> = {
NOT_ENOUGH_CANDLES: 'Not enough candles'
};
The behavior is the same, but the quotes make the intent explicit: this is symbolic code.
Exceptions
ALL_CAPS is only allowed where the name is an external contract and not an internal project name.
Allowed exceptions:
- environment variables;
- external protocol/API fields;
- names required by a third-party library;
- SQL/CLI/wire-format values;
- values that must match the external contract verbatim.
Examples of acceptable exceptions:
process.env.NODE_ENV;
process.env.TRANSFORMER_ENDPOINT;
process.env.CUDA_VISIBLE_DEVICES;
const envName = 'TRANSFORMER_ENDPOINT';
const externalPayload = {
API_KEY: valueFromExternalSystem
};
Published names are preserved as described in the shared naming policy.
Object properties
For internal object properties, camelCase is used.
Acceptable:
const options = {
maxRetryCount: 3,
workerPoolSize: 4
};
Prohibited:
const options = {
MAX_RETRY_COUNT: 3,
WORKER_POOL_SIZE: 4
};
Exceptions are allowed only for external payloads, wire-format structures or contracts of third-party systems:
const externalPayload = {
REQUEST_ID: requestId,
API_VERSION: apiVersion
};
Enum members
Enum members should use PascalCase.
Acceptable:
enum CandleInterval {
OneMinute = '1min',
FiveMinutes = '5min'
}
Prohibited:
enum CandleInterval {
ONE_MINUTE = '1min',
FIVE_MINUTES = '5min'
}
If the external value should be ALL_CAPS, it should be the value of an enum, not the name of the enum member:
enum ExternalStatus {
Active = 'ACTIVE',
Disabled = 'DISABLED'
}
Examples
Environment variables
Acceptable:
const transformerEndpoint = process.env.TRANSFORMER_ENDPOINT;
const nodeEnv = process.env.NODE_ENV;
Prohibited:
const TRANSFORMER_ENDPOINT = process.env.TRANSFORMER_ENDPOINT;
const NODE_ENV = process.env.NODE_ENV;
Components and functions
The following conventions apply for components and functions:
- component is called a noun, for example
DateTimePicker; - DOM handler receives the prefix
handle, callback prop -on; The - boolean prop/state starts with
is,has,canor directly if possible expresses a state without negation; parse,format,resolve,normalize,build,create,get,is,hasandcanare used according to the actual contract function;- common names
process,data,itemandhelperare valid only when context makes them unambiguous.
If a filename indicates its purpose, its contents must match that purpose. For example, a project may use the following conventions:
| Filename | Purpose |
|---|---|
*.engine.ts |
Independent calculations without side effects |
*.model.svelte.ts |
Reactive state and UI actions in Svelte |
*.draw.ts |
Canvas rendering |
*.test.ts |
Tests |
Names such as utils.ts, helpers.ts, and common.ts are appropriate only for modules that serve one clear shared purpose.
Grouping tests
The test code follows the same TypeScript rules, but may use local minimal fixtures and mocks for the sake of clear scripting.
Test purpose, observable behavior, and example names are described in the testing policy. The following conventions apply to grouping with describe().
Test suite naming
Test names must describe the public API path and expected behavior.
Top-level describe() calls unit under test:
ClassNamefor classes and runtime components;functionNamefor standalone exported functions;objectNamefor exported objects or namespaces;module-nameonly when several closely related exports are tested and there is no one main subject.
Good:
BufferedTextFileWriterisFigimarketFeatureProfile
Bad:
utilstests for writervalidation works
Naming nested suite
Nested describe() calls a public member or operation:
constructorfor constructor behavior;#methodNamefor instance methods called asinstance.methodName();.methodNamefor static methods called asClassName.methodName();.methodNamefor exported object/namespace methods called asobjectName.methodName();functionNamefor standalone functions grouped under module-level suite.
Examples:
BufferedTextFileWriter#writeLine#close
FeatureRegistry.fromProfile
argGuardsreadOptionalNumber
A parent suite must not contain sibling describe() blocks with the same name.
Bad:
BufferedTextFileWriter#close#close
If two blocks have the same name, then they need to be combined or named after different public scripts.
Node.js
npm scripts
The script and build policy describes when commands may change. The following details apply to Node.js.
Prohibited:
- add prebuild / postbuild
- add pretest / posttest
- replace node logic with shell commands
Example of the correct script:
"build": "tsc"
Example of an incorrect change:
"build": "rm -rf dist && tsc"
Examples of this cleanup through a separate command or automatic execution before builds and tests:
"clean": "rm -rf dist",
"build": "npm run clean && tsc",
"test": "npm run clean && fwa --prune",
"prebuild": "rm -rf dist",
"pretest": "rm -rf dist"
Invalid:
"test": "npm run lint && vitest"instead of the existing"test": "vitest""build": "node scripts/build.js"instead of the existing"build": "tsc"without a direct task requirement
npm dependencies
In the npm project, package.json and package-lock.json are updated together.
overrides applies to the specific problem explained and does not hide the incompatible dependency graph.
Dependency selection, updates, and checks are described in the dependency policy.
Svelte 5
The following examples show how the general principles apply in Svelte 5. They concern presentation code and use framework features in that context.
Reactive values
$state describes mutable state belonging to the current instance. $derived expresses a value computed from other data without side effects:
let total = $derived(price * quantity);
For this calculation, a separate mutable value and an effect that copies the result would introduce another piece of state to keep consistent.
$effect connects reactive data to an external system, such as the DOM API, a graphics library, or a subscription. A chain of effects that copy internal state into each other makes the reasons for changes harder to follow. Explicit actions and derived values make those reasons more visible.
Effects must not replace ordinary computations.
Models and context
A *.svelte.ts file allows a reactive model to live outside a component. Such a model serves presentation; the file extension alone does not change its architectural role. Domain calculations and independent scenarios retain their independence from Svelte reactivity.
Context provides dependencies to a limited component tree. Typed functions for providing and accessing context help express its purpose and lifetime. Preparing application dependencies remains a separate task; context can pass on values that have already been prepared.
The examples use Svelte 5 rune mode. Resource creation and cleanup follow the shared resource ownership principles.
Components
- Props are declared via
$propsand are typed next to the component boundary. - Bindable state is only used when bidirectional communication is part of API component.
- Do not transfer feature orchestration to markup expressions.
Local functions and closures are allowed for instance state and resource management. They are not placed in a class or module scope for the sake of style. bind, call and apply are valid if they preserve the receiver of the native DOM API or other necessary contract; a non-obvious reason is recorded next to the call.
Within .svelte, follow the local order script, style, markup. Don't rearrange large blocks just for the sake of consistency in an unrelated task.
Components and their files use PascalCase.
A top-level architectural comment is optional for trivial Svelte composition without its own logic, side effects, or a non-trivial contract. Other cases are described in the comment policy.
For Svelte markup, text nodes and significant spaces between elements are taken into account. Do not wrap text and snippet boundaries mechanically. CSS and existing configuration files retain their native format.
Component styles
- Component-specific styles remain scoped within the component.
:globalis used only for a conscious boundary with the child component or The document-level style.
SvelteKit
SvelteKit conventions establish the roles of route files and server modules. Their particular use and the location of other parts are described in the project's documentation.
Routes and server code
src/routes connects URLs, query parameters, server loading, HTTP statuses, and page composition. Route input validation can live in +page.server.ts when it concerns the route's HTTP behavior. Reusable domain checks stay near the corresponding application rules.
Server modules, including +page.server.ts and +server.ts, work with private environment data and server API clients. Separating server and browser code keeps secrets on the server; page data contains only values intended for the client.
A proxy route describes public HTTP behavior and response forwarding. The integration concentrates provider requests and the allowlist. This division helps explain route behavior and the conditions for accessing the external API separately.
Server rendering
Access to window, document, localStorage, Canvas, Worker, and the Clipboard API takes account of the execution environment. Code needing the browser after the component appears is tied to the component lifecycle. A utility working in a SvelteKit context can use browser from $app/environment.
This makes the execution environment an explicit part of the solution. Exception handling, dynamic imports, or a change to server rendering mode have a purpose when they match the task and the application's chosen structure.
User-specific state on the server belongs to a particular request or user session. This keeps different users' data independent. localStorage is suitable for UI preferences and versioned client state; validation and recovery take account of browser availability.
Module composition
A project might use the following conventions:
| File | Role |
|---|---|
*.svelte |
Markup, interaction, and local styles |
*.model.svelte.ts |
Reactive state and presentation actions |
*.engine.ts |
Independent pure calculations, parsing, and normalization |
config.ts |
Static defaults and limits |
types.ts |
Types for the corresponding module |
*.test.ts |
Checks of observable behavior |
This example shows a possible division of work. The set of files follows the task's complexity and the project's conventions.
Route files retain the names +page, +layout, and +server.
Web interfaces
Reusable UI elements preserve native semantics, keyboard accessibility, and meaningful names. When using third-party components, their public API helps keep the application independent of the library's internal structure.
A demonstration page uses the showcased component's API. The application's main code retains its own dependencies, while the demonstration remains a separate usage example.
Markup and accessibility
- Use the native element for its intended purpose before adding ARIA.
- Interactive
divdoes not replacebutton,a,inputor other control. - Label, accessible name, focus state and keyboard behavior are part of implementation, not optional documentation.
- Decorative SVG icon is hidden from the accessibility tree; name is given interactive control.
- Do not remove focus outline without an equivalent
:focus-visiblestate.
CSS and layout
- Write each CSS declaration on its own line, including in inline styles.
- Repeatable theme values are passed by existing CSS variables/config if is truly a shared responsibility.
- Responsive rules are checked next to the affected breakpoint.
- Fixed size is acceptable for a known control or canvas contract, but should not accidentally break the narrow viewport.
- Don't rewrite the entire style block for the sake of a local visual change.
Browser checks
SSR check or unit test in Node does not confirm DOM, hydration, focus, keyboard navigation, responsive layout and real browser integration of Canvas. For these properties, relevant browser checks are performed or manual checks are explicitly described using available means.
Pure calculations are checked on a DOM-independent boundary. This is not a replacement for checking component availability. Trivial Svelte composition, CSS and static markup usually do not require a separate unit test, but may require browser smoke.
A large Svelte DOM snapshot does not replace semantic assertions. A one-time screenshot is not an automated regression test.
Python
Python uses its own notation and the project’s conventions. Code formatting, typing, validation tools, and dependency management are described in the relevant project documentation. JavaScript and TypeScript rules for names, indentation, and statement formatting do not apply to Python.