Skip to content

Commit

Permalink
fix(lint): Bump lint deps, fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Oct 14, 2020
1 parent ff96bd0 commit 5ee8a30
Show file tree
Hide file tree
Showing 6 changed files with 362 additions and 448 deletions.
778 changes: 348 additions & 430 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
],
"devDependencies": {
"@types/jest": "^26.0.0",
"@types/node": "^14.0.6",
"@typescript-eslint/eslint-plugin": "^2.31.0",
"@typescript-eslint/parser": "^2.31.0",
"@types/node": "^14.11.8",
"@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^4.4.1",
"coveralls": "*",
"eslint": "^7.0.0",
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-node": "^11.1.0",
"jest": "^26.0.1",
"jest": "^26.5.3",
"prettier": "^2.0.5",
"ts-jest": "^26.1.0",
"typescript": "^4.0.2"
Expand Down
16 changes: 6 additions & 10 deletions scripts/benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable node/no-missing-import */
import * as entities from "../";
import he from "he";
// @ts-ignore
import htmlEscaper from "html-escaper";
import parseEntities from "parse-entities";
import * as htmlEntities from "html-entities";

Expand All @@ -10,8 +9,6 @@ const RUNS = 1e7;
const encoders: [string, (str: string) => string][] = [
["entities", (str: string) => entities.encodeHTML(str)],
["he", (str: string) => he.encode(str)],
// Only escapes the source.
// ["html-escaper", (str: string) => htmlEscaper.escape(str)],
[
"html-entities",
(str: string) => htmlEntities.AllHtmlEntities.encode(str),
Expand All @@ -21,22 +18,21 @@ const encoders: [string, (str: string) => string][] = [
const decoders: [string, (str: string) => string][] = [
["entities", (str: string) => entities.decodeHTML(str)],
["he", (str: string) => he.decode(str)],
// html-escaper does not produce correct output
// ["html-escaper", (str: string) => htmlEscaper.unescape(str)],
["parse-entities", (str: string) => parseEntities(str)],
[
"html-entities",
(str: string) => htmlEntities.AllHtmlEntities.decode(str),
],
];

// Note: Not shown on the README, as `entities` differs in behavior from other libraries.
// `entities` produces ASCII output, while other libraries only escape characters.
/*
* Note: Not shown on the README, as `entities` differs in behavior from other libraries.
* `entities` produces ASCII output, while other libraries only escape characters.
*/
const escapers: [string, (str: string) => string][] = [
["entities", (str: string) => entities.encodeXML(str)],
["he", (str: string) => he.escape(str)],
["html-escaper", (str: string) => htmlEscaper.escape(str)],
// html-entities cannot escape, so we use its simplest mode.
// Html-entities cannot escape, so we use its simplest mode.
["html-entities", (str: string) => htmlEntities.XmlEntities.encode(str)],
];

Expand Down
2 changes: 1 addition & 1 deletion src/decode_codepoint.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import decodeMap from "./maps/decode.json";

// Modified version of https://github.com/mathiasbynens/he/blob/master/src/he.js#L94-L119
export default function decodeCodePoint(codePoint: number) {
export default function decodeCodePoint(codePoint: number): string {
if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
return "\uFFFD";
}
Expand Down
2 changes: 1 addition & 1 deletion src/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function getInverse(inverse: MapType, re: RegExp) {

const reXmlChars = getInverseReplacer(inverseXML);

export function escape(data: string) {
export function escape(data: string): string {
return data
.replace(reXmlChars, singleCharReplacer)
.replace(reNonASCII, singleCharReplacer);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.json",
"include": ["src"],
"include": ["src", "scripts"],
"exclude": []
}

0 comments on commit 5ee8a30

Please sign in to comment.