Skip to content

Commit 1ac89bf

Browse files
Migrate to Jest 17, ESM, and config packages (#944)
1 parent c72d62e commit 1ac89bf

File tree

787 files changed

+8185
-8414
lines changed

Some content is hidden

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

787 files changed

+8185
-8414
lines changed

.eslintignore

-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,3 @@
1111
# Configuration
1212
/config
1313

14-
# These have their own config files (not overrides)
15-
/common/*
16-
/exercises/*
17-
18-
# typescript-eslint can't lint correctly files in a project without extension
19-
/scripts/*

.eslintrc

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
{
22
"root": true,
3-
"parser": "@typescript-eslint/parser",
4-
"parserOptions": {
5-
"project": "./tsconfig.json",
6-
"ecmaFeatures": {
7-
"jsx": true
8-
},
9-
"ecmaVersion": 2020,
10-
"sourceType": "module"
11-
},
123
"extends": "@exercism/eslint-config-typescript",
134
"env": {
145
"jest": true
156
},
167
"overrides": [
178
{
18-
"files": ["**/.meta/proof.ci.ts", "**/.meta/exemplar.ts", "**/*.test.ts"],
9+
"files": [".meta/proof.ci.ts", ".meta/exemplar.ts", "*.test.ts"],
1910
"excludedFiles": ["custom.test.ts"],
2011
"extends": "@exercism/eslint-config-typescript/maintainers"
2112
}

.github/workflows/action-format.yml

-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ jobs:
6262
6363
- name: 'Format code'
6464
run: ./bin/format.sh
65-
env:
66-
EXERCISM_PRETTIER_VERSION: '2.3.2'
6765

6866
- name: 'Commit formatted code'
6967
run: |

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

-2
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@ jobs:
1414

1515
- name: 'Verify formatting of all files'
1616
run: ./bin/check-formatting.sh
17-
env:
18-
EXERCISM_PRETTIER_VERSION: '2.3.2'

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
/.github/workflows/sync-labels.yml
33
exercises/**/README.md
44
!/README.md
5+
6+
# These are formatted via configlet and will not match prettier
7+
exercises/**/.meta/config.json

babel.config.cjs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
presets: ['@exercism/babel-preset-typescript'],
3+
plugins: [],
4+
}

babel.config.js

-20
This file was deleted.

bin/check-formatting.sh

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
11
#!/bin/bash
22

3+
if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
4+
echo "Pulling prettier version from package.json"
5+
EXERCISM_PRETTIER_VERSION=$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')
6+
fi
7+
8+
if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
9+
echo "---------------------------------------------------"
10+
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
11+
echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance."
12+
echo "---------------------------------------------------"
13+
echo "This is what yarn list reports:"
14+
echo "$(yarn list --pattern prettier)"
15+
echo ""
16+
echo "This is the version that can be extracted:"
17+
echo "$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')"
18+
echo ""
19+
echo "These files are found in the repo root:"
20+
echo "$(ls -p | grep -v /)"
21+
echo "---------------------------------------------------"
22+
exit 1
23+
else
24+
echo "Running format with prettier@$EXERCISM_PRETTIER_VERSION"
25+
fi
26+
327
npx "prettier@$EXERCISM_PRETTIER_VERSION" --check "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"

bin/format.sh

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
#!/usr/bin/env bash
22

33
if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
4-
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
5-
echo "Please see https://github.com/exercism/v3/blob/master/docs/maintainers/style-guide.md for guidance."
6-
exit 1
4+
echo "Pulling prettier version from package.json"
5+
EXERCISM_PRETTIER_VERSION=$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')
6+
fi
7+
8+
if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
9+
echo "---------------------------------------------------"
10+
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
11+
echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance."
12+
echo "---------------------------------------------------"
13+
echo "This is what yarn list reports:"
14+
echo "$(yarn list --pattern prettier)"
15+
echo ""
16+
echo "This is the version that can be extracted:"
17+
echo "$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')"
18+
echo ""
19+
echo "These files are found in the repo root:"
20+
echo "$(ls -p | grep -v /)"
21+
echo "---------------------------------------------------"
22+
exit 1
23+
else
24+
echo "Running format with prettier@$EXERCISM_PRETTIER_VERSION"
725
fi
826

927
npx "prettier@$EXERCISM_PRETTIER_VERSION" --write "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"

