Skip to content

Commit

Permalink
Merge pull request #98 from Esri/ssylvia/dependencies
Browse files Browse the repository at this point in the history
Update Dependencies and GitHub Action
  • Loading branch information
ssylvia authored May 8, 2024
2 parents 55c51e1 + 77e3370 commit 4e462f0
Show file tree
Hide file tree
Showing 7 changed files with 1,085 additions and 574 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x]
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v2
Expand All @@ -26,6 +26,6 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm install -g yarn
- run: yarn install
- run: yarn test
- run: yarn test && yarn lint
env:
CI: true
26 changes: 15 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"author": "Esri",
"license": "Apache-2.0",
"scripts": {
"build": "rimraf dist && rollup -c && yarn run build:dts",
"build": "rimraf dist && rollup -c --bundleConfigAsCjs && yarn run build:dts",
"build:dts": "tsc -p tsconfig-decl.json --outDir dist/esm && tsc -p tsconfig-decl.json --outDir dist/node",
"lint": "tslint --project tsconfig.json",
"lint:fix": "tslint --project tsconfig.json --fix",
Expand Down Expand Up @@ -51,22 +51,26 @@
"xss": "1.0.13"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-replace": "^4.0.0",
"@rollup/plugin-typescript": "^8.3.4",
"@types/jest": "^28.1.7",
"jest": "^28.1.3",
"rimraf": "^3.0.2",
"rollup": "^2.78.1",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-typescript": "^11.1.6",
"@types/jest": "^29.5.12",
"jest": "^29.7.0",
"rimraf": "^5.0.5",
"rollup": "^4.17.2",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^28.0.8",
"ts-jest": "^29.1.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-config-standard": "^9.0.0",
"typescript": "^4.7.4"
"typescript": "^5.4.5"
},
"publishConfig": {
"access": "public"
},
"packageManager": "[email protected]+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447",
"engines": {
"node": ">=18.0.0"
}
}
2 changes: 1 addition & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("Sanitizer", () => {
];

function getCSSOptions() {
const cssWhiteList = getDefaultCSSWhiteList();
const cssWhiteList: Record<string, any> = getDefaultCSSWhiteList();
cssWhiteList["flex"] = true;
cssWhiteList["flex-basis"] = true;
cssWhiteList["flex-direction"] = true;
Expand Down
14 changes: 7 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* The MIT License, see
* https://github.com/leizongmin/js-xss/blob/master/LICENSE for details
* */
import isPlainObject from "./plainObject";
import * as xss from "xss";
import isPlainObject from "./plainObject";

/**
* The response from the validate method
Expand Down Expand Up @@ -208,7 +208,7 @@ export class Sanitizer {
// Extend the defaults
xssFilterOptions = Object.create(this.arcgisFilterOptions);
xssFilterOptions.css = { whiteList: this.arcgisCSSWhiteList };
Object.keys(filterOptions).forEach((key) => {
(Object.keys(filterOptions) as (keyof XSS.IFilterXSSOptions)[]).forEach(<T extends keyof XSS.IFilterXSSOptions>(key: T) => {
if (key === "whiteList") {
// Extend the whitelist by concatenating arrays
xssFilterOptions.whiteList = this._extendObjectOfArrays([
Expand Down Expand Up @@ -362,7 +362,7 @@ export class Sanitizer {
*/
public encodeHTML(value: string): string {
return String(value).replace(/[&<>"'\/]/g, (s) => {
return this._entityMap[s];
return this._entityMap[s as keyof typeof this._entityMap];
});
}

Expand Down Expand Up @@ -395,10 +395,10 @@ export class Sanitizer {
* @memberof Sanitizer
*/
private _extendObjectOfArrays(objects: {}[]): {} {
const finalObj = {};
const finalObj: Record<string, any> = {};

objects.forEach((obj) => {
Object.keys(obj).forEach((key) => {
(Object.keys(obj) as (keyof typeof obj)[]).forEach(<T extends keyof typeof obj>(key: T) => {
if (Array.isArray(obj[key]) && Array.isArray(finalObj[key])) {
finalObj[key] = finalObj[key].concat(obj[key]);
} else {
Expand Down Expand Up @@ -441,8 +441,8 @@ export class Sanitizer {
}
return null;
} else {
const keys = Object.keys(obj);
changedObj = keys.reduce((prev, key) => {
const keys = Object.keys(obj) as (keyof typeof obj)[];
changedObj = keys.reduce(<T extends keyof typeof obj>(prev: Record<keyof typeof obj, unknown>, key: T) => {
const value = obj[key];
const validation = this.validate(value, options);
if (validation.isValid) {
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"noUnusedLocals": true,
"strict": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"target": "es5",
"types": ["jest", "xss"]
},
Expand Down
3 changes: 2 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"ordered-imports": true,
"only-arrow-functions": [false],
"object-literal-sort-keys": false,
"interface-name": [true, "always-prefix"]
"interface-name": [true, "always-prefix"],
"no-shadowed-variable": false
}
}
Loading

0 comments on commit 4e462f0

Please sign in to comment.