# Unified Naming Strategy for Files and Directories

* Status: accepted
* Deciders: devs
* Date: 2020-07-03

## Context and Problem Statement

As of the date of this writing, there are multiple different naming styles used in the monorepo, mostly because NX has defaults that differ between schematic types. In order for navigating the monorepo in a consistent rational manner, we should align on naming strategy for files and directories.

## Decision Drivers

* Provide consistency when navigating the codebase
* The earlier we decide on this, the better

## Considered Options

Some mixture of these:

* kebab-case
* PascalCase
* camelCase
* snake\_case

## Decision Outcome

Chosen option: Name files after their default export. If that default export is a React Component, or a class, then the file name should be in PascalCase. Otherwise, the filename should be in camelCase. Basically, for naming files avoid using kebab-case and snake\_case and make sure the name follows the default export of the file.

Naming directories should follow these guidelines: Only use kebab-case when naming NX apps and libraries, or folders containing apps and libraries, e.g. `island-ui` instead of `islandUi`: `import { Box } from '@island.is/island-ui/core'`

Use PascalCase for directories only containing React components:

```
components/CtaButton/index.ts
import 'components/CtaButton'
```

or:

```
components/CtaButton/CtaButton.tsx
import 'components/CtaButton/CtaButton'
```

rather than

```
components/cta-button/CtaButton.tsx
```

In all other cases, use camelCase.

### Positive Consequences

* Easier to navigate the codebase
* File names are more readable, and developers know what to expect
* This approach is the most common practice, and something most JS and TS developers are familiar with.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.devland.is/technical-overview/adr/0009-naming-files-and-directories.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
