Skip to content

Commit

Permalink
version 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stagas committed Jan 26, 2022
1 parent a643a0e commit e74c51e
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 108 deletions.
17 changes: 9 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
},
extends: [
'plugin:@typescript-eslint/recommended',
],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'html-jsx'],
ignorePatterns: ['dist', 'node_modules'],
plugins: ['import'],
rules: {
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-extra-semi': 'off',
'@typescript-eslint/no-inferrable-types': 'warn',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ args: 'all', argsIgnorePattern: '^_' },
],
'no-fallthrough': 'error'
'@typescript-eslint/no-unused-vars': ['error', { args: 'all', argsIgnorePattern: '^_' }],
'@typescript-eslint/no-var-requires': 'off',
'no-cond-assign': 'off',
},
}
2 changes: 1 addition & 1 deletion .husky/pre-commit → .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint
npm run prepush
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"useTabs": false,
"semi": false,
"singleQuote": true,
"printWidth": 80,
"printWidth": 100,
"trailingComma": "es5",
"arrowParens": "avoid"
}
17 changes: 17 additions & 0 deletions .pull-configs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { pullConfigs } = require('pull-configs')

const local = __dirname + '/'
const remote = 'https://github.com/stagas/typescript-minimal-template/raw/main/'

const { assign, omit, sort, merge, replace } = pullConfigs(remote, local)

merge('package.json', (prev, next) => {
assign(prev.scripts, omit(next.scripts, ['test', 'build:min']))
sort(assign(prev.devDependencies, next.devDependencies))
})
replace('.eslintrc.js')
replace('.prettierrc')
// replace('jest.config.js')
replace('tsconfig.json')
replace('web-test-runner.config.js')
merge('.vscode/settings.json')
13 changes: 0 additions & 13 deletions .vscode/extensions.json

This file was deleted.