common/.eslintignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
node_modules/*
99

1010
# Configuration files
11-
babel.config.js
12-
jest.config.js
11+
.eslintrc.cjs
12+
babel.config.cjs
13+
jest.config.cjs

common/.eslintrc

-23
This file was deleted.

common/.eslintrc.cjs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
tsconfigRootDir: __dirname,
5+
project: ['./tsconfig.json'],
6+
},
7+
overrides: [
8+
// Student provided files
9+
{
10+
files: ['*.ts'],
11+
excludedFiles: ['.meta/proof.ci.ts', '.meta/exemplar.ts', '*.test.ts'],
12+
extends: '@exercism/eslint-config-typescript',
13+
},
14+
// Exercism given tests
15+
{
16+
files: ['*.test.ts'],
17+
excludedFiles: ['custom.test.ts'],
18+
env: {
19+
jest: true,
20+
},
21+
extends: '@exercism/eslint-config-typescript/maintainers',
22+
},
23+
// Student provided tests
24+
{
25+
files: ['custom.test.ts'],
26+
env: {
27+
jest: true,
28+
},
29+
extends: '@exercism/eslint-config-typescript',
30+
},
31+
// Exercism provided files
32+
{
33+
files: ['.meta/proof.ci.ts', '.meta/exemplar.ts', '*.test.ts'],
34+
excludedFiles: ['custom.test.ts'],
35+
extends: '@exercism/eslint-config-typescript/maintainers',
36+
},
37+
],
38+
}

common/babel.config.cjs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
presets: ['@exercism/babel-preset-typescript'],
3+
plugins: [],
4+
}

common/babel.config.js

-20
This file was deleted.
File renamed without changes.

common/package.json

+12-13
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,20 @@
1111
"type": "git",
1212
"url": "https://github.com/exercism/typescript"
1313
},
14+
"type": "module",
15+
"engines": {
16+
"node": "^14.13.1 || >=16.0.0"
17+
},
1418
"devDependencies": {
15-
"@babel/core": "^7.16.5",
16-
"@babel/plugin-proposal-class-properties": "^7.16.5",
17-
"@babel/plugin-proposal-object-rest-spread": "^7.16.5",
18-
"@babel/plugin-syntax-bigint": "^7.8.3",
19-
"@babel/preset-env": "^7.16.11",
20-
"@babel/preset-typescript": "^7.16.5",
21-
"@types/jest": "^26.0.24",
22-
"@types/node": "^16.11.20",
19+
"@exercism/babel-preset-typescript": "^0.1.0",
2320
"@exercism/eslint-config-typescript": "^0.4.0",
24-
"babel-jest": "^26.6.3",
25-
"core-js": "^3.19.3",
26-
"eslint": "^8.7.0",
27-
"eslint-plugin-import": "^2.25.4",
28-
"jest": "^26.6.3",
21+
"@types/jest": "^27.4.0",
22+
"@types/node": "^16.11.24",
23+
"babel-jest": "^27.5.1",
24+
"core-js": "^3.21.0",
25+
"eslint": "^8.9.0",
26+
"jest": "^27.5.1",
27+
"prettier": "^2.5.1",
2928
"typescript": "^4.5.4"
3029
},
3130
"scripts": {

common/tsconfig.json

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
{
2-
"display": "Configuration for Node LTS",
2+
"display": "Configuration for Exercism TypeScript Exercises",
33
"compilerOptions": {
4-
"lib": ["es2020", "dom"],
5-
"module": "commonjs",
6-
"target": "es2020",
4+
// Allows you to use the newest syntax, and have access to console.log
5+
// https://www.typescriptlang.org/tsconfig#lib
6+
"lib": ["ESNEXT", "dom"],
7+
// Make sure typescript is configured to output ESM
8+
// https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-make-my-typescript-project-output-esm
9+
"module": "ES2020",
10+
// Since this project is using babel, TypeScript may target something very
11+
// high, and babel will make sure it runs on your local Node version.
12+
// https://babeljs.io/docs/en/
13+
"target": "ESNext", // ESLint doesn't support this yet: "es2022",
714

815
"strict": true,
916
"esModuleInterop": true,
1017
"skipLibCheck": true,
1118
"forceConsistentCasingInFileNames": true,
1219

13-
// Because we'll be using babel
14-
// Ensure that Babel can safely transpile files in the TypeScript project
20+
// Because we'll be using babel: ensure that Babel can safely transpile
21+
// files in the TypeScript project.
22+
//
23+
// https://babeljs.io/docs/en/babel-plugin-transform-typescript/#caveats
1524
"isolatedModules": true
1625
},
17-
"include": ["*", ".meta/*"],
26+
"include": ["*.ts", "*.tsx", ".meta/*.ts", ".meta/*.tsx"],
1827
"exclude": ["node_modules"]
1928
}

exercises/practice/accumulate/.eslintignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
node_modules/*
99

1010
# Configuration files
11-
babel.config.js
12-
jest.config.js
11+
.eslintrc.cjs
12+
babel.config.cjs
13+
jest.config.cjs

exercises/practice/accumulate/.eslintrc

-23
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
tsconfigRootDir: __dirname,
5+
project: ['./tsconfig.json'],
6+
},
7+
overrides: [
8+
// Student provided files
9+
{
10+
files: ['*.ts'],
11+
excludedFiles: ['.meta/proof.ci.ts', '.meta/exemplar.ts', '*.test.ts'],
12+
extends: '@exercism/eslint-config-typescript',
13+
},
14+
// Exercism given tests
15+
{
16+
files: ['*.test.ts'],
17+
excludedFiles: ['custom.test.ts'],
18+
env: {
19+
jest: true,
20+
},
21+
extends: '@exercism/eslint-config-typescript/maintainers',
22+
},
23+
// Student provided tests
24+
{
25+
files: ['custom.test.ts'],
26+
env: {
27+
jest: true,
28+
},
29+
extends: '@exercism/eslint-config-typescript',
30+
},
31+
// Exercism provided files
32+
{
33+
files: ['.meta/proof.ci.ts', '.meta/exemplar.ts', '*.test.ts'],
34+
excludedFiles: ['custom.test.ts'],
35+
extends: '@exercism/eslint-config-typescript/maintainers',
36+
},
37+
],
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
presets: ['@exercism/babel-preset-typescript'],
3+
plugins: [],
4+
}

0 commit comments

Comments
 (0)