From e712c61f3978c61fc9829910be4d4b382cbd652a Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Mon, 29 Jan 2024 11:04:36 -0500 Subject: [PATCH 1/6] ci: only format and lint changed files --- .eslintignore | 3 +++ .eslintrc.cjs | 2 +- .prettierignore | 3 +++ package.json | 11 +++++++++-- scripts/changed-files | 3 +++ 5 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 .eslintignore create mode 100644 .prettierignore create mode 100755 scripts/changed-files diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..113f29b --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +scripts/* +.eslintignore +.prettierignore diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 0bd04ba..f862385 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -11,7 +11,7 @@ module.exports = { 'plugin:svelte/recommended', 'prettier', ], - plugins: ['svelte', 'simple-import-sort'], + plugins: ['svelte', 'simple-import-sort', 'json-files'], rules: { 'simple-import-sort/imports': 'error', }, diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..113f29b --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +scripts/* +.eslintignore +.prettierignore diff --git a/package.json b/package.json index e3b9104..f075628 100644 --- a/package.json +++ b/package.json @@ -44,13 +44,19 @@ ], "scripts": { "toc": "doctoc README.md", - "lint": "(prettier . --check || true) && eslint .", + "lint": "prettier . --check && eslint .", + "lint:delta": "npm-run-all -p prettier:delta eslint:delta", + "prettier:delta": "prettier --check `./scripts/changed-files`", + "eslint:delta": "eslint `./scripts/changed-files`", "format": "prettier . --write && eslint . --fix", + "format:delta": "npm-run-all format:prettier:delta format:eslint:delta", + "format:prettier:delta": "prettier --write `./scripts/changed-files`", + "format:eslint:delta": "eslint --fix `./scripts/changed-files`", "test": "vitest run --coverage", "test:watch": "vitest", "test:update": "vitest run --update", "setup": "npm install && npm run validate", - "validate": "npm-run-all lint test", + "validate": "npm-run-all lint:delta test", "contributors:add": "all-contributors add", "contributors:generate": "all-contributors generate" }, @@ -72,6 +78,7 @@ "eslint-config-prettier": "^9.1.0", "eslint-config-standard": "^17.1.0", "eslint-plugin-import": "^2.27.5", + "eslint-plugin-json-files": "^4.1.0", "eslint-plugin-n": "^16.0.1", "eslint-plugin-promise": "^6.1.1", "eslint-plugin-simple-import-sort": "^10.0.0", diff --git a/scripts/changed-files b/scripts/changed-files new file mode 100755 index 0000000..1275bd8 --- /dev/null +++ b/scripts/changed-files @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +git diff --name-only --diff-filter=d main From dc4513d2d30d1ce366fdf99d5309b47466178eb5 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Mon, 29 Jan 2024 14:59:16 -0500 Subject: [PATCH 2/6] use origin/main as base branch --- scripts/changed-files | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/changed-files b/scripts/changed-files index 1275bd8..71aa342 100755 --- a/scripts/changed-files +++ b/scripts/changed-files @@ -1,3 +1,3 @@ #!/usr/bin/env bash -git diff --name-only --diff-filter=d main +git diff --name-only --diff-filter=d origin/main From b7a1b561af6beea413c4a5eeb98b96b246946da1 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Mon, 29 Jan 2024 15:06:47 -0500 Subject: [PATCH 3/6] tell github to check out the main as well --- .github/workflows/release.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c799e3..54e9781 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,11 @@ jobs: svelte: ['3', '4'] runs-on: ubuntu-latest steps: + - name: ⬇️ Checkout main branch of repo + uses: actions/checkout@v4 + with: + ref: main + - name: ⬇️ Checkout repo uses: actions/checkout@v4 From c9782d16ebac8328babb07693d9dfb16c4b8b927 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Mon, 29 Jan 2024 15:09:32 -0500 Subject: [PATCH 4/6] ignore the yaml files of the workflow --- .eslintignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintignore b/.eslintignore index 113f29b..38450f6 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ scripts/* .eslintignore .prettierignore +.github/workflows/* From b0546bbdfc7ac802ea835896d53e3c752927654c Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Mon, 29 Jan 2024 15:54:37 -0500 Subject: [PATCH 5/6] update the CONTRIBUTING doc --- CONTRIBUTING.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c7ba039..d5f35da 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,10 +15,10 @@ The module is released automatically from the `main` branch using [semantic-rele ## Development setup -After cloning the repository, use the `setup` script to install development dependencies and the `validate` script to run all checks and tests to verify your setup. +After cloning the repository, install the project's dependencies and run the `validate` script to run all checks and tests to verify your setup. ```shell -npm run setup +npm install # or `pnpm install`, or `yarn install`, etc. npm run validate ``` @@ -27,13 +27,13 @@ npm run validate Run auto-formatting to ensure any changes adhere to the code style of the repository: ```shell -npm run format +npm run format:delta ``` To run lint and format checks without making any changes: ```shell -npm run lint +npm run lint:delta ``` ### Test From bac6f0f68af8550da57f92aa5cea0b41d6ddbe99 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Mon, 29 Jan 2024 15:56:56 -0500 Subject: [PATCH 6/6] ignore markdown files --- .eslintignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintignore b/.eslintignore index 38450f6..111e490 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,3 +2,4 @@ scripts/* .eslintignore .prettierignore .github/workflows/* +*.md