Skip to content

Commit 9e2762b

Browse files
coliffregseb
andauthored
Add types and exports to package.json (#1857)
* Add types and exports to package.json Add TypeScript declaration and an explicit exports map. Adds a top-level "types" pointing to dist/core/core.d.ts and an "exports" field mapping the package root to types/import/require paths and exposing ./package.json. This clarifies ESM/CJS entry points and improves TypeScript and module resolution for consumers. Point package import export to dist/htmlhint.js Update package.json exports: change the 'import' entry from './dist/core/core.js' to './dist/htmlhint.js'. This aligns the ESM import entry with the CommonJS 'require' entry and ensures consumers import the intended bundled entry point. Point package import export to dist/htmlhint.js Update package.json exports: change the 'import' entry from './dist/core/core.js' to './dist/htmlhint.js'. This aligns the ESM import entry with the CommonJS 'require' entry and ensures consumers import the intended bundled entry point. Document ESM usage and bump version to 2.0.0-beta-1 Update README to clarify programmatic usage for both ESM and CommonJS consumers, adding an ESM example that imports the default export (htmlhint) and extracts HTMLHint. Also bump package.json and package-lock.json version from 1.9.2 to 2.0.0-beta-1. Document ESM usage and bump version to 2.0.0-beta-1 Update README to clarify programmatic usage for both ESM and CommonJS consumers, adding an ESM example that imports the default export (htmlhint) and extracts HTMLHint. Also bump package.json and package-lock.json version from 1.9.2 to 2.0.0-beta-1. * Update package.json Co-authored-by: Sébastien Règne <regseb@gmail.com> * Update README.md --------- Co-authored-by: Sébastien Règne <regseb@gmail.com>
1 parent e4840fb commit 9e2762b

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,25 @@ After that, You can run HTMLHint on any file or directory like this:
5757
./node_modules/.bin/htmlhint www/**/*.html
5858
```
5959

60-
Or, you can use HTMLHint linter programmatically, like this:
60+
Or, you can use HTMLHint programmatically.
61+
62+
For ESM:
6163

6264
```js
6365
import { HTMLHint } from 'htmlhint'
6466
const htmlVerificationHints = HTMLHint.verify(localHtmlContent)
6567
console.log('htmlVerificationHints', htmlVerificationHints) // this logs a list of `Hint`s which contain information on all linting errors
6668
```
6769

70+
For CommonJS:
71+
72+
```js
73+
const { HTMLHint } = require('htmlhint')
74+
75+
const htmlVerificationHints = HTMLHint.verify(localHtmlContent)
76+
console.log('htmlVerificationHints', htmlVerificationHints) // this logs a list of `Hint`s which contain information on all linting errors
77+
```
78+
6879
### Global Installation and Usage
6980

7081
If you want to make HTMLHint available to tools that run across all of your projects, you can install HTMLHint globally using npm:

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "htmlhint",
3-
"version": "1.9.2",
3+
"version": "2.0.0-beta-1",
44
"description": "The Static Code Analysis Tool for your HTML",
55
"keywords": [
66
"html",
@@ -22,8 +22,15 @@
2222
"url": "https://opencollective.com/htmlhint"
2323
},
2424
"license": "MIT",
25-
"main": "dist/htmlhint.js",
26-
"module": "dist/core/core.js",
25+
"main": "./dist/core/core.js",
26+
"types": "./dist/core/core.d.ts",
27+
"exports": {
28+
".": {
29+
"types": "./dist/core/core.d.ts",
30+
"default": "./dist/core/core.js"
31+
},
32+
"./package.json": "./package.json"
33+
},
2734
"bin": {
2835
"htmlhint": "bin/htmlhint"
2936
},

0 commit comments

Comments
 (0)