-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert codebase to typescript (#51)
* Use ESM imports * Move to typescript * Add first types * Build project to test against nodejs versions * relax eslint * move to ts * reformat code * fix esm build * remove cyclist type * change node:stream to stream for legacy * polish esm/cjs dist with sourcemap * prepare 0.9.0
- Loading branch information
Showing
104 changed files
with
8,445 additions
and
4,383 deletions.
There are no files selected for viewing
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,49 @@ | ||
{ | ||
"root": true, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:import/recommended", | ||
"plugin:import/typescript", | ||
"plugin:node/recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": ["tsconfig.test.json"], | ||
"sourceType": "module" | ||
}, | ||
"settings": { | ||
"import/resolver": { | ||
"typescript": true, | ||
"node": true | ||
} | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"mocha" | ||
], | ||
"env": { | ||
"node": true, | ||
"es6": true, | ||
"mocha": true | ||
}, | ||
"rules": { | ||
"@typescript-eslint/no-explicit-any": "error", | ||
"quote-props": ["error", "consistent"], | ||
"mocha/no-skipped-tests": "warn", | ||
"mocha/no-exclusive-tests": "error", | ||
"node/no-unsupported-features/es-syntax": [ | ||
"error", | ||
{ | ||
"version": ">=13.0.0", | ||
"ignores": ["modules"] | ||
} | ||
], | ||
"node/no-unpublished-import": [ | ||
"error", { | ||
"allowModules": ["slow-stream"] | ||
} | ||
] | ||
} | ||
} |
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
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,7 @@ | ||
node_modules/ | ||
.nyc_output/ | ||
.DS_Store | ||
.coverage/ | ||
.idea/ | ||
.nyc_output/ | ||
build/ | ||
dist/ | ||
node_modules/ |
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,10 @@ | ||
{ | ||
"timeout": 5000, | ||
"exit": true, | ||
"extension": ["ts", "js"], | ||
"recursive": true, | ||
"node-option": [ | ||
"experimental-specifier-resolution=node", | ||
"import=tsx" | ||
] | ||
} |
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,14 @@ | ||
.nyc_output/ | ||
.DS_Store | ||
.coverage/ | ||
.tools/ | ||
.idea/ | ||
.eslintrc.json | ||
.git/ | ||
.github/ | ||
.gitignore | ||
.idea/ | ||
.mocharc.json | ||
.nyc_output/ | ||
.prettierignore | ||
.prettierrc | ||
.tools/ | ||
build/ | ||
test/ |
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,4 @@ | ||
**/.git | ||
**/node_modules | ||
**/.coverage | ||
README.md |
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,5 @@ | ||
--- | ||
printWidth: 120 | ||
quoteProps: "consistent" | ||
bracketSpacing: false | ||
tabWidth: 4 |
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,40 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
readonly PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." | ||
readonly BUILD_DIR="${PROJECT_DIR}/build" | ||
readonly DIST_DIR="${PROJECT_DIR}/dist" | ||
|
||
rm -rf "${DIST_DIR}" "${BUILD_DIR}" | ||
mkdir -p "${DIST_DIR}" "${BUILD_DIR}" | ||
|
||
cd "${PROJECT_DIR}" | ||
|
||
echo "Compiling oleoduc (esm version)..." | ||
npm run tsc -- -p tsconfig.json | ||
cat >"${DIST_DIR}/esm/package.json" <<!EOF | ||
{ | ||
"type": "module" | ||
} | ||
!EOF | ||
|
||
echo "Compiling oleoduc (cjs version)..." | ||
npm run tsc -- -p tsconfig.cjs.json | ||
cat >"${DIST_DIR}/cjs/package.json" <<!EOF | ||
{ | ||
"type": "commonjs" | ||
} | ||
!EOF | ||
|
||
echo "Building oleoduc for test..." | ||
npm run tsc -- -p tsconfig.test.json | ||
echo "Patching package.json to be able to run tests against previous versions of nodejs..." | ||
cp "${PROJECT_DIR}/package.json" "${BUILD_DIR}" | ||
npx json -I -f "${BUILD_DIR}/package.json" -e 'this.type="commonjs"' | ||
npx json -I -f "${BUILD_DIR}/package.json" -e 'this.devDependencies.mocha="9.x"' | ||
npx json -I -f "${BUILD_DIR}/package.json" -e 'this.scripts.test="mocha --recursive --exit test/**/*-test.js"' | ||
cat >"${BUILD_DIR}/.mocharc.json" <<!EOF | ||
{} | ||
!EOF | ||
cd - | ||
|
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
readonly PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." | ||
readonly PRE_COMMIT_HOOK="${PROJECT_DIR}/.git/hooks/pre-commit" | ||
|
||
cat <<'EOF' >"${PRE_COMMIT_HOOK}" | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
# Do not edit. This file has been generated by oleoduc | ||
npm test | ||
npm run lint | ||
npm run build | ||
EOF | ||
|
||
chmod +x "${PRE_COMMIT_HOOK}" | ||
echo "pre-push hooks installed in ${PRE_COMMIT_HOOK}" |
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
Oops, something went wrong.