diff --git a/.commitlintrc.js b/.commitlintrc.js index 96615d4..f792f1e 100644 --- a/.commitlintrc.js +++ b/.commitlintrc.js @@ -1,10 +1,9 @@ module.exports = { extends: ['@commitlint/config-conventional'], - - - rules: { 'subject-case': [2, 'always', ['sentence-case']], 'scope-case': [2, 'always', ['lower-case', 'upper-case']], + 'body-max-line-length': [1, 'never'], + 'footer-max-line-length': [1, 'never'], }, }; diff --git a/.eslintrc.js b/.eslintrc.js index f6b2956..f4af5af 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,7 +17,7 @@ module.exports = { ], parser: '@typescript-eslint/parser', parserOptions: { - ecmaVersion: 2020, + ecmaVersion: 2022, project: 'tsconfig.json', sourceType: 'module', ecmaFeatures: { @@ -81,6 +81,7 @@ module.exports = { // typescript-eslint '@typescript-eslint/no-floating-promises': 1, '@typescript-eslint/no-unnecessary-condition': 1, + '@typescript-eslint/no-explicit-any': [1, { ignoreRestArgs: true }], // sort-class-members 'sort-class-members/sort-class-members': [ 1, diff --git a/.swcrc b/.swcrc index 1b960ed..d227dae 100644 --- a/.swcrc +++ b/.swcrc @@ -6,7 +6,7 @@ "jsc": { "externalHelpers": true, "keepClassNames": true, - "target": "es2019", + "target": "es2020", "parser": { "syntax": "typescript", "tsx": false, diff --git a/LICENSE b/LICENSE index 1637db2..4d20996 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 +Copyright (c) 2022 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 053b867..34dd5f8 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,6 @@ npm i -D stryker-cli @stryker-mutator/core @stryker-mutator/typescript @stryker- npm i -D karma @types/karma karma-chrome-launcher karma-jasmine karma-coverage-istanbul-reporter karma-sourcemap-loader karma-webpack @types/jasmine # setupmocha npm i -D mocha @types/mocha c8 -# ultra -npm install -g ultra-runner@latest ``` ## TODO diff --git a/Taskfile b/Taskfile index a841e28..ec5f524 100644 --- a/Taskfile +++ b/Taskfile @@ -65,6 +65,18 @@ build_cp() { set +x } +build_hybrid() { + set -x + rm -rfv dist + npx tsup src/index.ts -d=dist/mjs --keep-names --format=esm --target=es2020 --external=reflect-metadata --sourcemap + npx tsup src/index.ts -d=dist/cjs --keep-names --format=cjs --target=es2020 --external=reflect-metadata --sourcemap + npx tsup src/index.ts -d=dist --dts-only + echo {\"type\": \"module\"} >dist/mjs/package.json + echo {\"type\": \"commonjs\"} >dist/cjs/package.json + cp -fv README.md LICENSE dist + cat package.json | jq "del(.type)" >dist/package.json +} + generate_liense() { npx license-generator install MIT } diff --git a/jest.config.js b/jest.config.js index 5647dbe..bc7894e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,6 @@ const getJestMappersFromTSConfig = require('tsconfig-paths-jest-mapper'); +/** @type {import('@jest/types').Config.InitialOptions} */ module.exports = { testEnvironment: 'node', setupFiles: ['/jest.setup.ts'], diff --git a/package.json b/package.json index e47f8fd..98803ff 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,14 @@ "types": "index.d.ts", "author": "2020", "keywords": [], + "exports": { + ".": { + "import": "./mjs/index.mjs", + "require": "./cjs/index.js" + } + }, "scripts": { "test": "npm run eslint && npm run tscheck && npm run test:cov", - "test:p": "ultra test", "test:r": "npm run mocha -- src/**/*.spec.ts", "test:cov": "c8 --reporter text --exclude \"**/*.spec.ts\" --exclude \"**/testing/**\" npm run test:r -- --no-timeouts", "test:w": "npm run test:r -- --watch-files src --watch", @@ -27,64 +32,57 @@ "commit": "cz", "semantic-release": "semantic-release", "dev": "node node_modules/webpack-dev-server/bin/webpack-dev-server", - "build": "sh Taskfile build", - "bundle": "sh Taskfile bundle", + "build": "sh Taskfile build_hybrid", "lint:w": "run-p tscheck:w eslint:w", "test:m": "node node_modules/@stryker-mutator/core/bin/stryker run", - "mocha": "node -r @swc/register node_modules/mocha/bin/_mocha", + "mocha": "node -r tsconfig-paths/register -r @swc/register node_modules/mocha/bin/_mocha", "test:d": "ndb -r @swc/register node_modules/mocha/bin/_mocha --no-timeouts --watch-files src/**/*.ts --watch src/**/*.spec.ts" }, - "ultra": { - "concurrent": [ - "lint", - "test" - ] - }, "config": { "ghooks": { "pre-commit": "precise-commits", "commit-msg": "sh Taskfile commit_lint", - "pre-push": "ultra test" + "pre-push": "npm run test" } }, "devDependencies": { - "@commitlint/cli": "^16.1.0", - "@commitlint/config-conventional": "^16.0.0", + "@commitlint/cli": "16.2.3", + "@commitlint/config-conventional": "16.2.1", "@semantic-release/changelog": "^6.0.1", "@semantic-release/git": "^10.0.1", - "@swc/cli": "^0.1.55", - "@swc/core": "^1.2.137", - "@swc/helpers": "^0.3.2", - "@swc/jest": "^0.2.17", + "@swc/cli": "^0.1.57", + "@swc/core": "1.2.162", + "@swc/helpers": "0.3.8", + "@swc/jest": "0.2.20", "@swc/register": "^0.1.10", "@types/mocha": "^9.1.0", - "@types/node": "^17.0.16", - "@typescript-eslint/eslint-plugin": "^5.11.0", - "@typescript-eslint/parser": "^5.11.0", + "@types/node": "17.0.23", + "@typescript-eslint/eslint-plugin": "5.17.0", + "@typescript-eslint/parser": "5.17.0", "c8": "^7.11.0", "commitizen": "^4.2.4", "conventional-changelog-conventionalcommits": "^4.6.3", "cz-conventional-changelog": "^3.3.0", - "eslint": "^8.8.0", - "eslint-config-prettier": "^8.3.0", + "eslint": "8.12.0", + "eslint-config-prettier": "8.5.0", "eslint-import-resolver-node": "^0.3.6", "eslint-plugin-etc": "^2.0.2", "eslint-plugin-import": "^2.25.4", "eslint-plugin-only-warn": "^1.0.3", "eslint-plugin-prettier": "^4.0.0", - "eslint-plugin-regexp": "^1.5.1", + "eslint-plugin-regexp": "^1.6.0", "eslint-plugin-simple-import-sort": "^7.0.0", "eslint-plugin-sort-class-members": "^1.14.1", - "eslint-plugin-unicorn": "^40.1.0", + "eslint-plugin-unicorn": "42.0.0", "eslint-plugin-wix-editor": "^3.3.0", "expect": "^27.5.1", "ghooks": "^2.0.4", "git-branch-is": "^4.0.0", "jest": "^27.5.1", - "mocha": "^9.2.0", + "mocha": "9.2.2", "npm-run-all": "^4.1.5", "precise-commits": "^1.0.2", - "prettier": "^2.5.1", + "prettier": "^2.6.1", "reflect-metadata": "^0.1.13", "remark": "^14.0.2", "remark-cli": "^10.0.1", @@ -95,8 +93,8 @@ "simplytyped": "^3.3.0", "tsconfig-paths-jest-mapper": "^1.4.0", "tslib": "^2.3.1", - "typescript": "^4.5.5", - "ultra-runner": "^3.10.5", + "tsup": "^5.12.2", + "typescript": "4.6.3", "watchexec-bin": "^1.0.0" } } diff --git a/src/index.ts b/src/index.ts index 609b61b..8ee3126 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import 'reflect-metadata'; -import { PlainObject } from 'simplytyped'; +type PlainObject = Record; const dict: PlainObject = {}; diff --git a/tsconfig.json b/tsconfig.json index f0c6521..4b8d165 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,10 @@ { "ts-node": { - "transpileOnly": true, - "transpiler": "ts-node/transpilers/swc-experimental" + "swc": true, + "transpileOnly": true }, "compilerOptions": { - "target": "es2018", + "target": "ES2020", "module": "commonjs", "moduleResolution": "node", "importHelpers": true,