@amritk/lint 0.3.2 → 0.3.3

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 (72) hide show
  1. package/dist/core/document.js +12 -10
  2. package/dist/core/formats.js +10 -13
  3. package/dist/core/glob.js +96 -118
  4. package/dist/core/index.js +31 -11
  5. package/dist/core/jsonpath.js +487 -561
  6. package/dist/core/lint.js +78 -85
  7. package/dist/core/plugin.js +21 -29
  8. package/dist/core/pointers.js +107 -151
  9. package/dist/core/ruleset.js +0 -0
  10. package/dist/core/runner.js +214 -272
  11. package/dist/core/types.js +4 -1
  12. package/dist/core/validate-ruleset.js +98 -112
  13. package/dist/fix/apply.js +58 -96
  14. package/dist/fix/index.js +7 -2
  15. package/dist/fix/plugin.js +15 -20
  16. package/dist/functions/alphabetical.js +39 -50
  17. package/dist/functions/casing.js +39 -45
  18. package/dist/functions/defined.js +7 -5
  19. package/dist/functions/enumeration.js +15 -25
  20. package/dist/functions/falsy.js +7 -5
  21. package/dist/functions/index.js +60 -44
  22. package/dist/functions/length.js +22 -32
  23. package/dist/functions/or.js +18 -24
  24. package/dist/functions/pattern.js +39 -49
  25. package/dist/functions/schema.js +93 -119
  26. package/dist/functions/truthy.js +7 -5
  27. package/dist/functions/typed-enum.js +33 -36
  28. package/dist/functions/undefined.js +7 -8
  29. package/dist/functions/unreferenced-reusable-object.js +35 -47
  30. package/dist/functions/xor.js +13 -16
  31. package/dist/index.js +114 -164
  32. package/dist/parsers/edit-model.js +316 -444
  33. package/dist/parsers/index.js +22 -19
  34. package/dist/parsers/json.js +39 -37
  35. package/dist/parsers/lines.js +23 -26
  36. package/dist/parsers/types.js +9 -7
  37. package/dist/parsers/yaml.js +137 -204
  38. package/dist/rules/openapi/fixers.js +166 -221
  39. package/dist/rules/openapi/formats.js +26 -27
  40. package/dist/rules/openapi/functions/example-validation.js +98 -138
  41. package/dist/rules/openapi/functions/helpers.js +8 -10
  42. package/dist/rules/openapi/functions/index.js +98 -72
  43. package/dist/rules/openapi/functions/oas-additional-operations.js +16 -22
  44. package/dist/rules/openapi/functions/oas-discriminator.js +24 -22
  45. package/dist/rules/openapi/functions/oas-example-external-value.js +13 -21
  46. package/dist/rules/openapi/functions/oas-example-value.js +24 -27
  47. package/dist/rules/openapi/functions/oas-mutually-exclusive.js +15 -19
  48. package/dist/rules/openapi/functions/oas-no-nullable.js +13 -21
  49. package/dist/rules/openapi/functions/oas-op-form-data-consume-check.js +21 -19
  50. package/dist/rules/openapi/functions/oas-op-id-unique.js +27 -27
  51. package/dist/rules/openapi/functions/oas-op-params.js +36 -42
  52. package/dist/rules/openapi/functions/oas-op-security-defined.js +40 -39
  53. package/dist/rules/openapi/functions/oas-op-success-response.js +11 -13
  54. package/dist/rules/openapi/functions/oas-path-param.js +75 -96
  55. package/dist/rules/openapi/functions/oas-schema-example-deprecated.js +33 -40
  56. package/dist/rules/openapi/functions/oas-schema.js +9 -14
  57. package/dist/rules/openapi/functions/oas-server-name-unique.js +21 -19
  58. package/dist/rules/openapi/functions/oas-server-variables.js +45 -49
  59. package/dist/rules/openapi/functions/oas-tag-defined.js +20 -20
  60. package/dist/rules/openapi/functions/oas-tag-kind.js +16 -16
  61. package/dist/rules/openapi/functions/oas-tag-parent-defined.js +40 -43
  62. package/dist/rules/openapi/functions/oas-tags-unique.js +18 -16
  63. package/dist/rules/openapi/functions/oas-unused-component.js +48 -58
  64. package/dist/rules/openapi/functions/ref-siblings.js +13 -11
  65. package/dist/rules/openapi/index.js +99 -117
  66. package/dist/rules/openapi/oas.js +524 -536
  67. package/dist/rules/openapi/schemas/index.js +17 -33
  68. package/dist/rules/openapi/schemas/oas20.json +1 -1592
  69. package/dist/rules/openapi/schemas/oas30.json +1 -1651
  70. package/dist/rules/openapi/schemas/oas31.json +1 -1412
  71. package/dist/rules/openapi/schemas/oas32.json +1 -1684
  72. package/package.json +5 -5
@@ -1,36 +1,20 @@
1
- import { createRequire } from 'node:module';
2
- // The OpenAPI structural meta-schemas are the official JSON Schema documents
3
- // from spec.openapis.org, kept as raw `.json` files in this directory (see
4
- // `README.md` for the exact source URLs, dates, and the one adaptation the 2.0
5
- // schema needs). They are loaded with `require` rather than a static JSON import
6
- // so the emitted ESM stays valid without an import attribute, and the build
7
- // copies the `.json` files next to the compiled output. 3.1/3.2 express Schema
8
- // Objects as JSON Schema 2020-12 via a local `$dynamicRef`, which
9
- // @amritk/runtime-validators resolves natively — no bundling, no dialect engine.
10
- //
11
- // Loading is lazy and per-version: nothing is read until `loadOasSchema` is
12
- // called for a given version (which the `oasSchema` rule function only does for
13
- // the document's own OpenAPI version, since each `*-schema` rule is format-gated
14
- // to a single version). Linting a 3.1 document therefore never reads the 2.0 /
15
- // 3.0 / 3.2 schema files.
16
- const require = createRequire(import.meta.url);
1
+ import { createRequire } from "node:module";
2
+ const require2 = createRequire(import.meta.url);
17
3
  const SCHEMA_FILES = {
18
- '2.0': './oas20.json',
19
- '3.0': './oas30.json',
20
- '3.1': './oas31.json',
21
- '3.2': './oas32.json',
4
+ "2.0": "./oas20.json",
5
+ "3.0": "./oas30.json",
6
+ "3.1": "./oas31.json",
7
+ "3.2": "./oas32.json"
22
8
  };
23
- const cache = new Map();
24
- /**
25
- * Lazily loads (and memoizes) the official structural meta-schema for one
26
- * OpenAPI version. The returned object is stable across calls, so downstream
27
- * validator caches (keyed by schema identity) stay warm.
28
- */
29
- export const loadOasSchema = (version) => {
30
- let schema = cache.get(version);
31
- if (!schema) {
32
- schema = require(SCHEMA_FILES[version]);
33
- cache.set(version, schema);
34
- }
35
- return schema;
9
+ const cache = /* @__PURE__ */ new Map();
10
+ const loadOasSchema = (version) => {
11
+ let schema = cache.get(version);
12
+ if (!schema) {
13
+ schema = require2(SCHEMA_FILES[version]);
14
+ cache.set(version, schema);
15
+ }
16
+ return schema;
17
+ };
18
+ export {
19
+ loadOasSchema
36
20
  };