Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move ESLint plugin inside packages/js #4174

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codespell/ignore_lines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"addLabels": ["🟨 tech: javascript"]
},
{
"matchFileNames": ["{frontend,packages}/**"],
"matchFileNames": ["{frontend,packages/js}/**"],
"addLabels": ["🧱 stack: frontend"]
},
{
Expand Down Expand Up @@ -78,7 +78,7 @@
},
{
"groupName": "@openverse/eslint-plugin",
"matchFileNames": ["packages/eslint-plugin/**"]
"matchFileNames": ["packages/js/eslint-plugin/**"]
},
{
"groupName": "tailwind",
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,22 @@ 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
entry: bash -c 'pnpm run eslint --fix'

- 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
Expand Down
10 changes: 5 additions & 5 deletions documentation/meta/ci_cd/jobs/packages.md
Original file line number Diff line number Diff line change
@@ -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 |
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions documentation/packages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
🎉

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
},
"author": "Openverse <openverse@wordpress.org>",
"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": "pnpm@8.15.7",
"engines": {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ export = {
},
},
{
files: ["packages/**"],
files: ["packages/js/**"],
settings: {
"import/resolver": {
typescript: {
project: "packages/*/tsconfig.json",
project: "packages/js/*/tsconfig.json",
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"module": "NodeNext",
"noEmit": true,
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
packages:
- automations/js/
- frontend/
- packages/*
- packages/js/*
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"paths": {
"@openverse/*": ["./packages/*/src"]
"@openverse/*": ["./packages/js/*/src"]
},

/**
Expand Down