From 82717e1cc0f11e017786e6d329ade071ae32612e Mon Sep 17 00:00:00 2001 From: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com> Date: Fri, 21 Jul 2023 11:39:37 +1000 Subject: [PATCH] Add development guidelines/documentation for eslint-plugin --- documentation/packages/eslint_plugin/index.md | 13 +++++++++++++ documentation/packages/index.md | 18 ++++++++++++++++++ justfile | 4 ++++ 3 files changed, 35 insertions(+) diff --git a/documentation/packages/eslint_plugin/index.md b/documentation/packages/eslint_plugin/index.md index 40a0ed870ac..76a8c41d180 100644 --- a/documentation/packages/eslint_plugin/index.md +++ b/documentation/packages/eslint_plugin/index.md @@ -9,3 +9,16 @@ Please consult each rule's page for documentation regarding the rule. * ``` + +## Development + +All ESLint plugin rules and configuration must be written in TypeScript. + +All rules must have unit tests added using `ESLintUtils.RuleTester` from the +`@typescript-eslint/utils` package. Use the `@typescript-eslint/parser` as the +`parser` option. + +All rules are required to have a documentation page in this documentation +section. Rule documentation should follow the typical ESLint rule documentation, +including samples of valid and invalid code with options clearly documented. See +existing rule documentation for examples. diff --git a/documentation/packages/index.md b/documentation/packages/index.md index 8c8bc443137..c60ba5771c3 100644 --- a/documentation/packages/index.md +++ b/documentation/packages/index.md @@ -15,6 +15,21 @@ and how to add/maintain them. Openverse does not currently have any method for publishing packages to NPM. ``` +## Running package scripts + +Run scripts for individual packages using `just p {package} {script}`. For +example, to run tests for the `eslint-plugin`, run: + +``` +just p eslint-plugin test:unit +``` + +This also works for the Nuxt frontend as an alternative to `just frontend/run`: + +``` +just p frontend dev +``` + ## Adding new packages The easiest way to create a new package is to copy an existing one and modify @@ -60,3 +75,6 @@ This can be facilitated using `npm-run-all`'s `run-p`. e.g.: } ``` ```` + +All new packages should name their unit-test script `test:unit`. Our CI +recursively runs `test:unit` for all pnpm workspaces to ensure tests pass. diff --git a/justfile b/justfile index c383721a175..dc1e163297a 100644 --- a/justfile +++ b/justfile @@ -255,3 +255,7 @@ i: # alias for `just frontend/run dev` f: just frontend/run dev + +# alias for `pnpm --filter {package} run {script}` +p package script +args="": + pnpm --filter {{ package }} run {{ script }} {{ args }}