Skip to content

Commit

Permalink
Refactor to fix TypeScript errors in UserConfig.js (#3384)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat authored Jul 29, 2024
2 parents 1c7cd0e + b94c20e commit 608a36c
Show file tree
Hide file tree
Showing 26 changed files with 562 additions and 287 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ node_modules/
.nyc_output/
coverage/
docs/_data/coverage.json
jsdoc/

# Ignore API documentation
api-docs/
Expand Down
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
jsdoc
docs
docs-src
test
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"access": "public"
},
"type": "module",
"main": "src/Eleventy.js",
"main": "./src/Eleventy.js",
"exports": {
"import": "./src/Eleventy.js",
"require": "./src/EleventyCommonJs.cjs"
Expand Down Expand Up @@ -45,9 +45,9 @@
"test": "npm run test:node && npm run test:ava",
"test:ava": "ava --verbose --timeout 20s",
"test:node": "node --test test_node/tests.js",
"jsdoc": "rm -rf jsdoc && npx jsdoc src/* -r -d jsdoc",
"format": "prettier . --write",
"check": "eslint src",
"check-types": "tsc",
"lint-staged": "lint-staged",
"coverage": "npx c8 ava && npx c8 report --reporter=json-summary && cp coverage/coverage-summary.json docs/_data/coverage.json && node cmd.cjs --config=docs/eleventy.coverage.js",
"prepare": "husky"
Expand Down Expand Up @@ -86,6 +86,7 @@
"@eslint/js": "^9.7.0",
"@iarna/toml": "^2.2.5",
"@mdx-js/node-loader": "^3.0.1",
"@types/node": "^20.14.12",
"@vue/server-renderer": "^3.4.31",
"@zachleat/noop": "^1.0.3",
"ava": "^6.1.3",
Expand All @@ -95,7 +96,6 @@
"eslint-config-prettier": "^9.1.0",
"globals": "^15.8.0",
"husky": "^9.0.11",
"jsdoc": "^4.0.3",
"lint-staged": "^15.2.7",
"markdown-it-emoji": "^3.0.0",
"marked": "^13.0.2",
Expand All @@ -106,6 +106,7 @@
"rimraf": "^6.0.1",
"sass": "^1.77.8",
"tsx": "^4.16.2",
"typescript": "^5.5.4",
"vue": "^3.4.31",
"zod": "^3.23.8",
"zod-validation-error": "^3.3.0"
Expand Down
17 changes: 10 additions & 7 deletions src/Benchmark/Benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ import { performance } from "node:perf_hooks";

class Benchmark {
constructor() {
this.reset();
// TypeScript slop
this.timeSpent = 0;
this.timesCalled = 0;
this.beforeTimers = [];
}

reset() {
this.timeSpent = 0;
this.timesCalled = 0;
this.beforeTimers = [];
}

getNewTimestamp() {
Expand All @@ -12,12 +21,6 @@ class Benchmark {
return new Date().getTime();
}

reset() {
this.timeSpent = 0;
this.timesCalled = 0;
this.beforeTimers = [];
}

incrementCount() {
this.timesCalled++;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Benchmark/BenchmarkGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BenchmarkGroup {
this.benchmarks = {};
// Warning: aggregate benchmarks automatically default to false via BenchmarkManager->getBenchmarkGroup
this.isVerbose = true;
this.logger = new ConsoleLogger(this.isVerbose);
this.logger = new ConsoleLogger();
this.minimumThresholdMs = 50;
this.minimumThresholdPercent = 8;
}
Expand All @@ -31,6 +31,7 @@ class BenchmarkGroup {
add(type, callback) {
let benchmark = (this.benchmarks[type] = new Benchmark());

/** @this {any} */
let fn = function (...args) {
benchmark.before();
let ret = callback.call(this, ...args);
Expand Down
Loading

0 comments on commit 608a36c

Please sign in to comment.