denoland / denoland/std

Rename `front-matter/any.ts` to `front-matter/extract.ts`

Open
#6,421 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.6k
Forks
681
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**

Lots (if not most) of `@std` files are single export files wich only export one function or class.
The file name is normally the same as the exported thing (case may be adjusted, prefixed files with `unstable` are special treated).
Files that differ from that pattern are mostly multi export files (for example `fmt/colors.ts`).

There are multiple files in `@std/front-matter` that do not conform to any of these conventions:
- `front-matter/any.ts` exports `extract()`
- `front-matter/json.ts` exports `extract()`
- `front-matter/toml.ts` exports `extract()`
- `front-matter/yaml.ts` exports `extract()`
- `front-matter/unstable_yaml.ts` exports `extract()`

In `front-matter/mod.ts` the `extract()` functions even have aliases because their names overlap.

**Describe the solution you'd like**

I think we should enforce any apply that convention to `front-matter`:
- rename `front-matter/any.ts` to `front-matter/extract.ts`
- rename `front-matter/json.ts` to `front-matter/extract_json.ts`, rename exported function from `extract()` to `extractJson()`
- rename `front-matter/toml.ts` to `front-matter/extract_toml.ts`, rename exported function from `extract()` to `extractToml()`
- rename `front-matter/json.ts` to `front-matter/extract_yaml.ts`, rename exported function from `extract()` to `extractYaml()`

I am aware that `front-matter` is stable, but this issue may be part of `2.0` which I imagine would allow for breaking changes.
(@kt3k Is there a roadmap for 2.0 mods?)

In the meantime, We could add aliases for a smooth transition.

**Describe alternatives you've considered**

Don't enforce convention.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.