-
-
Notifications
You must be signed in to change notification settings - Fork 618
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work to mjs, ESLint 9, and newwer jest
- Loading branch information
1 parent
8f87893
commit d4028e4
Showing
34 changed files
with
7,721 additions
and
12,840 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/node_modules | ||
/bin/configlet | ||
/bin/configlet.exe | ||
/pnpm-lock.yaml | ||
/package-lock.json | ||
/yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = { | ||
presets: ['@exercism/babel-preset-javascript'], | ||
presets: [['@exercism/babel-preset-javascript', { corejs: '3.38' }]], | ||
plugins: [], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,50 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then | ||
echo "Pulling prettier version from package.json" | ||
EXERCISM_PRETTIER_VERSION=$(npm list prettier | grep -Po '.*\sprettier@\K.*') | ||
set -uo pipefail | ||
|
||
if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then | ||
echo "[format] pulling prettier version from pnpm list using sed" | ||
EXERCISM_PRETTIER_VERSION="$(corepack pnpm list prettier --parseable | sed -n -e '1,$s/^.*prettier@//' -e 's/\\node_modules\\prettier//p')" | ||
echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}" | ||
fi | ||
|
||
if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then | ||
echo "[format] pulling prettier version via pnpm-lock.yaml using grep" | ||
EXERCISM_PRETTIER_VERSION="$(cat pnpm-lock.yaml | grep -Po ' prettier@\K[^:]+')" | ||
echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}" | ||
fi | ||
|
||
if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then | ||
if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then | ||
echo "Version could not be pulled using sed or grep" >&2 | ||
echo "" | ||
echo "---------------------------------------------------" | ||
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work." | ||
echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance." | ||
echo "---------------------------------------------------" | ||
echo "This is what npm list reports:" | ||
echo "$(npm list prettier)" | ||
echo "$(corepack pnpm -v)" | ||
echo "" | ||
echo "This is what corepack pnpm list reports:" | ||
echo "$ corepack pnpm list prettier --parseable" | ||
echo "$(corepack pnpm list prettier --parseable)" | ||
echo "" | ||
echo "And corepack pnpm info reports the following:" | ||
echo "$ corepack pnpm info prettier" | ||
echo "$(corepack pnpm info prettier)" | ||
echo "" | ||
echo "This is the version that can be extracted using sed:" | ||
echo "$ corepack pnpm list prettier --parseable | sed -n -e '1,\$s/^.*prettier@//' -e 's/\\node_modules\\prettier//p'" | ||
echo "└─ $(corepack pnpm list prettier --parseable | sed -n -e '1,$s/^.*prettier@//' -e 's/\\node_modules\\prettier//p')" | ||
echo "" | ||
echo "This is the version that can be extracted:" | ||
echo "$(npm list prettier | grep -Po '.*\sprettier@\K.*')" | ||
echo "This is the version that can be extracted using grep:" | ||
echo "$ cat pnpm-lock.yaml | grep -Po ' prettier@\K[^:]+'" | ||
echo "└─ $(cat pnpm-lock.yaml | grep -Po ' prettier@\K[^:]+')" | ||
echo "" | ||
echo "These files are found in the repo root:" | ||
echo "$(ls -p | grep -v /)" | ||
echo "---------------------------------------------------" | ||
exit 1 | ||
else | ||
echo "Running format with prettier@$EXERCISM_PRETTIER_VERSION" | ||
echo "[format] running with prettier@$EXERCISM_PRETTIER_VERSION" | ||
fi | ||
|
||
npx "prettier@$EXERCISM_PRETTIER_VERSION" --check "*/**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}" | ||
corepack pnpm dlx "prettier@$EXERCISM_PRETTIER_VERSION" --check "**/*.{js,jsx,cjs,mjs,ts,tsx,css,sass,scss,html,json,md,yml}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,50 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then | ||
echo "Pulling prettier version from package.json" | ||
EXERCISM_PRETTIER_VERSION=$(npm list prettier | grep -Po '.*\sprettier@\K.*') | ||
set -uo pipefail | ||
|
||
if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then | ||
echo "[format] pulling prettier version from pnpm list using sed" | ||
EXERCISM_PRETTIER_VERSION="$(corepack pnpm list prettier --parseable | sed -n -e '1,$s/^.*prettier@//' -e 's/\\node_modules\\prettier//p')" | ||
echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}" | ||
fi | ||
|
||
if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then | ||
echo "[format] pulling prettier version via pnpm-lock.yaml using grep" | ||
EXERCISM_PRETTIER_VERSION="$(cat pnpm-lock.yaml | grep -Po ' prettier@\K[^:]+')" | ||
echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}" | ||
fi | ||
|
||
if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then | ||
if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then | ||
echo "Version could not be pulled using sed or grep" >&2 | ||
echo "" | ||
echo "---------------------------------------------------" | ||
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work." | ||
echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance." | ||
echo "---------------------------------------------------" | ||
echo "This is what npm list reports:" | ||
echo "$(npm list prettier)" | ||
echo "$(corepack pnpm -v)" | ||
echo "" | ||
echo "This is what corepack pnpm list reports:" | ||
echo "$ corepack pnpm list prettier --parseable" | ||
echo "$(corepack pnpm list prettier --parseable)" | ||
echo "" | ||
echo "And corepack pnpm info reports the following:" | ||
echo "$ corepack pnpm info prettier" | ||
echo "$(corepack pnpm info prettier)" | ||
echo "" | ||
echo "This is the version that can be extracted using sed:" | ||
echo "$ corepack pnpm list prettier --parseable | sed -n -e '1,\$s/^.*prettier@//' -e 's/\\node_modules\\prettier//p'" | ||
echo "└─ $(corepack pnpm list prettier --parseable | sed -n -e '1,$s/^.*prettier@//' -e 's/\\node_modules\\prettier//p')" | ||
echo "" | ||
echo "This is the version that can be extracted:" | ||
echo "$(npm list prettier | grep -Po '.*\sprettier@\K.*')" | ||
echo "This is the version that can be extracted using grep:" | ||
echo "$ cat pnpm-lock.yaml | grep -Po ' prettier@\K[^:]+'" | ||
echo "└─ $(cat pnpm-lock.yaml | grep -Po ' prettier@\K[^:]+')" | ||
echo "" | ||
echo "These files are found in the repo root:" | ||
echo "$(ls -p | grep -v /)" | ||
echo "---------------------------------------------------" | ||
exit 1 | ||
else | ||
echo "Running format with prettier@$EXERCISM_PRETTIER_VERSION" | ||
echo "[format] running with prettier@$EXERCISM_PRETTIER_VERSION" | ||
fi | ||
|
||
npx "prettier@$EXERCISM_PRETTIER_VERSION" --write "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}" | ||
corepack pnpm dlx "prettier@$EXERCISM_PRETTIER_VERSION" --write "**/*.{js,jsx,cjs,mjs,ts,tsx,css,sass,scss,html,json,md,yml}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
#!/usr/bin/env node | ||
|
||
const { exercises } = require('../config.json') | ||
const TAG_CORE = '__core' | ||
const TAG_BONUS = '__bonus' | ||
const { exercises } = require('../config.json'); | ||
const TAG_CORE = '__core'; | ||
const TAG_BONUS = '__bonus'; | ||
|
||
// node inter-opt exports | ||
exports.TAG_CORE = TAG_CORE | ||
exports.TAG_BONUS = TAG_BONUS | ||
exports.TAG_CORE = TAG_CORE; | ||
exports.TAG_BONUS = TAG_BONUS; | ||
|
||
exports.tree = exercises.reduce((result, exercise) => { | ||
const tag = exercise.slug | ||
const tag = exercise.slug; | ||
const item = { | ||
slug: tag, | ||
difficulty: exercise.difficulty, | ||
} | ||
}; | ||
|
||
if (exercise.core) { | ||
const current = result[TAG_CORE] || [] | ||
const current = result[TAG_CORE] || []; | ||
|
||
if (result[tag]) { | ||
console.warn(`${tag} is not ordered correctly in config.json`) | ||
console.warn(`${tag} is not ordered correctly in config.json`); | ||
} | ||
|
||
return { | ||
...result, | ||
__core: current.concat([item]), | ||
[tag]: result[tag] || [] | ||
} | ||
[tag]: result[tag] || [], | ||
}; | ||
} | ||
|
||
const parent = exercise.unlocked_by || TAG_BONUS | ||
const current = result[parent] || [] | ||
return { ...result, [parent]: current.concat([item]) } | ||
}, {}) | ||
const parent = exercise.unlocked_by || TAG_BONUS; | ||
const current = result[parent] || []; | ||
return { ...result, [parent]: current.concat([item]) }; | ||
}, {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
corepack enable pnpm | ||
corepack pnpm lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
#!/usr/bin/env node | ||
|
||
const actions = require('./generate-config-tree') | ||
const actions = require('./generate-config-tree'); | ||
|
||
const { tree, TAG_BONUS, TAG_CORE } = actions | ||
const { [TAG_BONUS]: __bonus, [TAG_CORE]: __core, ...track } = tree | ||
const { tree, TAG_BONUS, TAG_CORE } = actions; | ||
const { [TAG_BONUS]: __bonus, [TAG_CORE]: __core, ...track } = tree; | ||
|
||
function printLn(line) { | ||
process.stdout.write(`${line}\n`) | ||
process.stdout.write(`${line}\n`); | ||
} | ||
|
||
function printList(items) { | ||
items.forEach(item => { | ||
printLn(`- ${item.slug} (${item.difficulty})`) | ||
}) | ||
items.forEach((item) => { | ||
printLn(`- ${item.slug} (${item.difficulty})`); | ||
}); | ||
} | ||
|
||
printLn('Core (matches config.json) of this track:') | ||
printList(__core) | ||
printLn('\n') | ||
printLn('core') | ||
printLn('----') | ||
Object.keys(track).forEach(slug => { | ||
printLn(`├─ ${slug}`) | ||
printLn('Core (matches config.json) of this track:'); | ||
printList(__core); | ||
printLn('\n'); | ||
printLn('core'); | ||
printLn('----'); | ||
Object.keys(track).forEach((slug) => { | ||
printLn(`├─ ${slug}`); | ||
track[slug].forEach((side, index, self) => { | ||
junction = index === self.length - 1 ? '└─' : '├─' | ||
printLn(`│ ${junction} ${side.slug} (${side.difficulty})`) | ||
}) | ||
printLn('│') | ||
}) | ||
junction = index === self.length - 1 ? '└─' : '├─'; | ||
printLn(`│ ${junction} ${side.slug} (${side.difficulty})`); | ||
}); | ||
printLn('│'); | ||
}); | ||
|
||
printLn('bonus') | ||
printLn('----') | ||
printList(__bonus) | ||
printLn('bonus'); | ||
printLn('----'); | ||
printList(__bonus); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// @ts-check | ||
|
||
import config from '@exercism/eslint-config-javascript'; | ||
import maintainersConfig from '@exercism/eslint-config-javascript/maintainers.mjs'; | ||
|
||
import globals from 'globals'; | ||
|
||
export default [ | ||
...config, | ||
{ | ||
files: ['.meta/proof.ci.js', '.meta/exemplar.js', '*.spec.js'], | ||
extends: maintainersConfig, | ||
}, | ||
{ | ||
files: ['scripts/**/*.mjs'], | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
}, | ||
}, | ||
}, | ||
{ | ||
ignores: [ | ||
// # Protected or generated | ||
'/.appends/**/*', | ||
'/.github/**/*', | ||
'/.vscode/**/*', | ||
|
||
// # Binaries | ||
'/bin/*', | ||
|
||
// # Configuration | ||
'/config', | ||
'/babel.config.js', | ||
|
||
// # Typings | ||
'/exercises/**/global.d.ts', | ||
'/exercises/**/env.d.ts', | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
verbose: true, | ||
modulePathIgnorePatterns: ['package.json'], | ||
transform: { | ||
'^.+\\.[t|j]sx?$': 'babel-jest', | ||
}, | ||
reporters: [], | ||
}; |
Oops, something went wrong.