Function/Method Declaration Style

February 8, 2026 · View on GitHub

In this document coding and project practices are outlined.

CJS (CommonJS) vs ESM (ECMAScript Modules)

This project uses CommonJS (and not Pure ESM), due to it's currently better compatible with Jest and other tools.

  • Involved files: jest.config.js

Naming Conventions

The following naming conventions help maintain consistency across the project. Contributors should follow them where applicable.

Types and Interfaces (shapes)

All internal types and interfaces (shapes) (defined in the file internalTypes.ts) must be prefixed with T if it's a type and with a I if it's an interface.

Except, *public (user-facing) types and interfaces (defined in the file types/index.ts), these should NOT include the prefixes T or I (users dont't really care that much wheather a shape is a type or interface).

Style Memory Table

Casing style conventions table within this project, with exceptions for predefined names.

StyleExampleNotes
Title Case (with spaces)Short Name.mdVisible document or Markdown file names where readability matters (e.g. in docs/).
UPPER CASE (with spaces)SHORT NAME.mdVisible document or Markdown file names where readability matters (e.g. in the root /).
camelCaseshortNameAll variable names, optionally source file names.
kebab-caseshort-nameAll directory and general file names.
PascalCaseShortNameAll class names, interface names (prefixed with I), and type names (prefixed with T). Optionally source file names. ***
snake_caseshort_nameOnly used for predefined names.
UPPER_SNAKE_CASE / SCREAMING_SNAKE_CASESHORT_NAMEOptionally used for constant variable names.
kebab-case with caps (non-standard!)Short-nameNot recommended — not to be used in source.

Item Conventions Table

For this (Node.js + TypeScript) project, these conventions apply as strictly as possible to help maintain consistency across the project.

ItemConventionExample(s)
Repository and package nameskebab-caseyini-parser-typescript, yini-parser-ts
Directory names (within src/)kebab-case *smoke-fixtures
Source file namescamelCase or PascalCase **parseEntry.ts or ErrorHandler.ts
Script file nameskebab-case **clean-ts-js.sh
Fixture file names (for test data only)kebab-case **1-basic-key-value.smoke.yini
Markdown file namesTitle Case or UPPER CASE **Short Name.md, SHORT NAME.md
Class namesMust be: PascalCaseclass PascalCase, YINIClass
Variable (mutable) namesMust be: camelCasecamelCase
Constant variable namesUPPER_SNAKE_CASE (or camelCase)const UPPER_SNAKE_CASE, SCREAMING_SNAKE_CASE
Interface namesPascalCase plus prefix I ***interface IPascalCase
Type namesPascalCase plus prefix T ***type TPascalCase
  • (*) Some exceptions may occur where directories in the root directory have predefined names. E.g. node_modules.

  • (**) Some exceptions may occur where this improves clarity, and certain configuration files have predefined names. Files in the root directory and within docs may also follow different conventions as needed.

  • (***) Exception, *public (user-facing) types and interfaces (defined in the file types/index.ts), must NOT include the prefixes T or I (users dont't really care that much wheather a shape is a type or interface).

Function/Method Declaration Style

The default style for function declarations is arrow functions style, e.g:

const parseBooleanLiteral = (txt: string): boolean => { ... }

const doCheckAndBuild = (): ParsedObject => { ... }

However, (non-callback) methods (functions) within classes MAY (but is not required to) use traditional method style, e.g.:

constructor(syntaxTreeC: TSyntaxTreeContainer) { ... }

public doCheckAndBuild(): ParsedObject { ... }

^YINI ≡

A simple, structured, and human-friendly configuration format.

yini-lang.org · YINI on GitHub