Package Exports
- @formspec/eslint-plugin
- @formspec/eslint-plugin/base
Readme
@formspec/eslint-plugin
ESLint rules for FormSpec TSDoc tags and Chain DSL usage.
Install
pnpm add -D @formspec/eslint-plugin @typescript-eslint/parser eslintFlat Config
Recommended
import formspec from "@formspec/eslint-plugin";
export default [...formspec.configs.recommended];Strict
import formspec from "@formspec/eslint-plugin";
export default [...formspec.configs.strict];Manual
import formspec from "@formspec/eslint-plugin";
export default [
{
plugins: {
"@formspec": formspec,
},
rules: {
"@formspec/tag-recognition/no-unknown-tags": "warn",
"@formspec/tag-recognition/require-tag-arguments": "error",
"@formspec/value-parsing/valid-numeric-value": "error",
"@formspec/type-compatibility/tag-type-check": "error",
"@formspec/target-resolution/valid-path-target": "error",
"@formspec/constraint-validation/no-contradictions": "error",
},
},
];Keeping Docs Current
pnpm --filter @formspec/eslint-plugin run fix:eslint-docs
pnpm --filter @formspec/eslint-plugin run check:eslint-docsRule Groups
Tag Recognition
tag-recognition/no-unknown-tagstag-recognition/require-tag-argumentstag-recognition/no-disabled-tags
Value Parsing
value-parsing/valid-numeric-valuevalue-parsing/valid-integer-valuevalue-parsing/valid-regex-patternvalue-parsing/valid-json-value
Type Compatibility
type-compatibility/tag-type-check
Target Resolution
target-resolution/valid-path-targettarget-resolution/valid-member-targettarget-resolution/no-unsupported-targetingtarget-resolution/no-member-target-on-object
Constraint Validation
constraint-validation/no-contradictionsconstraint-validation/no-duplicate-tagsconstraint-validation/no-description-conflictconstraint-validation/no-contradictory-rules
.formspec.yml Capability Rules
constraints-allowed-field-typesconstraints-allowed-layouts
Rules
💼 Configurations enabled in.
⚠️ Configurations set to warn in.
✅ Set in the recommended configuration.
🔒 Set in the strict configuration.
| Name | Description | 💼 | ⚠️ |
|---|---|---|---|
| constraint-validation/no-contradictions | Reports contradictory FormSpec constraint combinations | ✅ 🔒 | |
| constraint-validation/no-contradictory-rules | Reports contradictory FormSpec conditional rules on the same behavioral axis | ✅ 🔒 | |
| constraint-validation/no-description-conflict | Reports conflicting @description and @remarks tags on the same field | 🔒 | ✅ |
| constraint-validation/no-duplicate-tags | Reports duplicate FormSpec tags on the same field target | 🔒 | ✅ |
| constraints-allowed-field-types | Validates that field types are allowed by the project's constraints | ||
| constraints-allowed-layouts | Validates that layout constructs (group, conditionals) are allowed by the project's constraints | ||
| tag-recognition/no-disabled-tags | Reports FormSpec tags disabled by project configuration | 🔒 | ✅ |
| tag-recognition/no-unknown-tags | Reports FormSpec tags that are not part of the specification | 🔒 | ✅ |
| tag-recognition/require-tag-arguments | Requires arguments for FormSpec tags that need values | ✅ 🔒 | |
| target-resolution/no-member-target-on-object | Disallows member-target syntax on non-string-literal-union fields | ✅ 🔒 | |
| target-resolution/no-unsupported-targeting | Disallows path or member target syntax on tags that do not support it | ✅ 🔒 | |
| target-resolution/valid-member-target | Validates member-target references against string literal union fields | ✅ 🔒 | |
| target-resolution/valid-path-target | Validates path-target references against the resolved field type | ✅ 🔒 | |
| type-compatibility/tag-type-check | Ensures FormSpec tags are applied to compatible field types | ✅ 🔒 | |
| value-parsing/valid-integer-value | Validates integer-valued FormSpec tags | ✅ 🔒 | |
| value-parsing/valid-json-value | Validates JSON-valued FormSpec tags | ✅ 🔒 | |
| value-parsing/valid-numeric-value | Validates numeric-valued FormSpec tags | ✅ 🔒 | |
| value-parsing/valid-regex-pattern | Validates @pattern tag values as regular expressions | ✅ 🔒 |
Example
class Example {
/** @minimum 0 */
age!: number;
/** @uniqueItems */
tags!: string[];
}The plugin validates tag names, argument syntax, target paths, and type compatibility before your build gets to static schema generation.
License
UNLICENSED