@herb-tools/linter 0.8.9 → 0.9.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.
- package/README.md +5 -5
- package/dist/{src/cli → cli}/argument-parser.js +15 -2
- package/dist/cli/argument-parser.js.map +1 -0
- package/dist/{src/cli → cli}/file-processor.js +155 -9
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/file-url.js +6 -0
- package/dist/cli/file-url.js.map +1 -0
- package/dist/cli/formatters/base-formatter.js.map +1 -0
- package/dist/{src/cli → cli}/formatters/detailed-formatter.js +16 -19
- package/dist/cli/formatters/detailed-formatter.js.map +1 -0
- package/dist/cli/formatters/github-actions-formatter.js.map +1 -0
- package/dist/cli/formatters/index.js.map +1 -0
- package/dist/cli/formatters/json-formatter.js.map +1 -0
- package/dist/cli/formatters/simple-formatter.js +54 -0
- package/dist/cli/formatters/simple-formatter.js.map +1 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/lint-worker.js +143 -0
- package/dist/cli/lint-worker.js.map +1 -0
- package/dist/cli/output-manager.js.map +1 -0
- package/dist/{src/cli → cli}/summary-reporter.js +13 -16
- package/dist/cli/summary-reporter.js.map +1 -0
- package/dist/{src/cli.js → cli.js} +5 -3
- package/dist/cli.js.map +1 -0
- package/dist/{src/custom-rule-loader.js → custom-rule-loader.js} +20 -4
- package/dist/custom-rule-loader.js.map +1 -0
- package/dist/herb-disable-comment-utils.js.map +1 -0
- package/dist/herb-lint.js +60648 -17513
- package/dist/herb-lint.js.map +1 -1
- package/dist/index.cjs +2621 -934
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2554 -873
- package/dist/index.js.map +1 -1
- package/dist/lint-worker.js +71462 -0
- package/dist/lint-worker.js.map +1 -0
- package/dist/linter-ignore.js.map +1 -0
- package/dist/{src/linter.js → linter.js} +89 -74
- package/dist/linter.js.map +1 -0
- package/dist/loader.cjs +31206 -7834
- package/dist/loader.cjs.map +1 -1
- package/dist/loader.js +31168 -7802
- package/dist/loader.js.map +1 -1
- package/dist/parse-cache.js +30 -0
- package/dist/parse-cache.js.map +1 -0
- package/dist/rules/actionview-no-silent-helper.js +45 -0
- package/dist/rules/actionview-no-silent-helper.js.map +1 -0
- package/dist/{src/rules → rules}/erb-comment-syntax.js +2 -2
- package/dist/rules/erb-comment-syntax.js.map +1 -0
- package/dist/{src/rules → rules}/erb-no-case-node-children.js +2 -2
- package/dist/rules/erb-no-case-node-children.js.map +1 -0
- package/dist/rules/erb-no-conditional-html-element.js +38 -0
- package/dist/rules/erb-no-conditional-html-element.js.map +1 -0
- package/dist/rules/erb-no-conditional-open-tag.js +24 -0
- package/dist/rules/erb-no-conditional-open-tag.js.map +1 -0
- package/dist/rules/erb-no-duplicate-branch-elements.js +245 -0
- package/dist/rules/erb-no-duplicate-branch-elements.js.map +1 -0
- package/dist/{src/rules → rules}/erb-no-empty-tags.js +2 -2
- package/dist/rules/erb-no-empty-tags.js.map +1 -0
- package/dist/{src/rules → rules}/erb-no-extra-newline.js +4 -21
- package/dist/rules/erb-no-extra-newline.js.map +1 -0
- package/dist/{src/rules → rules}/erb-no-extra-whitespace-inside-tags.js +39 -13
- package/dist/rules/erb-no-extra-whitespace-inside-tags.js.map +1 -0
- package/dist/rules/erb-no-inline-case-conditions.js +40 -0
- package/dist/rules/erb-no-inline-case-conditions.js.map +1 -0
- package/dist/rules/erb-no-instance-variables-in-partials.js +67 -0
- package/dist/rules/erb-no-instance-variables-in-partials.js.map +1 -0
- package/dist/rules/erb-no-interpolated-class-names.js +47 -0
- package/dist/rules/erb-no-interpolated-class-names.js.map +1 -0
- package/dist/rules/erb-no-javascript-tag-helper.js +34 -0
- package/dist/rules/erb-no-javascript-tag-helper.js.map +1 -0
- package/dist/{src/rules → rules}/erb-no-output-control-flow.js +9 -12
- package/dist/rules/erb-no-output-control-flow.js.map +1 -0
- package/dist/rules/erb-no-output-in-attribute-name.js +30 -0
- package/dist/rules/erb-no-output-in-attribute-name.js.map +1 -0
- package/dist/rules/erb-no-output-in-attribute-position.js +30 -0
- package/dist/rules/erb-no-output-in-attribute-position.js.map +1 -0
- package/dist/rules/erb-no-raw-output-in-attribute-value.js +35 -0
- package/dist/rules/erb-no-raw-output-in-attribute-value.js.map +1 -0
- package/dist/{src/rules → rules}/erb-no-silent-tag-in-attribute-name.js +2 -2
- package/dist/rules/erb-no-silent-tag-in-attribute-name.js.map +1 -0
- package/dist/rules/erb-no-statement-in-script.js +58 -0
- package/dist/rules/erb-no-statement-in-script.js.map +1 -0
- package/dist/rules/erb-no-then-in-control-flow.js +45 -0
- package/dist/rules/erb-no-then-in-control-flow.js.map +1 -0
- package/dist/rules/erb-no-trailing-whitespace.js +138 -0
- package/dist/rules/erb-no-trailing-whitespace.js.map +1 -0
- package/dist/rules/erb-no-unsafe-js-attribute.js +36 -0
- package/dist/rules/erb-no-unsafe-js-attribute.js.map +1 -0
- package/dist/rules/erb-no-unsafe-raw.js +63 -0
- package/dist/rules/erb-no-unsafe-raw.js.map +1 -0
- package/dist/rules/erb-no-unsafe-script-interpolation.js +54 -0
- package/dist/rules/erb-no-unsafe-script-interpolation.js.map +1 -0
- package/dist/{src/rules → rules}/erb-prefer-image-tag-helper.js +5 -4
- package/dist/rules/erb-prefer-image-tag-helper.js.map +1 -0
- package/dist/{src/rules → rules}/erb-require-trailing-newline.js +2 -2
- package/dist/rules/erb-require-trailing-newline.js.map +1 -0
- package/dist/{src/rules → rules}/erb-require-whitespace-inside-tags.js +39 -15
- package/dist/rules/erb-require-whitespace-inside-tags.js.map +1 -0
- package/dist/{src/rules → rules}/erb-right-trim.js +2 -2
- package/dist/rules/erb-right-trim.js.map +1 -0
- package/dist/{src/rules → rules}/erb-strict-locals-comment-syntax.js +5 -5
- package/dist/rules/erb-strict-locals-comment-syntax.js.map +1 -0
- package/dist/{src/rules → rules}/erb-strict-locals-required.js +2 -2
- package/dist/rules/erb-strict-locals-required.js.map +1 -0
- package/dist/rules/file-utils.js.map +1 -0
- package/dist/rules/herb-disable-comment-base.js.map +1 -0
- package/dist/{src/rules → rules}/herb-disable-comment-malformed.js +2 -2
- package/dist/rules/herb-disable-comment-malformed.js.map +1 -0
- package/dist/{src/rules → rules}/herb-disable-comment-missing-rules.js +2 -2
- package/dist/rules/herb-disable-comment-missing-rules.js.map +1 -0
- package/dist/{src/rules → rules}/herb-disable-comment-no-duplicate-rules.js +2 -2
- package/dist/rules/herb-disable-comment-no-duplicate-rules.js.map +1 -0
- package/dist/{src/rules → rules}/herb-disable-comment-no-redundant-all.js +2 -2
- package/dist/rules/herb-disable-comment-no-redundant-all.js.map +1 -0
- package/dist/{src/rules → rules}/herb-disable-comment-unnecessary.js +2 -2
- package/dist/rules/herb-disable-comment-unnecessary.js.map +1 -0
- package/dist/{src/rules → rules}/herb-disable-comment-valid-rule-name.js +2 -2
- package/dist/rules/herb-disable-comment-valid-rule-name.js.map +1 -0
- package/dist/rules/html-allowed-script-type.js +57 -0
- package/dist/rules/html-allowed-script-type.js.map +1 -0
- package/dist/rules/html-anchor-require-href.js +68 -0
- package/dist/rules/html-anchor-require-href.js.map +1 -0
- package/dist/{src/rules → rules}/html-aria-attribute-must-be-valid.js +3 -3
- package/dist/rules/html-aria-attribute-must-be-valid.js.map +1 -0
- package/dist/{src/rules → rules}/html-aria-label-is-well-formatted.js +3 -3
- package/dist/rules/html-aria-label-is-well-formatted.js.map +1 -0
- package/dist/{src/rules → rules}/html-aria-level-must-be-valid.js +3 -3
- package/dist/rules/html-aria-level-must-be-valid.js.map +1 -0
- package/dist/{src/rules → rules}/html-aria-role-heading-requires-level.js +5 -4
- package/dist/rules/html-aria-role-heading-requires-level.js.map +1 -0
- package/dist/{src/rules → rules}/html-aria-role-must-be-valid.js +3 -3
- package/dist/rules/html-aria-role-must-be-valid.js.map +1 -0
- package/dist/{src/rules → rules}/html-attribute-double-quotes.js +4 -4
- package/dist/rules/html-attribute-double-quotes.js.map +1 -0
- package/dist/{src/rules → rules}/html-attribute-equals-spacing.js +2 -2
- package/dist/rules/html-attribute-equals-spacing.js.map +1 -0
- package/dist/{src/rules → rules}/html-attribute-values-require-quotes.js +2 -2
- package/dist/rules/html-attribute-values-require-quotes.js.map +1 -0
- package/dist/{src/rules → rules}/html-avoid-both-disabled-and-aria-disabled.js +9 -9
- package/dist/rules/html-avoid-both-disabled-and-aria-disabled.js.map +1 -0
- package/dist/{src/rules → rules}/html-body-only-elements.js +5 -4
- package/dist/rules/html-body-only-elements.js.map +1 -0
- package/dist/{src/rules → rules}/html-boolean-attributes-no-value.js +4 -3
- package/dist/rules/html-boolean-attributes-no-value.js.map +1 -0
- package/dist/rules/html-details-has-summary.js +52 -0
- package/dist/rules/html-details-has-summary.js.map +1 -0
- package/dist/{src/rules → rules}/html-head-only-elements.js +6 -5
- package/dist/rules/html-head-only-elements.js.map +1 -0
- package/dist/{src/rules → rules}/html-iframe-has-title.js +8 -11
- package/dist/rules/html-iframe-has-title.js.map +1 -0
- package/dist/{src/rules → rules}/html-img-require-alt.js +11 -5
- package/dist/rules/html-img-require-alt.js.map +1 -0
- package/dist/{src/rules → rules}/html-input-require-autocomplete.js +7 -10
- package/dist/rules/html-input-require-autocomplete.js.map +1 -0
- package/dist/{src/rules → rules}/html-navigation-has-label.js +6 -5
- package/dist/rules/html-navigation-has-label.js.map +1 -0
- package/dist/rules/html-no-abstract-roles.js +29 -0
- package/dist/rules/html-no-abstract-roles.js.map +1 -0
- package/dist/rules/html-no-aria-hidden-on-body.js +42 -0
- package/dist/rules/html-no-aria-hidden-on-body.js.map +1 -0
- package/dist/{src/rules → rules}/html-no-aria-hidden-on-focusable.js +6 -5
- package/dist/rules/html-no-aria-hidden-on-focusable.js.map +1 -0
- package/dist/{src/rules → rules}/html-no-block-inside-inline.js +6 -9
- package/dist/rules/html-no-block-inside-inline.js.map +1 -0
- package/dist/{src/rules → rules}/html-no-duplicate-attributes.js +4 -3
- package/dist/rules/html-no-duplicate-attributes.js.map +1 -0
- package/dist/{src/rules → rules}/html-no-duplicate-ids.js +14 -11
- package/dist/rules/html-no-duplicate-ids.js.map +1 -0
- package/dist/{src/rules → rules}/html-no-duplicate-meta-names.js +22 -20
- package/dist/rules/html-no-duplicate-meta-names.js.map +1 -0
- package/dist/{src/rules → rules}/html-no-empty-attributes.js +2 -2
- package/dist/rules/html-no-empty-attributes.js.map +1 -0
- package/dist/rules/html-no-empty-headings.js +98 -0
- package/dist/rules/html-no-empty-headings.js.map +1 -0
- package/dist/{src/rules → rules}/html-no-nested-links.js +23 -15
- package/dist/rules/html-no-nested-links.js.map +1 -0
- package/dist/{src/rules → rules}/html-no-positive-tab-index.js +3 -3
- package/dist/rules/html-no-positive-tab-index.js.map +1 -0
- package/dist/{src/rules → rules}/html-no-self-closing.js +4 -4
- package/dist/rules/html-no-self-closing.js.map +1 -0
- package/dist/{src/rules → rules}/html-no-space-in-tag.js +4 -6
- package/dist/rules/html-no-space-in-tag.js.map +1 -0
- package/dist/{src/rules → rules}/html-no-title-attribute.js +6 -5
- package/dist/rules/html-no-title-attribute.js.map +1 -0
- package/dist/{src/rules → rules}/html-no-underscores-in-attribute-names.js +2 -2
- package/dist/rules/html-no-underscores-in-attribute-names.js.map +1 -0
- package/dist/rules/html-require-closing-tags.js +29 -0
- package/dist/rules/html-require-closing-tags.js.map +1 -0
- package/dist/{src/rules → rules}/html-tag-name-lowercase.js +13 -9
- package/dist/rules/html-tag-name-lowercase.js.map +1 -0
- package/dist/{src/rules → rules}/index.js +19 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/{src/rules → rules}/parser-no-errors.js +3 -3
- package/dist/rules/parser-no-errors.js.map +1 -0
- package/dist/{src/rules → rules}/rule-utils.js +141 -219
- package/dist/rules/rule-utils.js.map +1 -0
- package/dist/rules/string-utils.js.map +1 -0
- package/dist/{src/rules → rules}/svg-tag-name-capitalization.js +7 -6
- package/dist/rules/svg-tag-name-capitalization.js.map +1 -0
- package/dist/rules/turbo-permanent-require-id.js +34 -0
- package/dist/rules/turbo-permanent-require-id.js.map +1 -0
- package/dist/{src/rules.js → rules.js} +56 -10
- package/dist/rules.js.map +1 -0
- package/dist/types/cli/argument-parser.d.ts +1 -0
- package/dist/types/cli/file-processor.d.ts +13 -0
- package/dist/types/cli/file-url.d.ts +1 -0
- package/dist/types/cli/index.d.ts +1 -0
- package/dist/types/cli/lint-worker.d.ts +34 -0
- package/dist/types/custom-rule-loader.d.ts +4 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/linter.d.ts +13 -6
- package/dist/types/parse-cache.d.ts +9 -0
- package/dist/types/{src/rules/html-aria-level-must-be-valid.d.ts → rules/actionview-no-silent-helper.d.ts} +4 -3
- package/dist/types/rules/erb-comment-syntax.d.ts +1 -1
- package/dist/types/rules/erb-no-case-node-children.d.ts +1 -1
- package/dist/types/{src/rules/herb-disable-comment-malformed.d.ts → rules/erb-no-conditional-html-element.d.ts} +3 -3
- package/dist/types/{src/rules/erb-prefer-image-tag-helper.d.ts → rules/erb-no-conditional-open-tag.d.ts} +3 -3
- package/dist/types/rules/erb-no-duplicate-branch-elements.d.ts +17 -0
- package/dist/types/rules/erb-no-empty-tags.d.ts +1 -1
- package/dist/types/rules/erb-no-extra-newline.d.ts +1 -1
- package/dist/types/rules/erb-no-extra-whitespace-inside-tags.d.ts +1 -1
- package/dist/types/{src/rules/html-no-duplicate-attributes.d.ts → rules/erb-no-inline-case-conditions.d.ts} +4 -3
- package/dist/types/rules/erb-no-instance-variables-in-partials.d.ts +10 -0
- package/dist/types/{src/rules/html-no-aria-hidden-on-focusable.d.ts → rules/erb-no-interpolated-class-names.d.ts} +2 -2
- package/dist/types/{src/rules/html-aria-attribute-must-be-valid.d.ts → rules/erb-no-javascript-tag-helper.d.ts} +2 -2
- package/dist/types/rules/erb-no-output-control-flow.d.ts +1 -1
- package/dist/types/{src/rules/erb-no-silent-tag-in-attribute-name.d.ts → rules/erb-no-output-in-attribute-name.d.ts} +2 -2
- package/dist/types/{src/rules/herb-disable-comment-missing-rules.d.ts → rules/erb-no-output-in-attribute-position.d.ts} +2 -2
- package/dist/types/{src/rules/erb-no-empty-tags.d.ts → rules/erb-no-raw-output-in-attribute-value.d.ts} +2 -2
- package/dist/types/rules/erb-no-silent-tag-in-attribute-name.d.ts +1 -1
- package/dist/types/{src/rules/html-navigation-has-label.d.ts → rules/erb-no-statement-in-script.d.ts} +2 -2
- package/dist/types/rules/erb-no-then-in-control-flow.d.ts +9 -0
- package/dist/types/rules/erb-no-trailing-whitespace.d.ts +19 -0
- package/dist/types/{src/rules/html-no-positive-tab-index.d.ts → rules/erb-no-unsafe-js-attribute.d.ts} +2 -2
- package/dist/types/{src/rules/erb-no-case-node-children.d.ts → rules/erb-no-unsafe-raw.d.ts} +2 -2
- package/dist/types/rules/erb-no-unsafe-script-interpolation.d.ts +8 -0
- package/dist/types/rules/erb-prefer-image-tag-helper.d.ts +1 -1
- package/dist/types/rules/erb-require-trailing-newline.d.ts +1 -1
- package/dist/types/rules/erb-require-whitespace-inside-tags.d.ts +1 -1
- package/dist/types/rules/erb-right-trim.d.ts +1 -1
- package/dist/types/rules/erb-strict-locals-comment-syntax.d.ts +1 -1
- package/dist/types/rules/erb-strict-locals-required.d.ts +1 -1
- package/dist/types/rules/herb-disable-comment-malformed.d.ts +1 -1
- package/dist/types/rules/herb-disable-comment-missing-rules.d.ts +1 -1
- package/dist/types/rules/herb-disable-comment-no-duplicate-rules.d.ts +1 -1
- package/dist/types/rules/herb-disable-comment-no-redundant-all.d.ts +1 -1
- package/dist/types/rules/herb-disable-comment-unnecessary.d.ts +1 -1
- package/dist/types/rules/herb-disable-comment-valid-rule-name.d.ts +1 -1
- package/dist/types/{src/rules/html-anchor-require-href.d.ts → rules/html-allowed-script-type.d.ts} +2 -2
- package/dist/types/rules/html-anchor-require-href.d.ts +3 -2
- package/dist/types/rules/html-aria-attribute-must-be-valid.d.ts +1 -1
- package/dist/types/rules/html-aria-label-is-well-formatted.d.ts +1 -1
- package/dist/types/rules/html-aria-level-must-be-valid.d.ts +1 -1
- package/dist/types/rules/html-aria-role-heading-requires-level.d.ts +1 -1
- package/dist/types/rules/html-aria-role-must-be-valid.d.ts +1 -1
- package/dist/types/rules/html-attribute-double-quotes.d.ts +1 -1
- package/dist/types/rules/html-attribute-equals-spacing.d.ts +1 -1
- package/dist/types/rules/html-attribute-values-require-quotes.d.ts +1 -1
- package/dist/types/rules/html-avoid-both-disabled-and-aria-disabled.d.ts +1 -1
- package/dist/types/rules/html-body-only-elements.d.ts +1 -1
- package/dist/types/rules/html-boolean-attributes-no-value.d.ts +1 -1
- package/dist/types/{src/rules/html-no-empty-attributes.d.ts → rules/html-details-has-summary.d.ts} +4 -3
- package/dist/types/rules/html-head-only-elements.d.ts +1 -1
- package/dist/types/rules/html-iframe-has-title.d.ts +1 -1
- package/dist/types/rules/html-img-require-alt.d.ts +1 -1
- package/dist/types/rules/html-input-require-autocomplete.d.ts +1 -1
- package/dist/types/rules/html-navigation-has-label.d.ts +1 -1
- package/dist/types/{src/rules/html-no-empty-headings.d.ts → rules/html-no-abstract-roles.d.ts} +2 -2
- package/dist/types/{src/rules/erb-no-output-control-flow.d.ts → rules/html-no-aria-hidden-on-body.d.ts} +3 -3
- package/dist/types/rules/html-no-aria-hidden-on-focusable.d.ts +1 -1
- package/dist/types/rules/html-no-block-inside-inline.d.ts +1 -1
- package/dist/types/rules/html-no-duplicate-attributes.d.ts +1 -1
- package/dist/types/rules/html-no-duplicate-ids.d.ts +1 -1
- package/dist/types/rules/html-no-duplicate-meta-names.d.ts +1 -1
- package/dist/types/rules/html-no-empty-attributes.d.ts +1 -1
- package/dist/types/rules/html-no-empty-headings.d.ts +1 -1
- package/dist/types/rules/html-no-nested-links.d.ts +1 -1
- package/dist/types/rules/html-no-positive-tab-index.d.ts +1 -1
- package/dist/types/rules/html-no-self-closing.d.ts +1 -1
- package/dist/types/rules/html-no-space-in-tag.d.ts +1 -1
- package/dist/types/rules/html-no-title-attribute.d.ts +1 -1
- package/dist/types/rules/html-no-underscores-in-attribute-names.d.ts +1 -1
- package/dist/types/{src/rules/html-body-only-elements.d.ts → rules/html-require-closing-tags.d.ts} +4 -3
- package/dist/types/rules/html-tag-name-lowercase.d.ts +1 -1
- package/dist/types/rules/index.d.ts +19 -0
- package/dist/types/rules/parser-no-errors.d.ts +1 -1
- package/dist/types/rules/rule-utils.d.ts +35 -88
- package/dist/types/rules/svg-tag-name-capitalization.d.ts +1 -1
- package/dist/types/{src/rules/html-aria-role-must-be-valid.d.ts → rules/turbo-permanent-require-id.d.ts} +2 -2
- package/dist/types/types.d.ts +25 -7
- package/dist/types/urls.d.ts +1 -0
- package/dist/{src/types.js → types.js} +53 -0
- package/dist/types.js.map +1 -0
- package/dist/urls.js +5 -0
- package/dist/urls.js.map +1 -0
- package/docs/rules/README.md +23 -2
- package/docs/rules/actionview-no-silent-helper.md +57 -0
- package/docs/rules/erb-no-conditional-html-element.md +90 -0
- package/docs/rules/erb-no-conditional-open-tag.md +130 -0
- package/docs/rules/erb-no-duplicate-branch-elements.md +98 -0
- package/docs/rules/erb-no-inline-case-conditions.md +85 -0
- package/docs/rules/erb-no-instance-variables-in-partials.md +43 -0
- package/docs/rules/erb-no-interpolated-class-names.md +57 -0
- package/docs/rules/erb-no-javascript-tag-helper.md +33 -0
- package/docs/rules/erb-no-output-in-attribute-name.md +38 -0
- package/docs/rules/erb-no-output-in-attribute-position.md +60 -0
- package/docs/rules/erb-no-raw-output-in-attribute-value.md +37 -0
- package/docs/rules/erb-no-statement-in-script.md +68 -0
- package/docs/rules/erb-no-then-in-control-flow.md +86 -0
- package/docs/rules/erb-no-trailing-whitespace.md +69 -0
- package/docs/rules/erb-no-unsafe-js-attribute.md +41 -0
- package/docs/rules/erb-no-unsafe-raw.md +47 -0
- package/docs/rules/erb-no-unsafe-script-interpolation.md +73 -0
- package/docs/rules/html-allowed-script-type.md +59 -0
- package/docs/rules/html-anchor-require-href.md +19 -6
- package/docs/rules/html-details-has-summary.md +46 -0
- package/docs/rules/html-img-require-alt.md +5 -3
- package/docs/rules/html-no-abstract-roles.md +74 -0
- package/docs/rules/html-no-aria-hidden-on-body.md +44 -0
- package/docs/rules/html-require-closing-tags.md +142 -0
- package/docs/rules/parser-no-errors.md +4 -17
- package/docs/rules/turbo-permanent-require-id.md +41 -0
- package/package.json +12 -11
- package/src/cli/argument-parser.ts +20 -2
- package/src/cli/file-processor.ts +189 -10
- package/src/cli/file-url.ts +6 -0
- package/src/cli/formatters/detailed-formatter.ts +19 -21
- package/src/cli/formatters/simple-formatter.ts +23 -13
- package/src/cli/index.ts +2 -0
- package/src/cli/lint-worker.ts +208 -0
- package/src/cli/summary-reporter.ts +14 -15
- package/src/cli.ts +5 -3
- package/src/custom-rule-loader.ts +20 -5
- package/src/herb-disable-comment-utils.ts +0 -3
- package/src/index.ts +1 -0
- package/src/linter.ts +98 -79
- package/src/parse-cache.ts +39 -0
- package/src/rules/actionview-no-silent-helper.ts +58 -0
- package/src/rules/erb-comment-syntax.ts +2 -2
- package/src/rules/erb-no-case-node-children.ts +2 -2
- package/src/rules/erb-no-conditional-html-element.ts +53 -0
- package/src/rules/erb-no-conditional-open-tag.ts +37 -0
- package/src/rules/erb-no-duplicate-branch-elements.ts +320 -0
- package/src/rules/erb-no-empty-tags.ts +2 -2
- package/src/rules/erb-no-extra-newline.ts +5 -25
- package/src/rules/erb-no-extra-whitespace-inside-tags.ts +45 -15
- package/src/rules/erb-no-inline-case-conditions.ts +54 -0
- package/src/rules/erb-no-instance-variables-in-partials.ts +101 -0
- package/src/rules/erb-no-interpolated-class-names.ts +65 -0
- package/src/rules/erb-no-javascript-tag-helper.ts +47 -0
- package/src/rules/erb-no-output-control-flow.ts +10 -10
- package/src/rules/erb-no-output-in-attribute-name.ts +39 -0
- package/src/rules/erb-no-output-in-attribute-position.ts +39 -0
- package/src/rules/erb-no-raw-output-in-attribute-value.ts +47 -0
- package/src/rules/erb-no-silent-tag-in-attribute-name.ts +2 -2
- package/src/rules/erb-no-statement-in-script.ts +82 -0
- package/src/rules/erb-no-then-in-control-flow.ts +62 -0
- package/src/rules/erb-no-trailing-whitespace.ts +187 -0
- package/src/rules/erb-no-unsafe-js-attribute.ts +47 -0
- package/src/rules/erb-no-unsafe-raw.ts +83 -0
- package/src/rules/erb-no-unsafe-script-interpolation.ts +76 -0
- package/src/rules/erb-prefer-image-tag-helper.ts +5 -4
- package/src/rules/erb-require-trailing-newline.ts +2 -2
- package/src/rules/erb-require-whitespace-inside-tags.ts +42 -18
- package/src/rules/erb-right-trim.ts +2 -2
- package/src/rules/erb-strict-locals-comment-syntax.ts +5 -5
- package/src/rules/erb-strict-locals-required.ts +2 -2
- package/src/rules/herb-disable-comment-malformed.ts +2 -2
- package/src/rules/herb-disable-comment-missing-rules.ts +2 -2
- package/src/rules/herb-disable-comment-no-duplicate-rules.ts +2 -2
- package/src/rules/herb-disable-comment-no-redundant-all.ts +2 -2
- package/src/rules/herb-disable-comment-unnecessary.ts +2 -2
- package/src/rules/herb-disable-comment-valid-rule-name.ts +2 -2
- package/src/rules/html-allowed-script-type.ts +84 -0
- package/src/rules/html-anchor-require-href.ts +73 -11
- package/src/rules/html-aria-attribute-must-be-valid.ts +3 -3
- package/src/rules/html-aria-label-is-well-formatted.ts +3 -3
- package/src/rules/html-aria-level-must-be-valid.ts +3 -3
- package/src/rules/html-aria-role-heading-requires-level.ts +5 -4
- package/src/rules/html-aria-role-must-be-valid.ts +3 -3
- package/src/rules/html-attribute-double-quotes.ts +4 -4
- package/src/rules/html-attribute-equals-spacing.ts +2 -2
- package/src/rules/html-attribute-values-require-quotes.ts +2 -2
- package/src/rules/html-avoid-both-disabled-and-aria-disabled.ts +10 -11
- package/src/rules/html-body-only-elements.ts +5 -4
- package/src/rules/html-boolean-attributes-no-value.ts +4 -3
- package/src/rules/html-details-has-summary.ts +69 -0
- package/src/rules/html-head-only-elements.ts +6 -5
- package/src/rules/html-iframe-has-title.ts +8 -11
- package/src/rules/html-img-require-alt.ts +16 -5
- package/src/rules/html-input-require-autocomplete.ts +7 -10
- package/src/rules/html-navigation-has-label.ts +6 -5
- package/src/rules/html-no-abstract-roles.ts +40 -0
- package/src/rules/html-no-aria-hidden-on-body.ts +58 -0
- package/src/rules/html-no-aria-hidden-on-focusable.ts +6 -5
- package/src/rules/html-no-block-inside-inline.ts +7 -13
- package/src/rules/html-no-duplicate-attributes.ts +4 -3
- package/src/rules/html-no-duplicate-ids.ts +16 -13
- package/src/rules/html-no-duplicate-meta-names.ts +20 -19
- package/src/rules/html-no-empty-attributes.ts +2 -2
- package/src/rules/html-no-empty-headings.ts +44 -58
- package/src/rules/html-no-nested-links.ts +25 -16
- package/src/rules/html-no-positive-tab-index.ts +3 -3
- package/src/rules/html-no-self-closing.ts +5 -5
- package/src/rules/html-no-space-in-tag.ts +5 -8
- package/src/rules/html-no-title-attribute.ts +6 -5
- package/src/rules/html-no-underscores-in-attribute-names.ts +2 -2
- package/src/rules/html-require-closing-tags.ts +41 -0
- package/src/rules/html-tag-name-lowercase.ts +14 -9
- package/src/rules/index.ts +19 -0
- package/src/rules/parser-no-errors.ts +3 -3
- package/src/rules/rule-utils.ts +162 -279
- package/src/rules/svg-tag-name-capitalization.ts +10 -10
- package/src/rules/turbo-permanent-require-id.ts +49 -0
- package/src/rules.ts +60 -10
- package/src/types.ts +76 -7
- package/src/urls.ts +5 -0
- package/dist/package.json +0 -65
- package/dist/src/cli/argument-parser.js.map +0 -1
- package/dist/src/cli/file-processor.js.map +0 -1
- package/dist/src/cli/formatters/base-formatter.js.map +0 -1
- package/dist/src/cli/formatters/detailed-formatter.js.map +0 -1
- package/dist/src/cli/formatters/github-actions-formatter.js.map +0 -1
- package/dist/src/cli/formatters/index.js.map +0 -1
- package/dist/src/cli/formatters/json-formatter.js.map +0 -1
- package/dist/src/cli/formatters/simple-formatter.js +0 -44
- package/dist/src/cli/formatters/simple-formatter.js.map +0 -1
- package/dist/src/cli/index.js.map +0 -1
- package/dist/src/cli/output-manager.js.map +0 -1
- package/dist/src/cli/summary-reporter.js.map +0 -1
- package/dist/src/cli.js.map +0 -1
- package/dist/src/custom-rule-loader.js.map +0 -1
- package/dist/src/herb-disable-comment-utils.js.map +0 -1
- package/dist/src/herb-lint.js +0 -5
- package/dist/src/herb-lint.js.map +0 -1
- package/dist/src/index.js +0 -5
- package/dist/src/index.js.map +0 -1
- package/dist/src/linter-ignore.js.map +0 -1
- package/dist/src/linter.js.map +0 -1
- package/dist/src/loader.js +0 -17
- package/dist/src/loader.js.map +0 -1
- package/dist/src/rules/erb-comment-syntax.js.map +0 -1
- package/dist/src/rules/erb-no-case-node-children.js.map +0 -1
- package/dist/src/rules/erb-no-empty-tags.js.map +0 -1
- package/dist/src/rules/erb-no-extra-newline.js.map +0 -1
- package/dist/src/rules/erb-no-extra-whitespace-inside-tags.js.map +0 -1
- package/dist/src/rules/erb-no-output-control-flow.js.map +0 -1
- package/dist/src/rules/erb-no-silent-tag-in-attribute-name.js.map +0 -1
- package/dist/src/rules/erb-prefer-image-tag-helper.js.map +0 -1
- package/dist/src/rules/erb-require-trailing-newline.js.map +0 -1
- package/dist/src/rules/erb-require-whitespace-inside-tags.js.map +0 -1
- package/dist/src/rules/erb-right-trim.js.map +0 -1
- package/dist/src/rules/erb-strict-locals-comment-syntax.js.map +0 -1
- package/dist/src/rules/erb-strict-locals-required.js.map +0 -1
- package/dist/src/rules/file-utils.js.map +0 -1
- package/dist/src/rules/herb-disable-comment-base.js.map +0 -1
- package/dist/src/rules/herb-disable-comment-malformed.js.map +0 -1
- package/dist/src/rules/herb-disable-comment-missing-rules.js.map +0 -1
- package/dist/src/rules/herb-disable-comment-no-duplicate-rules.js.map +0 -1
- package/dist/src/rules/herb-disable-comment-no-redundant-all.js.map +0 -1
- package/dist/src/rules/herb-disable-comment-unnecessary.js.map +0 -1
- package/dist/src/rules/herb-disable-comment-valid-rule-name.js.map +0 -1
- package/dist/src/rules/html-anchor-require-href.js +0 -32
- package/dist/src/rules/html-anchor-require-href.js.map +0 -1
- package/dist/src/rules/html-aria-attribute-must-be-valid.js.map +0 -1
- package/dist/src/rules/html-aria-label-is-well-formatted.js.map +0 -1
- package/dist/src/rules/html-aria-level-must-be-valid.js.map +0 -1
- package/dist/src/rules/html-aria-role-heading-requires-level.js.map +0 -1
- package/dist/src/rules/html-aria-role-must-be-valid.js.map +0 -1
- package/dist/src/rules/html-attribute-double-quotes.js.map +0 -1
- package/dist/src/rules/html-attribute-equals-spacing.js.map +0 -1
- package/dist/src/rules/html-attribute-values-require-quotes.js.map +0 -1
- package/dist/src/rules/html-avoid-both-disabled-and-aria-disabled.js.map +0 -1
- package/dist/src/rules/html-body-only-elements.js.map +0 -1
- package/dist/src/rules/html-boolean-attributes-no-value.js.map +0 -1
- package/dist/src/rules/html-head-only-elements.js.map +0 -1
- package/dist/src/rules/html-iframe-has-title.js.map +0 -1
- package/dist/src/rules/html-img-require-alt.js.map +0 -1
- package/dist/src/rules/html-input-require-autocomplete.js.map +0 -1
- package/dist/src/rules/html-navigation-has-label.js.map +0 -1
- package/dist/src/rules/html-no-aria-hidden-on-focusable.js.map +0 -1
- package/dist/src/rules/html-no-block-inside-inline.js.map +0 -1
- package/dist/src/rules/html-no-duplicate-attributes.js.map +0 -1
- package/dist/src/rules/html-no-duplicate-ids.js.map +0 -1
- package/dist/src/rules/html-no-duplicate-meta-names.js.map +0 -1
- package/dist/src/rules/html-no-empty-attributes.js.map +0 -1
- package/dist/src/rules/html-no-empty-headings.js +0 -115
- package/dist/src/rules/html-no-empty-headings.js.map +0 -1
- package/dist/src/rules/html-no-nested-links.js.map +0 -1
- package/dist/src/rules/html-no-positive-tab-index.js.map +0 -1
- package/dist/src/rules/html-no-self-closing.js.map +0 -1
- package/dist/src/rules/html-no-space-in-tag.js.map +0 -1
- package/dist/src/rules/html-no-title-attribute.js.map +0 -1
- package/dist/src/rules/html-no-underscores-in-attribute-names.js.map +0 -1
- package/dist/src/rules/html-tag-name-lowercase.js.map +0 -1
- package/dist/src/rules/index.js.map +0 -1
- package/dist/src/rules/parser-no-errors.js.map +0 -1
- package/dist/src/rules/rule-utils.js.map +0 -1
- package/dist/src/rules/string-utils.js.map +0 -1
- package/dist/src/rules/svg-tag-name-capitalization.js.map +0 -1
- package/dist/src/rules.js.map +0 -1
- package/dist/src/types.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/src/cli/argument-parser.d.ts +0 -25
- package/dist/types/src/cli/file-processor.d.ts +0 -43
- package/dist/types/src/cli/formatters/base-formatter.d.ts +0 -6
- package/dist/types/src/cli/formatters/detailed-formatter.d.ts +0 -13
- package/dist/types/src/cli/formatters/github-actions-formatter.d.ts +0 -17
- package/dist/types/src/cli/formatters/index.d.ts +0 -5
- package/dist/types/src/cli/formatters/json-formatter.d.ts +0 -48
- package/dist/types/src/cli/formatters/simple-formatter.d.ts +0 -8
- package/dist/types/src/cli/index.d.ts +0 -5
- package/dist/types/src/cli/output-manager.d.ts +0 -32
- package/dist/types/src/cli/summary-reporter.d.ts +0 -28
- package/dist/types/src/cli.d.ts +0 -28
- package/dist/types/src/custom-rule-loader.d.ts +0 -62
- package/dist/types/src/herb-disable-comment-utils.d.ts +0 -69
- package/dist/types/src/herb-lint.d.ts +0 -2
- package/dist/types/src/index.d.ts +0 -4
- package/dist/types/src/linter-ignore.d.ts +0 -12
- package/dist/types/src/linter.d.ts +0 -133
- package/dist/types/src/loader.d.ts +0 -20
- package/dist/types/src/rules/erb-comment-syntax.d.ts +0 -14
- package/dist/types/src/rules/erb-no-extra-newline.d.ts +0 -14
- package/dist/types/src/rules/erb-no-extra-whitespace-inside-tags.d.ts +0 -18
- package/dist/types/src/rules/erb-require-trailing-newline.d.ts +0 -9
- package/dist/types/src/rules/erb-require-whitespace-inside-tags.d.ts +0 -18
- package/dist/types/src/rules/erb-right-trim.d.ts +0 -14
- package/dist/types/src/rules/erb-strict-locals-comment-syntax.d.ts +0 -9
- package/dist/types/src/rules/erb-strict-locals-required.d.ts +0 -9
- package/dist/types/src/rules/file-utils.d.ts +0 -13
- package/dist/types/src/rules/herb-disable-comment-base.d.ts +0 -37
- package/dist/types/src/rules/herb-disable-comment-no-duplicate-rules.d.ts +0 -8
- package/dist/types/src/rules/herb-disable-comment-no-redundant-all.d.ts +0 -8
- package/dist/types/src/rules/herb-disable-comment-unnecessary.d.ts +0 -8
- package/dist/types/src/rules/herb-disable-comment-valid-rule-name.d.ts +0 -8
- package/dist/types/src/rules/html-aria-label-is-well-formatted.d.ts +0 -8
- package/dist/types/src/rules/html-aria-role-heading-requires-level.d.ts +0 -8
- package/dist/types/src/rules/html-attribute-double-quotes.d.ts +0 -15
- package/dist/types/src/rules/html-attribute-equals-spacing.d.ts +0 -14
- package/dist/types/src/rules/html-attribute-values-require-quotes.d.ts +0 -15
- package/dist/types/src/rules/html-avoid-both-disabled-and-aria-disabled.d.ts +0 -8
- package/dist/types/src/rules/html-boolean-attributes-no-value.d.ts +0 -14
- package/dist/types/src/rules/html-head-only-elements.d.ts +0 -9
- package/dist/types/src/rules/html-iframe-has-title.d.ts +0 -8
- package/dist/types/src/rules/html-img-require-alt.d.ts +0 -8
- package/dist/types/src/rules/html-input-require-autocomplete.d.ts +0 -8
- package/dist/types/src/rules/html-no-block-inside-inline.d.ts +0 -8
- package/dist/types/src/rules/html-no-duplicate-ids.d.ts +0 -8
- package/dist/types/src/rules/html-no-duplicate-meta-names.d.ts +0 -9
- package/dist/types/src/rules/html-no-nested-links.d.ts +0 -8
- package/dist/types/src/rules/html-no-self-closing.d.ts +0 -16
- package/dist/types/src/rules/html-no-space-in-tag.d.ts +0 -16
- package/dist/types/src/rules/html-no-title-attribute.d.ts +0 -8
- package/dist/types/src/rules/html-no-underscores-in-attribute-names.d.ts +0 -8
- package/dist/types/src/rules/html-tag-name-lowercase.d.ts +0 -18
- package/dist/types/src/rules/index.d.ts +0 -54
- package/dist/types/src/rules/parser-no-errors.d.ts +0 -9
- package/dist/types/src/rules/rule-utils.d.ts +0 -351
- package/dist/types/src/rules/string-utils.d.ts +0 -15
- package/dist/types/src/rules/svg-tag-name-capitalization.d.ts +0 -16
- package/dist/types/src/rules.d.ts +0 -2
- package/dist/types/src/types.d.ts +0 -190
- /package/dist/{src/cli → cli}/formatters/base-formatter.js +0 -0
- /package/dist/{src/cli → cli}/formatters/github-actions-formatter.js +0 -0
- /package/dist/{src/cli → cli}/formatters/index.js +0 -0
- /package/dist/{src/cli → cli}/formatters/json-formatter.js +0 -0
- /package/dist/{src/cli → cli}/index.js +0 -0
- /package/dist/{src/cli → cli}/output-manager.js +0 -0
- /package/dist/{src/herb-disable-comment-utils.js → herb-disable-comment-utils.js} +0 -0
- /package/dist/{src/linter-ignore.js → linter-ignore.js} +0 -0
- /package/dist/{src/rules → rules}/file-utils.js +0 -0
- /package/dist/{src/rules → rules}/herb-disable-comment-base.js +0 -0
- /package/dist/{src/rules → rules}/string-utils.js +0 -0
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export * from "./rule-utils.js";
|
|
2
|
-
export * from "./file-utils.js";
|
|
3
|
-
export * from "./string-utils.js";
|
|
4
|
-
export * from "./herb-disable-comment-base.js";
|
|
5
|
-
export * from "./erb-comment-syntax.js";
|
|
6
|
-
export * from "./erb-no-case-node-children.js";
|
|
7
|
-
export * from "./erb-no-empty-tags.js";
|
|
8
|
-
export * from "./erb-no-extra-newline.js";
|
|
9
|
-
export * from "./erb-no-extra-whitespace-inside-tags.js";
|
|
10
|
-
export * from "./erb-no-output-control-flow.js";
|
|
11
|
-
export * from "./erb-no-silent-tag-in-attribute-name.js";
|
|
12
|
-
export * from "./erb-prefer-image-tag-helper.js";
|
|
13
|
-
export * from "./erb-require-trailing-newline.js";
|
|
14
|
-
export * from "./erb-require-whitespace-inside-tags.js";
|
|
15
|
-
export * from "./erb-right-trim.js";
|
|
16
|
-
export * from "./erb-strict-locals-comment-syntax.js";
|
|
17
|
-
export * from "./erb-strict-locals-required.js";
|
|
18
|
-
export * from "./herb-disable-comment-valid-rule-name.js";
|
|
19
|
-
export * from "./herb-disable-comment-no-redundant-all.js";
|
|
20
|
-
export * from "./herb-disable-comment-no-duplicate-rules.js";
|
|
21
|
-
export * from "./herb-disable-comment-missing-rules.js";
|
|
22
|
-
export * from "./herb-disable-comment-malformed.js";
|
|
23
|
-
export * from "./herb-disable-comment-unnecessary.js";
|
|
24
|
-
export * from "./html-anchor-require-href.js";
|
|
25
|
-
export * from "./html-aria-label-is-well-formatted.js";
|
|
26
|
-
export * from "./html-aria-level-must-be-valid.js";
|
|
27
|
-
export * from "./html-aria-role-heading-requires-level.js";
|
|
28
|
-
export * from "./html-aria-role-must-be-valid.js";
|
|
29
|
-
export * from "./html-attribute-double-quotes.js";
|
|
30
|
-
export * from "./html-attribute-equals-spacing.js";
|
|
31
|
-
export * from "./html-attribute-values-require-quotes.js";
|
|
32
|
-
export * from "./html-avoid-both-disabled-and-aria-disabled.js";
|
|
33
|
-
export * from "./html-body-only-elements.js";
|
|
34
|
-
export * from "./html-boolean-attributes-no-value.js";
|
|
35
|
-
export * from "./html-head-only-elements.js";
|
|
36
|
-
export * from "./html-iframe-has-title.js";
|
|
37
|
-
export * from "./html-img-require-alt.js";
|
|
38
|
-
export * from "./html-input-require-autocomplete.js";
|
|
39
|
-
export * from "./html-navigation-has-label.js";
|
|
40
|
-
export * from "./html-no-aria-hidden-on-focusable.js";
|
|
41
|
-
export * from "./html-no-block-inside-inline.js";
|
|
42
|
-
export * from "./html-no-duplicate-attributes.js";
|
|
43
|
-
export * from "./html-no-duplicate-ids.js";
|
|
44
|
-
export * from "./html-no-duplicate-meta-names.js";
|
|
45
|
-
export * from "./html-no-empty-attributes.js";
|
|
46
|
-
export * from "./html-no-empty-headings.js";
|
|
47
|
-
export * from "./html-no-nested-links.js";
|
|
48
|
-
export * from "./html-no-positive-tab-index.js";
|
|
49
|
-
export * from "./html-no-self-closing.js";
|
|
50
|
-
export * from "./html-no-space-in-tag.js";
|
|
51
|
-
export * from "./html-no-title-attribute.js";
|
|
52
|
-
export * from "./html-no-underscores-in-attribute-names.js";
|
|
53
|
-
export * from "./html-tag-name-lowercase.js";
|
|
54
|
-
export * from "./svg-tag-name-capitalization.js";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ParserRule } from "../types.js";
|
|
2
|
-
import type { LintOffense, FullRuleConfig } from "../types.js";
|
|
3
|
-
import type { ParseResult } from "@herb-tools/core";
|
|
4
|
-
export declare class ParserNoErrorsRule extends ParserRule {
|
|
5
|
-
name: string;
|
|
6
|
-
get defaultConfig(): FullRuleConfig;
|
|
7
|
-
check(result: ParseResult): LintOffense[];
|
|
8
|
-
private herbErrorToLintOffense;
|
|
9
|
-
}
|
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
import { Visitor, Location } from "@herb-tools/core";
|
|
2
|
-
import type { HTMLAttributeNode, HTMLAttributeValueNode, HTMLElementNode, HTMLOpenTagNode, LexResult, Token, Node } from "@herb-tools/core";
|
|
3
|
-
import type * as Nodes from "@herb-tools/core";
|
|
4
|
-
import type { UnboundLintOffense, LintContext, BaseAutofixContext } from "../types.js";
|
|
5
|
-
export declare enum ControlFlowType {
|
|
6
|
-
CONDITIONAL = 0,
|
|
7
|
-
LOOP = 1
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Base visitor class that provides common functionality for rule visitors
|
|
11
|
-
*/
|
|
12
|
-
export declare abstract class BaseRuleVisitor<TAutofixContext extends BaseAutofixContext = BaseAutofixContext> extends Visitor {
|
|
13
|
-
readonly offenses: UnboundLintOffense<TAutofixContext>[];
|
|
14
|
-
protected ruleName: string;
|
|
15
|
-
protected context: LintContext;
|
|
16
|
-
constructor(ruleName: string, context?: Partial<LintContext>);
|
|
17
|
-
/**
|
|
18
|
-
* Helper method to create an unbound lint offense (without severity).
|
|
19
|
-
* The Linter will bind severity based on the rule's config.
|
|
20
|
-
*/
|
|
21
|
-
protected createOffense(message: string, location: Location, autofixContext?: TAutofixContext): UnboundLintOffense<TAutofixContext>;
|
|
22
|
-
/**
|
|
23
|
-
* Helper method to add an offense to the offenses array
|
|
24
|
-
*/
|
|
25
|
-
protected addOffense(message: string, location: Location, autofixContext?: TAutofixContext): void;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Mixin that adds control flow tracking capabilities to rule visitors
|
|
29
|
-
* This allows rules to track state across different control flow structures
|
|
30
|
-
* like if/else branches, loops, etc.
|
|
31
|
-
*
|
|
32
|
-
* @template TAutofixContext - Type for autofix context (node + custom data)
|
|
33
|
-
* @template TControlFlowState - Type for state passed between onEnterControlFlow and onExitControlFlow
|
|
34
|
-
* @template TBranchState - Type for state passed between onEnterBranch and onExitBranch
|
|
35
|
-
*/
|
|
36
|
-
export declare abstract class ControlFlowTrackingVisitor<TAutofixContext extends BaseAutofixContext = BaseAutofixContext, TControlFlowState = any, TBranchState = any> extends BaseRuleVisitor<TAutofixContext> {
|
|
37
|
-
protected isInControlFlow: boolean;
|
|
38
|
-
protected currentControlFlowType: ControlFlowType | null;
|
|
39
|
-
/**
|
|
40
|
-
* Handle visiting a control flow node with proper scope management
|
|
41
|
-
*/
|
|
42
|
-
protected handleControlFlowNode(_node: Node, controlFlowType: ControlFlowType, visitChildren: () => void): void;
|
|
43
|
-
/**
|
|
44
|
-
* Handle visiting a branch node (like else, when) with proper scope management
|
|
45
|
-
*/
|
|
46
|
-
protected startNewBranch(visitChildren: () => void): void;
|
|
47
|
-
visitERBIfNode(node: Nodes.ERBIfNode): void;
|
|
48
|
-
visitERBUnlessNode(node: Nodes.ERBUnlessNode): void;
|
|
49
|
-
visitERBCaseNode(node: Nodes.ERBCaseNode): void;
|
|
50
|
-
visitERBCaseMatchNode(node: Nodes.ERBCaseMatchNode): void;
|
|
51
|
-
visitERBWhileNode(node: Nodes.ERBWhileNode): void;
|
|
52
|
-
visitERBForNode(node: Nodes.ERBForNode): void;
|
|
53
|
-
visitERBUntilNode(node: Nodes.ERBUntilNode): void;
|
|
54
|
-
visitERBBlockNode(node: Nodes.ERBBlockNode): void;
|
|
55
|
-
visitERBElseNode(node: Nodes.ERBElseNode): void;
|
|
56
|
-
visitERBWhenNode(node: Nodes.ERBWhenNode): void;
|
|
57
|
-
protected abstract onEnterControlFlow(controlFlowType: ControlFlowType, wasAlreadyInControlFlow: boolean): TControlFlowState;
|
|
58
|
-
protected abstract onExitControlFlow(controlFlowType: ControlFlowType, wasAlreadyInControlFlow: boolean, stateToRestore: TControlFlowState): void;
|
|
59
|
-
protected abstract onEnterBranch(): TBranchState;
|
|
60
|
-
protected abstract onExitBranch(stateToRestore: TBranchState): void;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Gets attributes from an HTMLOpenTagNode
|
|
64
|
-
*/
|
|
65
|
-
export declare function getAttributes(node: HTMLOpenTagNode): HTMLAttributeNode[];
|
|
66
|
-
/**
|
|
67
|
-
* Gets the tag name from an HTML tag node (lowercased)
|
|
68
|
-
*/
|
|
69
|
-
export declare function getTagName(node: HTMLElementNode | HTMLOpenTagNode | null | undefined): string | null;
|
|
70
|
-
/**
|
|
71
|
-
* Gets the attribute name from an HTMLAttributeNode (lowercased)
|
|
72
|
-
* Returns null if the attribute name contains dynamic content (ERB)
|
|
73
|
-
*/
|
|
74
|
-
export declare function getAttributeName(attributeNode: HTMLAttributeNode, lowercase?: boolean): string | null;
|
|
75
|
-
/**
|
|
76
|
-
* Checks if an attribute has a dynamic (ERB-containing) name
|
|
77
|
-
*/
|
|
78
|
-
export declare function hasDynamicAttributeName(attributeNode: HTMLAttributeNode): boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Gets the combined string representation of an attribute name (for debugging)
|
|
81
|
-
* This includes both static content and ERB syntax
|
|
82
|
-
*/
|
|
83
|
-
export declare function getCombinedAttributeNameString(attributeNode: HTMLAttributeNode): string;
|
|
84
|
-
/**
|
|
85
|
-
* Checks if an attribute value contains only static content (no ERB)
|
|
86
|
-
*/
|
|
87
|
-
export declare function hasStaticAttributeValue(attributeNode: HTMLAttributeNode): boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Checks if an attribute value contains dynamic content (ERB)
|
|
90
|
-
*/
|
|
91
|
-
export declare function hasDynamicAttributeValue(attributeNode: HTMLAttributeNode): boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Gets the static string value of an attribute (returns null if it contains ERB)
|
|
94
|
-
*/
|
|
95
|
-
export declare function getStaticAttributeValue(attributeNode: HTMLAttributeNode): string | null;
|
|
96
|
-
/**
|
|
97
|
-
* Gets the value nodes array for dynamic inspection
|
|
98
|
-
*/
|
|
99
|
-
export declare function getAttributeValueNodes(attributeNode: HTMLAttributeNode): Node[];
|
|
100
|
-
/**
|
|
101
|
-
* Checks if an attribute value contains any static content (for validation purposes)
|
|
102
|
-
*/
|
|
103
|
-
export declare function hasStaticAttributeValueContent(attributeNode: HTMLAttributeNode): boolean;
|
|
104
|
-
/**
|
|
105
|
-
* Gets the static content of an attribute value (all literal parts combined)
|
|
106
|
-
* Returns the concatenated literal content, or null if no literal nodes exist
|
|
107
|
-
*/
|
|
108
|
-
export declare function getStaticAttributeValueContent(attributeNode: HTMLAttributeNode): string | null;
|
|
109
|
-
/**
|
|
110
|
-
* Gets the attribute value content from an HTMLAttributeValueNode
|
|
111
|
-
*/
|
|
112
|
-
export declare function getAttributeValue(attributeNode: HTMLAttributeNode): string | null;
|
|
113
|
-
/**
|
|
114
|
-
* Checks if an attribute has a value
|
|
115
|
-
*/
|
|
116
|
-
export declare function hasAttributeValue(attributeNode: HTMLAttributeNode): boolean;
|
|
117
|
-
/**
|
|
118
|
-
* Gets the quote type used for an attribute value
|
|
119
|
-
*/
|
|
120
|
-
export declare function getAttributeValueQuoteType(nodeOrAttribute: HTMLAttributeNode | HTMLAttributeValueNode): "single" | "double" | "none" | null;
|
|
121
|
-
/**
|
|
122
|
-
* Finds an attribute by name in a list of attributes
|
|
123
|
-
*/
|
|
124
|
-
export declare function findAttributeByName(attributes: Node[], attributeName: string): HTMLAttributeNode | null;
|
|
125
|
-
/**
|
|
126
|
-
* Checks if a tag has a specific attribute
|
|
127
|
-
*/
|
|
128
|
-
export declare function hasAttribute(node: HTMLOpenTagNode | null | undefined, attributeName: string): boolean;
|
|
129
|
-
/**
|
|
130
|
-
* Checks if a tag has a specific attribute
|
|
131
|
-
*/
|
|
132
|
-
export declare function getAttribute(node: HTMLOpenTagNode, attributeName: string): HTMLAttributeNode | null;
|
|
133
|
-
/**
|
|
134
|
-
* Common HTML element categorization
|
|
135
|
-
*/
|
|
136
|
-
export declare const HTML_INLINE_ELEMENTS: Set<string>;
|
|
137
|
-
export declare const HTML_BLOCK_ELEMENTS: Set<string>;
|
|
138
|
-
export declare const HTML_VOID_ELEMENTS: Set<string>;
|
|
139
|
-
export declare const HTML_BOOLEAN_ATTRIBUTES: Set<string>;
|
|
140
|
-
export declare const HEADING_TAGS: Set<string>;
|
|
141
|
-
/**
|
|
142
|
-
* SVG elements that use camelCase naming
|
|
143
|
-
*/
|
|
144
|
-
export declare const SVG_CAMEL_CASE_ELEMENTS: Set<string>;
|
|
145
|
-
/**
|
|
146
|
-
* Mapping from lowercase SVG element names to their correct camelCase versions
|
|
147
|
-
* Generated dynamically from SVG_CAMEL_CASE_ELEMENTS
|
|
148
|
-
*/
|
|
149
|
-
export declare const SVG_LOWERCASE_TO_CAMELCASE: Map<string, string>;
|
|
150
|
-
export declare const VALID_ARIA_ROLES: Set<string>;
|
|
151
|
-
/**
|
|
152
|
-
* Parameter types for AttributeVisitorMixin methods
|
|
153
|
-
*/
|
|
154
|
-
export interface StaticAttributeStaticValueParams {
|
|
155
|
-
attributeName: string;
|
|
156
|
-
attributeValue: string;
|
|
157
|
-
attributeNode: HTMLAttributeNode;
|
|
158
|
-
originalAttributeName: string;
|
|
159
|
-
parentNode: HTMLOpenTagNode;
|
|
160
|
-
}
|
|
161
|
-
export interface StaticAttributeDynamicValueParams {
|
|
162
|
-
attributeName: string;
|
|
163
|
-
valueNodes: Node[];
|
|
164
|
-
attributeNode: HTMLAttributeNode;
|
|
165
|
-
originalAttributeName: string;
|
|
166
|
-
parentNode: HTMLOpenTagNode;
|
|
167
|
-
combinedValue?: string | null;
|
|
168
|
-
}
|
|
169
|
-
export interface DynamicAttributeStaticValueParams {
|
|
170
|
-
nameNodes: Node[];
|
|
171
|
-
attributeValue: string;
|
|
172
|
-
attributeNode: HTMLAttributeNode;
|
|
173
|
-
parentNode: HTMLOpenTagNode;
|
|
174
|
-
combinedName?: string;
|
|
175
|
-
}
|
|
176
|
-
export interface DynamicAttributeDynamicValueParams {
|
|
177
|
-
nameNodes: Node[];
|
|
178
|
-
valueNodes: Node[];
|
|
179
|
-
attributeNode: HTMLAttributeNode;
|
|
180
|
-
parentNode: HTMLOpenTagNode;
|
|
181
|
-
combinedName?: string;
|
|
182
|
-
combinedValue?: string | null;
|
|
183
|
-
}
|
|
184
|
-
export declare const ARIA_ATTRIBUTES: Set<string>;
|
|
185
|
-
/**
|
|
186
|
-
* Helper function to create a location at the end of the source with a 1-character range
|
|
187
|
-
*/
|
|
188
|
-
export declare function createEndOfFileLocation(source: string): Location;
|
|
189
|
-
/**
|
|
190
|
-
* Checks if an element is inline
|
|
191
|
-
*/
|
|
192
|
-
export declare function isInlineElement(tagName: string): boolean;
|
|
193
|
-
/**
|
|
194
|
-
* Checks if an element is block-level
|
|
195
|
-
*/
|
|
196
|
-
export declare function isBlockElement(tagName: string): boolean;
|
|
197
|
-
/**
|
|
198
|
-
* Checks if an element is a void element
|
|
199
|
-
*/
|
|
200
|
-
export declare function isVoidElement(tagName: string): boolean;
|
|
201
|
-
/**
|
|
202
|
-
* Checks if an attribute is a boolean attribute
|
|
203
|
-
*/
|
|
204
|
-
export declare function isBooleanAttribute(attributeName: string): boolean;
|
|
205
|
-
/**
|
|
206
|
-
* Attribute visitor that provides granular processing based on both
|
|
207
|
-
* attribute name type (static/dynamic) and value type (static/dynamic)
|
|
208
|
-
*
|
|
209
|
-
* This gives you 4 distinct methods to override:
|
|
210
|
-
* - checkStaticAttributeStaticValue() - name="class" value="foo"
|
|
211
|
-
* - checkStaticAttributeDynamicValue() - name="class" value="<%= css_class %>"
|
|
212
|
-
* - checkDynamicAttributeStaticValue() - name="data-<%= key %>" value="foo"
|
|
213
|
-
* - checkDynamicAttributeDynamicValue() - name="data-<%= key %>" value="<%= value %>"
|
|
214
|
-
*/
|
|
215
|
-
export declare abstract class AttributeVisitorMixin<TAutofixContext extends BaseAutofixContext = BaseAutofixContext> extends BaseRuleVisitor<TAutofixContext> {
|
|
216
|
-
constructor(ruleName: string, context?: Partial<LintContext>);
|
|
217
|
-
visitHTMLOpenTagNode(node: HTMLOpenTagNode): void;
|
|
218
|
-
private checkAttributesOnNode;
|
|
219
|
-
/**
|
|
220
|
-
* Static attribute name with static value: class="container"
|
|
221
|
-
*/
|
|
222
|
-
protected checkStaticAttributeStaticValue(_params: StaticAttributeStaticValueParams): void;
|
|
223
|
-
/**
|
|
224
|
-
* Static attribute name with dynamic value: class="<%= css_class %>"
|
|
225
|
-
*/
|
|
226
|
-
protected checkStaticAttributeDynamicValue(_params: StaticAttributeDynamicValueParams): void;
|
|
227
|
-
/**
|
|
228
|
-
* Dynamic attribute name with static value: data-<%= key %>="foo"
|
|
229
|
-
*/
|
|
230
|
-
protected checkDynamicAttributeStaticValue(_params: DynamicAttributeStaticValueParams): void;
|
|
231
|
-
/**
|
|
232
|
-
* Dynamic attribute name with dynamic value: data-<%= key %>="<%= value %>"
|
|
233
|
-
*/
|
|
234
|
-
protected checkDynamicAttributeDynamicValue(_params: DynamicAttributeDynamicValueParams): void;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Checks if an attribute value is quoted
|
|
238
|
-
*/
|
|
239
|
-
export declare function isAttributeValueQuoted(attributeNode: HTMLAttributeNode): boolean;
|
|
240
|
-
/**
|
|
241
|
-
* Iterates over all attributes of a tag node, calling the callback for each attribute
|
|
242
|
-
*/
|
|
243
|
-
export declare function forEachAttribute(node: HTMLOpenTagNode, callback: (attributeNode: HTMLAttributeNode) => void): void;
|
|
244
|
-
/**
|
|
245
|
-
* Base lexer visitor class that provides common functionality for lexer-based rule visitors
|
|
246
|
-
*/
|
|
247
|
-
export declare abstract class BaseLexerRuleVisitor<TAutofixContext extends BaseAutofixContext = BaseAutofixContext> {
|
|
248
|
-
readonly offenses: UnboundLintOffense<TAutofixContext>[];
|
|
249
|
-
protected ruleName: string;
|
|
250
|
-
protected context: LintContext;
|
|
251
|
-
constructor(ruleName: string, context?: Partial<LintContext>);
|
|
252
|
-
/**
|
|
253
|
-
* Helper method to create an unbound lint offense (without severity).
|
|
254
|
-
* The Linter will bind severity based on the rule's config.
|
|
255
|
-
*/
|
|
256
|
-
protected createOffense(message: string, location: Location, autofixContext?: TAutofixContext): UnboundLintOffense<TAutofixContext>;
|
|
257
|
-
/**
|
|
258
|
-
* Helper method to add an offense to the offenses array
|
|
259
|
-
*/
|
|
260
|
-
protected addOffense(message: string, location: Location, autofixContext?: TAutofixContext): void;
|
|
261
|
-
/**
|
|
262
|
-
* Main entry point for lexer rule visitors
|
|
263
|
-
* @param lexResult - The lexer result containing tokens and source
|
|
264
|
-
*/
|
|
265
|
-
visit(lexResult: LexResult): void;
|
|
266
|
-
/**
|
|
267
|
-
* Visit all tokens
|
|
268
|
-
* Override this method to implement token-level checks
|
|
269
|
-
*/
|
|
270
|
-
protected visitTokens(tokens: Token[]): void;
|
|
271
|
-
/**
|
|
272
|
-
* Visit individual tokens
|
|
273
|
-
* Override this method to implement per-token checks
|
|
274
|
-
*/
|
|
275
|
-
protected visitToken(_token: Token): void;
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Base source visitor class that provides common functionality for source-based rule visitors
|
|
279
|
-
*/
|
|
280
|
-
export declare abstract class BaseSourceRuleVisitor<TAutofixContext extends BaseAutofixContext = BaseAutofixContext> {
|
|
281
|
-
readonly offenses: UnboundLintOffense<TAutofixContext>[];
|
|
282
|
-
protected ruleName: string;
|
|
283
|
-
protected context: LintContext;
|
|
284
|
-
constructor(ruleName: string, context?: Partial<LintContext>);
|
|
285
|
-
/**
|
|
286
|
-
* Helper method to create an unbound lint offense (without severity).
|
|
287
|
-
* The Linter will bind severity based on the rule's config.
|
|
288
|
-
*/
|
|
289
|
-
protected createOffense(message: string, location: Location, autofixContext?: TAutofixContext): UnboundLintOffense<TAutofixContext>;
|
|
290
|
-
/**
|
|
291
|
-
* Helper method to add an offense to the offenses array
|
|
292
|
-
*/
|
|
293
|
-
protected addOffense(message: string, location: Location, autofixContext?: TAutofixContext): void;
|
|
294
|
-
/**
|
|
295
|
-
* Main entry point for source rule visitors
|
|
296
|
-
* @param source - The raw source code
|
|
297
|
-
*/
|
|
298
|
-
visit(source: string): void;
|
|
299
|
-
/**
|
|
300
|
-
* Visit the source code directly
|
|
301
|
-
* Override this method to implement source-level checks
|
|
302
|
-
*/
|
|
303
|
-
protected abstract visitSource(source: string): void;
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Autofix utilities for applying string replacements
|
|
307
|
-
*/
|
|
308
|
-
/**
|
|
309
|
-
* Checks if two locations are equal
|
|
310
|
-
* @param a - First location
|
|
311
|
-
* @param b - Second location
|
|
312
|
-
* @returns true if locations are equal
|
|
313
|
-
*/
|
|
314
|
-
export declare function locationsEqual(a: Location, b: Location): boolean;
|
|
315
|
-
/**
|
|
316
|
-
* Finds a node in the AST that has a specific location
|
|
317
|
-
* Uses direct recursive traversal for reliability
|
|
318
|
-
* @param root - The root node to search from
|
|
319
|
-
* @param location - The location to match
|
|
320
|
-
* @param predicate - Optional predicate function to filter nodes (e.g., isERBNode)
|
|
321
|
-
* @returns The matching node or null if not found
|
|
322
|
-
*/
|
|
323
|
-
export declare function findNodeByLocation(root: Node, location: Location, predicate?: (node: Node) => boolean): any;
|
|
324
|
-
/**
|
|
325
|
-
* AST Navigation Utilities
|
|
326
|
-
* These utilities help navigate the AST tree for complex autofix operations
|
|
327
|
-
*/
|
|
328
|
-
/**
|
|
329
|
-
* Finds the parent node of a given child node in the AST
|
|
330
|
-
* @param root - The root node to search from (typically the document node)
|
|
331
|
-
* @param target - The child node to find the parent of
|
|
332
|
-
* @returns The parent node, or null if not found
|
|
333
|
-
*
|
|
334
|
-
* @example
|
|
335
|
-
* const parent = findParent(result.value, offense.autofixContext.node)
|
|
336
|
-
* if (parent?.type === "AST_HTML_ELEMENT_NODE") {
|
|
337
|
-
* // Modify parent...
|
|
338
|
-
* }
|
|
339
|
-
*/
|
|
340
|
-
export declare function findParent(root: Node, target: Node): Node | null;
|
|
341
|
-
export declare const DOCUMENT_ONLY_TAG_NAMES: Set<string>;
|
|
342
|
-
export declare const HTML_ONLY_TAG_NAMES: Set<string>;
|
|
343
|
-
export declare const HEAD_ONLY_TAG_NAMES: Set<string>;
|
|
344
|
-
export declare const HEAD_AND_BODY_TAG_NAMES: Set<string>;
|
|
345
|
-
export declare function isDocumentOnlyTag(tagName: string): boolean;
|
|
346
|
-
export declare function isHtmlOnlyTag(tagName: string): boolean;
|
|
347
|
-
export declare function isHeadOnlyTag(tagName: string): boolean;
|
|
348
|
-
export declare function isHeadAndBodyTag(tagName: string): boolean;
|
|
349
|
-
export declare function isBodyOnlyTag(tagName: string): boolean;
|
|
350
|
-
export declare function isBodyTag(tagName: string): boolean;
|
|
351
|
-
export declare function isHeadTag(tagName: string): boolean;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if parentheses in a string are balanced
|
|
3
|
-
* Returns false if there are more closing parens than opening at any point
|
|
4
|
-
*/
|
|
5
|
-
export declare function hasBalancedParentheses(content: string): boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Splits a string by commas at the top level only
|
|
8
|
-
* Respects nested parentheses, brackets, braces, and strings
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* splitByTopLevelComma("a, b, c") // ["a", " b", " c"]
|
|
12
|
-
* splitByTopLevelComma("a, (b, c), d") // ["a", " (b, c)", " d"]
|
|
13
|
-
* splitByTopLevelComma('a, "b, c", d') // ["a", ' "b, c"', " d"]
|
|
14
|
-
*/
|
|
15
|
-
export declare function splitByTopLevelComma(str: string): string[];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ParserRule } from "../types.js";
|
|
2
|
-
import type { UnboundLintOffense, LintOffense, LintContext, BaseAutofixContext, Mutable, FullRuleConfig } from "../types.js";
|
|
3
|
-
import type { HTMLOpenTagNode, HTMLCloseTagNode, ParseResult } from "@herb-tools/core";
|
|
4
|
-
interface SVGTagNameCapitalizationAutofixContext extends BaseAutofixContext {
|
|
5
|
-
node: Mutable<HTMLOpenTagNode | HTMLCloseTagNode>;
|
|
6
|
-
currentTagName: string;
|
|
7
|
-
correctCamelCase: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class SVGTagNameCapitalizationRule extends ParserRule<SVGTagNameCapitalizationAutofixContext> {
|
|
10
|
-
static autocorrectable: boolean;
|
|
11
|
-
name: string;
|
|
12
|
-
get defaultConfig(): FullRuleConfig;
|
|
13
|
-
check(result: ParseResult, context?: Partial<LintContext>): UnboundLintOffense<SVGTagNameCapitalizationAutofixContext>[];
|
|
14
|
-
autofix(offense: LintOffense<SVGTagNameCapitalizationAutofixContext>, result: ParseResult, _context?: Partial<LintContext>): ParseResult | null;
|
|
15
|
-
}
|
|
16
|
-
export {};
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { Diagnostic, LexResult, ParseResult } from "@herb-tools/core";
|
|
2
|
-
import type { rules } from "./rules.js";
|
|
3
|
-
import type { Node } from "@herb-tools/core";
|
|
4
|
-
import type { RuleConfig } from "@herb-tools/config";
|
|
5
|
-
import type { Mutable } from "@herb-tools/rewriter";
|
|
6
|
-
export type { Mutable } from "@herb-tools/rewriter";
|
|
7
|
-
export type LintSeverity = "error" | "warning" | "info" | "hint";
|
|
8
|
-
export type FullRuleConfig = Required<Pick<RuleConfig, 'enabled' | 'severity'>> & Omit<RuleConfig, 'enabled' | 'severity'>;
|
|
9
|
-
/**
|
|
10
|
-
* Automatically inferred union type of all available linter rule names.
|
|
11
|
-
* This type extracts the 'name' property from each rule class instance.
|
|
12
|
-
*/
|
|
13
|
-
export type LinterRule = InstanceType<typeof rules[number]>['name'];
|
|
14
|
-
/**
|
|
15
|
-
* Base context for autofix operations. Contains the offending node.
|
|
16
|
-
* Rules can extend this interface to include rule-specific autofix data.
|
|
17
|
-
* Note: The node is typed as Mutable to allow direct mutation in autofix methods.
|
|
18
|
-
*/
|
|
19
|
-
export interface BaseAutofixContext {
|
|
20
|
-
/** The AST node, token, or data structure that caused the offense (mutable) */
|
|
21
|
-
node: Mutable<Node>;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* A lint offense without severity bound. Rules produce these, and the Linter
|
|
25
|
-
* binds severity based on the rule's defaultConfig and user config overrides.
|
|
26
|
-
*/
|
|
27
|
-
export interface UnboundLintOffense<TAutofixContext extends BaseAutofixContext = BaseAutofixContext> extends Omit<Diagnostic, 'severity'> {
|
|
28
|
-
rule: LinterRule;
|
|
29
|
-
/** Context data for autofix, including the offending node and rule-specific data */
|
|
30
|
-
autofixContext?: TAutofixContext;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* A lint offense with severity bound. The Linter produces these by binding
|
|
34
|
-
* severity to UnboundLintOffenses based on rule configuration.
|
|
35
|
-
*/
|
|
36
|
-
export interface LintOffense<TAutofixContext extends BaseAutofixContext = BaseAutofixContext> extends UnboundLintOffense<TAutofixContext> {
|
|
37
|
-
severity: LintSeverity;
|
|
38
|
-
}
|
|
39
|
-
export interface LintResult<TAutofixContext extends BaseAutofixContext = BaseAutofixContext> {
|
|
40
|
-
offenses: LintOffense<TAutofixContext>[];
|
|
41
|
-
errors: number;
|
|
42
|
-
warnings: number;
|
|
43
|
-
info: number;
|
|
44
|
-
hints: number;
|
|
45
|
-
ignored: number;
|
|
46
|
-
wouldBeIgnored?: number;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Result of applying autofixes to source code
|
|
50
|
-
*/
|
|
51
|
-
export interface AutofixResult<TAutofixContext extends BaseAutofixContext = BaseAutofixContext> {
|
|
52
|
-
/** The corrected source code with all fixes applied */
|
|
53
|
-
source: string;
|
|
54
|
-
/** Offenses that were successfully fixed */
|
|
55
|
-
fixed: LintOffense<TAutofixContext>[];
|
|
56
|
-
/** Offenses that could not be automatically fixed */
|
|
57
|
-
unfixed: LintOffense<TAutofixContext>[];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Default configuration for rules when defaultConfig is not specified.
|
|
61
|
-
* Custom rules can omit defaultConfig and will use these defaults.
|
|
62
|
-
*/
|
|
63
|
-
export declare const DEFAULT_RULE_CONFIG: FullRuleConfig;
|
|
64
|
-
/**
|
|
65
|
-
* Base class for parser rules.
|
|
66
|
-
*/
|
|
67
|
-
export declare abstract class ParserRule<TAutofixContext extends BaseAutofixContext = BaseAutofixContext> {
|
|
68
|
-
static type: "parser";
|
|
69
|
-
/** Indicates whether this rule supports autofix. Defaults to false. */
|
|
70
|
-
static autocorrectable: boolean;
|
|
71
|
-
/** Indicates whether this rule supports unsafe autofix (requires --fix-unsafely). Defaults to false. */
|
|
72
|
-
static unsafeAutocorrectable: boolean;
|
|
73
|
-
abstract name: string;
|
|
74
|
-
get defaultConfig(): FullRuleConfig;
|
|
75
|
-
abstract check(result: ParseResult, context?: Partial<LintContext>): UnboundLintOffense<TAutofixContext>[];
|
|
76
|
-
/**
|
|
77
|
-
* Optional method to determine if this rule should run.
|
|
78
|
-
* If not implemented, rule is always enabled.
|
|
79
|
-
* @param result - The parse result to analyze
|
|
80
|
-
* @param context - Optional context for linting
|
|
81
|
-
* @returns true if rule should run, false to skip
|
|
82
|
-
*/
|
|
83
|
-
isEnabled?(result: ParseResult, context?: Partial<LintContext>): boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Optional method to automatically fix an offense by mutating the AST.
|
|
86
|
-
* If not implemented, the rule does not support autofix.
|
|
87
|
-
* @param offense - The offense to fix (includes autofixContext with node and rule-specific data)
|
|
88
|
-
* @param result - The parse result containing the AST (mutate it directly and return it)
|
|
89
|
-
* @param context - Optional context for linting
|
|
90
|
-
* @returns The mutated ParseResult if fixed, or null if the offense could not be fixed
|
|
91
|
-
*/
|
|
92
|
-
autofix?(offense: LintOffense<TAutofixContext>, result: ParseResult, context?: Partial<LintContext>): ParseResult | null;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Base class for lexer rules.
|
|
96
|
-
*/
|
|
97
|
-
export declare abstract class LexerRule<TAutofixContext extends BaseAutofixContext = BaseAutofixContext> {
|
|
98
|
-
static type: "lexer";
|
|
99
|
-
/** Indicates whether this rule supports autofix. Defaults to false. */
|
|
100
|
-
static autocorrectable: boolean;
|
|
101
|
-
/** Indicates whether this rule supports unsafe autofix (requires --fix-unsafely). Defaults to false. */
|
|
102
|
-
static unsafeAutocorrectable: boolean;
|
|
103
|
-
abstract name: string;
|
|
104
|
-
get defaultConfig(): FullRuleConfig;
|
|
105
|
-
abstract check(lexResult: LexResult, context?: Partial<LintContext>): UnboundLintOffense<TAutofixContext>[];
|
|
106
|
-
/**
|
|
107
|
-
* Optional method to determine if this rule should run.
|
|
108
|
-
* If not implemented, rule is always enabled.
|
|
109
|
-
* @param lexResult - The lex result to analyze
|
|
110
|
-
* @param context - Optional context for linting
|
|
111
|
-
* @returns true if rule should run, false to skip
|
|
112
|
-
*/
|
|
113
|
-
isEnabled?(lexResult: LexResult, context?: Partial<LintContext>): boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Optional method to automatically fix an offense by mutating tokens.
|
|
116
|
-
* If not implemented, the rule does not support autofix.
|
|
117
|
-
* @param offense - The offense to fix (includes autofixContext with node and rule-specific data)
|
|
118
|
-
* @param lexResult - The lex result containing tokens (mutate them directly and return)
|
|
119
|
-
* @param context - Optional context for linting
|
|
120
|
-
* @returns The mutated LexResult if fixed, or null if the offense could not be fixed
|
|
121
|
-
*/
|
|
122
|
-
autofix?(offense: LintOffense<TAutofixContext>, lexResult: LexResult, context?: Partial<LintContext>): LexResult | null;
|
|
123
|
-
}
|
|
124
|
-
export interface LexerRuleConstructor {
|
|
125
|
-
type: "lexer";
|
|
126
|
-
new (): LexerRule;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Complete lint context with all properties defined.
|
|
130
|
-
* Use Partial<LintContext> when passing context to rules.
|
|
131
|
-
*/
|
|
132
|
-
export interface LintContext {
|
|
133
|
-
fileName: string | undefined;
|
|
134
|
-
validRuleNames: string[] | undefined;
|
|
135
|
-
ignoredOffensesByLine: Map<number, Set<string>> | undefined;
|
|
136
|
-
ignoreDisableComments: boolean | undefined;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Default context object with all keys defined but set to undefined
|
|
140
|
-
*/
|
|
141
|
-
export declare const DEFAULT_LINT_CONTEXT: LintContext;
|
|
142
|
-
export declare abstract class SourceRule<TAutofixContext extends BaseAutofixContext = BaseAutofixContext> {
|
|
143
|
-
static type: "source";
|
|
144
|
-
/** Indicates whether this rule supports autofix. Defaults to false. */
|
|
145
|
-
static autocorrectable: boolean;
|
|
146
|
-
/** Indicates whether this rule supports unsafe autofix (requires --fix-unsafely). Defaults to false. */
|
|
147
|
-
static unsafeAutocorrectable: boolean;
|
|
148
|
-
abstract name: string;
|
|
149
|
-
get defaultConfig(): FullRuleConfig;
|
|
150
|
-
abstract check(source: string, context?: Partial<LintContext>): UnboundLintOffense<TAutofixContext>[];
|
|
151
|
-
/**
|
|
152
|
-
* Optional method to determine if this rule should run.
|
|
153
|
-
* If not implemented, rule is always enabled.
|
|
154
|
-
* @param source - The source code to analyze
|
|
155
|
-
* @param context - Optional context for linting
|
|
156
|
-
* @returns true if rule should run, false to skip
|
|
157
|
-
*/
|
|
158
|
-
isEnabled?(source: string, context?: Partial<LintContext>): boolean;
|
|
159
|
-
/**
|
|
160
|
-
* Optional method to automatically fix an offense.
|
|
161
|
-
* If not implemented, the rule does not support autofix.
|
|
162
|
-
* @param offense - The offense to fix (includes autofixContext with node and rule-specific data)
|
|
163
|
-
* @param source - The original source code
|
|
164
|
-
* @param context - Optional context for linting
|
|
165
|
-
* @returns The corrected source if the offense can be fixed, null otherwise
|
|
166
|
-
*/
|
|
167
|
-
autofix?(offense: LintOffense<TAutofixContext>, source: string, context?: Partial<LintContext>): string | null;
|
|
168
|
-
}
|
|
169
|
-
export interface SourceRuleConstructor {
|
|
170
|
-
type: "source";
|
|
171
|
-
new (): SourceRule;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Type representing a parser/AST rule class constructor.
|
|
175
|
-
* The Linter accepts rule classes rather than instances for better performance and memory usage.
|
|
176
|
-
* Parser rules are the default and don't require static properties.
|
|
177
|
-
*/
|
|
178
|
-
export type ParserRuleClass = (new () => ParserRule) & {
|
|
179
|
-
type?: "parser";
|
|
180
|
-
};
|
|
181
|
-
export type LexerRuleClass = LexerRuleConstructor;
|
|
182
|
-
export type SourceRuleClass = SourceRuleConstructor;
|
|
183
|
-
/**
|
|
184
|
-
* Union type for any rule instance (Parser/AST, Lexer, or Source)
|
|
185
|
-
*/
|
|
186
|
-
export type Rule = ParserRule | LexerRule | SourceRule;
|
|
187
|
-
/**
|
|
188
|
-
* Union type for any rule class (Parser/AST, Lexer, or Source)
|
|
189
|
-
*/
|
|
190
|
-
export type RuleClass = ParserRuleClass | LexerRuleClass | SourceRuleClass;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|