Skip to content

Commit 0b5c72c

Browse files
authored
build(deps-dev): replace standard with neostandard (#750)
* build(deps-dev): replace standard with neostandard * test(types): ignore unused import
1 parent 9ad7089 commit 0b5c72c

File tree

6 files changed

+112
-108
lines changed

6 files changed

+112
-108
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![CI](https://github.com/fastify/fast-json-stringify/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/fast-json-stringify/actions/workflows/ci.yml)
44
[![NPM version](https://img.shields.io/npm/v/fast-json-stringify.svg?style=flat)](https://www.npmjs.com/package/fast-json-stringify)
5-
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
5+
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)
66
[![NPM downloads](https://img.shields.io/npm/dm/fast-json-stringify.svg?style=flat)](https://www.npmjs.com/package/fast-json-stringify)
77

88

benchmark/bench-cmp-lib.js

-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ const getRandomString = (length) => {
134134
return result[0].toUpperCase() + result.slice(1)
135135
}
136136

137-
// eslint-disable-next-line
138137
for (let i = 0; i < STR_LEN; i++) {
139138
largeArray[i] = {
140139
firstName: getRandomString(8),

eslint.config.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict'
2+
3+
module.exports = require('neostandard')({
4+
ignores: [
5+
...require('neostandard').resolveIgnoresFromGitignore(),
6+
'lib/schema-validator.js'
7+
],
8+
ts: true
9+
})

package.json

+3-8
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"bench:cmp": "node ./benchmark/bench-cmp-branch.js",
1111
"bench:cmp:ci": "node ./benchmark/bench-cmp-branch.js --ci",
1212
"benchmark": "node ./benchmark/bench-cmp-lib.js",
13-
"lint": "standard",
14-
"lint:fix": "standard --fix",
13+
"lint": "eslint",
14+
"lint:fix": "eslint --fix",
1515
"test:typescript": "tsd",
1616
"test:unit": "c8 node --test",
1717
"test": "npm run test:unit && npm run test:typescript"
@@ -45,8 +45,8 @@
4545
"compile-json-stringify": "^0.1.2",
4646
"fast-json-stringify": ".",
4747
"is-my-json-valid": "^2.20.6",
48+
"neostandard": "^0.11.9",
4849
"simple-git": "^3.23.0",
49-
"standard": "^17.1.0",
5050
"tsd": "^0.31.0",
5151
"webpack": "^5.90.3"
5252
},
@@ -58,10 +58,5 @@
5858
"json-schema-ref-resolver": "^2.0.0",
5959
"rfdc": "^1.2.0"
6060
},
61-
"standard": {
62-
"ignore": [
63-
"schema-validator.js"
64-
]
65-
},
6661
"runkitExampleFilename": "./examples/example.js"
6762
}

types/index.d.ts

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Ajv, { Options as AjvOptions } from "ajv"
1+
import Ajv, { Options as AjvOptions } from 'ajv'
22

33
type Build = typeof build
44

@@ -70,36 +70,36 @@ declare namespace build {
7070
}
7171

7272
export interface StringSchema extends BaseSchema {
73-
type: "string";
73+
type: 'string';
7474
format?: string;
7575
}
7676

7777
export interface IntegerSchema extends BaseSchema {
78-
type: "integer";
78+
type: 'integer';
7979
}
8080

8181
export interface NumberSchema extends BaseSchema {
82-
type: "number";
82+
type: 'number';
8383
}
8484

8585
export interface NullSchema extends BaseSchema {
86-
type: "null";
86+
type: 'null';
8787
}
8888

8989
export interface BooleanSchema extends BaseSchema {
90-
type: "boolean";
90+
type: 'boolean';
9191
}
9292

9393
export interface ArraySchema extends BaseSchema {
94-
type: "array";
94+
type: 'array';
9595
/**
9696
* The schema for the items in the array
9797
*/
9898
items: Schema | {}
9999
}
100100

101101
export interface TupleSchema extends BaseSchema {
102-
type: "array";
102+
type: 'array';
103103
/**
104104
* The schemas for the items in the tuple
105105
*/
@@ -115,7 +115,7 @@ declare namespace build {
115115
}
116116

117117
export interface ObjectSchema extends BaseSchema {
118-
type: "object";
118+
type: 'object';
119119
/**
120120
* Describe the properties of the object
121121
*/
@@ -145,7 +145,7 @@ declare namespace build {
145145
| BooleanSchema
146146
| ArraySchema
147147
| TupleSchema
148-
| ObjectSchema;
148+
| ObjectSchema
149149

150150
export interface Options {
151151
/**
@@ -208,24 +208,24 @@ interface StandaloneOption extends build.Options {
208208
mode: 'standalone'
209209
}
210210

211-
type StringCoercible = string | Date | RegExp;
212-
type IntegerCoercible = number | BigInt;
211+
type StringCoercible = string | Date | RegExp
212+
type IntegerCoercible = number | BigInt
213213

214214
/**
215215
* Build a stringify function using a schema of the documents that should be stringified
216216
* @param schema The schema used to stringify values
217217
* @param options The options to use (optional)
218218
*/
219-
declare function build(schema: build.AnySchema, options: DebugOption): { code: string, ajv: Ajv };
220-
declare function build(schema: build.AnySchema, options: DeprecateDebugOption): { code: string, ajv: Ajv };
221-
declare function build(schema: build.AnySchema, options: StandaloneOption): string;
222-
declare function build(schema: build.AnySchema, options?: build.Options): <TDoc = any>(doc: TDoc) => any;
223-
declare function build(schema: build.StringSchema, options?: build.Options): <TDoc extends StringCoercible = StringCoercible>(doc: TDoc) => string;
224-
declare function build(schema: build.IntegerSchema | build.NumberSchema, options?: build.Options): <TDoc extends IntegerCoercible = IntegerCoercible>(doc: TDoc) => string;
225-
declare function build(schema: build.NullSchema, options?: build.Options): <TDoc extends null = null>(doc: TDoc) => "null";
226-
declare function build(schema: build.BooleanSchema, options?: build.Options): <TDoc extends boolean = boolean>(doc: TDoc) => string;
227-
declare function build(schema: build.ArraySchema | build.TupleSchema, options?: build.Options): <TDoc extends any[]= any[]>(doc: TDoc) => string;
228-
declare function build(schema: build.ObjectSchema, options?: build.Options): <TDoc extends object = object>(doc: TDoc) => string;
229-
declare function build(schema: build.Schema, options?: build.Options): <TDoc = object | any[] | string | number | boolean | null> (doc: TDoc) => string;
230-
231-
export = build;
219+
declare function build (schema: build.AnySchema, options: DebugOption): { code: string, ajv: Ajv }
220+
declare function build (schema: build.AnySchema, options: DeprecateDebugOption): { code: string, ajv: Ajv }
221+
declare function build (schema: build.AnySchema, options: StandaloneOption): string
222+
declare function build (schema: build.AnySchema, options?: build.Options): <TDoc = any>(doc: TDoc) => any
223+
declare function build (schema: build.StringSchema, options?: build.Options): <TDoc extends StringCoercible = StringCoercible>(doc: TDoc) => string
224+
declare function build (schema: build.IntegerSchema | build.NumberSchema, options?: build.Options): <TDoc extends IntegerCoercible = IntegerCoercible>(doc: TDoc) => string
225+
declare function build (schema: build.NullSchema, options?: build.Options): <TDoc extends null = null>(doc: TDoc) => 'null'
226+
declare function build (schema: build.BooleanSchema, options?: build.Options): <TDoc extends boolean = boolean>(doc: TDoc) => string
227+
declare function build (schema: build.ArraySchema | build.TupleSchema, options?: build.Options): <TDoc extends any[]= any[]>(doc: TDoc) => string
228+
declare function build (schema: build.ObjectSchema, options?: build.Options): <TDoc extends object = object>(doc: TDoc) => string
229+
declare function build (schema: build.Schema, options?: build.Options): <TDoc = object | any[] | string | number | boolean | null> (doc: TDoc) => string
230+
231+
export = build

types/index.test-d.ts

+74-73
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Test using this disabled, see https://github.com/fastify/fast-json-stringify/pull/683
12
import Ajv from 'ajv'
23
import build, { restore, Schema, validLargeArrayMechanisms } from '..'
34
import { expectError, expectType } from 'tsd'
45

56
// Number schemas
67
build({
7-
type: 'number'
8+
type: 'number'
89
})(25)
910
build({
10-
type: 'integer'
11+
type: 'integer'
1112
})(-5)
1213
build({
13-
type: 'integer'
14+
type: 'integer'
1415
})(5n)
1516

1617
build({
17-
type: 'number'
18+
type: 'number'
1819
}, { rounding: 'ceil' })
1920
build({
20-
type: 'number'
21+
type: 'number'
2122
}, { rounding: 'floor' })
2223
build({
23-
type: 'number'
24+
type: 'number'
2425
}, { rounding: 'round' })
2526
build({
26-
type: 'number'
27+
type: 'number'
2728
}, { rounding: 'trunc' })
2829
expectError(build({
29-
type: 'number'
30+
type: 'number'
3031
}, { rounding: 'invalid' }))
3132

3233
// String schema
@@ -36,55 +37,55 @@ build({
3637

3738
// Boolean schema
3839
build({
39-
type: 'boolean'
40+
type: 'boolean'
4041
})(true)
4142

4243
// Null schema
4344
build({
44-
type: 'null'
45+
type: 'null'
4546
})(null)
4647

4748
// Array schemas
4849
build({
49-
type: 'array',
50-
items: { type: 'number' }
50+
type: 'array',
51+
items: { type: 'number' }
5152
})([25])
5253
build({
53-
type: 'array',
54-
items: [{ type: 'string'}, {type: 'integer'}]
54+
type: 'array',
55+
items: [{ type: 'string' }, { type: 'integer' }]
5556
})(['hello', 42])
5657

5758
// Object schemas
5859
build({
59-
type: 'object'
60+
type: 'object'
6061
})({})
6162
build({
62-
type: 'object',
63-
properties: {
64-
foo: { type: 'string' },
65-
bar: { type: 'integer' }
66-
},
67-
required: ['foo'],
68-
patternProperties: {
69-
'baz*': { type: 'null' }
70-
},
71-
additionalProperties: {
72-
type: 'boolean'
73-
}
63+
type: 'object',
64+
properties: {
65+
foo: { type: 'string' },
66+
bar: { type: 'integer' }
67+
},
68+
required: ['foo'],
69+
patternProperties: {
70+
'baz*': { type: 'null' }
71+
},
72+
additionalProperties: {
73+
type: 'boolean'
74+
}
7475
})({ foo: 'bar' })
7576
build({
76-
type: 'object',
77-
properties: {
78-
foo: { type: 'string' },
79-
bar: { type: 'integer' }
80-
},
81-
required: ['foo'],
82-
patternProperties: {
83-
'baz*': { type: 'null' }
84-
},
85-
additionalProperties: {
86-
type: 'boolean'
87-
}
77+
type: 'object',
78+
properties: {
79+
foo: { type: 'string' },
80+
bar: { type: 'integer' }
81+
},
82+
required: ['foo'],
83+
patternProperties: {
84+
'baz*': { type: 'null' }
85+
},
86+
additionalProperties: {
87+
type: 'boolean'
88+
}
8889
}, { rounding: 'floor' })({ foo: 'bar' })
8990

9091
// Reference schemas
@@ -113,7 +114,7 @@ build({
113114
}
114115
},
115116
patternProperties: {
116-
'num': {
117+
num: {
117118
$ref: '#/definitions/num'
118119
}
119120
},
@@ -207,52 +208,52 @@ interface InferenceSchema {
207208
}
208209

209210
const stringify3 = build({
210-
type: "object",
211-
properties: { a: { type: "string" } },
212-
});
213-
stringify3<InferenceSchema>({ id: "123" });
214-
stringify3<InferenceSchema>({ a: 123, id: "123" });
215-
expectError(stringify3<InferenceSchema>({ anotherOne: "bar" }));
216-
expectError(stringify3<Schema>({ a: "bar" }));
211+
type: 'object',
212+
properties: { a: { type: 'string' } },
213+
})
214+
stringify3<InferenceSchema>({ id: '123' })
215+
stringify3<InferenceSchema>({ a: 123, id: '123' })
216+
expectError(stringify3<InferenceSchema>({ anotherOne: 'bar' }))
217+
expectError(stringify3<Schema>({ a: 'bar' }))
217218

218219
// Without inference
219220
const stringify4 = build({
220-
type: "object",
221-
properties: { a: { type: "string" } },
222-
});
223-
stringify4({ id: "123" });
224-
stringify4({ a: 123, id: "123" });
225-
stringify4({ anotherOne: "bar" });
226-
stringify4({ a: "bar" });
221+
type: 'object',
222+
properties: { a: { type: 'string' } },
223+
})
224+
stringify4({ id: '123' })
225+
stringify4({ a: 123, id: '123' })
226+
stringify4({ anotherOne: 'bar' })
227+
stringify4({ a: 'bar' })
227228

228229
// Without inference - string type
229230
const stringify5 = build({
230-
type: "string",
231-
});
232-
stringify5("foo");
233-
expectError(stringify5({ id: "123" }));
231+
type: 'string',
232+
})
233+
stringify5('foo')
234+
expectError(stringify5({ id: '123' }))
234235

235236
// Without inference - null type
236237
const stringify6 = build({
237-
type: "null",
238-
});
239-
stringify6(null);
240-
expectError(stringify6("a string"));
238+
type: 'null',
239+
})
240+
stringify6(null)
241+
expectError(stringify6('a string'))
241242

242243
// Without inference - boolean type
243244
const stringify7 = build({
244-
type: "boolean",
245-
});
246-
stringify7(true);
247-
expectError(stringify7("a string"));
245+
type: 'boolean',
246+
})
247+
stringify7(true)
248+
expectError(stringify7('a string'))
248249

249250
// largeArrayMechanism
250251

251-
build({}, { largeArrayMechanism: 'json-stringify'} )
252-
build({}, { largeArrayMechanism: 'default'} )
253-
expectError(build({} as Schema, { largeArrayMechanism: 'invalid'} ))
252+
build({}, { largeArrayMechanism: 'json-stringify' })
253+
build({}, { largeArrayMechanism: 'default' })
254+
expectError(build({} as Schema, { largeArrayMechanism: 'invalid' }))
254255

255-
build({}, { largeArraySize: 2000 } )
256-
build({}, { largeArraySize: '2e4' } )
257-
build({}, { largeArraySize: 2n } )
258-
expectError(build({} as Schema, { largeArraySize: ['asdf']} ))
256+
build({}, { largeArraySize: 2000 })
257+
build({}, { largeArraySize: '2e4' })
258+
build({}, { largeArraySize: 2n })
259+
expectError(build({} as Schema, { largeArraySize: ['asdf'] }))

0 commit comments

Comments
 (0)