@alexlit/lint-kit 117.3.1 → 117.4.0

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.
Files changed (159) hide show
  1. package/package.json +1 -1
  2. package/packages/config-eslint/package.json +5 -9
  3. package/packages/config-eslint/plugins/no-await-in-promise.js +1 -1
  4. package/packages/config-eslint/utils/create-config.js +3 -3
  5. package/scripts/.config.sh +1 -1
  6. package/packages/config-eslint/node_modules/@eslint/eslintrc/LICENSE +0 -19
  7. package/packages/config-eslint/node_modules/@eslint/eslintrc/README.md +0 -126
  8. package/packages/config-eslint/node_modules/@eslint/eslintrc/conf/config-schema.js +0 -79
  9. package/packages/config-eslint/node_modules/@eslint/eslintrc/conf/environments.js +0 -215
  10. package/packages/config-eslint/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs +0 -1143
  11. package/packages/config-eslint/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map +0 -1
  12. package/packages/config-eslint/node_modules/@eslint/eslintrc/dist/eslintrc.cjs +0 -4371
  13. package/packages/config-eslint/node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map +0 -1
  14. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js +0 -532
  15. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array/config-array.js +0 -510
  16. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array/config-dependency.js +0 -124
  17. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array/extracted-config.js +0 -145
  18. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array/ignore-pattern.js +0 -238
  19. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array/index.js +0 -19
  20. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array/override-tester.js +0 -225
  21. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/config-array-factory.js +0 -1155
  22. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/flat-compat.js +0 -318
  23. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/index-universal.js +0 -29
  24. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/index.js +0 -58
  25. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/ajv.js +0 -191
  26. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/config-ops.js +0 -135
  27. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/config-validator.js +0 -370
  28. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/deprecation-warnings.js +0 -63
  29. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/naming.js +0 -96
  30. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js +0 -42
  31. package/packages/config-eslint/node_modules/@eslint/eslintrc/lib/shared/types.js +0 -149
  32. package/packages/config-eslint/node_modules/@eslint/eslintrc/package.json +0 -82
  33. package/packages/config-eslint/node_modules/@eslint/eslintrc/universal.js +0 -9
  34. package/packages/config-eslint/node_modules/ajv/.tonic_example.js +0 -20
  35. package/packages/config-eslint/node_modules/ajv/LICENSE +0 -22
  36. package/packages/config-eslint/node_modules/ajv/README.md +0 -1497
  37. package/packages/config-eslint/node_modules/ajv/dist/ajv.bundle.js +0 -7189
  38. package/packages/config-eslint/node_modules/ajv/dist/ajv.min.js +0 -3
  39. package/packages/config-eslint/node_modules/ajv/dist/ajv.min.js.map +0 -1
  40. package/packages/config-eslint/node_modules/ajv/lib/ajv.d.ts +0 -397
  41. package/packages/config-eslint/node_modules/ajv/lib/ajv.js +0 -506
  42. package/packages/config-eslint/node_modules/ajv/lib/cache.js +0 -26
  43. package/packages/config-eslint/node_modules/ajv/lib/compile/async.js +0 -90
  44. package/packages/config-eslint/node_modules/ajv/lib/compile/equal.js +0 -5
  45. package/packages/config-eslint/node_modules/ajv/lib/compile/error_classes.js +0 -34
  46. package/packages/config-eslint/node_modules/ajv/lib/compile/formats.js +0 -142
  47. package/packages/config-eslint/node_modules/ajv/lib/compile/index.js +0 -387
  48. package/packages/config-eslint/node_modules/ajv/lib/compile/resolve.js +0 -270
  49. package/packages/config-eslint/node_modules/ajv/lib/compile/rules.js +0 -66
  50. package/packages/config-eslint/node_modules/ajv/lib/compile/schema_obj.js +0 -9
  51. package/packages/config-eslint/node_modules/ajv/lib/compile/ucs2length.js +0 -20
  52. package/packages/config-eslint/node_modules/ajv/lib/compile/util.js +0 -239
  53. package/packages/config-eslint/node_modules/ajv/lib/data.js +0 -49
  54. package/packages/config-eslint/node_modules/ajv/lib/definition_schema.js +0 -37
  55. package/packages/config-eslint/node_modules/ajv/lib/dot/_limit.jst +0 -113
  56. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitItems.jst +0 -12
  57. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitLength.jst +0 -12
  58. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitProperties.jst +0 -12
  59. package/packages/config-eslint/node_modules/ajv/lib/dot/allOf.jst +0 -32
  60. package/packages/config-eslint/node_modules/ajv/lib/dot/anyOf.jst +0 -46
  61. package/packages/config-eslint/node_modules/ajv/lib/dot/coerce.def +0 -51
  62. package/packages/config-eslint/node_modules/ajv/lib/dot/comment.jst +0 -9
  63. package/packages/config-eslint/node_modules/ajv/lib/dot/const.jst +0 -11
  64. package/packages/config-eslint/node_modules/ajv/lib/dot/contains.jst +0 -55
  65. package/packages/config-eslint/node_modules/ajv/lib/dot/custom.jst +0 -191
  66. package/packages/config-eslint/node_modules/ajv/lib/dot/defaults.def +0 -47
  67. package/packages/config-eslint/node_modules/ajv/lib/dot/definitions.def +0 -203
  68. package/packages/config-eslint/node_modules/ajv/lib/dot/dependencies.jst +0 -79
  69. package/packages/config-eslint/node_modules/ajv/lib/dot/enum.jst +0 -30
  70. package/packages/config-eslint/node_modules/ajv/lib/dot/errors.def +0 -194
  71. package/packages/config-eslint/node_modules/ajv/lib/dot/format.jst +0 -106
  72. package/packages/config-eslint/node_modules/ajv/lib/dot/if.jst +0 -73
  73. package/packages/config-eslint/node_modules/ajv/lib/dot/items.jst +0 -98
  74. package/packages/config-eslint/node_modules/ajv/lib/dot/missing.def +0 -39
  75. package/packages/config-eslint/node_modules/ajv/lib/dot/multipleOf.jst +0 -22
  76. package/packages/config-eslint/node_modules/ajv/lib/dot/not.jst +0 -43
  77. package/packages/config-eslint/node_modules/ajv/lib/dot/oneOf.jst +0 -54
  78. package/packages/config-eslint/node_modules/ajv/lib/dot/pattern.jst +0 -14
  79. package/packages/config-eslint/node_modules/ajv/lib/dot/properties.jst +0 -245
  80. package/packages/config-eslint/node_modules/ajv/lib/dot/propertyNames.jst +0 -52
  81. package/packages/config-eslint/node_modules/ajv/lib/dot/ref.jst +0 -85
  82. package/packages/config-eslint/node_modules/ajv/lib/dot/required.jst +0 -108
  83. package/packages/config-eslint/node_modules/ajv/lib/dot/uniqueItems.jst +0 -62
  84. package/packages/config-eslint/node_modules/ajv/lib/dot/validate.jst +0 -276
  85. package/packages/config-eslint/node_modules/ajv/lib/dotjs/README.md +0 -3
  86. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limit.js +0 -163
  87. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitItems.js +0 -80
  88. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitLength.js +0 -85
  89. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitProperties.js +0 -80
  90. package/packages/config-eslint/node_modules/ajv/lib/dotjs/allOf.js +0 -42
  91. package/packages/config-eslint/node_modules/ajv/lib/dotjs/anyOf.js +0 -73
  92. package/packages/config-eslint/node_modules/ajv/lib/dotjs/comment.js +0 -14
  93. package/packages/config-eslint/node_modules/ajv/lib/dotjs/const.js +0 -56
  94. package/packages/config-eslint/node_modules/ajv/lib/dotjs/contains.js +0 -81
  95. package/packages/config-eslint/node_modules/ajv/lib/dotjs/custom.js +0 -228
  96. package/packages/config-eslint/node_modules/ajv/lib/dotjs/dependencies.js +0 -168
  97. package/packages/config-eslint/node_modules/ajv/lib/dotjs/enum.js +0 -66
  98. package/packages/config-eslint/node_modules/ajv/lib/dotjs/format.js +0 -150
  99. package/packages/config-eslint/node_modules/ajv/lib/dotjs/if.js +0 -103
  100. package/packages/config-eslint/node_modules/ajv/lib/dotjs/index.js +0 -33
  101. package/packages/config-eslint/node_modules/ajv/lib/dotjs/items.js +0 -140
  102. package/packages/config-eslint/node_modules/ajv/lib/dotjs/multipleOf.js +0 -80
  103. package/packages/config-eslint/node_modules/ajv/lib/dotjs/not.js +0 -84
  104. package/packages/config-eslint/node_modules/ajv/lib/dotjs/oneOf.js +0 -73
  105. package/packages/config-eslint/node_modules/ajv/lib/dotjs/pattern.js +0 -75
  106. package/packages/config-eslint/node_modules/ajv/lib/dotjs/properties.js +0 -335
  107. package/packages/config-eslint/node_modules/ajv/lib/dotjs/propertyNames.js +0 -81
  108. package/packages/config-eslint/node_modules/ajv/lib/dotjs/ref.js +0 -124
  109. package/packages/config-eslint/node_modules/ajv/lib/dotjs/required.js +0 -270
  110. package/packages/config-eslint/node_modules/ajv/lib/dotjs/uniqueItems.js +0 -86
  111. package/packages/config-eslint/node_modules/ajv/lib/dotjs/validate.js +0 -482
  112. package/packages/config-eslint/node_modules/ajv/lib/keyword.js +0 -146
  113. package/packages/config-eslint/node_modules/ajv/lib/refs/data.json +0 -17
  114. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-04.json +0 -149
  115. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-06.json +0 -154
  116. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-07.json +0 -168
  117. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-secure.json +0 -94
  118. package/packages/config-eslint/node_modules/ajv/package.json +0 -106
  119. package/packages/config-eslint/node_modules/ajv/scripts/.eslintrc.yml +0 -3
  120. package/packages/config-eslint/node_modules/ajv/scripts/bundle.js +0 -61
  121. package/packages/config-eslint/node_modules/ajv/scripts/compile-dots.js +0 -73
  122. package/packages/config-eslint/node_modules/ajv/scripts/info +0 -10
  123. package/packages/config-eslint/node_modules/ajv/scripts/prepare-tests +0 -12
  124. package/packages/config-eslint/node_modules/ajv/scripts/publish-built-version +0 -32
  125. package/packages/config-eslint/node_modules/ajv/scripts/travis-gh-pages +0 -23
  126. package/packages/config-eslint/node_modules/eslint-visitor-keys/LICENSE +0 -201
  127. package/packages/config-eslint/node_modules/eslint-visitor-keys/README.md +0 -105
  128. package/packages/config-eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs +0 -384
  129. package/packages/config-eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts +0 -27
  130. package/packages/config-eslint/node_modules/eslint-visitor-keys/dist/index.d.ts +0 -16
  131. package/packages/config-eslint/node_modules/eslint-visitor-keys/dist/visitor-keys.d.ts +0 -12
  132. package/packages/config-eslint/node_modules/eslint-visitor-keys/lib/index.js +0 -65
  133. package/packages/config-eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.js +0 -315
  134. package/packages/config-eslint/node_modules/eslint-visitor-keys/package.json +0 -74
  135. package/packages/config-eslint/node_modules/espree/LICENSE +0 -25
  136. package/packages/config-eslint/node_modules/espree/README.md +0 -244
  137. package/packages/config-eslint/node_modules/espree/dist/espree.cjs +0 -883
  138. package/packages/config-eslint/node_modules/espree/espree.js +0 -177
  139. package/packages/config-eslint/node_modules/espree/lib/espree.js +0 -349
  140. package/packages/config-eslint/node_modules/espree/lib/features.js +0 -27
  141. package/packages/config-eslint/node_modules/espree/lib/options.js +0 -123
  142. package/packages/config-eslint/node_modules/espree/lib/token-translator.js +0 -263
  143. package/packages/config-eslint/node_modules/espree/lib/version.js +0 -3
  144. package/packages/config-eslint/node_modules/espree/package.json +0 -86
  145. package/packages/config-eslint/node_modules/globals/globals.json +0 -1998
  146. package/packages/config-eslint/node_modules/globals/index.d.ts +0 -2077
  147. package/packages/config-eslint/node_modules/globals/index.js +0 -2
  148. package/packages/config-eslint/node_modules/globals/license +0 -9
  149. package/packages/config-eslint/node_modules/globals/package.json +0 -58
  150. package/packages/config-eslint/node_modules/globals/readme.md +0 -44
  151. package/packages/config-eslint/node_modules/json-schema-traverse/.eslintrc.yml +0 -27
  152. package/packages/config-eslint/node_modules/json-schema-traverse/.travis.yml +0 -8
  153. package/packages/config-eslint/node_modules/json-schema-traverse/LICENSE +0 -21
  154. package/packages/config-eslint/node_modules/json-schema-traverse/README.md +0 -83
  155. package/packages/config-eslint/node_modules/json-schema-traverse/index.js +0 -89
  156. package/packages/config-eslint/node_modules/json-schema-traverse/package.json +0 -43
  157. package/packages/config-eslint/node_modules/json-schema-traverse/spec/.eslintrc.yml +0 -6
  158. package/packages/config-eslint/node_modules/json-schema-traverse/spec/fixtures/schema.js +0 -125
  159. package/packages/config-eslint/node_modules/json-schema-traverse/spec/index.spec.js +0 -171
