Skip to content

Revert "🔖 7.0" #864

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

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f81f1d3
Revert "feat(deps): upgrade all dependencies to latest"
jrolfs Jan 18, 2023
d7939a4
Revert "refactor(deps): remove direct dependency on arrify"
jrolfs Jan 18, 2023
0fbe6cd
Revert "fix(test): add `@swc/helpers`"
jrolfs Jan 18, 2023
6751701
Revert "build(deps-dev): add latest `@types/node`"
jrolfs Jan 18, 2023
c8fb9c0
Revert "build(deps): deduplicate dependencies"
jrolfs Jan 18, 2023
9c65206
Revert "feat(deps): upgrade Prettier to 2.8.1"
jrolfs Jan 18, 2023
7fd094b
Revert "feat(deps): update eslint"
jrolfs Jan 18, 2023
0a959df
Revert "build: move shared TypeScript configuration to project root i…
jrolfs Jan 18, 2023
fa08c20
Revert "feat(deps): upgrade commitlint"
jrolfs Jan 18, 2023
77524be
Revert "fix(scripts/pre-commit): don't fail when no related tests are…
jrolfs Jan 18, 2023
6e3e1de
Revert "feat(deps): upgrade `@swc-node/jest` and `@swc/core`"
jrolfs Jan 18, 2023
5c51d35
Revert "feat(api/commit): add support for excluding directories in `l…
jrolfs Jan 18, 2023
e2551ae
Revert "build: use Node 18"
jrolfs Jan 18, 2023
2a2f10d
Revert "feat(config/jest): `@swc/jest` → `@swc-node/jest` (supports …
jrolfs Jan 18, 2023
70867b4
Revert "fix(config/jest): add jest-environment-jsdom as a dependency"
jrolfs Jan 18, 2023
35c5af1
Revert "build: use latest Node 16"
jrolfs Jan 18, 2023
17ff53e
Revert "fix: remove `skipLibCheck` as it's no longer necessary"
jrolfs Jan 18, 2023
94dba10
Revert "feat(config/test): use **@swc/jest** as default Jest transform"
jrolfs Jan 18, 2023
81ffc60
Revert "build: deduplicate lockfile"
jrolfs Jan 18, 2023
ef3648c
Revert "ci(actions): release on Node 16"
jrolfs Jan 18, 2023
b021fd3
Revert "feat(scripts/test): upgrade Jest to 29.x"
jrolfs Jan 18, 2023
7f1583b
Revert "feat(scripts/ci-after-success): use Semantic Release 19"
jrolfs Jan 18, 2023
59db6c4
Revert "feat(scripts/test): upgrade Jest to 28.x"
jrolfs Jan 18, 2023
e958193
Revert "feat(config/eslint): dissallow default exports in strict conf…
jrolfs Jan 18, 2023
61056a0
Revert "fix(api/test): forward ts-jest utils from `ts-jest`, remove `…
jrolfs Jan 18, 2023
27a7135
Revert "build(deps): upgrade Jest to 27.4"
jrolfs Jan 18, 2023
496460f
Revert "build: set `skipLibCheck`... ts-jest and jest aren't playing …
jrolfs Jan 18, 2023
6a6edfa
Revert "fix(config/jest): set `ts-jest` transform unconditionally"
jrolfs Jan 18, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
if: ${{ needs.deduplicate.outputs.should_skip != 'true' }}
strategy:
matrix:
node: ['14', '16', '18']
node: ['12', '14', '16']

steps:
- name: Get Yarn cache path
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:

