Skip to content

Commit 67314d7

Browse files
committed
refactor: Convert to TypeScript
1 parent b2c74a1 commit 67314d7

37 files changed

+4512
-4183
lines changed

.eslintrc.json

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@
33
"extends": [
44
"eslint:recommended",
55
"plugin:jsdoc/recommended",
6-
"plugin:jest/recommended",
76
"plugin:node/recommended",
87
"prettier"
98
],
10-
"env": {
11-
"node": true,
12-
"es6": true
13-
},
9+
"env": { "node": true },
1410
"rules": {
1511
"array-callback-return": [
1612
2,
1713
{
1814
"allowImplicit": true
1915
}
2016
],
21-
"block-scoped-var": 2,
2217
"no-lonely-if": 2,
2318
"no-proto": 2,
2419
"eqeqeq": [2, "smart"],
@@ -48,7 +43,6 @@
4843
"no-useless-call": 2,
4944
"no-use-before-define": [2, "nofunc"],
5045
"no-void": 2,
51-
"strict": 2,
5246

5347
"jsdoc/require-jsdoc": 0,
5448
"jsdoc/check-param-names": 0,
@@ -62,17 +56,18 @@
6256
"jsdoc/require-param-type": 0,
6357
"jsdoc/require-returns-type": 0,
6458
"jsdoc/require-param": 0,
59+
"jsdoc/no-types": 2,
6560
"jsdoc/valid-types": 2,
6661

6762
"node/no-unsupported-features/es-syntax": 0,
68-
"node/no-missing-import": [
69-
2,
70-
{ "tryExtensions": [".js", ".json", ".node", ".ts"] }
71-
]
63+
"node/no-missing-import": [2, { "tryExtensions": [".js", ".json", ".ts"] }]
7264
},
7365
"settings": {
7466
"jsdoc": {
75-
"mode": "typescript"
67+
"mode": "typescript",
68+
"tagNamePreference": {
69+
"category": "category"
70+
}
7671
}
7772
},
7873
"overrides": [
@@ -103,9 +98,15 @@
10398
"@typescript-eslint/switch-exhaustiveness-check": 2,
10499
"@typescript-eslint/prefer-nullish-coalescing": 2,
105100

106-
"@typescript-eslint/no-explicit-any": 1, // TODO
107-
"@typescript-eslint/ban-ts-comment": 0, // TODO
108-
"@typescript-eslint/no-non-null-assertion": 0 // TODO
101+
"@typescript-eslint/no-explicit-any": 1 // TODO
102+
}
103+
},
104+
{
105+
"files": "*.spec.ts",
106+
"extends": "plugin:jest/recommended",
107+
"rules": {
108+
"@typescript-eslint/no-explicit-any": 0,
109+
"@typescript-eslint/ban-ts-comment": 0
109110
}
110111
}
111112
]

.github/workflows/lint.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,3 @@ jobs:
3737

3838
- name: Run lint
3939
run: npm run lint
40-
41-
- name: Test types
42-
run: npm run test:types

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ node_modules
22
npm-debug.log
33
.DS_Store
44
/.netlify/
5-
/coverage/
6-
/docs/
5+
/coverage
6+
/docs
7+
/lib

Readme.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
<a href="https://coveralls.io/github/cheeriojs/cheerio">
1010
<img src="https://img.shields.io/coveralls/github/cheeriojs/cheerio/main" alt="Coverage">
1111
</a>
12-
<a href="https://gitter.im/cheeriojs/cheerio">
13-
<img src="https://img.shields.io/gitter/room/cheeriojs/cheerio?color=%2348b293" alt="Join the chat at https://gitter.im/cheeriojs/cheerio">
14-
</a>
1512
<a href="#backers">
1613
<img src="https://img.shields.io/opencollective/backers/cheerio" alt="OpenCollective backers">
1714
</a>
@@ -79,7 +76,12 @@ First you need to load in the HTML. This step in jQuery is implicit, since jQuer
7976
This is the _preferred_ method:
8077

8178
```js
79+
// ES6 or TypeScript:
80+
import * as cheerio from 'cheerio';
81+
82+
// In other environments:
8283
const cheerio = require('cheerio');
84+
8385
const $ = cheerio.load('<ul id="fruits">...</ul>');
8486

8587
$.html();
@@ -131,7 +133,7 @@ The options in the `xml` object are taken directly from [htmlparser2](https://gi
131133
}
132134
```
133135

134-
For a full list of options and their effects, see [this](https://github.com/fb55/DomHandler) and
136+
For a full list of options and their effects, see [domhandler](https://github.com/fb55/DomHandler) and
135137
[htmlparser2's options](https://github.com/fb55/htmlparser2/wiki/Parser-options).
136138

137139
Some users may wish to parse markup with the `htmlparser2` library, and
@@ -149,9 +151,9 @@ structure as its first argument. Users may install `htmlparser2`, use it to
149151
parse input, and pass the result to `load`:
150152

151153
```js
152-
// Usage as of htmlparser2 version 3:
154+
// Usage as of htmlparser2 version 6:
153155
const htmlparser2 = require('htmlparser2');
154-
const dom = htmlparser2.parseDOM(document, options);
156+
const dom = htmlparser2.parseDocument(document, options);
155157

156158
const $ = cheerio.load(dom);
157159
```

0 commit comments

Comments
 (0)