@@ -1,270 +0,0 @@
1
- 'use strict';
2
-
3
- var URI = require('uri-js')
4
- , equal = require('fast-deep-equal')
5
- , util = require('./util')
6
- , SchemaObject = require('./schema_obj')
7
- , traverse = require('json-schema-traverse');
8
-
9
- module.exports = resolve;
10
-
11
- resolve.normalizeId = normalizeId;
12
- resolve.fullPath = getFullPath;
13
- resolve.url = resolveUrl;
14
- resolve.ids = resolveIds;
15
- resolve.inlineRef = inlineRef;
16
- resolve.schema = resolveSchema;
17
-
18
- /**
19
- * [resolve and compile the references ($ref)]
20
- * @this Ajv
21
- * @param {Function} compile reference to schema compilation funciton (localCompile)
22
- * @param {Object} root object with information about the root schema for the current schema
23
- * @param {String} ref reference to resolve
24
- * @return {Object|Function} schema object (if the schema can be inlined) or validation function
25
- */
26
- function resolve(compile, root, ref) {
27
- /* jshint validthis: true */
28
- var refVal = this._refs[ref];
29
- if (typeof refVal == 'string') {
30
- if (this._refs[refVal]) refVal = this._refs[refVal];
31
- else return resolve.call(this, compile, root, refVal);
32
- }
33
-
34
- refVal = refVal || this._schemas[ref];
35
- if (refVal instanceof SchemaObject) {
36
- return inlineRef(refVal.schema, this._opts.inlineRefs)
37
- ? refVal.schema
38
- : refVal.validate || this._compile(refVal);
39
- }
40
-
41
- var res = resolveSchema.call(this, root, ref);
42
- var schema, v, baseId;
43
- if (res) {
44
- schema = res.schema;
45
- root = res.root;
46
- baseId = res.baseId;
47
- }
48
-
49
- if (schema instanceof SchemaObject) {
50
- v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
51
- } else if (schema !== undefined) {
52
- v = inlineRef(schema, this._opts.inlineRefs)
53
- ? schema
54
- : compile.call(this, schema, root, undefined, baseId);
55
- }
56
-
57
- return v;
58
- }
59
-
60
-
61
- /**
62
- * Resolve schema, its root and baseId
63
- * @this Ajv
64
- * @param {Object} root root object with properties schema, refVal, refs
65
- * @param {String} ref reference to resolve
66
- * @return {Object} object with properties schema, root, baseId
67
- */
68
- function resolveSchema(root, ref) {
69
- /* jshint validthis: true */
70
- var p = URI.parse(ref)
71
- , refPath = _getFullPath(p)
72
- , baseId = getFullPath(this._getId(root.schema));
73
- if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
74
- var id = normalizeId(refPath);
75
- var refVal = this._refs[id];
76
- if (typeof refVal == 'string') {
77
- return resolveRecursive.call(this, root, refVal, p);
78
- } else if (refVal instanceof SchemaObject) {
79
- if (!refVal.validate) this._compile(refVal);
80
- root = refVal;
81
- } else {
82
- refVal = this._schemas[id];
83
- if (refVal instanceof SchemaObject) {
84
- if (!refVal.validate) this._compile(refVal);
85
- if (id == normalizeId(ref))
86
- return { schema: refVal, root: root, baseId: baseId };
87
- root = refVal;
88
- } else {
89
- return;
90
- }
91
- }
92
- if (!root.schema) return;
93
- baseId = getFullPath(this._getId(root.schema));
94
- }
95
- return getJsonPointer.call(this, p, baseId, root.schema, root);
96
- }
97
-
98
-
99
- /* @this Ajv */
100
- function resolveRecursive(root, ref, parsedRef) {
101
- /* jshint validthis: true */
102
- var res = resolveSchema.call(this, root, ref);
103
- if (res) {
104
- var schema = res.schema;
105
- var baseId = res.baseId;
106
- root = res.root;
107
- var id = this._getId(schema);
108
- if (id) baseId = resolveUrl(baseId, id);
109
- return getJsonPointer.call(this, parsedRef, baseId, schema, root);
110
- }
111
- }
112
-
113
-
114
- var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
115
- /* @this Ajv */
116
- function getJsonPointer(parsedRef, baseId, schema, root) {
117
- /* jshint validthis: true */
118
- parsedRef.fragment = parsedRef.fragment || '';
119
- if (parsedRef.fragment.slice(0,1) != '/') return;
120
- var parts = parsedRef.fragment.split('/');
121
-
122
- for (var i = 1; i < parts.length; i++) {
123
- var part = parts[i];
124
- if (part) {
125
- part = util.unescapeFragment(part);
126
- schema = schema[part];
127
- if (schema === undefined) break;
128
- var id;
129
- if (!PREVENT_SCOPE_CHANGE[part]) {
130
- id = this._getId(schema);
131
- if (id) baseId = resolveUrl(baseId, id);
132
- if (schema.$ref) {
133
- var $ref = resolveUrl(baseId, schema.$ref);
134
- var res = resolveSchema.call(this, root, $ref);
135
- if (res) {
136
- schema = res.schema;
137
- root = res.root;
138
- baseId = res.baseId;
139
- }
140
- }
141
- }
142
- }
143
- }
144
- if (schema !== undefined && schema !== root.schema)
145
- return { schema: schema, root: root, baseId: baseId };
146
- }
147
-
148
-
149
- var SIMPLE_INLINED = util.toHash([
150
- 'type', 'format', 'pattern',
151
- 'maxLength', 'minLength',
152
- 'maxProperties', 'minProperties',
153
- 'maxItems', 'minItems',
154
- 'maximum', 'minimum',
155
- 'uniqueItems', 'multipleOf',
156
- 'required', 'enum'
157
- ]);
158
- function inlineRef(schema, limit) {
159
- if (limit === false) return false;
160
- if (limit === undefined || limit === true) return checkNoRef(schema);
161
- else if (limit) return countKeys(schema) <= limit;
162
- }
163
-
164
-
165
- function checkNoRef(schema) {
166
- var item;
167
- if (Array.isArray(schema)) {
168
- for (var i=0; i<schema.length; i++) {
169
- item = schema[i];
170
- if (typeof item == 'object' && !checkNoRef(item)) return false;
171
- }
172
- } else {
173
- for (var key in schema) {
174
- if (key == '$ref') return false;
175
- item = schema[key];
176
- if (typeof item == 'object' && !checkNoRef(item)) return false;
177
- }
178
- }
179
- return true;
180
- }
181
-
182
-
183
- function countKeys(schema) {
184
- var count = 0, item;
185
- if (Array.isArray(schema)) {
186
- for (var i=0; i<schema.length; i++) {
187
- item = schema[i];
188
- if (typeof item == 'object') count += countKeys(item);
189
- if (count == Infinity) return Infinity;
190
- }
191
- } else {
192
- for (var key in schema) {
193
- if (key == '$ref') return Infinity;
194
- if (SIMPLE_INLINED[key]) {
195
- count++;
196
- } else {
197
- item = schema[key];
198
- if (typeof item == 'object') count += countKeys(item) + 1;
199
- if (count == Infinity) return Infinity;
200
- }
201
- }
202
- }
203
- return count;
204
- }
205
-
206
-
207
- function getFullPath(id, normalize) {
208
- if (normalize !== false) id = normalizeId(id);
209
- var p = URI.parse(id);
210
- return _getFullPath(p);
211
- }
212
-
213
-
214
- function _getFullPath(p) {
215
- return URI.serialize(p).split('#')[0] + '#';
216
- }
217
-
218
-
219
- var TRAILING_SLASH_HASH = /#\/?$/;
220
- function normalizeId(id) {
221
- return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
222
- }
223
-
224
-
225
- function resolveUrl(baseId, id) {
226
- id = normalizeId(id);
227
- return URI.resolve(baseId, id);
228
- }
229
-
230
-
231
- /* @this Ajv */
232
- function resolveIds(schema) {
233
- var schemaId = normalizeId(this._getId(schema));
234
- var baseIds = {'': schemaId};
235
- var fullPaths = {'': getFullPath(schemaId, false)};
236
- var localRefs = {};
237
- var self = this;
238
-
239
- traverse(schema, {allKeys: true}, function(sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
240
- if (jsonPtr === '') return;
241
- var id = self._getId(sch);
242
- var baseId = baseIds[parentJsonPtr];
243
- var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
244
- if (keyIndex !== undefined)
245
- fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
246
-
247
- if (typeof id == 'string') {
248
- id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id);
249
-
250
- var refVal = self._refs[id];
251
- if (typeof refVal == 'string') refVal = self._refs[refVal];
252
- if (refVal && refVal.schema) {
253
- if (!equal(sch, refVal.schema))
254
- throw new Error('id "' + id + '" resolves to more than one schema');
255
- } else if (id != normalizeId(fullPath)) {
256
- if (id[0] == '#') {
257
- if (localRefs[id] && !equal(sch, localRefs[id]))
258
- throw new Error('id "' + id + '" resolves to more than one schema');
259
- localRefs[id] = sch;
260
- } else {
261
- self._refs[id] = fullPath;
262
- }
263
- }
264
- }
265
- baseIds[jsonPtr] = baseId;
266
- fullPaths[jsonPtr] = fullPath;
267
- });
268
-
269
- return localRefs;
270
- }
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- var ruleModules = require('../dotjs')
4
- , toHash = require('./util').toHash;
5
-
6
- module.exports = function rules() {
7
- var RULES = [
8
- { type: 'number',
9
- rules: [ { 'maximum': ['exclusiveMaximum'] },
10
- { 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] },
11
- { type: 'string',
12
- rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
13
- { type: 'array',
14
- rules: [ 'maxItems', 'minItems', 'items', 'contains', 'uniqueItems' ] },
15
- { type: 'object',
16
- rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames',
17
- { 'properties': ['additionalProperties', 'patternProperties'] } ] },
18
- { rules: [ '$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf', 'if' ] }
19
- ];
20
-
21
- var ALL = [ 'type', '$comment' ];
22
- var KEYWORDS = [
23
- '$schema', '$id', 'id', '$data', '$async', 'title',
24
- 'description', 'default', 'definitions',
25
- 'examples', 'readOnly', 'writeOnly',
26
- 'contentMediaType', 'contentEncoding',
27
- 'additionalItems', 'then', 'else'
28
- ];
29
- var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
30
- RULES.all = toHash(ALL);
31
- RULES.types = toHash(TYPES);
32
-
33
- RULES.forEach(function (group) {
34
- group.rules = group.rules.map(function (keyword) {
35
- var implKeywords;
36
- if (typeof keyword == 'object') {
37
- var key = Object.keys(keyword)[0];
38
- implKeywords = keyword[key];
39
- keyword = key;
40
- implKeywords.forEach(function (k) {
41
- ALL.push(k);
42
- RULES.all[k] = true;
43
- });
44
- }
45
- ALL.push(keyword);
46
- var rule = RULES.all[keyword] = {
47
- keyword: keyword,
48
- code: ruleModules[keyword],
49
- implements: implKeywords
50
- };
51
- return rule;
52
- });
53
-
54
- RULES.all.$comment = {
55
- keyword: '$comment',
56
- code: ruleModules.$comment
57
- };
58
-
59
- if (group.type) RULES.types[group.type] = group;
60
- });
61
-
62
- RULES.keywords = toHash(ALL.concat(KEYWORDS));
63
- RULES.custom = {};
64
-
65
- return RULES;
66
- };
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var util = require('./util');
4
-
5
- module.exports = SchemaObject;
6
-
7
- function SchemaObject(obj) {
8
- util.copy(obj, this);
9
- }
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- // https://mathiasbynens.be/notes/javascript-encoding
4
- // https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
5
- module.exports = function ucs2length(str) {
6
- var length = 0
7
- , len = str.length
8
- , pos = 0
9
- , value;
10
- while (pos < len) {
11
- length++;
12
- value = str.charCodeAt(pos++);
13
- if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
14
- // high surrogate, and there is a next character
15
- value = str.charCodeAt(pos);
16
- if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
17
- }
18
- }
19
- return length;
20
- };
@@ -1,239 +0,0 @@
1
- 'use strict';
2
-
3
-
4
- module.exports = {
5
- copy: copy,
6
- checkDataType: checkDataType,
7
- checkDataTypes: checkDataTypes,
8
- coerceToTypes: coerceToTypes,
9
- toHash: toHash,
10
- getProperty: getProperty,
11
- escapeQuotes: escapeQuotes,
12
- equal: require('fast-deep-equal'),
13
- ucs2length: require('./ucs2length'),
14
- varOccurences: varOccurences,
15
- varReplace: varReplace,
16
- schemaHasRules: schemaHasRules,
17
- schemaHasRulesExcept: schemaHasRulesExcept,
18
- schemaUnknownRules: schemaUnknownRules,
19
- toQuotedString: toQuotedString,
20
- getPathExpr: getPathExpr,
21
- getPath: getPath,
22
- getData: getData,
23
- unescapeFragment: unescapeFragment,
24
- unescapeJsonPointer: unescapeJsonPointer,
25
- escapeFragment: escapeFragment,
26
- escapeJsonPointer: escapeJsonPointer
27
- };
28
-
29
-
30
- function copy(o, to) {
31
- to = to || {};
32
- for (var key in o) to[key] = o[key];
33
- return to;
34
- }
35
-
36
-
37
- function checkDataType(dataType, data, strictNumbers, negate) {
38
- var EQUAL = negate ? ' !== ' : ' === '
39
- , AND = negate ? ' || ' : ' && '
40
- , OK = negate ? '!' : ''
41
- , NOT = negate ? '' : '!';
42
- switch (dataType) {
43
- case 'null': return data + EQUAL + 'null';
44
- case 'array': return OK + 'Array.isArray(' + data + ')';
45
- case 'object': return '(' + OK + data + AND +
46
- 'typeof ' + data + EQUAL + '"object"' + AND +
47
- NOT + 'Array.isArray(' + data + '))';
48
- case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
49
- NOT + '(' + data + ' % 1)' +
50
- AND + data + EQUAL + data +
51
- (strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
52
- case 'number': return '(typeof ' + data + EQUAL + '"' + dataType + '"' +
53
- (strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
54
- default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
55
- }
56
- }
57
-
58
-
59
- function checkDataTypes(dataTypes, data, strictNumbers) {
60
- switch (dataTypes.length) {
61
- case 1: return checkDataType(dataTypes[0], data, strictNumbers, true);
62
- default:
63
- var code = '';
64
- var types = toHash(dataTypes);
65
- if (types.array && types.object) {
66
- code = types.null ? '(': '(!' + data + ' || ';
67
- code += 'typeof ' + data + ' !== "object")';
68
- delete types.null;
69
- delete types.array;
70
- delete types.object;
71
- }
72
- if (types.number) delete types.integer;
73
- for (var t in types)
74
- code += (code ? ' && ' : '' ) + checkDataType(t, data, strictNumbers, true);
75
-
76
- return code;
77
- }
78
- }
79
-
80
-
81
- var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]);
82
- function coerceToTypes(optionCoerceTypes, dataTypes) {
83
- if (Array.isArray(dataTypes)) {
84
- var types = [];
85
- for (var i=0; i<dataTypes.length; i++) {
86
- var t = dataTypes[i];
87
- if (COERCE_TO_TYPES[t]) types[types.length] = t;
88
- else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
89
- }
90
- if (types.length) return types;
91
- } else if (COERCE_TO_TYPES[dataTypes]) {
92
- return [dataTypes];
93
- } else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
94
- return ['array'];
95
- }
96
- }
97
-
98
-
99
- function toHash(arr) {
100
- var hash = {};
101
- for (var i=0; i<arr.length; i++) hash[arr[i]] = true;
102
- return hash;
103
- }
104
-
105
-
106
- var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
107
- var SINGLE_QUOTE = /'|\\/g;
108
- function getProperty(key) {
109
- return typeof key == 'number'
110
- ? '[' + key + ']'
111
- : IDENTIFIER.test(key)
112
- ? '.' + key
113
- : "['" + escapeQuotes(key) + "']";
114
- }
115
-
116
-
117
- function escapeQuotes(str) {
118
- return str.replace(SINGLE_QUOTE, '\\$&')
119
- .replace(/\n/g, '\\n')
120
- .replace(/\r/g, '\\r')
121
- .replace(/\f/g, '\\f')
122
- .replace(/\t/g, '\\t');
123
- }
124
-
125
-
126
- function varOccurences(str, dataVar) {
127
- dataVar += '[^0-9]';
128
- var matches = str.match(new RegExp(dataVar, 'g'));
129
- return matches ? matches.length : 0;
130
- }
131
-
132
-
133
- function varReplace(str, dataVar, expr) {
134
- dataVar += '([^0-9])';
135
- expr = expr.replace(/\$/g, '$$$$');
136
- return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
137
- }
138
-
139
-
140
- function schemaHasRules(schema, rules) {
141
- if (typeof schema == 'boolean') return !schema;
142
- for (var key in schema) if (rules[key]) return true;
143
- }
144
-
145
-
146
- function schemaHasRulesExcept(schema, rules, exceptKeyword) {
147
- if (typeof schema == 'boolean') return !schema && exceptKeyword != 'not';
148
- for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
149
- }
150
-
151
-
152
- function schemaUnknownRules(schema, rules) {
153
- if (typeof schema == 'boolean') return;
154
- for (var key in schema) if (!rules[key]) return key;
155
- }
156
-
157
-
158
- function toQuotedString(str) {
159
- return '\'' + escapeQuotes(str) + '\'';
160
- }
161
-
162
-
163
- function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
164
- var path = jsonPointers // false by default
165
- ? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')')
166
- : (isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'');
167
- return joinPaths(currentPath, path);
168
- }
169
-
170
-
171
- function getPath(currentPath, prop, jsonPointers) {
172
- var path = jsonPointers // false by default
173
- ? toQuotedString('/' + escapeJsonPointer(prop))
174
- : toQuotedString(getProperty(prop));
175
- return joinPaths(currentPath, path);
176
- }
177
-
178
-
179
- var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
180
- var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
181
- function getData($data, lvl, paths) {
182
- var up, jsonPointer, data, matches;
183
- if ($data === '') return 'rootData';
184
- if ($data[0] == '/') {
185
- if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
186
- jsonPointer = $data;
187
- data = 'rootData';
188
- } else {
189
- matches = $data.match(RELATIVE_JSON_POINTER);
190
- if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
191
- up = +matches[1];
192
- jsonPointer = matches[2];
193
- if (jsonPointer == '#') {
194
- if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
195
- return paths[lvl - up];
196
- }
197
-
198
- if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
199
- data = 'data' + ((lvl - up) || '');
200
- if (!jsonPointer) return data;
201
- }
202
-
203
- var expr = data;
204
- var segments = jsonPointer.split('/');
205
- for (var i=0; i<segments.length; i++) {
206
- var segment = segments[i];
207
- if (segment) {
208
- data += getProperty(unescapeJsonPointer(segment));
209
- expr += ' && ' + data;
210
- }
211
- }
212
- return expr;
213
- }
214
-
215
-
216
- function joinPaths (a, b) {
217
- if (a == '""') return b;
218
- return (a + ' + ' + b).replace(/([^\\])' \+ '/g, '$1');
219
- }
220
-
221
-
222
- function unescapeFragment(str) {
223
- return unescapeJsonPointer(decodeURIComponent(str));
224
- }
225
-
226
-
227
- function escapeFragment(str) {
228
- return encodeURIComponent(escapeJsonPointer(str));
229
- }
230
-
231
-
232
- function escapeJsonPointer(str) {
233
- return str.replace(/~/g, '~0').replace(/\//g, '~1');
234
- }
235
-
236
-
237
- function unescapeJsonPointer(str) {
238
- return str.replace(/~1/g, '/').replace(/~0/g, '~');
239
- }
@@ -1,49 +0,0 @@
1
- 'use strict';
2
-
3
- var KEYWORDS = [
4
- 'multipleOf',
5
- 'maximum',
6
- 'exclusiveMaximum',
7
- 'minimum',
8
- 'exclusiveMinimum',
9
- 'maxLength',
10
- 'minLength',
11
- 'pattern',
12
- 'additionalItems',
13
- 'maxItems',
14
- 'minItems',
15
- 'uniqueItems',
16
- 'maxProperties',
17
- 'minProperties',
18
- 'required',
19
- 'additionalProperties',
20
- 'enum',
21
- 'format',
22
- 'const'
23
- ];
24
-
25
- module.exports = function (metaSchema, keywordsJsonPointers) {
26
- for (var i=0; i<keywordsJsonPointers.length; i++) {
27
- metaSchema = JSON.parse(JSON.stringify(metaSchema));
28
- var segments = keywordsJsonPointers[i].split('/');
29
- var keywords = metaSchema;
30
- var j;
31
- for (j=1; j<segments.length; j++)
32
- keywords = keywords[segments[j]];
33
-
34
- for (j=0; j<KEYWORDS.length; j++) {
35
- var key = KEYWORDS[j];
36
- var schema = keywords[key];
37
- if (schema) {
38
- keywords[key] = {
39
- anyOf: [
40
- schema,
41
- { $ref: 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
42
- ]
43
- };
44
- }
45
- }
46
- }
47
-
48
- return metaSchema;
49
- };
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- var metaSchema = require('./refs/json-schema-draft-07.json');
4
-
5
- module.exports = {
6
- $id: 'https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js',
7
- definitions: {
8
- simpleTypes: metaSchema.definitions.simpleTypes
9
- },
10
- type: 'object',
11
- dependencies: {
12
- schema: ['validate'],
13
- $data: ['validate'],
14
- statements: ['inline'],
15
- valid: {not: {required: ['macro']}}
16
- },
17
- properties: {
18
- type: metaSchema.properties.type,
19
- schema: {type: 'boolean'},
20
- statements: {type: 'boolean'},
21
- dependencies: {
22
- type: 'array',
23
- items: {type: 'string'}
24
- },
25
- metaSchema: {type: 'object'},
26
- modifying: {type: 'boolean'},
27
- valid: {type: 'boolean'},
28
- $data: {type: 'boolean'},
29
- async: {type: 'boolean'},
30
- errors: {
31
- anyOf: [
32
- {type: 'boolean'},
33
- {const: 'full'}
34
- ]
35
- }
36
- }
37
- };