- name: Upload Coverage / Release
run: yarn ci-after-success
if: ${{ matrix.node == '16' }}
if: ${{ matrix.node == '14' }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.12.1
16.13.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,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-v18.12.1-green
[node-badge]: https://img.shields.io/badge/node-v16.13.0-green
[prettier-badge]:
https://img.shields.io/badge/code_style-prettier-ff69b4.svg?logo=prettier
[prettier-link]: https://prettierjs.org/en/download/
Expand Down
10 changes: 10 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@ module.exports = {
roots: ['<rootDir>/src'],
coverageThreshold: null,
transformIgnorePatterns: [...transformIgnorePatterns, '.prettierrc.js'],
globals: {
'ts-jest': {
...globals['ts-jest'],
tsconfig: './src/tsconfig.json',
diagnostics: {
warnOnly: true,
exclude: ['**/*'],
},
},
},
}
84 changes: 37 additions & 47 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"start": "run-p start:*",
"start:source": "yarn build:source --watch",
"start:types": "tsc -b -w --preserveWatchOutput src/",
"test": "SWC_NODE_PROJECT=src/tsconfig.json node src test",
"test": "node src test",
"test:update": "node src test --updateSnapshot",
"validate": "node src validate",
"prepare": "husky install"
Expand All @@ -50,53 +50,51 @@
"author": "Jamie Rolfs <jamie.rolfs@hover.to>",
"license": "MIT",
"dependencies": {
"@commitlint/cli": "^17.4.2",
"@commitlint/config-conventional": "^17.4.2",
"@commitlint/prompt": "^17.4.2",
"@swc-node/jest": "^1.5.6",
"@swc/core": "^1.3.27",
"@swc/helpers": "^0.4.14",
"@types/jest": "^29.2.5",
"@commitlint/cli": "^16.1.0",
"@commitlint/config-conventional": "^16.2.1",
"@commitlint/prompt": "^16.1.0",
"@types/jest": "^27.0.2",
"@types/lodash.has": "^4.5.7",
"@types/mkdirp": "^1.0.2",
"@types/node": "^18.11.18",
"@types/node": ">=17.x",
"@types/rimraf": "^3.0.2",
"@types/which": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"@typescript-eslint/eslint-plugin": "^5.45.1",
"@typescript-eslint/parser": "^5.45.1",
"arrify": "^2.0.1",
"commitizen": "^4.2.6",
"concurrently": "^7.6.0",
"cosmiconfig": "^8.0.0",
"concurrently": "^7.0.0",
"cosmiconfig": "^7.0.1",
"cross-env": "^7.0.3",
"cross-spawn": "^7.0.1",
"cross-spawn": "^7.0.3",
"depcheck": "^1.4.3",
"doctoc": "^2.2.1",
"eslint": "^8.32.0",
"doctoc": "^2.1.0",
"eslint": "^8.29.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.9.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.1",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.6.0",
"glob": "^8.1.0",
"glob": "^8.0.3",
"is-ci": "^3.0.1",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"jest": "^27.5.1",
"jest-github-actions-reporter": "^1.0.3",
"jest-watch-typeahead": "^2.2.1",
"lint-staged": "^13.1.0",
"jest-watch-typeahead": "^1.0.0",
"lint-staged": "^12.3.4",
"lodash.has": "^4.5.2",
"mkdirp": "^2.1.3",
"prettier": "^2.8.3",
"mkdirp": "^1.0.4",
"prettier": "^2.5.1",
"read-pkg-up": "^7.0.1",
"rimraf": "^4.1.1",
"tslib": "^2.4.1",
"rimraf": "^3.0.2",
"ts-jest": "^27.1.3",
"tslib": "^2.4.0",
"typescript": "^4",
"which": "^3.0.0",
"yargs-parser": "^21.1.1"
"which": "^2.0.2",
"yargs-parser": "^21.0.1"
},
"eslintConfig": {
"parserOptions": {
Expand All @@ -112,8 +110,7 @@
"import/no-unassigned-import": "off",
"no-console": "off",
"no-nested-ternary": "off",
"no-useless-catch": "off",
"jest/prefer-snapshot-hint": "off"
"no-useless-catch": "off"
}
},
"eslintIgnore": [
Expand All @@ -130,22 +127,15 @@
},
"homepage": "https://github.com/hoverinc/hover-javascript#readme",
"devDependencies": {
"@babel/cli": "^7.20.7",
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"@babel/cli": "^7.17.10",
"@babel/core": "^7.17.2",
"@babel/preset-env": "^7.16.11",
"@types/cross-spawn": "^6.0.2",
"eslint-config-kentcdodds": "^20.4.0",
"husky": "^8.0.3",
"babel-jest": "^28.1.0",
"eslint-config-kentcdodds": "^20.0.1",
"husky": "^7.0.4",
"jest-in-case": "^1.0.2",
"npm-run-all": "^4.1.5",
"slash": "^3.0.0"
},
"peerDependencies": {
"ts-jest": "^29.0.0"
},
"peerDependenciesMeta": {
"ts-jest": {
"optional": true
}
}
}
1 change: 0 additions & 1 deletion src/api/__tests__/__fixtures__/ls/dirs/.gitignore

This file was deleted.

Empty file.
20 changes: 1 addition & 19 deletions src/api/__tests__/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,11 @@ describe('ls', () => {
})

test('with prefix', () => {
const result = ls.dirs(`${fixtures}/ls/dirs`, {prefix: 'prefix'})
const result = ls.dirs(`${fixtures}/ls/dirs`, '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())
})
})
})
11 changes: 11 additions & 0 deletions src/api/__tests__/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as utilsExports from 'ts-jest/utils'
import * as testExports from '../test' // eslint-disable-line import/namespace