29 changes: 4 additions & 25 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
{
"files.exclude": {
".husky": true,
".npmrc": true,
".gitignore": true,
".gitattributes": true,
".prettierignore": true,
"coverage": true
},
"auto-run-command.rules": [
{
"condition": [
"hasFile: coverage/lcov.info"
],
"command": "coverage-gutters.watchCoverageAndVisibleEditors",
"message": "Running coverage"
}
],
"restoreTerminals.terminals": [
{
"splitTerminals": [
{
"name": "coverage",
"commands": [
"npm run cov:watch"
]
},
{
"name": "zsh",
"commands": []
}
]
},
],
"todo-tree.tree.scanMode": "workspace only",
"npm-scripts.showStartNotification": false
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ queueMicrotask(() => {

### debounce

[src/index.ts:8-24](https://github.com/stagas/debounce-micro/blob/47ad0aec0ffc4b0f13650d5a26dc02ee52e46efb/src/index.ts#L8-L24 "Source code on GitHub")
[src/index.ts:8-33](https://github.com/stagas/debounce-micro/blob/a643a0e748435a0c5b8e7dc183d3303dcebf5d8a/src/index.ts#L8-L33 "Source code on GitHub")

Wraps a function in a debounce microtask.

Expand Down
16 changes: 10 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
const actualProcess = process
process.actual = () => actualProcess

module.exports = {
testEnvironment: 'node',
rootDir: 'src',
testEnvironment: 'jsdom', // or node
rootDir: '.',
roots: ['<rootDir>/test/', '<rootDir>/src'],
testMatch: ['**/*.spec.{js,jsx,ts,tsx}'],
coverageDirectory: '../coverage',
testPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/test/web/'],
coverageDirectory: '<rootDir>/coverage',
collectCoverageFrom: ['src/**/*.{ts,tsx}'],
coverageProvider: 'v8',

// enable this for real typescript builds (slow but accurate)
// preset: 'ts-jest',
Expand Down Expand Up @@ -36,6 +43,3 @@ module.exports = {
// ],
// },
}

const actualProcess = process
process.actual = () => actualProcess
50 changes: 31 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "stagas",
"short": "stagas/debounce-micro",
"description": "wrap a function in a debounce microtask",
"version": "1.0.0",
"version": "2.0.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -33,46 +33,58 @@
"dist"
],
"scripts": {
"build": "npm run clean && npm run build:cjs && npm run build:esm && echo done.",
"build": "npm run build:cjs && npm run build:esm && echo done.",
"docs": "documentation readme src --resolve=node --pe ts --re ts --re d.ts --github --section=API --markdown-toc-max-depth=3",
"test": "jest",
"test": "npm run test:node",
"cov": "jest --coverage",
"lint": "eslint src && prettier --check src",
"build:watch": "onchange -i src --await-write-finish 400 -- npm run build",
"build:watch": "tsc --outDir dist/esm --module esnext --watch & tsc --outDir dist/cjs --watch",
"docs:watch": "onchange -i src --await-write-finish 400 -- npm run docs",
"test:watch": "jest --watchAll",
"cov:watch": "jest --coverage --watchAll",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' >dist/esm/package.json",
"build:cjs": "tsc --outDir dist/cjs",
"build:esm": "tsc --outDir dist/esm --module esnext && echo '{\"type\":\"module\"}' >dist/esm/package.json",
"build:min": "esbuild src/index.ts --bundle --format=esm | terser --compress --module --mangle -o build.min.js",
"lint:fix": "eslint --fix src && prettier --write src",
"clean": "rimraf dist",
"prepack": "npm run build",
"prepack": "npm run clean && npm run build",
"prepack:dry": "npm pack --dry-run",
"prepare": "husky install"
"prepare": "husky install && node .pull-configs.js",
"test:node": "jest",
"test:web": "web-test-runner",
"prepush": "npm run lint && npm run test"
},
"devDependencies": {
"@n1kk/intspector": "^1.0.2",
"@rollup/plugin-commonjs": "^21.0.1",
"@stagas/documentation-fork": "^13.2.5",
"@stagas/sucrase-jest-plugin": "^2.2.0-fork",
"@swc-node/jest": "^1.4.3",
"@tsconfig/node16": "^1.0.2",
"@types/jest": "^27.0.3",
"@types/node": "^17.0.2",
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"esbuild": "^0.14.6",
"esbuild-register": "^3.2.1",
"eslint": "^8.5.0",
"eslint-plugin-import": "^2.25.3",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.10",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"@web/dev-server-esbuild": "^0.2.16",
"@web/dev-server-rollup": "^0.3.14",
"@web/test-runner": "^0.13.25",
"esbuild": "^0.14.12",
"esbuild-register": "^3.3.2",
"eslint": "^8.7.0",
"eslint-config-html-jsx": "^1.0.0",
"eslint-plugin-import": "^2.25.4",
"fpick": "^1.1.0",
"husky": "^7.0.4",
"jest": "^27.4.5",
"jest": "^27.4.7",
"jest-browser-globals": "^25.1.0-beta",
"onchange": "^7.1.0",
"prettier": "^2.5.1",
"pull-configs": "^0.1.1",
"rimraf": "^3.0.2",
"terser": "^5.10.0",
"ts-jest": "^27.1.2",
"ts-jest": "^27.1.3",
"ts-node": "^10.4.0",
"typescript": "^4.5.4"
"typescript": "^4.5.5",
"vite-open": "^1.1.0"
}
}
7 changes: 0 additions & 7 deletions tsconfig.cjs.json

This file was deleted.

13 changes: 0 additions & 13 deletions tsconfig.dist.json

This file was deleted.

7 changes: 0 additions & 7 deletions tsconfig.esm.json

This file was deleted.

29 changes: 22 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
{
"extends": "@tsconfig/node16/tsconfig.json",
"include": [
"benchmark",
"example",
"src"
],
"watchOptions": {
"watchFile": "priorityPollingInterval",
"watchDirectory": "dynamicPriorityPolling"
},
"ts-node": {
"files": true
},
"include": [
"src",
"types"
],
"exclude": [
"**/*.spec.ts",
"**/*.spec.tsx"
],
"compilerOptions": {
"outDir": "dist/cjs",
"lib": [
"dom"
"DOM",
"DOM.Iterable",
"ESNext"
],
"outDir": "dist",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"resolveJsonModule": true,
"isolatedModules": true,
"inlineSources": true,
"declaration": true,
"sourceMap": true,
"module": "commonjs",
"target": "esnext",
"jsx": "react",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment",
"strict": true
}
}
35 changes: 35 additions & 0 deletions web-test-runner.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { esbuildPlugin } = require('@web/dev-server-esbuild')
const { summaryReporter } = require('@web/test-runner')
const { fromRollup } = require('@web/dev-server-rollup')
const rollupCommonjs = require('@rollup/plugin-commonjs')

const commonjs = fromRollup(rollupCommonjs);

module.exports = {
concurrency: 1,
nodeResolve: true,
files: ['test/**/*.spec.web.{ts,tsx}'],
plugins: [
esbuildPlugin({
ts: true,
tsx: true,
jsxFactory: 'h',
jsxFragment: 'Fragment',
}),
commonjs(),
],
reporters: [
summaryReporter(),
],
coverageConfig: {
include: ['src/**/*.{ts,tsx}'],
},
testRunnerHtml: testFramework => `
<html>
<head>
<script type="module" src="${testFramework}"></script>
<script type="module">import 'jest-browser-globals';</script>
</head>
</html>
`,
}

0 comments on commit e74c51e

Please sign in to comment.