Skip to content

Commit 90e1f86

Browse files
Convert to ESLint 9 flat config and move to pnpm, use .mjs and new jest types (#2548)
* Initial work to mjs, ESLint 9, and newwer jest * Start switching workflows to pnpm * Update docs for corepack and pnpm * Add missing step for changed files * Add jest imports * Fix test configuration * Fix texts * Fix linting issues, update CONTRIBUTING * Update configurations * Update latent references * Fix cleanups
1 parent d0324d5 commit 90e1f86

File tree

1,148 files changed

+20094
-17564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,148 files changed

+20094
-17564
lines changed

.eslintignore

-16
This file was deleted.

.eslintrc

-14
This file was deleted.

.github/workflows/action-format.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,18 @@ jobs:
6060
git clone $HEAD_REPO .
6161
git checkout -b "$HEAD_REF" "origin/$HEAD_REF"
6262
63-
- name: Use Node.js LTS (18.x)
63+
- name: Enable corepack to fix https://github.com/actions/setup-node/pull/901
64+
run: corepack enable pnpm
65+
66+
- name: Use Node.js LTS (20.x)
6467
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
6568
with:
66-
node-version: '18'
69+
node-version: 20.x
70+
cache: 'pnpm'
71+
6772
- name: Install project development dependencies
68-
run: npm install --no-save
73+
run: corepack pnpm install --no-save
74+
6975
- name: 'Format code'
7076
run: ./bin/format.sh
7177

.github/workflows/action-sync.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ jobs:
6161
git checkout -b "$HEAD_REF" "origin/$HEAD_REF"
6262
6363
- name: 'Install dependencies'
64-
run: yarn install
64+
run: |
65+
corepack enable pnpm
66+
corepack pnpm install
6567
- name: 'Sync exercises'
66-
run: npx babel-node scripts/sync
68+
run: corepack pnpm node scripts/sync.mjs
6769

6870
- name: 'Commit changes'
6971
run: |

.github/workflows/ci.js.yml

+15-7
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,41 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
16-
- name: Use Node.js LTS (18.x)
16+
- name: Enable corepack to fix https://github.com/actions/setup-node/pull/901
17+
run: corepack enable pnpm
18+
19+
- name: Use Node.js LTS (20.x)
1720
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
1821
with:
19-
node-version: '18'
22+
node-version: 20.x
23+
cache: 'pnpm'
2024

2125
- name: Install project dependencies
22-
run: npm ci
26+
run: corepack pnpm install --frozen-lockfile
2327

2428
- name: Run exercism/javascript ci precheck (checks config, lint code, and runs tests) for all exercises
25-
run: npx babel-node scripts/ci-check
29+
run: corepack pnpm node scripts/ci-check.mjs
2630

2731
ci:
2832
runs-on: ubuntu-22.04
2933

3034
strategy:
3135
matrix:
32-
node-version: ['18', '20']
36+
node-version: [20.x, 22.x]
3337

3438
steps:
3539
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
40+
- name: Enable corepack to fix https://github.com/actions/setup-node/pull/901
41+
run: corepack enable pnpm
42+
3643
- name: Use Node.js ${{ matrix.node-version }}
3744
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
3845
with:
3946
node-version: ${{ matrix.node-version }}
47+
cache: 'pnpm'
4048

4149
- name: Install project dependencies
42-
run: npm ci
50+
run: corepack pnpm install --frozen-lockfile
4351

4452
- name: Run exercism/javascript ci (checks config, lint code, and runs tests) for all exercises
45-
run: npx babel-node scripts/ci
53+
run: corepack pnpm node scripts/ci.mjs

.github/workflows/pr.ci.js.yml

+37-15
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,66 @@ jobs:
1212
steps:
1313
- name: Checkout PR
1414
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
15+
with:
16+
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
17+
18+
- name: Get changed files
19+
id: changed-files
20+
run: |
21+
if ${{ github.event_name == 'pull_request' }}; then
22+
echo "changed_files=$(git diff --name-only --diff-filter=ACM -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
23+
else
24+
echo "changed_files=$(git diff --name-only --diff-filter=ACM ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
25+
fi
1526
16-
- name: Use Node.js LTS (18.x)
27+
- name: Enable corepack to fix https://github.com/actions/setup-node/pull/901
28+
run: corepack enable pnpm
29+
30+
- name: Use Node.js LTS (20.x)
1731
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
1832
with:
19-
node-version: '18'
33+
node-version: 20.x
34+
cache: 'pnpm'
2035

2136
- name: Install project dependencies
22-
run: npm ci
37+
run: corepack pnpm install --frozen-lockfile
2338

2439
- name: Run exercism/javascript ci precheck (stub files, config integrity) for changed exercises
25-
run: |
26-
PULL_REQUEST_URL=$(jq -r ".pull_request.url" "$GITHUB_EVENT_PATH")
27-
curl --url $"${PULL_REQUEST_URL}/files?per_page=100" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \
28-
jq -c '.[] | select(.status == "added" or .status == "modified") | select(.filename | match("\\.(js|jsx|md|json)$")) | .filename' | \
29-
xargs -r npx babel-node scripts/pr-check
40+
run: corepack pnpm node scripts/pr.mjs ${{ steps.changed-files.outputs.changed_files }}
3041

3142
ci:
3243
runs-on: ubuntu-22.04
3344

3445
strategy:
3546
matrix:
36-
node-version: ['18', '20']
47+
node-version: [20.x, 22.x]
3748

3849
steps:
3950
- name: Checkout PR
4051
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
52+
with:
53+
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
54+
55+
- name: Get changed files
56+
id: changed-files
57+
run: |
58+
if ${{ github.event_name == 'pull_request' }}; then
59+
echo "changed_files=$(git diff --name-only --diff-filter=ACM -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
60+
else
61+
echo "changed_files=$(git diff --name-only --diff-filter=ACM ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
62+
fi
63+
64+
- name: Enable corepack to fix https://github.com/actions/setup-node/pull/901
65+
run: corepack enable pnpm
4166

4267
- name: Use Node.js ${{ matrix.node-version }}
4368
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
4469
with:
4570
node-version: ${{ matrix.node-version }}
71+
cache: 'pnpm'
4672

4773
- name: Install project dependencies
48-
run: npm ci
74+
run: corepack pnpm install --frozen-lockfile
4975

5076
- name: Run exercism/javascript ci (runs tests) for changed/added exercises
51-
run: |
52-
PULL_REQUEST_URL=$(jq -r ".pull_request.url" "$GITHUB_EVENT_PATH")
53-
curl --url $"${PULL_REQUEST_URL}/files?per_page=100" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \
54-
jq -c '.[] | select(.status == "added" or .status == "modified") | select(.filename | match("\\.(js|jsx|md|json)$")) | .filename' | \
55-
xargs -r npx babel-node scripts/pr
77+
run: corepack pnpm node scripts/pr.mjs ${{ steps.changed-files.outputs.changed_files }}

.github/workflows/verify-code-formatting.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ jobs:
1111
steps:
1212
- name: 'Checkout code'
1313
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
14-
- name: Use Node.js LTS (18.x)
15-
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
16-
with:
17-
node-version: '18'
18-
- name: Install project development dependencies
19-
run: npm i
14+
2015
- name: 'Verify formatting of all files'
2116
run: ./bin/check-formatting.sh

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/node_modules
22
/bin/configlet
33
/bin/configlet.exe
4-
/pnpm-lock.yaml
4+
/package-lock.json
55
/yarn.lock

0 commit comments

Comments
 (0)