From 2a50d49b8b08b2b9f89868a084e97c000b5bcabf Mon Sep 17 00:00:00 2001 From: nmccready Date: Thu, 12 Sep 2024 18:16:32 -0400 Subject: [PATCH] chore: ts-jest save off --- .editorconfig | 13 ++++++++++++ .eslintignore | 6 ++++++ .prettierrc.js | 8 ++++++++ .travis.yml | 29 --------------------------- _jest.config.no | 32 ++++++++++++++++++++++++++++++ gulpfile.ts | 51 ------------------------------------------------ jest.config.js | 36 ++++++---------------------------- package.json | 27 ++++++++++++------------- rollup.config.ts | 18 ----------------- tsconfig.json | 2 +- 10 files changed, 78 insertions(+), 144 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintignore create mode 100644 .prettierrc.js delete mode 100644 .travis.yml create mode 100644 _jest.config.no delete mode 100644 gulpfile.ts delete mode 100644 rollup.config.ts diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..da0310f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..65a08ee --- /dev/null +++ b/.eslintignore @@ -0,0 +1,6 @@ +submodules +node_modules +node_modules/**/*.js +dist +lib +!.storybook diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..501f8fb --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,8 @@ +module.exports = { + useTabs: false, + printWidth: 95, + tabWidth: 2, + singleQuote: true, + trailingComma: 'es5', + arrowParens: 'always', +}; diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b272fc9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -sudo: false - -language: node_js - -node_js: - - 12 - - 10 - -script: - - npm i -g yarn@1.22 - - yarn test:ci - -cache: - yarn: true - directories: - - node_modules - -branches: - except: - - /^v[0-9]/ - -env: - - CXX=g++-4.8 -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 diff --git a/_jest.config.no b/_jest.config.no new file mode 100644 index 0000000..7b32442 --- /dev/null +++ b/_jest.config.no @@ -0,0 +1,32 @@ +// jest.config.ts +import { createDefaultPreset, JestConfigWithTsJest } from 'ts-jest' + +const jestConfig: JestConfigWithTsJest = { + // [...] + ...createDefaultPreset(), +} +// const toNotIgnore = { +// modules: [].join('|'), +// }; + +// const toExport = { +// roots: [''], +// // moduleFileExtensions: ['js', 'css', 'ts'], +// transformIgnorePatterns: ['node_modules', '//lib', '//(?!src)'], +// verbose: true, +// collectCoverageFrom: [ +// 'src/**/*.{ts,js}', +// '!/node_modules/', +// '!/lib/', +// '!/umd/', +// '!/config/', +// '!/test/', +// ], +// testRegex: '(/test/.*(test|spec))\\.[jt]sx?$', +// }; + +// if (toNotIgnore.modules.length) { +// toExport.transformIgnorePatterns.push(`/node_modules/(?!(${toNotIgnore.modules}))`); +// } + +// module.exports = toExport; diff --git a/gulpfile.ts b/gulpfile.ts deleted file mode 100644 index 27523b7..0000000 --- a/gulpfile.ts +++ /dev/null @@ -1,51 +0,0 @@ -import gulp from 'gulp'; -import ts from 'gulp-typescript'; -import del from 'del'; -import run from 'gulp-run'; -// import replace from 'gulp-replace'; -// import rename from 'gulp-rename'; - -/* -Gulp is for an itemized build so you can easily -pick exactly what files you want without tree shaking. - -So this is for lib / cjs build. -*/ -const { compilerOptions: tsconfig } = require('./tsconfig.json'); -const pkg = require('./package.json'); - -const getDir = (fileName: string) => fileName.split('/')[0]; - -gulp.task('clean', () => - del(['.tmp', getDir(pkg.main), '*.log', getDir(pkg.umd)]) -); - -const build = ( - src = [ - 'src/**/*.ts?(x)', - '!src/**/*.spec.ts?(x)', - '!src/**/*.test.ts?(x)', - '!src/test/**/*', - ], - dest = 'lib' -) => () => - gulp - .src(src) - .pipe(ts(tsconfig)) - .pipe(gulp.dest(dest)); - -gulp.task('build', build()); - -const docsClean = () => del(['docs']); - -gulp.task('docs:clean', docsClean); - -const docsApiWebsite = () => run('yarn docs:api:website', { verbosity: 3 }).exec(); - -const docsApiMarkdown = () => run('yarn docs:api:markdown', { verbosity: 3 }).exec(); - -const noJekyll = () => gulp.src('.nojekyll').pipe(gulp.dest('docs')); - -gulp.task('default', gulp.series('clean', 'build')); - -gulp.task('docs', gulp.series(docsClean, docsApiWebsite, docsApiMarkdown, noJekyll)); diff --git a/jest.config.js b/jest.config.js index 1cbaf19..5fd4a4e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,32 +1,8 @@ -const toNotIgnore = { - modules: [].join('|'), -}; - -const toExport = { - roots: [''], - // moduleFileExtensions: ['js', 'css', 'ts'], - transformIgnorePatterns: ['node_modules', '//lib', '//(?!src)'], - moduleNameMapper: { - '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': - '/node_modules/@znemz/react-extras-jest/lib/assetsTransformer.js', - '\\.(css|less|pcss)(!js)$': - '/node_modules/@znemz/react-extras-jest/lib/assetsTransformer.js', +/** @type {import('ts-jest').JestConfigWithTsJest} * */ +module.exports = { + testEnvironment: 'node', + transform: { + '^.+.tsx?$': ['ts-jest', {}], }, - setupFilesAfterEnv: ['/node_modules/@znemz/react-extras-jest/lib/setup.js'], - verbose: true, - collectCoverageFrom: [ - 'src/**/*.{ts,js}', - '!/node_modules/', - '!/lib/', - '!/umd/', - '!/config/', - '!/test/', - ], - testRegex: '(/test/.*(test|spec))\\.[jt]sx?$', + testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'], }; - -if (toNotIgnore.modules.length) { - toExport.transformIgnorePatterns.push(`/node_modules/(?!(${toNotIgnore.modules}))`); -} - -module.exports = toExport; diff --git a/package.json b/package.json index f7edffb..e06316f 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,11 @@ "umd" ], "scripts": { - "build": "npm run gulp default && npm run roll:it", + "build": "npx tsc", "coveralls": "cat ./coverage/lcov.info | coveralls", "docs:api:markdown": "npx typedoc --theme markdown --exclude ./src/test --out ./docs/api ./src", "docs:api:website": "npx typedoc --exclude ./src/test --out docs ./src", - "gulp": "node -r esm ./node_modules/.bin/gulp", - "jest": "node -r esm ./node_modules/.bin/jest", + "jest": "npx ts-jest", "lint": "eslint --ext .js,.ts,.tsx *.js src test --color", "mocha": "mocha", "prepare": "npx sort-package-json", @@ -45,31 +44,29 @@ "@commitlint/cli": "^19", "@commitlint/config-conventional": "^19", "@types/debug": "^4", - "@znemz/js-common-babel-config": "^0.2.1", + "@types/jest": "^29.5.13", "@znemz/js-common-eslint-config": "^0.2.2", - "@znemz/react-extras-jest": "^1.1.0", - "JSONStream": "1.X", - "bluebird": "^3.5.5", "commitlint": "19", "config": "^3.2.2", "coveralls": "^3.0.4", "del": "^4.1.1", "esm": "^3.2.22", + "gulp": "^4.0.2", "gulp-run": "^1.7.1", "gulp-typescript": "^5.0.1", "hook-std": "0.X", + "jest": "^29.7.0", + "jest-extended": "^0.11.5", + "JSONStream": "1.X", "prettier": "^1.18.2", - "react": "^16.8", - "rollup": "^1.20.1", - "rollup-plugin-commonjs": "^10.1.0", - "rollup-plugin-typescript": "^1.0.1", "sort-package-json": "^2.10.1", - "typedoc": "~0.15.0", - "typedoc-plugin-markdown": "~2.1.4", - "typescript": "~4.4" + "ts-jest": "^29.2.5", + "typedoc": "0.26.7", + "typedoc-plugin-markdown": "^4.2.7", + "typescript": "^4.2.4" }, "engines": { - "node": ">= 8" + "node": ">= 14" }, "umd": "umd/index.js" } diff --git a/rollup.config.ts b/rollup.config.ts deleted file mode 100644 index 7fb6850..0000000 --- a/rollup.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -import typescript from 'rollup-plugin-typescript'; -import commonjs from 'rollup-plugin-commonjs'; - -// @ts-ignore -import pkg from './package.json'; - -export default { - input: 'src/index.ts', - output: [ - { - file: pkg.umd, - format: 'umd', - sourceMap: true, - name: 'DebugFabulous', - }, - ], - plugins: [commonjs(), typescript()], -}; diff --git a/tsconfig.json b/tsconfig.json index 17cd55e..8d210a8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "emitDecoratorMetadata": true, "noImplicitAny": false, "module": "commonjs", - "target": "ES5", + "target": "ES2020", "experimentalDecorators": true, "sourceMap": false, "declaration": true,