Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Move ESLint plugin inside `packages/js` (#4174)

Dhruv Bhanushalida3101db8944
diff --git a/.codespell/ignore_lines.txt b/.codespell/ignore_lines.txt
index 9563d9731..1366e9149 100644
--- a/.codespell/ignore_lines.txt
+++ b/.codespell/ignore_lines.txt
@@ -17,6 +17,6 @@
"Identificatie Titel(s): Allegorie op kunstenaar Francesco Mazzoli, "
"bekend als Parmigianino"
-;; packages/eslint-plugin/configs/vue.ts
+;; packages/js/eslint-plugin/configs/vue.ts
;; `te` gets matched with `the` and others
const i18nDestructureRules = ["t", "tc", "te", "td", "d", "n"].map(
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 36f3dd0e5..ac9f27b13 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -10,7 +10,7 @@ load_sample_data.sh @WordPress/openverse-api
pyproject.toml @WordPress/openverse-api
frontend/ @WordPress/openverse-frontend
-packages/ @WordPress/openverse-frontend
+packages/js/ @WordPress/openverse-frontend
.eslintignore @WordPress/openverse-frontend
.eslintrc.js @WordPress/openverse-frontend
.npmrc @WordPress/openverse-frontend
diff --git a/.github/filters.yml b/.github/filters.yml
index a94b5b272..d5cda4e29 100644
--- a/.github/filters.yml
+++ b/.github/filters.yml
@@ -23,15 +23,15 @@ ingestion_server:
- load_sample_data.sh
frontend:
- frontend/**
- - packages/**
+ - packages/js/**
- package.json
- pnpm-lock.yaml
- pnpm-workspace.yaml
- tsconfig.base.json
- .npmrc
- .pnpmfile.cjs
-packages:
- - packages/**
+js_packages:
+ - packages/js/**
- package.json
- pnpm-lock.yaml
- pnpm-workspace.yaml
diff --git a/.github/renovate.json b/.github/renovate.json
index 4ead83bc7..8b9b0a165 100644
--- a/.github/renovate.json
+++ b/.github/renovate.json
@@ -47,7 +47,7 @@
"addLabels": ["🟨 tech: javascript"]
},
{
- "matchFileNames": ["{frontend,packages}/**"],
+ "matchFileNames": ["{frontend,packages/js}/**"],
"addLabels": ["🧱 stack: frontend"]
},
{
@@ -78,7 +78,7 @@
},
{
"groupName": "@openverse/eslint-plugin",
- "matchFileNames": ["packages/eslint-plugin/**"]
+ "matchFileNames": ["packages/js/eslint-plugin/**"]
},
{
"groupName": "tailwind",
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index 743c244a2..7c1860d58 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -44,7 +44,7 @@ jobs:
frontend: ${{ contains(fromJson(steps.paths-filter.outputs.changes), 'frontend') }}
documentation: ${{ contains(fromJson(steps.paths-filter.outputs.changes), 'documentation') }}
ci_cd: ${{ contains(fromJson(steps.paths-filter.outputs.changes), 'ci_cd') }}
- packages: ${{ contains(fromJson(steps.paths-filter.outputs.changes), 'packages') }}
+ js_packages: ${{ contains(fromJson(steps.paths-filter.outputs.changes), 'js_packages') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
@@ -600,10 +600,10 @@ jobs:
- name: Pass
run: echo 'Playwright tests are skipped because frontend is unchanged.'
- package-checks:
- name: Run checks for packages/*
+ js-package-checks:
+ name: Run checks for JS packages/*
if: |
- needs.get-changes.outputs.packages == 'true'
+ needs.get-changes.outputs.js_packages == 'true'
runs-on: ubuntu-latest
needs:
- get-changes
@@ -630,19 +630,19 @@ jobs:
setup_python: false
install_recipe: node-install
- - name: Run packages checks
- run: pnpm --filter ./packages/* run --aggregate-output ${{ matrix.script }}
+ - name: Run JS packages checks
+ run: pnpm --filter ./packages/js/* run --aggregate-output ${{ matrix.script }}
- # This job runs when `package-checks` doesn't and always passes, thus allowing
- # PRs to meet the required checks criteria and be merged.
- bypass-package-checks:
- name: Run checks for packages/*
+ # This job runs when `js-package-checks` doesn't and always passes, thus
+ # allowing PRs to meet the required checks criteria and be merged.
+ bypass-js-package-checks:
+ name: Run checks for JS packages/*
if: |
!cancelled() &&
- needs.package-checks.result == 'skipped'
+ needs.js-package-checks.result == 'skipped'
runs-on: ubuntu-latest
needs:
- - package-checks
+ - js-package-checks
strategy:
fail-fast: false
matrix:
@@ -652,7 +652,7 @@ jobs:
steps:
- name: Pass
- run: echo 'Checks for packages are skipped because packages are unchanged.'
+ run: echo 'Checks for JS packages are skipped because they are unchanged.'
playwright:
name: Run Playwright tests
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 1cb44402d..e125a8266 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -118,14 +118,14 @@ repos:
hooks:
- id: types
name: types
- files: ^(frontend|packages)/.*$
+ files: ^(frontend|packages/js)/.*$
entry: bash -c 'pnpm run -r types'
language: system
pass_filenames: false
- id: eslint
name: eslint
- files: (frontend|automations|packages).*?\.(js|ts|vue|json5|json)$
+ files: (frontend|automations|packages/js).*?\.(js|ts|vue|json5|json)$
"types": [file] # ESLint only accepts [javascript] by default.
language: system
pass_filenames: false
@@ -133,7 +133,7 @@ repos:
- id: test:unit
name: test:unit
- files: ^(frontend|packages)/.*$
+ files: ^(frontend|packages/js)/.*$
entry: bash -c 'pnpm run -r test:unit'
language: system
pass_filenames: false
diff --git a/documentation/meta/ci_cd/jobs/packages.md b/documentation/meta/ci_cd/jobs/packages.md
index 1540818e9..029a8bb6d 100644
--- a/documentation/meta/ci_cd/jobs/packages.md
+++ b/documentation/meta/ci_cd/jobs/packages.md
@@ -1,8 +1,8 @@
# Packages jobs
-## `package-checks`
+## `js-package-checks`
-Runs a matrix for various checks of workspace packages in the `packages`
+Runs a matrix for various checks of workspace packages in the `packages/js`
directory using the following `package.json` scripts.
| Name | Script |
@@ -11,9 +11,9 @@ directory using the following `package.json` scripts.
| `unit_test` | `test:unit` |
```{note}
-Not all packages in `packages` necessarily need to define both or any of these scripts.
-`pnpm run -r` will safely ignore packages that do not define a given script and just
-run it for the ones that do.
+Not all packages in `packages/js/` necessarily need to define both or any of
+these scripts. `pnpm run -r` will safely ignore packages that do not define a
+given script and just run it for the ones that do.
```
Since this is a required check for a matrix job, it has a bypass counterpart.
diff --git a/documentation/packages/index.md b/documentation/packages/index.md
index 6c53f44c4..21fa5043e 100644
--- a/documentation/packages/index.md
+++ b/documentation/packages/index.md
@@ -36,10 +36,10 @@ The easiest way to create a new package is to copy an existing one and modify
the details to match the needs. To create a new `@openverse/license-parsing`
package, for example, we would do the following:
-1. Copy `packages/eslint-plugin` to `packages/license-parsing`
-2. Update `packages/license-parsing/package.json` to remove unneeded
+1. Copy `packages/js/eslint-plugin` to `packages/js/license-parsing`
+2. Update `packages/js/license-parsing/package.json` to remove unneeded
dependencies and update the package name
-3. Delete the code in `packages/license-parsing/src`, update any relevant
+3. Delete the code in `packages/js/license-parsing/src`, update any relevant
configuration (`babel.config.js`, etc) and write the code for the new package
🎉
diff --git a/package.json b/package.json
index 2bdc36d1e..1342c14d0 100644
--- a/package.json
+++ b/package.json
@@ -9,9 +9,9 @@
},
"author": "Openverse <[email protected]>",
"scripts": {
- "postinstall": "pnpm --filter './packages/*' run build",
+ "postinstall": "pnpm --filter './packages/js/*' run build",
"preeslint": "pnpm --filter '@openverse/eslint-plugin' run build",
- "eslint": "eslint --ext .js,.ts,.vue,.json,.json5 --ignore-path .gitignore --ignore-path .eslintignore --max-warnings=0 frontend automations/js packages .pnpmfile.cjs .eslintrc.js prettier.config.js tsconfig.base.json"
+ "eslint": "eslint --ext .js,.ts,.vue,.json,.json5 --ignore-path .gitignore --ignore-path .eslintignore --max-warnings=0 frontend automations/js packages/js .pnpmfile.cjs .eslintrc.js prettier.config.js tsconfig.base.json"
},
"packageManager": "[email protected]",
"engines": {
diff --git a/packages/eslint-plugin/.swcrc b/packages/js/eslint-plugin/.swcrc
similarity index 100%
rename from packages/eslint-plugin/.swcrc
rename to packages/js/eslint-plugin/.swcrc
diff --git a/packages/eslint-plugin/README.md b/packages/js/eslint-plugin/README.md
similarity index 100%
rename from packages/eslint-plugin/README.md
rename to packages/js/eslint-plugin/README.md
diff --git a/packages/eslint-plugin/jest.config.js b/packages/js/eslint-plugin/jest.config.js
similarity index 100%
rename from packages/eslint-plugin/jest.config.js
rename to packages/js/eslint-plugin/jest.config.js
diff --git a/packages/eslint-plugin/package.json b/packages/js/eslint-plugin/package.json
similarity index 100%
rename from packages/eslint-plugin/package.json
rename to packages/js/eslint-plugin/package.json
diff --git a/packages/eslint-plugin/src/configs/custom.ts b/packages/js/eslint-plugin/src/configs/custom.ts
similarity index 100%
rename from packages/eslint-plugin/src/configs/custom.ts
rename to packages/js/eslint-plugin/src/configs/custom.ts
diff --git a/packages/eslint-plugin/src/configs/import.ts b/packages/js/eslint-plugin/src/configs/import.ts
similarity index 97%
rename from packages/eslint-plugin/src/configs/import.ts
rename to packages/js/eslint-plugin/src/configs/import.ts
index bcab27231..ab5b0af30 100644
--- a/packages/eslint-plugin/src/configs/import.ts
+++ b/packages/js/eslint-plugin/src/configs/import.ts
@@ -82,11 +82,11 @@ export = {
},
},
{
- files: ["packages/**"],
+ files: ["packages/js/**"],
settings: {
"import/resolver": {
typescript: {
- project: "packages/*/tsconfig.json",
+ project: "packages/js/*/tsconfig.json",
},
},
},
diff --git a/packages/eslint-plugin/src/configs/index.ts b/packages/js/eslint-plugin/src/configs/index.ts
similarity index 98%
rename from packages/eslint-plugin/src/configs/index.ts
rename to packages/js/eslint-plugin/src/configs/index.ts
index 8baabe7da..30a673edd 100644
--- a/packages/eslint-plugin/src/configs/index.ts
+++ b/packages/js/eslint-plugin/src/configs/index.ts
@@ -43,7 +43,7 @@ export const project: TSESLint.Linter.Config = {
},
{
env: { jest: true },
- files: ["packages/**/*/test", "frontend/test/unit/**"],
+ files: ["packages/js/**/*/test", "frontend/test/unit/**"],
plugins: ["jest"],
extends: ["plugin:jest/recommended"],
rules: {
diff --git a/packages/eslint-plugin/src/configs/typescript.ts b/packages/js/eslint-plugin/src/configs/typescript.ts
similarity index 100%
rename from packages/eslint-plugin/src/configs/typescript.ts
rename to packages/js/eslint-plugin/src/configs/typescript.ts
diff --git a/packages/eslint-plugin/src/configs/vue.ts b/packages/js/eslint-plugin/src/configs/vue.ts
similarity index 100%
rename from packages/eslint-plugin/src/configs/vue.ts
rename to packages/js/eslint-plugin/src/configs/vue.ts
diff --git a/packages/eslint-plugin/src/index.ts b/packages/js/eslint-plugin/src/index.ts
similarity index 100%
rename from packages/eslint-plugin/src/index.ts
rename to packages/js/eslint-plugin/src/index.ts
diff --git a/packages/eslint-plugin/src/rules/analytics-configuration.ts b/packages/js/eslint-plugin/src/rules/analytics-configuration.ts
similarity index 100%
rename from packages/eslint-plugin/src/rules/analytics-configuration.ts
rename to packages/js/eslint-plugin/src/rules/analytics-configuration.ts
diff --git a/packages/eslint-plugin/src/rules/index.ts b/packages/js/eslint-plugin/src/rules/index.ts
similarity index 100%
rename from packages/eslint-plugin/src/rules/index.ts
rename to packages/js/eslint-plugin/src/rules/index.ts
diff --git a/packages/eslint-plugin/src/rules/no-unexplained-disabled-test.ts b/packages/js/eslint-plugin/src/rules/no-unexplained-disabled-test.ts
similarity index 100%
rename from packages/eslint-plugin/src/rules/no-unexplained-disabled-test.ts
rename to packages/js/eslint-plugin/src/rules/no-unexplained-disabled-test.ts
diff --git a/packages/eslint-plugin/src/rules/translation-strings.ts b/packages/js/eslint-plugin/src/rules/translation-strings.ts
similarity index 100%
rename from packages/eslint-plugin/src/rules/translation-strings.ts
rename to packages/js/eslint-plugin/src/rules/translation-strings.ts
diff --git a/packages/eslint-plugin/src/utils/rule-creator.ts b/packages/js/eslint-plugin/src/utils/rule-creator.ts
similarity index 66%
rename from packages/eslint-plugin/src/utils/rule-creator.ts
rename to packages/js/eslint-plugin/src/utils/rule-creator.ts
index f12c0e5e5..ee9b55357 100644
--- a/packages/eslint-plugin/src/utils/rule-creator.ts
+++ b/packages/js/eslint-plugin/src/utils/rule-creator.ts
@@ -2,7 +2,7 @@ import { ESLintUtils } from "@typescript-eslint/utils"
export const OpenverseRule = ESLintUtils.RuleCreator(
(ruleName) =>
- `https://docs.openverse.org/packages/eslint_plugin/${ruleName.replaceAll(
+ `https://docs.openverse.org/packages/js/eslint_plugin/${ruleName.replaceAll(
"-",
"_"
)}.html`
diff --git a/packages/eslint-plugin/test/rules/analytics-configuration.spec.ts b/packages/js/eslint-plugin/test/rules/analytics-configuration.spec.ts
similarity index 100%
rename from packages/eslint-plugin/test/rules/analytics-configuration.spec.ts
rename to packages/js/eslint-plugin/test/rules/analytics-configuration.spec.ts
diff --git a/packages/eslint-plugin/test/rules/no-unexplained-disabled-test.spec.ts b/packages/js/eslint-plugin/test/rules/no-unexplained-disabled-test.spec.ts
similarity index 100%
rename from packages/eslint-plugin/test/rules/no-unexplained-disabled-test.spec.ts
rename to packages/js/eslint-plugin/test/rules/no-unexplained-disabled-test.spec.ts
diff --git a/packages/eslint-plugin/test/rules/translation-strings.spec.ts b/packages/js/eslint-plugin/test/rules/translation-strings.spec.ts
similarity index 100%
rename from packages/eslint-plugin/test/rules/translation-strings.spec.ts
rename to packages/js/eslint-plugin/test/rules/translation-strings.spec.ts
diff --git a/packages/eslint-plugin/tsconfig.json b/packages/js/eslint-plugin/tsconfig.json
similarity index 84%
rename from packages/eslint-plugin/tsconfig.json
rename to packages/js/eslint-plugin/tsconfig.json
index 81f5e9760..b2fc9635d 100644
--- a/packages/eslint-plugin/tsconfig.json
+++ b/packages/js/eslint-plugin/tsconfig.json
@@ -1,5 +1,5 @@
{
- "extends": "../../tsconfig.base.json",
+ "extends": "../../../tsconfig.base.json",
"compilerOptions": {
"module": "NodeNext",
"noEmit": true,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 54890b6a6..e2bf34173 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -10,7 +10,7 @@ importers:
devDependencies:
'@openverse/eslint-plugin':
specifier: workspace:0.0.0
- version: link:packages/eslint-plugin
+ version: link:packages/js/eslint-plugin
prettier:
specifier: 3.2.5
version: 3.2.5
@@ -311,7 +311,7 @@ importers:
specifier: ^4.46.0
version: 4.46.0
- packages/eslint-plugin:
+ packages/js/eslint-plugin:
dependencies:
'@intlify/eslint-plugin-vue-i18n':
specifier: ^2.0.0
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index f202b4f5f..e94175faa 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -1,4 +1,4 @@
packages:
- automations/js/
- frontend/
- - packages/*
+ - packages/js/*
diff --git a/tsconfig.base.json b/tsconfig.base.json
index cc5c9d24f..e0fb1ace2 100644
--- a/tsconfig.base.json
+++ b/tsconfig.base.json
@@ -13,7 +13,7 @@
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"paths": {
- "@openverse/*": ["./packages/*/src"]
+ "@openverse/*": ["./packages/js/*/src"]
},
/**