Important
Work in Progress
Caution
Do not use deno fmt
, since that runs Deno's formatter.
Despite being significantly slower, Prettier is needed to format .astro
files.
Unless specified otherwise the Deno Code Style applies. (Yes, for Node Modules too)
deno task fmt
will run Prettier to lint all code.
deno task lint:web
will run ESLint to lint all frontend code.
Even though TypeScript supports multiple paradigms, GDOL loosely follows procedural/functional programming principles.
Avoid classes, unless it is public facing API where namespacing is important. Use objects and functions instead.
Avoid state and mutations where it doesn't conflict with expensive operations.
Avoid the spread operator (...foo
). Use mutations instead.
Avoid complex iterator-style pipelines (e.g. foo.filter().map().reduce()
).
Use loops, mutations, and break
/continue
/return
statements instead. Simple pipelines are fine.
Note
Naming conventions may be disregarded if required (e.g. pnpm-workspace.yaml
).
Subject | Case |
---|---|
Folders | snake_case |
Files | snake_case |
Static top-level constants (const , that define fixed values) |
SCREAMING_SNAKE_CASE |
CSS-in-JS const , let , function |
snake_case |
JS/TS const , let , function |
PascalCase |
Classes (class ) |
PascalCase |
Components (Astro, SolidJS) | PascalCase |
Types | PascalCase |
Avoid relative imports (import { bar } from '../../foo/bar.ts'
), unless the module is
within the same directory. (Unfortunately in Deno relative imports have to be used)
Do not omit the file suffix (e.g. .ts
, .svg
), unless it is a package (e.g. hono
,
@gdol/api
).
Do not use default exports (export default ...
). Use named exports (export const foo = ...
,
export function bar() { ... }
) instead.
All pages and routes should be named index
. For Astro Pages: index.astro
. For Hono Routes:
index.ts
.
Path segments are represented as folders.
For example the page/route /foo/bar
should be resembled as web/src/pages/foo/bar/index.astro
(Astro) or api/routes/foo/bar/index.ts
(Hono).