Skip to content

Commit

Permalink
Merge pull request #25 from mbland/improve-type-checking
Browse files Browse the repository at this point in the history
Add stricter TypeScript type checking
  • Loading branch information
mbland committed Jan 16, 2024
2 parents 532bf70 + e377922 commit 1cba4d6
Show file tree
Hide file tree
Showing 16 changed files with 771 additions and 268 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Expand Up @@ -14,7 +14,7 @@
],
"extends": [
"eslint:recommended",
"plugin:jsdoc/recommended"
"plugin:jsdoc/recommended-typescript-flavor-error"
],
"overrides": [
{
Expand Down
1 change: 0 additions & 1 deletion ci/vitest.config.browser.js
@@ -1,4 +1,3 @@
// @ts-nocheck
import { defineConfig, mergeConfig } from 'vitest/config'
import baseConfig from './vitest.config.js'

Expand Down
1 change: 0 additions & 1 deletion ci/vitest.config.js
@@ -1,4 +1,3 @@
// @ts-nocheck
import { defineConfig, mergeConfig } from 'vitest/config'
import viteConfig from '../vite.config.js'

Expand Down
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -6,7 +6,7 @@

import BrowserPageOpener from './lib/browser.js'
import JsdomPageOpener from './lib/jsdom.js'
import { OpenedPage } from './lib/types.js'
import {OpenedPage} from './lib/types.js' // eslint-disable-line no-unused-vars

/**
* Enables tests to open an application's own page URLs both in the browser and
Expand Down
16 changes: 0 additions & 16 deletions jsconfig.json

This file was deleted.

4 changes: 4 additions & 0 deletions jsdoc.json
@@ -1,13 +1,17 @@
{
"plugins": [
"plugins/markdown",
"jsdoc-plugin-typescript",
"node_modules/jsdoc-plugin-intersection"
],
"recurseDepth": 10,
"source": {
"includePattern": ".+\\.js$",
"exclude": ["node_modules", "test"]
},
"typescript": {
"moduleRoot": "."
},
"opts": {
"destination": "jsdoc",
"recurse": true,
Expand Down
7 changes: 5 additions & 2 deletions lib/browser.js
Expand Up @@ -6,11 +6,14 @@
*/

import libCoverage from 'istanbul-lib-coverage'
import { OpenedPage } from './types.js'
import {OpenedPage} from './types.js' // eslint-disable-line no-unused-vars

/**
* @typedef {import("istanbul-lib-coverage").CoverageMap} CoverageMap
*/
/**
* Type for accessing the Istanbul coverage object in Window
* @typedef {Window & Object.<string, libCoverage.CoverageMap>} CovWindow
* @typedef {Window & Object.<string, CoverageMap>} CovWindow
*/

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/jsdom.js
Expand Up @@ -5,7 +5,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { OpenedPage } from './types.js'
import {OpenedPage} from './types.js' // eslint-disable-line no-unused-vars

/**
* @typedef {object} JSDOM - simulated jsdom.JSDOM
Expand Down Expand Up @@ -98,7 +98,7 @@ export default class JsdomPageOpener {
* @param {Window} window - the jsdom window object
* @param {Document} document - the jsdom window.document object
* @returns {Promise<void>} - resolves after importing all ECMAScript modules
* @throws if importing any ECMAScript modules fails
* @throws {Error} if importing any ECMAScript modules fails
*/
#importModules(window, document) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -180,7 +180,7 @@ export default class JsdomPageOpener {
* Only works with the `src` attribute; it will not execute inline code.
* @param {Document} doc - the jsdom window.document object
* @returns {Promise<void[]>} - resolves after importing all modules in doc
* @throws if any module import fails
* @throws {Error} if any module import fails
*/
function importModules(doc) {
/** @type {HTMLScriptElement[]} */
Expand Down
32 changes: 16 additions & 16 deletions package.json
Expand Up @@ -11,13 +11,12 @@
"test:ci:jsdom": "vitest run -c ci/vitest.config.js",
"test:ci:browser": "vitest run -c ci/vitest.config.browser.js",
"jsdoc": "jsdoc-cli-wrapper -c jsdoc.json .",
"typecheck": "npx -p typescript tsc -p jsconfig.json --noEmit --pretty",
"prepack": "npx -p typescript tsc ./index.js --allowJs --declaration --declarationMap --emitDeclarationOnly --outDir types"
"typecheck": "npx tsc",
"prepack": "npx rimraf types && npx tsc ./index.js --allowJs --declaration --declarationMap --emitDeclarationOnly --outDir types"
},
"files": [
"index.js",
"lib/*",
"types/*"
"lib/**",
"types/**"
],
"keywords": [
"testing",
Expand All @@ -28,33 +27,34 @@
"license": "MPL-2.0",
"type": "module",
"engines": {
"node": ">= 18.0.0"
"node": ">=18.0.0"
},
"homepage": "https://github.com/mbland/test-page-opener",
"repository": "https://github.com/mbland/test-page-opener",
"bugs": "https://github.com/mbland/test-page-opener/issues",
"devDependencies": {
"@stylistic/eslint-plugin-js": "^1.5.3",
"@types/chai": "^4.3.11",
"@types/istanbul-lib-coverage": "^2.0.6",
"@types/jsdom": "^21.1.6",
"@vitest/browser": "^1.1.3",
"@vitest/coverage-istanbul": "^1.1.3",
"@vitest/coverage-v8": "^1.1.3",
"@vitest/ui": "^1.1.3",
"@vitest/browser": "^1.2.0",
"@vitest/coverage-istanbul": "^1.2.0",
"@vitest/coverage-v8": "^1.2.0",
"@vitest/ui": "^1.2.0",
"eslint": "^8.56.0",
"eslint-plugin-jsdoc": "^46.10.1",
"eslint-plugin-vitest": "^0.3.20",
"jsdoc": "^4.0.2",
"jsdoc-cli-wrapper": "^1.0.5",
"jsdoc-cli-wrapper": "^1.0.6",
"jsdoc-plugin-intersection": "^1.0.4",
"jsdoc-plugin-typescript": "^2.2.1",
"jsdom": "^23.2.0",
"rimraf": "^5.0.5",
"typescript": "^5.3.3",
"vite": "^5.0.11",
"vitest": "^1.1.3",
"webdriverio": "^8.27.0"
"vitest": "^1.2.0",
"webdriverio": "^8.27.2"
},
"dependencies": {
"@types/istanbul-lib-coverage": "^2.0.6",
"@types/jsdom": "^21.1.6",
"istanbul-lib-coverage": "^3.2.2"
}
}

0 comments on commit 1cba4d6

Please sign in to comment.