AGENTS.md 2.9 KB

Coding & Formatting Rules

The user expects strict adherence to the following coding, formatting, and behavioral rules in this repository:

General Formatting

  1. Double Quotes: Use double quotes (") instead of single quotes for all strings and imports.
  2. Sort by Length: Sort arrays, object properties, and import statements from longest to shortest string length (uzundan kısaya). For JSON objects or key-value pairs (like translations), sort by the combined length of the key and the value (key + value) from longest to shortest. This is a strict visual aesthetic preference. This applies deeply to destructured imports, props, array data, and types as well.
  3. Line Breaks (Newlines): Pay attention to line breaks. Add new lines between imports and JSON object keys where appropriate. ESLint rules regarding newlines must be strictly followed.
  4. Hook Spacing: Always leave a blank line between each distinct hook call (e.g. useContext, useState, useNavigation, useLayoutEffect). Do not group them tightly together without empty lines.
  5. Array Destructuring: When destructuring arrays (such as from useState), place the opening bracket on one line, each destructured item on its own separate line, and the closing bracket on its own line. Example:

    const [
       title,
       setTitle
    ] = useState<string>("");
    
  6. Main Component / Object Export: Always define the main component or object as a variable/arrow function (e.g., const PageName = () => { ... } or const stylesheet = StyleSheet.create({ ... })) and place the export default PageName; or export default stylesheet; at the very bottom of the file. Do not use export default function PageName() or inline export default StyleSheet.create(...).

  7. Top-level Blank Lines: Top-level variables, arrays, types, and functions located outside of the main component must be separated by an empty line. Do not group them without new lines.

  8. No any with localize: Never use as any when calling the localize function (e.g., use localize("key") instead of localize("key" as any)). The any type is strictly forbidden.

  9. String Interpolation: Use template literals (`${...}`) for string concatenation instead of the + operator.

Tooling & Checks

  1. ESLint Validation: Habitually run yarn run eslint --fix <file> or yarn run eslint <file> after making code edits to ensure strict ESLint compliance.
  2. TypeScript Validation: Habitually check and respect TypeScript compiler errors (e.g., using tsc or IDE feedback). Do not ignore any or strict typing constraints.
  3. No External Formatters: Do not introduce Prettier or automatic scripts that might break these explicit manual formatting rules. Format code block by block meticulously.

Behavior

Always follow these rules by default. Pay "extreme attention" (aşırı dikkat) to the sorting rules, ESLint, and TS constraints during modifications.