diff --git a/README.md b/README.md index 97a4aa7..a5d9245 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![CI](https://github.com/fastify/secure-json-parse/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/secure-json-parse/actions/workflows/ci.yml) [![NPM version](https://img.shields.io/npm/v/secure-json-parse.svg?style=flat)](https://www.npmjs.com/package/secure-json-parse) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/) +[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard) `JSON.parse()` drop-in replacement with prototype poisoning protection. diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..89fd678 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,6 @@ +'use strict' + +module.exports = require('neostandard')({ + ignores: require('neostandard').resolveIgnoresFromGitignore(), + ts: true +}) diff --git a/package.json b/package.json index 2a42788..a8c34f4 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "types": "types/index.d.ts", "scripts": { "benchmark": "cd benchmarks && npm install && npm run all", - "lint": "standard", + "lint": "eslint", + "lint:fix": "eslint --fix", "test": "nyc npm run test:unit && npm run test:typescript", "test:unit": "tape \"test/*.test.js\"", "test:typescript": "tsd", @@ -34,9 +35,9 @@ "@fastify/pre-commit": "^2.1.0", "airtap": "^5.0.0", "airtap-playwright": "^1.0.1", + "neostandard": "^0.11.9", "nyc": "^17.0.0", "playwright": "^1.43.1", - "standard": "^17.1.0", "tape": "^5.7.5", "tsd": "^0.31.0" } diff --git a/types/index.d.ts b/types/index.d.ts index 9b67de1..5d22d4b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -39,7 +39,7 @@ declare namespace parse { * @param reviver The `JSON.parse()` optional `reviver` argument. * @returns The parsed object, or `null` if there was an error or if the JSON contained possibly insecure properties. */ - export function safeParse(text: string | Buffer, reviver?: Reviver | null): any + export function safeParse (text: string | Buffer, reviver?: Reviver | null): any /** * Scans a given object for prototype properties. @@ -48,11 +48,11 @@ declare namespace parse { * @param options Optional configuration object. * @returns The object, or `null` if onError is set to `nullify` */ - export function scan(obj: { [key: string | number]: any }, options?: ParseOptions): any + export function scan (obj: { [key: string | number]: any }, options?: ParseOptions): any - export { parse as default} + export { parse as default } } -declare function parse(text: string | Buffer, options?: parse.ParseOptions): any -declare function parse(text: string | Buffer, reviver?: parse.Reviver | null, options?: parse.ParseOptions): any +declare function parse (text: string | Buffer, options?: parse.ParseOptions): any +declare function parse (text: string | Buffer, reviver?: parse.Reviver | null, options?: parse.ParseOptions): any export = parse diff --git a/types/index.test-d.ts b/types/index.test-d.ts index b5832af..338bf2f 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -21,7 +21,7 @@ sjson.scan({}, { protoAction: 'remove' }) sjson.scan({}, { protoAction: 'ignore' }) sjson.scan({}, { constructorAction: 'error' }) sjson.scan({}, { constructorAction: 'ignore' }) -sjson.scan(new Array(), {}) +sjson.scan([], {}) declare const input: Buffer sjson.parse(input)