@wtf/project-oxlint 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/standard.d.ts +8 -4
- package/dist/standard.js +78 -7
- package/dist/standard.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,3 +49,6 @@ export default defineConfig({
|
|
|
49
49
|
```json
|
|
50
50
|
{ "oxlint": { "rules": { "no-console": "error" }, "ignorePatterns": ["**/dist/**", "site/**"] } }
|
|
51
51
|
```
|
|
52
|
+
|
|
53
|
+
A key that starts with `//` is a comment, as `"//": "why"`: `oxlintSchema` takes it, at the top of
|
|
54
|
+
the section, and leaves it out of the options it gives.
|
package/dist/standard.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
/**
|
|
3
3
|
* A JSON Schema of the keywords the check knows: the `type` of a value, its `const` or `enum`, a
|
|
4
|
-
* number's `minimum`, a string's `pattern`, a list's `items`, an object's `properties
|
|
5
|
-
* `additionalProperties`, and `anyOf`; a `description` says what a value
|
|
6
|
-
* keyword takes any value, as a function a code config gives.
|
|
4
|
+
* number's `minimum`, a string's `pattern`, a list's `items`, an object's `properties`,
|
|
5
|
+
* `patternProperties` and `additionalProperties`, and `anyOf`; a `description` says what a value
|
|
6
|
+
* is. A schema of no keyword takes any value, as a function a code config gives.
|
|
7
7
|
*/
|
|
8
8
|
export type JsonSchema = {
|
|
9
9
|
readonly type?: string | readonly string[];
|
|
@@ -13,6 +13,7 @@ export type JsonSchema = {
|
|
|
13
13
|
readonly pattern?: string;
|
|
14
14
|
readonly items?: JsonSchema;
|
|
15
15
|
readonly properties?: Readonly<Record<string, JsonSchema>>;
|
|
16
|
+
readonly patternProperties?: Readonly<Record<string, JsonSchema>>;
|
|
16
17
|
readonly additionalProperties?: boolean | JsonSchema;
|
|
17
18
|
readonly anyOf?: readonly JsonSchema[];
|
|
18
19
|
readonly description?: string;
|
|
@@ -22,6 +23,9 @@ export type OptionsSchema<T> = StandardSchemaV1<T> & StandardJSONSchemaV1<T>;
|
|
|
22
23
|
/**
|
|
23
24
|
* The schema of the options `T` of a preset, `vendor`, of their JSON Schema `json`: it checks a
|
|
24
25
|
* value by the keywords of `json`, as {@link JsonSchema} has them, and gives `json`, of draft
|
|
25
|
-
* 2020-12, as the JSON Schema of its input and of its output alike.
|
|
26
|
+
* 2020-12, as the JSON Schema of its input and of its output alike. A key that starts with `//` is
|
|
27
|
+
* a comment, of the options and of each object in them that takes no key but its `properties`, and
|
|
28
|
+
* the JSON Schema takes it by `patternProperties`: the check takes it, and leaves it out of the
|
|
29
|
+
* value it gives, as it leaves each value else as it is.
|
|
26
30
|
*/
|
|
27
31
|
export declare function optionsSchema<T>(vendor: string, json: JsonSchema): OptionsSchema<T>;
|
package/dist/standard.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
/** The draft of the JSON Schema an options schema gives. */
|
|
2
2
|
const DRAFT = 'https://json-schema.org/draft/2020-12/schema';
|
|
3
3
|
const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
4
|
+
/** The pattern of the key of a comment, of `patternProperties`: a key that starts with `//`. */
|
|
5
|
+
const COMMENT = '^//';
|
|
6
|
+
/** Whether `key` is the key of a comment. */
|
|
7
|
+
const isComment = (key) => key.startsWith('//');
|
|
8
|
+
/** Whether `schema` is of an object, of the keys it names or of any. */
|
|
9
|
+
const isObjectSchema = (schema) => schema.properties !== undefined ||
|
|
10
|
+
schema.patternProperties !== undefined ||
|
|
11
|
+
schema.additionalProperties !== undefined;
|
|
12
|
+
/**
|
|
13
|
+
* The schema of the value of `key` of an object of `schema`: of its `properties`, else of the
|
|
14
|
+
* first of its `patternProperties` that `key` matches, else its `additionalProperties`, else any.
|
|
15
|
+
*/
|
|
16
|
+
const propertyOf = (schema, key) => schema.properties?.[key] ??
|
|
17
|
+
Object.entries(schema.patternProperties ?? {}).find(([pattern]) => new RegExp(pattern, 'u').test(key))?.[1] ??
|
|
18
|
+
schema.additionalProperties ??
|
|
19
|
+
true;
|
|
4
20
|
/** The type of `value`, as a JSON Schema names it, and `function` of a function. */
|
|
5
21
|
const typeOf = (value) => value === null
|
|
6
22
|
? 'null'
|
|
@@ -35,10 +51,9 @@ function issuesOf(value, schema, path) {
|
|
|
35
51
|
const items = schema.items;
|
|
36
52
|
return value.flatMap((item, index) => issuesOf(item, items, [...path, index]));
|
|
37
53
|
}
|
|
38
|
-
if (isObject(value) &&
|
|
39
|
-
(schema.properties !== undefined || schema.additionalProperties !== undefined))
|
|
54
|
+
if (isObject(value) && isObjectSchema(schema))
|
|
40
55
|
return Object.entries(value).flatMap(([key, item]) => {
|
|
41
|
-
const property = schema
|
|
56
|
+
const property = propertyOf(schema, key);
|
|
42
57
|
if (property === true)
|
|
43
58
|
return [];
|
|
44
59
|
if (property === false)
|
|
@@ -49,20 +64,76 @@ function issuesOf(value, schema, path) {
|
|
|
49
64
|
}
|
|
50
65
|
/** What is wrong with `value` of `schema`, none when it is valid. */
|
|
51
66
|
const check = (value, schema) => issuesOf(value, schema, []);
|
|
67
|
+
/**
|
|
68
|
+
* `schema` with a comment taken by each object of options in it, by `patternProperties` of
|
|
69
|
+
* {@link COMMENT}: the options themselves, at the `top`, whatever keys they take, and each object
|
|
70
|
+
* in them that takes no key but its `properties`. A map, of a schema of `additionalProperties`,
|
|
71
|
+
* takes each key as one of its own.
|
|
72
|
+
*/
|
|
73
|
+
function withComments(schema, top) {
|
|
74
|
+
const { properties, items, additionalProperties, anyOf } = schema;
|
|
75
|
+
const takes = top ? isObjectSchema(schema) : additionalProperties === false;
|
|
76
|
+
return {
|
|
77
|
+
...schema,
|
|
78
|
+
...(properties !== undefined && {
|
|
79
|
+
properties: Object.fromEntries(Object.entries(properties).map(([key, each]) => [key, withComments(each, false)]))
|
|
80
|
+
}),
|
|
81
|
+
...(items !== undefined && { items: withComments(items, false) }),
|
|
82
|
+
...(typeof additionalProperties === 'object' && {
|
|
83
|
+
additionalProperties: withComments(additionalProperties, false)
|
|
84
|
+
}),
|
|
85
|
+
...(anyOf !== undefined && { anyOf: anyOf.map((each) => withComments(each, top)) }),
|
|
86
|
+
...(takes && {
|
|
87
|
+
patternProperties: {
|
|
88
|
+
...schema.patternProperties,
|
|
89
|
+
[COMMENT]: { description: 'A comment, which the options leave out.' }
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* `value`, valid of `schema`, without its comments: each key of a comment of an object whose schema
|
|
96
|
+
* takes them by {@link COMMENT}, and its `properties` do not name. A value of none is itself.
|
|
97
|
+
*/
|
|
98
|
+
function withoutComments(value, schema) {
|
|
99
|
+
const form = schema.anyOf?.find((each) => check(value, each).length === 0);
|
|
100
|
+
const read = form === undefined ? value : withoutComments(value, form);
|
|
101
|
+
const { items } = schema;
|
|
102
|
+
if (Array.isArray(read) && items !== undefined) {
|
|
103
|
+
const each = read.map((item) => withoutComments(item, items));
|
|
104
|
+
return each.every((item, index) => item === read[index]) ? read : each;
|
|
105
|
+
}
|
|
106
|
+
if (!isObject(read) || !isObjectSchema(schema))
|
|
107
|
+
return read;
|
|
108
|
+
const takes = schema.patternProperties?.[COMMENT] !== undefined;
|
|
109
|
+
const entries = Object.entries(read).flatMap(([key, item]) => {
|
|
110
|
+
if (takes && isComment(key) && schema.properties?.[key] === undefined)
|
|
111
|
+
return [];
|
|
112
|
+
const property = propertyOf(schema, key);
|
|
113
|
+
return [[key, typeof property === 'object' ? withoutComments(item, property) : item]];
|
|
114
|
+
});
|
|
115
|
+
const same = entries.length === Object.keys(read).length &&
|
|
116
|
+
entries.every(([key, item]) => item === read[key]);
|
|
117
|
+
return same ? read : Object.fromEntries(entries);
|
|
118
|
+
}
|
|
52
119
|
/**
|
|
53
120
|
* The schema of the options `T` of a preset, `vendor`, of their JSON Schema `json`: it checks a
|
|
54
121
|
* value by the keywords of `json`, as {@link JsonSchema} has them, and gives `json`, of draft
|
|
55
|
-
* 2020-12, as the JSON Schema of its input and of its output alike.
|
|
122
|
+
* 2020-12, as the JSON Schema of its input and of its output alike. A key that starts with `//` is
|
|
123
|
+
* a comment, of the options and of each object in them that takes no key but its `properties`, and
|
|
124
|
+
* the JSON Schema takes it by `patternProperties`: the check takes it, and leaves it out of the
|
|
125
|
+
* value it gives, as it leaves each value else as it is.
|
|
56
126
|
*/
|
|
57
127
|
export function optionsSchema(vendor, json) {
|
|
58
|
-
const
|
|
128
|
+
const schema = withComments(json, true);
|
|
129
|
+
const jsonSchema = () => ({ $schema: DRAFT, ...schema });
|
|
59
130
|
return {
|
|
60
131
|
'~standard': {
|
|
61
132
|
version: 1,
|
|
62
133
|
vendor,
|
|
63
134
|
validate: (value) => {
|
|
64
|
-
const issues = check(value,
|
|
65
|
-
return issues.length === 0 ? { value: value } : { issues };
|
|
135
|
+
const issues = check(value, schema);
|
|
136
|
+
return issues.length === 0 ? { value: withoutComments(value, schema) } : { issues };
|
|
66
137
|
},
|
|
67
138
|
jsonSchema: { input: jsonSchema, output: jsonSchema }
|
|
68
139
|
}
|
package/dist/standard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard.js","sourceRoot":"","sources":["../src/standard.ts"],"names":[],"mappings":"AA8BA,4DAA4D;AAC5D,MAAM,KAAK,GAAG,8CAA8C,CAAA;AAK5D,MAAM,QAAQ,GAAG,CAAC,KAAc,EAA8C,EAAE,CAC9E,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAEtE,oFAAoF;AACpF,MAAM,MAAM,GAAG,CAAC,KAAc,EAAU,EAAE,CACxC,KAAK,KAAK,IAAI;IACZ,CAAC,CAAC,MAAM;IACR,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,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AE,KAAU,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAA;YACjE,CAAC;YACD,UAAU,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE;SACtD;KACF,CAAA;AACH,CAAC","sourcesContent":["// The Standard Schema of a preset's options, of their JSON Schema: `optionsSchema` gives an object\n// of the Standard Schema and Standard JSON Schema interfaces of `@standard-schema/spec`, which checks\n// a value by the keywords of the JSON Schema it is written in, and gives that JSON Schema, so a\n// config of the options can be checked, and an editor completes it. The same file is in each\n// preset, which depends on no package of a schema (test/workspace.test.ts holds the copies alike).\n// Internal: no export map entry names it.\nimport type { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/spec'\n\n/**\n * A JSON Schema of the keywords the check knows: the `type` of a value, its `const` or `enum`, a\n * number's `minimum`, a string's `pattern`, a list's `items`, an object's `properties` and\n * `additionalProperties`, and `anyOf`; a `description` says what a value is. A schema of no\n * keyword takes any value, as a function a code config gives.\n */\nexport type JsonSchema = {\n readonly type?: string | readonly string[]\n readonly const?: unknown\n readonly enum?: readonly unknown[]\n readonly minimum?: number\n readonly pattern?: string\n readonly items?: JsonSchema\n readonly properties?: Readonly<Record<string, JsonSchema>>\n readonly additionalProperties?: boolean | JsonSchema\n readonly anyOf?: readonly JsonSchema[]\n readonly description?: string\n}\n\n/** The schema of the options `T`: a Standard Schema that checks them, and gives their JSON Schema. */\nexport type OptionsSchema<T> = StandardSchemaV1<T> & StandardJSONSchemaV1<T>\n\n/** The draft of the JSON Schema an options schema gives. */\nconst DRAFT = 'https://json-schema.org/draft/2020-12/schema'\n\ntype Issue = StandardSchemaV1.Issue\ntype Path = readonly PropertyKey[]\n\nconst isObject = (value: unknown): value is Readonly<Record<string, unknown>> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/** The type of `value`, as a JSON Schema names it, and `function` of a function. */\nconst typeOf = (value: unknown): string =>\n value === null\n ? 'null'\n : Array.isArray(value)\n ? 'array'\n : Number.isInteger(value)\n ? 'integer'\n : typeof value\n\n/** Whether `value` is of one of the `types`: an integer is a number. */\nconst isOfType = (value: unknown, types: string | readonly string[]): boolean => {\n const type = typeOf(value)\n return [types].flat().some((each) => each === type || (each === 'number' && type === 'integer'))\n}\n\n/** What is wrong with `value` of `schema`, at `path`. */\nfunction issuesOf(value: unknown, schema: JsonSchema, path: Path): Issue[] {\n const issue = (message: string): Issue[] => [{ message, path }]\n if (schema.anyOf !== undefined && !schema.anyOf.some((each) => check(value, each).length === 0))\n return issue(\n schema.description === undefined ? 'is none of its forms' : `is no ${schema.description}`\n )\n if ('const' in schema && value !== schema.const)\n return issue(`is not ${JSON.stringify(schema.const)}`)\n if (schema.enum !== undefined && !schema.enum.includes(value))\n return issue(`is none of ${schema.enum.map((each) => JSON.stringify(each)).join(', ')}`)\n if (schema.type !== undefined && !isOfType(value, schema.type))\n return issue(`is no ${[schema.type].flat().join(' or ')}`)\n if (typeof value === 'number' && schema.minimum !== undefined && value < schema.minimum)\n return issue(`is less than ${schema.minimum}`)\n if (\n typeof value === 'string' &&\n schema.pattern !== undefined &&\n !new RegExp(schema.pattern, 'u').test(value)\n )\n return issue(`does not match ${schema.pattern}`)\n if (Array.isArray(value) && schema.items !== undefined) {\n const items = schema.items\n return value.flatMap((item: unknown, index) => issuesOf(item, items, [...path, index]))\n }\n if (\n isObject(value) &&\n (schema.properties !== undefined || schema.additionalProperties !== undefined)\n )\n return Object.entries(value).flatMap(([key, item]) => {\n const property = schema.properties?.[key] ?? schema.additionalProperties ?? true\n if (property === true) return []\n if (property === false) return [{ message: 'is no option it takes', path: [...path, key] }]\n return issuesOf(item, property, [...path, key])\n })\n return []\n}\n\n/** What is wrong with `value` of `schema`, none when it is valid. */\nconst check = (value: unknown, schema: JsonSchema): Issue[] => issuesOf(value, schema, [])\n\n/**\n * The schema of the options `T` of a preset, `vendor`, of their JSON Schema `json`: it checks a\n * value by the keywords of `json`, as {@link JsonSchema} has them, and gives `json`, of draft\n * 2020-12, as the JSON Schema of its input and of its output alike.\n */\nexport function optionsSchema<T>(vendor: string, json: JsonSchema): OptionsSchema<T> {\n const jsonSchema = (): Record<string, unknown> => ({ $schema: DRAFT, ...json })\n return {\n '~standard': {\n version: 1,\n vendor,\n validate: (value) => {\n const issues = check(value, json)\n return issues.length === 0 ? { value: value as T } : { issues }\n },\n jsonSchema: { input: jsonSchema, output: jsonSchema }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"standard.js","sourceRoot":"","sources":["../src/standard.ts"],"names":[],"mappings":"AAiCA,4DAA4D;AAC5D,MAAM,KAAK,GAAG,8CAA8C,CAAA;AAK5D,MAAM,QAAQ,GAAG,CAAC,KAAc,EAA8C,EAAE,CAC9E,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAEtE,gGAAgG;AAChG,MAAM,OAAO,GAAG,KAAK,CAAA;AAErB,6CAA6C;AAC7C,MAAM,SAAS,GAAG,CAAC,GAAW,EAAW,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAEhE,wEAAwE;AACxE,MAAM,cAAc,GAAG,CAAC,MAAkB,EAAW,EAAE,CACrD,MAAM,CAAC,UAAU,KAAK,SAAS;IAC/B,MAAM,CAAC,iBAAiB,KAAK,SAAS;IACtC,MAAM,CAAC,oBAAoB,KAAK,SAAS,CAAA;AAE3C;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,MAAkB,EAAE,GAAW,EAAwB,EAAE,CAC3E,MAAM,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC;IACxB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAChE,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAA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AC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IACpD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;AAClD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAI,MAAc,EAAE,IAAgB;IAC/D,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACvC,MAAM,UAAU,GAAG,GAA4B,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;IACjF,OAAO;QACL,WAAW,EAAE;YACX,OAAO,EAAE,CAAC;YACV,MAAM;YACN,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;gBAClB,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;gBACnC,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,CAAM,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAA;YAC1F,CAAC;YACD,UAAU,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE;SACtD;KACF,CAAA;AACH,CAAC","sourcesContent":["// The Standard Schema of a preset's options, of their JSON Schema: `optionsSchema` gives an object\n// of the Standard Schema and Standard JSON Schema interfaces of `@standard-schema/spec`, which checks\n// a value by the keywords of the JSON Schema it is written in, and gives that JSON Schema, so a\n// config of the options can be checked, and an editor completes it. The same file is in each\n// preset, which depends on no package of a schema (test/workspace.test.ts holds the copies alike).\n// A key that starts with `//`, of the options or of an object of options in them, is a comment: the\n// check takes it, and leaves it out of the value it gives.\n// Internal: no export map entry names it.\nimport type { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/spec'\n\n/**\n * A JSON Schema of the keywords the check knows: the `type` of a value, its `const` or `enum`, a\n * number's `minimum`, a string's `pattern`, a list's `items`, an object's `properties`,\n * `patternProperties` and `additionalProperties`, and `anyOf`; a `description` says what a value\n * is. A schema of no keyword takes any value, as a function a code config gives.\n */\nexport type JsonSchema = {\n readonly type?: string | readonly string[]\n readonly const?: unknown\n readonly enum?: readonly unknown[]\n readonly minimum?: number\n readonly pattern?: string\n readonly items?: JsonSchema\n readonly properties?: Readonly<Record<string, JsonSchema>>\n readonly patternProperties?: Readonly<Record<string, JsonSchema>>\n readonly additionalProperties?: boolean | JsonSchema\n readonly anyOf?: readonly JsonSchema[]\n readonly description?: string\n}\n\n/** The schema of the options `T`: a Standard Schema that checks them, and gives their JSON Schema. */\nexport type OptionsSchema<T> = StandardSchemaV1<T> & StandardJSONSchemaV1<T>\n\n/** The draft of the JSON Schema an options schema gives. */\nconst DRAFT = 'https://json-schema.org/draft/2020-12/schema'\n\ntype Issue = StandardSchemaV1.Issue\ntype Path = readonly PropertyKey[]\n\nconst isObject = (value: unknown): value is Readonly<Record<string, unknown>> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/** The pattern of the key of a comment, of `patternProperties`: a key that starts with `//`. */\nconst COMMENT = '^//'\n\n/** Whether `key` is the key of a comment. */\nconst isComment = (key: string): boolean => key.startsWith('//')\n\n/** Whether `schema` is of an object, of the keys it names or of any. */\nconst isObjectSchema = (schema: JsonSchema): boolean =>\n schema.properties !== undefined ||\n schema.patternProperties !== undefined ||\n schema.additionalProperties !== undefined\n\n/**\n * The schema of the value of `key` of an object of `schema`: of its `properties`, else of the\n * first of its `patternProperties` that `key` matches, else its `additionalProperties`, else any.\n */\nconst propertyOf = (schema: JsonSchema, key: string): JsonSchema | boolean =>\n schema.properties?.[key] ??\n Object.entries(schema.patternProperties ?? {}).find(([pattern]) =>\n new RegExp(pattern, 'u').test(key)\n )?.[1] ??\n schema.additionalProperties ??\n true\n\n/** The type of `value`, as a JSON Schema names it, and `function` of a function. */\nconst typeOf = (value: unknown): string =>\n value === null\n ? 'null'\n : Array.isArray(value)\n ? 'array'\n : Number.isInteger(value)\n ? 'integer'\n : typeof value\n\n/** Whether `value` is of one of the `types`: an integer is a number. */\nconst isOfType = (value: unknown, types: string | readonly string[]): boolean => {\n const type = typeOf(value)\n return [types].flat().some((each) => each === type || (each === 'number' && type === 'integer'))\n}\n\n/** What is wrong with `value` of `schema`, at `path`. */\nfunction issuesOf(value: unknown, schema: JsonSchema, path: Path): Issue[] {\n const issue = (message: string): Issue[] => [{ message, path }]\n if (schema.anyOf !== undefined && !schema.anyOf.some((each) => check(value, each).length === 0))\n return issue(\n schema.description === undefined ? 'is none of its forms' : `is no ${schema.description}`\n )\n if ('const' in schema && value !== schema.const)\n return issue(`is not ${JSON.stringify(schema.const)}`)\n if (schema.enum !== undefined && !schema.enum.includes(value))\n return issue(`is none of ${schema.enum.map((each) => JSON.stringify(each)).join(', ')}`)\n if (schema.type !== undefined && !isOfType(value, schema.type))\n return issue(`is no ${[schema.type].flat().join(' or ')}`)\n if (typeof value === 'number' && schema.minimum !== undefined && value < schema.minimum)\n return issue(`is less than ${schema.minimum}`)\n if (\n typeof value === 'string' &&\n schema.pattern !== undefined &&\n !new RegExp(schema.pattern, 'u').test(value)\n )\n return issue(`does not match ${schema.pattern}`)\n if (Array.isArray(value) && schema.items !== undefined) {\n const items = schema.items\n return value.flatMap((item: unknown, index) => issuesOf(item, items, [...path, index]))\n }\n if (isObject(value) && isObjectSchema(schema))\n return Object.entries(value).flatMap(([key, item]) => {\n const property = propertyOf(schema, key)\n if (property === true) return []\n if (property === false) return [{ message: 'is no option it takes', path: [...path, key] }]\n return issuesOf(item, property, [...path, key])\n })\n return []\n}\n\n/** What is wrong with `value` of `schema`, none when it is valid. */\nconst check = (value: unknown, schema: JsonSchema): Issue[] => issuesOf(value, schema, [])\n\n/**\n * `schema` with a comment taken by each object of options in it, by `patternProperties` of\n * {@link COMMENT}: the options themselves, at the `top`, whatever keys they take, and each object\n * in them that takes no key but its `properties`. A map, of a schema of `additionalProperties`,\n * takes each key as one of its own.\n */\nfunction withComments(schema: JsonSchema, top: boolean): JsonSchema {\n const { properties, items, additionalProperties, anyOf } = schema\n const takes = top ? isObjectSchema(schema) : additionalProperties === false\n return {\n ...schema,\n ...(properties !== undefined && {\n properties: Object.fromEntries(\n Object.entries(properties).map(([key, each]) => [key, withComments(each, false)])\n )\n }),\n ...(items !== undefined && { items: withComments(items, false) }),\n ...(typeof additionalProperties === 'object' && {\n additionalProperties: withComments(additionalProperties, false)\n }),\n ...(anyOf !== undefined && { anyOf: anyOf.map((each) => withComments(each, top)) }),\n ...(takes && {\n patternProperties: {\n ...schema.patternProperties,\n [COMMENT]: { description: 'A comment, which the options leave out.' }\n }\n })\n }\n}\n\n/**\n * `value`, valid of `schema`, without its comments: each key of a comment of an object whose schema\n * takes them by {@link COMMENT}, and its `properties` do not name. A value of none is itself.\n */\nfunction withoutComments(value: unknown, schema: JsonSchema): unknown {\n const form = schema.anyOf?.find((each) => check(value, each).length === 0)\n const read = form === undefined ? value : withoutComments(value, form)\n const { items } = schema\n if (Array.isArray(read) && items !== undefined) {\n const each = read.map((item: unknown) => withoutComments(item, items))\n return each.every((item, index) => item === read[index]) ? read : each\n }\n if (!isObject(read) || !isObjectSchema(schema)) return read\n const takes = schema.patternProperties?.[COMMENT] !== undefined\n const entries = Object.entries(read).flatMap(([key, item]): [string, unknown][] => {\n if (takes && isComment(key) && schema.properties?.[key] === undefined) return []\n const property = propertyOf(schema, key)\n return [[key, typeof property === 'object' ? withoutComments(item, property) : item]]\n })\n const same =\n entries.length === Object.keys(read).length &&\n entries.every(([key, item]) => item === read[key])\n return same ? read : Object.fromEntries(entries)\n}\n\n/**\n * The schema of the options `T` of a preset, `vendor`, of their JSON Schema `json`: it checks a\n * value by the keywords of `json`, as {@link JsonSchema} has them, and gives `json`, of draft\n * 2020-12, as the JSON Schema of its input and of its output alike. A key that starts with `//` is\n * a comment, of the options and of each object in them that takes no key but its `properties`, and\n * the JSON Schema takes it by `patternProperties`: the check takes it, and leaves it out of the\n * value it gives, as it leaves each value else as it is.\n */\nexport function optionsSchema<T>(vendor: string, json: JsonSchema): OptionsSchema<T> {\n const schema = withComments(json, true)\n const jsonSchema = (): Record<string, unknown> => ({ $schema: DRAFT, ...schema })\n return {\n '~standard': {\n version: 1,\n vendor,\n validate: (value) => {\n const issues = check(value, schema)\n return issues.length === 0 ? { value: withoutComments(value, schema) as T } : { issues }\n },\n jsonSchema: { input: jsonSchema, output: jsonSchema }\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wtf/project-oxlint",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "The shared oxlint config (./config): the typescript, unicorn and import plugins, correctness rules as errors, suspicious and perf rules as warnings, and import cycles, loose equality and explicit any as errors. oxlintConfig(options) gives it with a repo's options over it; the schema of those (./schema), oxlintSchema, a Standard Schema that gives their JSON Schema, checks the oxlint section of a repo's configuration before it spreads it in.",
|
|
5
5
|
"homepage": "https://gitlab.com/wetryfun/project/project/-/tree/main/packages/project-oxlint",
|
|
6
6
|
"bugs": {
|