@wix/validation-rules 0.0.0-stage → 0.5.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 CHANGED
@@ -1,3 +1,75 @@
1
- # Temporary Holding Version
1
+ # @wix/validation-rules
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ One site validator combining all team rule packages, run by `@wix/validation-infra`.
4
+ Published to npm. Its build bundles the four private team packages into `dist/index.js`; `@wix/validation-infra` and the teams' npm dependencies stay external.
5
+ When a team package adds an npm dependency, add it to this package's `dependencies` and to an `--external` in its `build` script.
6
+ Its build first builds infra and all four team workspaces, so CI can build this workspace without existing dependency declarations.
7
+
8
+ ```ts
9
+ import { validate } from '@wix/validation-rules'
10
+ const problems = validate({ files, editor: 'studio2' })
11
+ // → { rule, check, severity, file, line, column, message }[]
12
+ ```
13
+
14
+ `files` maps site-relative paths to text. Optional `only`, `catalog`, `fonts` and `onEvent` inputs are the same as the
15
+ infra runner's. Project rules run before page rules. Exported `RULES` lists every included rule. Parse problems have
16
+ rule `parse`; crashes have check `CRASHED` and error severity (`PAGE_RULES` identifies page crashes).
17
+
18
+ Pass `scope` to run the rules of one kind only: `'project'` (the project rules), `'site-code'` (the site-code rules) or
19
+ `'page'` (the page rules: every rule whose `scope` is neither). All three run when it is left out, project rules first,
20
+ then site-code rules, then the pages. No team package has a site-code rule yet. A caller that runs passes, like
21
+ origami-lint (the project rules on the whole site, then the page rules on the changed pages, each with its own BI step),
22
+ calls `validate` once per pass:
23
+
24
+ ```ts
25
+ const projectProblems = validate({ files, editor, scope: 'project' })
26
+ const pageProblems = validate({ files, editor, scope: 'page', only: changedPages })
27
+ ```
28
+
29
+ So that such a caller depends on this package alone, it also re-exports from `@wix/validation-infra` the values
30
+ `COMPONENT_CATALOG_FILE`, `CRASHED`, `DIRECTIVE`, `findPages`, `GLOBAL_COMPONENTS_FOLDER`, `PAGE_RULES`, `SITE_CODE`,
31
+ `SITE_PACKAGE_JSON` and `THEME_FILE`, and the types `AnyRule`, `CompanionKinds`, `ComponentCatalog`, `Editor`, `Files`, `FontCatalog`,
32
+ `Problem` and `ValidateEvent`.
33
+
34
+ `RULES` includes the complete lists from `@wix/lint-dm`, `@wix/lint-origami`, `@wix/lint-studio` and
35
+ `@wix/lint-thunderbolt`: 41 distinct rule names. Shared rule names intentionally appear
36
+ more than once, with different checks owned by different packages.
37
+
38
+ Pass `packageFiles` for the installed wrappers' contracts, definitions and package manifests, and InternalContainer's
39
+ contract from `@wix/origami-system-components`: each file's text by its path from the site root
40
+ (`node_modules/@origami-wrappers/<app>/package.json`, `…/<name>/component-contract.json`), next to `files`. The library
41
+ reads no disk itself, so a caller on the site's machine reads them first and a service is sent them; which files, and
42
+ how they are found: [the infra README](../validation-infra/README.md#package-files). Without them,
43
+ `style-properties-allowed` reports `wrapper_not_installed` on every wrapper tag and the contract checks cannot run.
44
+
45
+ ```ts
46
+ validate({ files, packageFiles })
47
+ ```
48
+
49
+ Pass `experimentalPopups: true` to enable `pages-context`, matching origami-lint's `ORIGAMI_EXPERIMENTAL_POPUPS=1`.
50
+ The default is false; the library never reads the environment. `pages-context` reuses `@wix/origami-types` 2.0's checks.
51
+
52
+ ## Synced with Origami
53
+
54
+ `RULES` matches origami-lint at Origami master commit `35e1cbe1` (2026-11-17 17:45 +02:00, #700): every rule and check
55
+ there, with the same severity and editors. The last port took every origami-lint change in `d6e07b54..35e1cbe1`:
56
+ `76488285` (#919, style-properties-allowed finds a nested component as the build resolves it: its classes in any order, a
57
+ child combinator, not a sibling; origami-transforms' element-match is copied into validation-infra, as it isn't published
58
+ yet) and `35e1cbe1` (#700, data-values `duplicate_data_id` and `invalid_background_color`, and data-values-notes, warnings:
59
+ `null_image`, `duplicate_rich_text_id`, `duplicate_image_id`, `background_ref_id`, `video_poster_ref`; the rules were here
60
+ from an earlier draft, and this port adds the merged fixes and the tests). The next sync starts from the origami-lint
61
+ commits after `35e1cbe1`.
62
+
63
+ ## Ownership
64
+
65
+ All rule implementations and tests live in `@wix/lint-dm`, `@wix/lint-origami`, `@wix/lint-studio` or
66
+ `@wix/lint-thunderbolt`. This package combines their lists and exposes `validate`, `RULES` and the consumer types.
67
+ It has no local shared-rule list. Add a team package as a devDependency, import its public `RULES` list in
68
+ `src/constants.ts`, and spread that list whole.
69
+
70
+ Two teams may own different checks of a rule with the same name and scope. Each part keeps its own callbacks,
71
+ severity and editors; all problems show the common rule name. Check keys must differ between parts.
72
+
73
+ `yarn test:package` checks independent typed team packages, including parts of a rule sharing one name.
74
+ It also installs the actual production validator and all four team tarballs outside the workspace and runs every
75
+ registered rule. The combined validator and team packages remain private; these tarballs are temporary test artifacts.
@@ -0,0 +1,2 @@
1
+ import type { AnyRule } from '@wix/validation-infra';
2
+ export declare const RULES: readonly AnyRule[];
@@ -0,0 +1,5 @@
1
+ export { validate } from './validate.ts';
2
+ export { RULES } from './constants.ts';
3
+ export type { ValidateInput } from './types.ts';
4
+ export { COMPONENT_CATALOG_FILE, CRASHED, DIRECTIVE, findPages, GLOBAL_COMPONENTS_FOLDER, PAGE_RULES, SITE_CODE, SITE_PACKAGE_JSON, THEME_FILE } from '@wix/validation-infra';
5
+ export type { AnyRule, CompanionKinds, ComponentCatalog, Editor, Files, FontCatalog, Problem, ValidateEvent } from '@wix/validation-infra';