describe('re-exporting ts-jest utils', () => {
test.each(Object.entries(utilsExports).filter(([key]) => key !== 'default'))(
'forwards `%s` export',
(exportName, exportValue) => {
expect(testExports).toHaveProperty(exportName, exportValue)
},
)
})
30 changes: 4 additions & 26 deletions src/api/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,39 +44,17 @@ 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 {DirsOptions} options -
* @param {string} [prefix] - prefix for each scope entry (e.g: `prefix/entry`)
*/
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))
const dirs = (path, prefix) =>
readdirSync(path)
.filter(f => statSync(join(path, f)).isDirectory())
.map(item => (prefix ? `${prefix}/${item}` : item))
.map(item => item.toLowerCase())
}

const ls = {configs, dirs}

Expand Down
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 {hasFile, uniq} = require('../../utils')
const hoverSpecials = require('./specials')
const {hasFile, uniq} = require('../../utils')

/**
* @typedef Config
Expand Down
1 change: 1 addition & 0 deletions src/api/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from 'ts-jest/utils'
3 changes: 0 additions & 3 deletions src/config/__tests__/__snapshots__/eslintrc.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ Object {
},
],
"import/prefer-default-export": "off",
"jest/prefer-snapshot-hint": "off",
"no-implied-eval": "error",
"no-throw-literal": "error",
"no-void": Array [
Expand Down Expand Up @@ -252,7 +251,6 @@ Object {
},
],
"import/prefer-default-export": "off",
"jest/prefer-snapshot-hint": "off",
"no-implied-eval": "error",
"no-throw-literal": "error",
"no-void": Array [
Expand Down Expand Up @@ -289,7 +287,6 @@ Object {
exports[`Strict ESLint configuration 1`] = `
Object {
"rules": Object {
"import/no-default-export": "error",
"import/order": Array [
"error",
Object {
Expand Down
1 change: 0 additions & 1 deletion src/config/eslintrc-strict.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = {
rules: {
'import/no-default-export': 'error',
'import/order': [
'error',
{
Expand Down
2 changes: 0 additions & 2 deletions src/config/helpers/build-eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ const buildConfig = ({withReact = 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: [
Expand Down
2 changes: 1 addition & 1 deletion src/config/helpers/build-lint-staged.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {resolveHoverScripts, resolveBin} = require('../../utils')
const hoverScripts = resolveHoverScripts()
const doctoc = resolveBin('doctoc')

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

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

Expand Down
49 changes: 26 additions & 23 deletions src/config/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/** @typedef {import('@jest/types').Config.InitialOptions} JestConfig */

const {ifAnyDep, hasFile, fromRoot, hasDevDep} = require('../utils')
const {jsWithTs: preset} = require('ts-jest/presets')

const {ifAnyDep, hasAnyDep, hasFile, fromRoot} = require('../utils')

const {
testMatch,
Expand All @@ -20,31 +22,13 @@ const ignores = [
/** @type JestConfig */
const jestConfig = {
roots: [fromRoot('.')],
// Here we're preserving Jest <= 28 snapshot format to prevent the need
// to update snapshots when upgrading Jest via @hover/javascript, see:
// https://jestjs.io/docs/upgrading-to-jest29#snapshot-format
snapshotFormat: {escapeString: true, printBasicPrototype: true},
testEnvironment: ifAnyDep(['webpack', 'rollup', 'react'], 'jsdom', 'node'),
testEnvironmentOptions: {url: 'http://localhost'},
testURL: 'http://localhost',
moduleFileExtensions: testMatchExtensions.concat('json'),
collectCoverageFrom: [`**/${testMatchGlob}`],
testMatch,
testPathIgnorePatterns: [...ignores, '<rootDir>/dist'],
testLocationInResults: true,
// The default transform is now SWC, however, `ts-jest` will
// still be used if it is installed in the host project
transform: hasDevDep('ts-jest')
? 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]) => [
glob,
[require.resolve(transformer), {diagnostics: {warnOnly: true}}],
],
),
)
: {'^.+\\.(t|j)sx?$': ['@swc-node/jest']},
coveragePathIgnorePatterns: [
...ignores,
'src/(umd|cjs|esm)-entry.js$',
Expand All @@ -67,9 +51,28 @@ const jestConfig = {
require.resolve('jest-watch-typeahead/filename'),
require.resolve('jest-watch-typeahead/testname'),
],
setupFilesAfterEnv: hasFile('tests/setup-env.js')
? [fromRoot('tests/setup-env.js')]
: undefined,
globals: {},
}

if (hasAnyDep('ts-jest') || hasFile('tsconfig.json')) {
jestConfig.transform = Object.fromEntries(
// Ensure we can resolve the preset even when
// it's in a nested `node_modules` installation
Object.entries(preset.transform).map(([key, value]) => [
key,
require.resolve(value),
]),
)

jestConfig.globals['ts-jest'] = {
diagnostics: {
warnOnly: true,
},
}
}

if (hasFile('tests/setup-env.js')) {
jestConfig.setupFilesAfterEnv = [fromRoot('tests/setup-env.js')]
}

module.exports = jestConfig
Loading