Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hoverinc/hover-javascript
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.0.0-beta.5
Choose a base ref
...
head repository: hoverinc/hover-javascript
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: beta
Choose a head ref

Commits on Jul 6, 2022

  1. feat(config/release): specify next as a pre-release channel as well

    BREAKING CHANGE: the `next` branch will now be treated as pre-releases too
    jrolfs committed Jul 6, 2022

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    5ace598 View commit details

Commits on Sep 7, 2022

  1. feat(scripts/test): upgrade Jest to 29.x

    BREAKING CHANGE: upgrades Jest a major version (28 to 29)
    BREAKING CHANGE: Node 12 is no longer supported
    jrolfs committed Sep 7, 2022

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    955ea31 View commit details
  2. chore(deps): add renovate.json

    renovate[bot] authored and jrolfs committed Sep 7, 2022
    Copy the full SHA
    8f49b24 View commit details
  3. build(deps): use public Renovate configuration until we sort 404

    I _think_ it's because this repository is a fork which is preventing
    access to the protected configuration on `hoverinc`
    jrolfs committed Sep 7, 2022
    Copy the full SHA
    d6f72af View commit details
  4. Copy the full SHA
    984e7e7 View commit details

Commits on Sep 8, 2022

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    4999a8b View commit details
  2. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    f71e508 View commit details
  3. build(deps): update dependency @types/lodash.has to ^4.5.7 (#830)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Sep 8, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c151836 View commit details
  4. build(deps): update dependency cross-spawn to ^7.0.3 (#835)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Sep 8, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7bc30c8 View commit details
  5. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    3f5cbb6 View commit details

Commits on Sep 16, 2022

  1. Copy the full SHA
    b284128 View commit details

Commits on Sep 29, 2022

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    7627f06 View commit details

Commits on Oct 5, 2022

  1. Merge pull request #845 from hoverinc/MEOW-598

    fix(scripts): move depcheck to main dep so other apps can use it
    viviannguyen authored Oct 5, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    24ab346 View commit details

Commits on Dec 9, 2022

  1. build: use Node 18

    jrolfs committed Dec 9, 2022
    Copy the full SHA
    9997545 View commit details
  2. feat(deps): update eslint

    renovate[bot] authored and jrolfs committed Dec 9, 2022
    Copy the full SHA
    7a1d36a View commit details
  3. Copy the full SHA
    97546ec View commit details
  4. feat(api/commit): add support for excluding directories in ls.dirs()

    BREAKING CHANGE: `ls.dirs()` from `api/commit` now takes an options
    object as the second parameter instead of a `prefix`. If you're using
    a prefix you'll need to make the following change:
    
    ```ts
    // Before
    ls.dirs('./packages', 'my-prefix');
    
    // After
    ls.dirs('./packages', { prefix: 'my-prefix' });
    ```
    
    BREAKING CHANGE: `ls.dirs()` now excludes `node_modules` directories
    by default. If for some reason you want to include \`node_modules\`,
    you'll need to explicitly set \`exclude\` to \`null\`:
    
    ```ts
    // Before
    ls.dirs('./packages');
    
    // After
    ls.dirs('./packages', { exclude: null });
    ```
    jrolfs committed Dec 9, 2022
    Copy the full SHA
    8648a39 View commit details
  5. Copy the full SHA
    2547de7 View commit details
  6. Copy the full SHA
    c7f4d8f View commit details
  7. Copy the full SHA
    da73557 View commit details
  8. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    a5d4057 View commit details
  9. Copy the full SHA
    12c307b View commit details
  10. Copy the full SHA
    fcb02d2 View commit details
  11. build: move shared TypeScript configuration to project root instead o…

    …f extending
    
    For consistency, up until now, the shared TypeScript configuration has lived in
    `src/config` with all of the other shared configurations that this package
    provides. For all of the other configurations we're able to simple re-export
    the configuration at the project root to provide it to consumers at
    `require('@hover/javascript/[config]')`. Because the TypeScript configuration
    is JSON, however, we were using `extends` instead of re-exporting. This has been
    causing all kinds of trouble within this package since we were extending from the
    `dist` directory. This finally moves the canonical TypeScript configuration
    to the root, so that we don't need to `extends` from `dist/` while preserving
    `src/config/tsconfig.json` via `extends` just in case. The actual configuration
    for this project itself still lives at `src/tsconfig.json`, but this prevents
    issues when anything (like the `ts-node` that gets loaded in `commitlint`
    from trying to read a non-existent `dist/tsconfig.json` if it does read
    the `tsconfig.json` at the root of the project.
    jrolfs committed Dec 9, 2022
    Copy the full SHA
    8ba039c View commit details

Commits on Dec 17, 2022

  1. feat(deps): update eslint

    renovate[bot] authored and jrolfs committed Dec 17, 2022
    Copy the full SHA
    17e60e0 View commit details
  2. Copy the full SHA
    3f56e8a View commit details
  3. Copy the full SHA
    5e14147 View commit details
  4. Copy the full SHA
    c58825a View commit details

Commits on Jan 7, 2023

  1. build(deps): bump json5 from 1.0.1 to 1.0.2

    Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
    - [Release notes](https://github.com/json5/json5/releases)
    - [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
    - [Commits](json5/json5@v1.0.1...v1.0.2)
    
    ---
    updated-dependencies:
    - dependency-name: json5
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and kodiakhq[bot] committed Jan 7, 2023
    Copy the full SHA
    5e94f75 View commit details

Commits on Jan 10, 2023

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    446707a View commit details

Commits on Jan 18, 2023

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    6bb9799 View commit details
  2. feat(deps): upgrade all dependencies to latest

    BREAKING CHANGE: potential breaking change as some upgrades were major
    jrolfs committed Jan 18, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    82d6fdd View commit details

Commits on Jan 19, 2023

  1. Merge branch 'main' into beta

    # Conflicts:
    #	package.json
    #	yarn.lock
    jrolfs committed Jan 19, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    17ce718 View commit details
  2. Merge pull request #782 from hoverinc/beta

    🔖 Beta
    jrolfs authored Jan 19, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ad6df53 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    03ea9b1 View commit details
  4. Merge branch 'main' into next

    # Conflicts:
    #	jest.config.js
    #	package.json
    #	src/config/jest.config.js
    #	yarn.lock
    jrolfs committed Jan 19, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    62e4012 View commit details
  5. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    c01832f View commit details
  6. chore: remove discrepancy in Jest configuration

    I have to merge `next` to appease Semantic Release... my fault
    for abandoning it I guess 😩 EINVALIDNEXTVERSION
    jrolfs committed Jan 19, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    e0f0875 View commit details
  7. Merge pull request #829 from hoverinc/next

    Ugh I abandoned this branch/release channel because I rebased it and fucked up semantic-release... now it won't let me release on main (EINVALIDNEXTVERSION) until this is merged so hopefully merging it with a minimal diff appeases semantic-release otherwise I'm ditching it for good for Changesets 🖕🏻
    jrolfs authored Jan 19, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6f208dd View commit details

Commits on Feb 27, 2023

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    33c2fcd View commit details
  2. fix(scripts/commit-msg): prevent commitlint from ever type-checking c…

    …onfiguration
    
    **@commitlint/cli** added support for TypeScript-based configurations via `ts-node`, and that has caused a good deal of grief:
    
    conventional-changelog/commitlint#3420
    conventional-changelog/commitlint#3351
    conventional-changelog/commitlint#3218
    conventional-changelog/commitlint#3256
    
    hoverinc/web-react#1792
    
    Both because it's a heavy-ass dependency and because it requires configuration to
    work properly. It seems like project-local configuration can affect it's invocation
    of ts-node, which happens even JavaScript configuration files now?... lame.
    
    Anyways, this ensures we avoid any type-checking that happens in it's ts-node
    invocation until we get a better solution upstream (or contribute one). Ideally,
    installing ts-node would be opt-in etc.
    jrolfs committed Feb 27, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    b195b15 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    6801d01 View commit details
  4. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    f95265d View commit details
  5. Merge pull request #873 from hoverinc/fix/post-seven-dot-oh

    🐛 Post 7.0 fixes
    jrolfs authored Feb 27, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    567aaf9 View commit details
  6. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    9a3be51 View commit details

Commits on Feb 28, 2023

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    5e2c409 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    ffaf7e8 View commit details
  3. Merge pull request #874 from hoverinc/feature/allow-some-default-exports

    ✨ Allow default exports in some specific cases
    jrolfs authored Feb 28, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b08c0ab View commit details
  4. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jrolfs Jamie Rolfs
    Copy the full SHA
    0d9a28c View commit details
  5. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f821282 View commit details
18 changes: 0 additions & 18 deletions .github/dependabot.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ jobs:
node-version: ${{ matrix.node }}

- name: Load Yarn cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -5,4 +5,13 @@ dist
.opt-out
.DS_Store
.eslintcache
.idea
.idea

# See: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.17.1
18.12.1
363 changes: 363 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

873 changes: 873 additions & 0 deletions .yarn/releases/yarn-3.4.1.cjs

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
enableInlineBuilds: true

changesetBaseRefs:
- HEAD

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: '@yarnpkg/plugin-typescript'
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools'
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'

yarnPath: .yarn/releases/yarn-3.4.1.cjs
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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')
@@ -294,7 +300,7 @@ This project is actively maintained by engineers at
[license-badge]: https://img.shields.io/npm/l/@hover/javascript.svg
[license-link]: https://github.com/hoverinc/hover-javascript/blob/master/LICENSE
[node-link]: https://nodejs.org/en/download/
[node-badge]: https://img.shields.io/badge/node-v16.13.0-green
[node-badge]: https://img.shields.io/badge/node-v18.12.1-green
[prettier-badge]:
https://img.shields.io/badge/code_style-prettier-ff69b4.svg?logo=prettier
[prettier-link]: https://prettierjs.org/en/download/
95 changes: 48 additions & 47 deletions package.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
"version": "0.0.0-semantically-released",
"description": "CLI toolbox for common scripts for JavaScript + TypeScript projects",
"engines": {
"node": ">=12",
"node": ">=v14",
"npm": ">=6",
"yarn": ">=1"
},
@@ -14,7 +14,7 @@
"hover-scripts": "dist/index.js"
},
"scripts": {
"build": "run-p build:*",
"build": "run-p 'build:*'",
"build:source": "babel --source-maps --out-dir dist --ignore '**/__tests__/**','**/__mocks__/**' --copy-files --no-copy-ignored src",
"build:types": "tsc -p src/",
"ci-after-success": "node src ci-after-success",
@@ -23,10 +23,10 @@
"format": "node src format",
"lint": "node src lint",
"prepublishOnly": "yarn build",
"start": "run-p start:*",
"start": "run-p 'start:*'",
"start:source": "yarn build:source --watch",
"start:types": "tsc -b -w --preserveWatchOutput src/",
"test": "node src test",
"test": "SWC_NODE_PROJECT=src/tsconfig.json node src test",
"test:update": "node src test --updateSnapshot",
"validate": "node src validate",
"prepare": "husky install"
@@ -50,52 +50,52 @@
"author": "Jamie Rolfs <jamie.rolfs@hover.to>",
"license": "MIT",
"dependencies": {
"@commitlint/cli": "^16.1.0",
"@commitlint/config-conventional": "^16.2.1",
"@commitlint/prompt": "^16.1.0",
"@swc/core": "^1.2.248",
"@swc/jest": "^0.2.22",
"@types/jest": "^29.0.0",
"@types/lodash.has": "^4.5.6",
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@commitlint/prompt": "^17.4.4",
"@swc-node/jest": "^1.5.6",
"@swc/core": "^1.3.38",
"@swc/helpers": "^0.4.14",
"@types/jest": "^29.4.0",
"@types/lodash.has": "^4.5.7",
"@types/mkdirp": "^1.0.2",
"@types/node": ">=17.x",
"@types/node": "^18.11.18",
"@types/rimraf": "^3.0.2",
"@types/which": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.27.0",
"arrify": "^2.0.1",
"commitizen": "^4.2.4",
"concurrently": "^7.0.0",
"cosmiconfig": "^7.0.1",
"@types/which": "^2.0.2",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.54.1",
"commitizen": "^4.3.0",
"concurrently": "^7.6.0",
"cosmiconfig": "^8.0.0",
"cross-env": "^7.0.3",
"cross-spawn": "^7.0.1",
"doctoc": "^2.1.0",
"eslint": "^8.16.0",
"eslint-config-airbnb": "19.0.0",
"cross-spawn": "^7.0.3",
"doctoc": "^2.2.1",
"eslint": "^8.35.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^26.1.1",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.30.0",
"eslint-plugin-react-hooks": "^4.3.0",
"glob": "^8.0.3",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"glob": "^8.1.0",
"is-ci": "^3.0.1",
"jest": "^29.0.2",
"jest-environment-jsdom": "^29.0.3",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-github-actions-reporter": "^1.0.3",
"jest-watch-typeahead": "^2.1.1",
"lint-staged": "^12.3.4",
"jest-watch-typeahead": "^2.2.2",
"lint-staged": "^13.1.0",
"lodash.has": "^4.5.2",
"mkdirp": "^1.0.3",
"prettier": "^2.5.1",
"mkdirp": "^2.1.3",
"prettier": "^2.8.3",
"read-pkg-up": "^7.0.1",
"rimraf": "^3.0.2",
"tslib": "^2.4.0",
"rimraf": "^4.1.1",
"tslib": "^2.4.1",
"typescript": "^4",
"which": "^2.0.2",
"yargs-parser": "^21.0.1"
"which": "^3.0.0",
"yargs-parser": "^21.1.1"
},
"eslintConfig": {
"parserOptions": {
@@ -111,7 +111,8 @@
"import/no-unassigned-import": "off",
"no-console": "off",
"no-nested-ternary": "off",
"no-useless-catch": "off"
"no-useless-catch": "off",
"jest/prefer-snapshot-hint": "off"
}
},
"eslintIgnore": [
@@ -128,13 +129,13 @@
},
"homepage": "https://github.com/hoverinc/hover-javascript#readme",
"devDependencies": {
"@babel/cli": "^7.17.10",
"@babel/core": "^7.17.2",
"@babel/preset-env": "^7.16.11",
"@babel/cli": "^7.20.7",
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"@types/cross-spawn": "^6.0.2",
"depcheck": "^1.4.3",
"eslint-config-kentcdodds": "^20.0.1",
"husky": "^7.0.4",
"eslint-config-kentcdodds": "^20.4.0",
"husky": "^8.0.3",
"jest-in-case": "^1.0.2",
"npm-run-all": "^4.1.5",
"slash": "^3.0.0"
14 changes: 14 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>jrolfs/renovate:npm.json5",
"github>jrolfs/renovate:npm-feat.json5",
":widenPeerDependencies"
],
"packageRules": [
{
"matchPackagePatterns": ["eslint"],
"groupName": "eslint"
}
]
}
1 change: 1 addition & 0 deletions src/api/__tests__/__fixtures__/ls/dirs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!node_modules
Empty file.
20 changes: 19 additions & 1 deletion src/api/__tests__/commit.js
Original file line number Diff line number Diff line change
@@ -26,11 +26,29 @@ describe('ls', () => {
})

test('with prefix', () => {
const result = ls.dirs(`${fixtures}/ls/dirs`, 'prefix')
const result = ls.dirs(`${fixtures}/ls/dirs`, {prefix: 'prefix'})

const expected = ['prefix/.baz', 'prefix/bar', 'prefix/foo']

expect(result.sort()).toEqual(expected.sort())
})

test('with custom exclude (string)', () => {
const result = ls.dirs(`${fixtures}/ls/dirs`, {exclude: 'foo'})

const expected = ['.baz', 'bar', 'node_modules']

expect(result.sort()).toEqual(expected.sort())
})

test('with custom exclude (RegExp)', () => {
const result = ls.dirs(`${fixtures}/ls/dirs`, {
exclude: /(^node_modules|^bar)/,
})

const expected = ['.baz', 'foo']

expect(result.sort()).toEqual(expected.sort())
})
})
})
30 changes: 26 additions & 4 deletions src/api/commit.js
Original file line number Diff line number Diff line change
@@ -44,17 +44,39 @@ const configs = path =>
)}`,
)

/**
* @typedef DirsOptions
* @property {string} [prefix] prefix to prepend to each scope entry (e.g:
* `{ prefix: 'prefix' }` becomes `type(prefix/scope)`)
* @property {RegExp | string | null} [exclude] expression for excluding
* directories, defaults to `^node_modules`
*/

/**
* Enumerate one level of directories
*
* @param {string} path - directory to enumerate
* @param {string} [prefix] - prefix for each scope entry (e.g: `prefix/entry`)
* @param {DirsOptions} [options] - options
*/
const dirs = (path, prefix) =>
readdirSync(path)
.filter(f => statSync(join(path, f)).isDirectory())
const dirs = (path, options) => {
const {exclude, prefix} = {exclude: /^node_modules/, ...options}

/**
* @param {string} f filename
*/
const test = f => {
if (!exclude) return true

return !(typeof exclude === 'string'
? f.includes(exclude)
: exclude.test(f))
}

return readdirSync(path)
.filter(f => statSync(join(path, f)).isDirectory() && test(f))
.map(item => (prefix ? `${prefix}/${item}` : item))
.map(item => item.toLowerCase())
}

const ls = {configs, dirs}

2 changes: 1 addition & 1 deletion src/api/depcheck/depcheck.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs')
const depcheck = require('depcheck')
const hoverSpecials = require('./specials')
const {hasFile, uniq} = require('../../utils')
const hoverSpecials = require('./specials')

/**
* @typedef Config
18 changes: 16 additions & 2 deletions src/config/__tests__/__snapshots__/eslintrc.js.snap
Original file line number Diff line number Diff line change
@@ -113,12 +113,13 @@ Object {
"jest/**",
"test/**",
"e2e/**",
"**/*.config.{js,cjs,ts}",
"**/*.config.{js,cjs,ts,mjs}",
],
"optionalDependencies": false,
},
],
"import/prefer-default-export": "off",
"jest/prefer-snapshot-hint": "off",
"no-implied-eval": "error",
"no-throw-literal": "error",
"no-void": Array [
@@ -245,12 +246,13 @@ Object {
"jest/**",
"test/**",
"e2e/**",
"**/*.config.{js,cjs,ts}",
"**/*.config.{js,cjs,ts,mjs}",
],
"optionalDependencies": false,
},
],
"import/prefer-default-export": "off",
"jest/prefer-snapshot-hint": "off",
"no-implied-eval": "error",
"no-throw-literal": "error",
"no-void": Array [
@@ -286,6 +288,18 @@ Object {
exports[`Strict ESLint configuration 1`] = `
Object {
"overrides": Array [
Object {
"files": Array [
"**/*.d.ts",
"**/__mocks__/**/*",
"**/*.config.{js,cjs,ts,mjs}",
],
"rules": Object {
"import/no-default-export": "off",
},
},
],
"rules": Object {
"import/no-default-export": "error",
"import/order": Array [
8 changes: 8 additions & 0 deletions src/config/eslintrc-strict.js
Original file line number Diff line number Diff line change
@@ -16,4 +16,12 @@ module.exports = {
],
'sort-imports': ['error', {ignoreDeclarationSort: true}],
},
overrides: [
{
files: ['**/*.d.ts', '**/__mocks__/**/*', '**/*.config.{js,cjs,ts,mjs}'],
rules: {
'import/no-default-export': 'off',
},
},
],
}
4 changes: 3 additions & 1 deletion src/config/helpers/build-eslint.js
Original file line number Diff line number Diff line change
@@ -62,13 +62,15 @@ const buildConfig = ({withReact = false} = {}) => {
'jest/**',
'test/**',
'e2e/**',
'**/*.config.{js,cjs,ts}',
'**/*.config.{js,cjs,ts,mjs}',
]),
optionalDependencies: false,
},
],
'no-void': ['error', {allowAsStatement: true}],
'prettier/prettier': 'error',
// TODO: consider enabling this as a warning?
'jest/prefer-snapshot-hint': 'off',
...parserRules(false, isReact),
},
overrides: [
2 changes: 1 addition & 1 deletion src/config/helpers/build-lint-staged.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ const {resolveHoverScripts, resolveBin} = require('../../utils')
const hoverScripts = resolveHoverScripts()
const doctoc = resolveBin('doctoc')

const defaultTestCommand = `${hoverScripts} test --findRelatedTests`
const defaultTestCommand = `${hoverScripts} test --findRelatedTests --passWithNoTests`

const sourceExtensions = ['js', 'jsx', 'ts', 'tsx']

14 changes: 10 additions & 4 deletions src/config/jest.config.js
Original file line number Diff line number Diff line change
@@ -37,14 +37,20 @@ 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: false,
},
],
],
),
)
: {'^.+\\.(t|j)sx?$': ['@swc/jest']},
: {'^.+\\.(t|j)sx?$': ['@swc-node/jest']},
coveragePathIgnorePatterns: [
...ignores,
'src/(umd|cjs|esm)-entry.js$',
2 changes: 1 addition & 1 deletion src/config/release.config.js
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@ module.exports = {
'+([0-9])?(.{+([0-9]),x}).x',
'main',
'master',
'next',
'next-major',
{name: 'next', prerelease: true},
{name: 'alpha', prerelease: true},
{name: 'beta', prerelease: true},
],
24 changes: 1 addition & 23 deletions src/config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
{
"compilerOptions": {
"alwaysStrict": true,
"declaration": true,
"esModuleInterop": true,
"importHelpers": true,
"jsx": "react",
"lib": ["dom", "esnext"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": false,
"noUnusedParameters": true,
"resolveJsonModule": true,
"sourceMap": true,
"strict": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"target": "es5"
}
"extends": "../../tsconfig.json"
}
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`;
2 changes: 1 addition & 1 deletion src/scripts/__tests__/__snapshots__/pre-commit.js.snap
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ Array [
exports[`pre-commit disables DocToc and forwards args 2`] = `
Array [
.test-tmp/hover-javascriptTMPSUFFIX/.lintstaged.json,
{"*.+(js|jsx|json|json5|yml|yaml|css|less|scss|ts|tsx|md|graphql|mdx|vue)":["./src/index.js format"],"*.+(js|jsx|ts|tsx)":["./src/index.js lint"],"*.+(tsx|ts|jsx|js)":["./src/index.js test --findRelatedTests"]},
{"*.+(js|jsx|json|json5|yml|yaml|css|less|scss|ts|tsx|md|graphql|mdx|vue)":["./src/index.js format"],"*.+(js|jsx|ts|tsx)":["./src/index.js lint"],"*.+(tsx|ts|jsx|js)":["./src/index.js test --findRelatedTests --passWithNoTests"]},
]
`;

4 changes: 3 additions & 1 deletion src/scripts/commit-msg.js
Original file line number Diff line number Diff line change
@@ -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',
58 changes: 43 additions & 15 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ const fs = require('fs')
const path = require('path')
const rimraf = require('rimraf')
const mkdirp = require('mkdirp')
const arrify = require('arrify')
const has = require('lodash.has')
const readPkgUp = require('read-pkg-up')
const which = require('which')
@@ -66,19 +65,42 @@ function resolveBin(
const fromRoot = (/** @type {string[]} */ ...p) => path.join(appDirectory, ...p)
const hasFile = (/** @type {string[]} */ ...p) => fs.existsSync(fromRoot(...p))

const ifFile = (
/** @type {*} */ files,
/** @type {*} */ t,
/** @type {*} */ f,
) => (arrify(files).some((/** @type {*} */ file) => hasFile(file)) ? t : f)
/**
* @param {string | string[]} stringOrArray
*/
const liftStringArray = stringOrArray =>
typeof stringOrArray === 'string' ? [stringOrArray] : stringOrArray

/**
*
* @template T
* @template F
*
* @param {string | string[]} files
* @param {T} t
* @param {F} f
*/
const ifFile = (files, t, f) =>
liftStringArray(files).some(file => hasFile(file)) ? t : f

const getPkgName = () => pkg.name

const hasPkgProp = (/** @type {*} */ props) =>
arrify(props).some((/** @type {*} */ prop) => has(pkg, prop))
/**
* @param {string | string[]} props
*/
const hasPkgProp = props => liftStringArray(props).some(prop => has(pkg, prop))

const hasPkgSubProp = (/** @type {*} */ pkgProp) => (/** @type {*} */ props) =>
hasPkgProp(arrify(props).map((/** @type {*} */ p) => `${pkgProp}.${p}`))
/**
* @param {string} pkgProp
*/
const hasPkgSubProp =
pkgProp =>
/**
* @param {string | string[]} props
* @returns
*/
props =>
hasPkgProp(liftStringArray(props).map(p => `${pkgProp}.${p}`))

const ifPkgSubProp =
(/** @type {*} */ pkgProp) =>
@@ -95,11 +117,17 @@ const hasAnyDep = (/** @type {*} */ args) =>
const ifPeerDep = ifPkgSubProp('peerDependencies')
const ifDep = ifPkgSubProp('dependencies')
const ifDevDep = ifPkgSubProp('devDependencies')
const ifAnyDep = (
/** @type {*} */ deps,
/** @type {*} */ t,
/** @type {*} */ f,
) => (hasAnyDep(arrify(deps)) ? t : f)

/**
* @template T
* @template F
*
* @param {string | string[]} deps
* @param {T} t
* @param {F} f
*/
const ifAnyDep = (deps, t, f) => (hasAnyDep(liftStringArray(deps)) ? t : f)

const ifScript = ifPkgSubProp('scripts')

function parseEnv(/** @type {string} */ name, /** @type {*} */ def) {
23 changes: 21 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
{
"extends": "./dist/config/tsconfig",
"compilerOptions": {
"allowJs": true
"alwaysStrict": true,
"declaration": true,
"esModuleInterop": true,
"importHelpers": true,
"jsx": "react",
"lib": ["dom", "esnext"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": false,
"noUnusedParameters": true,
"resolveJsonModule": true,
"sourceMap": true,
"strict": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"target": "es5"
}
}
19,144 changes: 11,640 additions & 7,504 deletions yarn.lock

Large diffs are not rendered by default.