Skip to content

🐛 Post 7.0 fixes #873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,13 @@ module.exports = require('@hover/javascript/prettier')

Or, for Jest in `jest.config.js`:

> ℹ️ If **ts-jest** is installed, it will automatically be used as the `preset`
> ⚠️ Starting with
> [**7.0**](https://github.com/hoverinc/hover-javascript/releases/tag/v7.0.0),
> the default Jest `transform` is
> [**@swc-node/jest**](https://github.com/swc-project/swc-node/#swc-nodejest).
> If you want to continue using
> [**ts-jest**](https://kulshekhar.github.io/ts-jest/), simpy install `ts-jest`
> in your project and it will automatically be used as the `transform` instead.

```js
const config = require('@hover/javascript/jest')
Expand Down
2 changes: 1 addition & 1 deletion src/api/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const configs = path =>
* Enumerate one level of directories
*
* @param {string} path - directory to enumerate
* @param {DirsOptions} options -
* @param {DirsOptions} [options] - options
*/
const dirs = (path, options) => {
const {exclude, prefix} = {exclude: /^node_modules/, ...options}
Expand Down
14 changes: 11 additions & 3 deletions src/config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ const jestConfig = {
? Object.fromEntries(
// Ensure we can resolve the preset even when
// it's in a nested `node_modules` installation
Object.entries(require('ts-jest/presets').transform).map(
([glob, transformer]) => [
Object.entries(require('ts-jest/presets').jsWithTs.transform).map(
([glob, [transformer, options]]) => [
glob,
[require.resolve(transformer), {diagnostics: {warnOnly: true}}],
[
require.resolve(transformer),
{
...options,
diagnostics: {
warnOnly: true,
},
},
],
],
),
)
Expand Down
12 changes: 6 additions & 6 deletions src/scripts/__tests__/__snapshots__/commit-msg.js.snap
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`commit-msg adds env flag with HUSKY_GIT_PARAMS when available 1`] = `commitlint --env HUSKY_GIT_PARAMS --config ./src/config/commitlint.config.js`;
exports[`commit-msg adds env flag with HUSKY_GIT_PARAMS when available 1`] = `TS_NODE_TRANSPILE_ONLY=true commitlint --env HUSKY_GIT_PARAMS --config ./src/config/commitlint.config.js`;

exports[`commit-msg calls @commitlint/cli with default args 1`] = `commitlint --config ./src/config/commitlint.config.js --edit`;
exports[`commit-msg calls @commitlint/cli with default args 1`] = `TS_NODE_TRANSPILE_ONLY=true commitlint --config ./src/config/commitlint.config.js --edit`;

exports[`commit-msg defaults to \`--edit\` when no args are passed and HUSKY_GIT_PARAMS is not available 1`] = `commitlint --config ./src/config/commitlint.config.js --edit`;
exports[`commit-msg defaults to \`--edit\` when no args are passed and HUSKY_GIT_PARAMS is not available 1`] = `TS_NODE_TRANSPILE_ONLY=true commitlint --config ./src/config/commitlint.config.js --edit`;

exports[`commit-msg does not use built-in config with --config 1`] = `commitlint --config ./custom-config.js`;
exports[`commit-msg does not use built-in config with --config 1`] = `TS_NODE_TRANSPILE_ONLY=true commitlint --config ./custom-config.js`;

exports[`commit-msg does not use built-in config with commitlint.config.js file 1`] = `commitlint --edit`;
exports[`commit-msg does not use built-in config with commitlint.config.js file 1`] = `TS_NODE_TRANSPILE_ONLY=true commitlint --edit`;

exports[`commit-msg forwards args 1`] = `commitlint --config ./src/config/commitlint.config.js --edit .git/COMMIT_EDITMSG`;
exports[`commit-msg forwards args 1`] = `TS_NODE_TRANSPILE_ONLY=true commitlint --config ./src/config/commitlint.config.js --edit .git/COMMIT_EDITMSG`;
4 changes: 3 additions & 1 deletion src/scripts/commit-msg.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const config = useBuiltinConfig
: []

const result = spawn.sync(
resolveBin('@commitlint/cli', {executable: 'commitlint'}),
`TS_NODE_TRANSPILE_ONLY=true ${resolveBin('@commitlint/cli', {
executable: 'commitlint',
})}`,
[...env, ...config, ...args, ...defaultEdit],
{
stdio: 'inherit',
Expand Down