@herb-tools/linter 0.7.4 → 0.8.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 +253 -13
- package/dist/herb-lint.js +26087 -3414
- package/dist/herb-lint.js.map +1 -1
- package/dist/index.cjs +5783 -1568
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5749 -1569
- package/dist/index.js.map +1 -1
- package/dist/loader.cjs +17010 -0
- package/dist/loader.cjs.map +1 -0
- package/dist/loader.js +16879 -0
- package/dist/loader.js.map +1 -0
- package/dist/package.json +13 -5
- package/dist/src/cli/argument-parser.js +42 -35
- package/dist/src/cli/argument-parser.js.map +1 -1
- package/dist/src/cli/file-processor.js +124 -23
- package/dist/src/cli/file-processor.js.map +1 -1
- package/dist/src/cli/formatters/detailed-formatter.js +18 -3
- package/dist/src/cli/formatters/detailed-formatter.js.map +1 -1
- package/dist/src/cli/formatters/github-actions-formatter.js +15 -1
- package/dist/src/cli/formatters/github-actions-formatter.js.map +1 -1
- package/dist/src/cli/formatters/json-formatter.js +3 -0
- package/dist/src/cli/formatters/json-formatter.js.map +1 -1
- package/dist/src/cli/formatters/simple-formatter.js +20 -7
- package/dist/src/cli/formatters/simple-formatter.js.map +1 -1
- package/dist/src/cli/output-manager.js +22 -3
- package/dist/src/cli/output-manager.js.map +1 -1
- package/dist/src/cli/summary-reporter.js +26 -3
- package/dist/src/cli/summary-reporter.js.map +1 -1
- package/dist/src/cli.js +109 -43
- package/dist/src/cli.js.map +1 -1
- package/dist/src/custom-rule-loader.js +139 -0
- package/dist/src/custom-rule-loader.js.map +1 -0
- package/dist/src/herb-disable-comment-utils.js +129 -0
- package/dist/src/herb-disable-comment-utils.js.map +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/linter.js +369 -34
- package/dist/src/linter.js.map +1 -1
- package/dist/src/loader.js +17 -0
- package/dist/src/loader.js.map +1 -0
- package/dist/src/rules/erb-comment-syntax.js +48 -0
- package/dist/src/rules/erb-comment-syntax.js.map +1 -0
- package/dist/src/rules/erb-no-case-node-children.js +52 -0
- package/dist/src/rules/erb-no-case-node-children.js.map +1 -0
- package/dist/src/rules/erb-no-empty-tags.js +7 -1
- package/dist/src/rules/erb-no-empty-tags.js.map +1 -1
- package/dist/src/rules/erb-no-extra-newline.js +65 -0
- package/dist/src/rules/erb-no-extra-newline.js.map +1 -0
- package/dist/src/rules/erb-no-extra-whitespace-inside-tags.js +95 -0
- package/dist/src/rules/erb-no-extra-whitespace-inside-tags.js.map +1 -0
- package/dist/src/rules/erb-no-output-control-flow.js +7 -1
- package/dist/src/rules/erb-no-output-control-flow.js.map +1 -1
- package/dist/src/rules/erb-no-silent-tag-in-attribute-name.js +7 -1
- package/dist/src/rules/erb-no-silent-tag-in-attribute-name.js.map +1 -1
- package/dist/src/rules/erb-prefer-image-tag-helper.js +7 -1
- package/dist/src/rules/erb-prefer-image-tag-helper.js.map +1 -1
- package/dist/src/rules/erb-require-trailing-newline.js +35 -0
- package/dist/src/rules/erb-require-trailing-newline.js.map +1 -0
- package/dist/src/rules/erb-require-whitespace-inside-tags.js +70 -20
- package/dist/src/rules/erb-require-whitespace-inside-tags.js.map +1 -1
- package/dist/src/rules/erb-right-trim.js +45 -0
- package/dist/src/rules/erb-right-trim.js.map +1 -0
- package/dist/src/rules/herb-disable-comment-base.js +51 -0
- package/dist/src/rules/herb-disable-comment-base.js.map +1 -0
- package/dist/src/rules/herb-disable-comment-malformed.js +51 -0
- package/dist/src/rules/herb-disable-comment-malformed.js.map +1 -0
- package/dist/src/rules/herb-disable-comment-missing-rules.js +29 -0
- package/dist/src/rules/herb-disable-comment-missing-rules.js.map +1 -0
- package/dist/src/rules/herb-disable-comment-no-duplicate-rules.js +32 -0
- package/dist/src/rules/herb-disable-comment-no-duplicate-rules.js.map +1 -0
- package/dist/src/rules/herb-disable-comment-no-redundant-all.js +31 -0
- package/dist/src/rules/herb-disable-comment-no-redundant-all.js.map +1 -0
- package/dist/src/rules/herb-disable-comment-unnecessary.js +65 -0
- package/dist/src/rules/herb-disable-comment-unnecessary.js.map +1 -0
- package/dist/src/rules/herb-disable-comment-valid-rule-name.js +44 -0
- package/dist/src/rules/herb-disable-comment-valid-rule-name.js.map +1 -0
- package/dist/src/rules/html-anchor-require-href.js +7 -1
- package/dist/src/rules/html-anchor-require-href.js.map +1 -1
- package/dist/src/rules/html-aria-attribute-must-be-valid.js +7 -1
- package/dist/src/rules/html-aria-attribute-must-be-valid.js.map +1 -1
- package/dist/src/rules/html-aria-label-is-well-formatted.js +9 -3
- package/dist/src/rules/html-aria-label-is-well-formatted.js.map +1 -1
- package/dist/src/rules/html-aria-level-must-be-valid.js +6 -0
- package/dist/src/rules/html-aria-level-must-be-valid.js.map +1 -1
- package/dist/src/rules/html-aria-role-heading-requires-level.js +7 -1
- package/dist/src/rules/html-aria-role-heading-requires-level.js.map +1 -1
- package/dist/src/rules/html-aria-role-must-be-valid.js +7 -1
- package/dist/src/rules/html-aria-role-must-be-valid.js.map +1 -1
- package/dist/src/rules/html-attribute-double-quotes.js +29 -2
- package/dist/src/rules/html-attribute-double-quotes.js.map +1 -1
- package/dist/src/rules/html-attribute-equals-spacing.js +18 -2
- package/dist/src/rules/html-attribute-equals-spacing.js.map +1 -1
- package/dist/src/rules/html-attribute-values-require-quotes.js +39 -3
- package/dist/src/rules/html-attribute-values-require-quotes.js.map +1 -1
- package/dist/src/rules/html-avoid-both-disabled-and-aria-disabled.js +7 -1
- package/dist/src/rules/html-avoid-both-disabled-and-aria-disabled.js.map +1 -1
- package/dist/src/rules/html-body-only-elements.js +46 -0
- package/dist/src/rules/html-body-only-elements.js.map +1 -0
- package/dist/src/rules/html-boolean-attributes-no-value.js +18 -1
- package/dist/src/rules/html-boolean-attributes-no-value.js.map +1 -1
- package/dist/src/rules/html-head-only-elements.js +51 -0
- package/dist/src/rules/html-head-only-elements.js.map +1 -0
- package/dist/src/rules/html-iframe-has-title.js +8 -2
- package/dist/src/rules/html-iframe-has-title.js.map +1 -1
- package/dist/src/rules/html-img-require-alt.js +7 -1
- package/dist/src/rules/html-img-require-alt.js.map +1 -1
- package/dist/src/rules/html-input-require-autocomplete.js +70 -0
- package/dist/src/rules/html-input-require-autocomplete.js.map +1 -0
- package/dist/src/rules/html-navigation-has-label.js +7 -1
- package/dist/src/rules/html-navigation-has-label.js.map +1 -1
- package/dist/src/rules/html-no-aria-hidden-on-focusable.js +7 -1
- package/dist/src/rules/html-no-aria-hidden-on-focusable.js.map +1 -1
- package/dist/src/rules/html-no-block-inside-inline.js +7 -1
- package/dist/src/rules/html-no-block-inside-inline.js.map +1 -1
- package/dist/src/rules/html-no-duplicate-attributes.js +7 -1
- package/dist/src/rules/html-no-duplicate-attributes.js.map +1 -1
- package/dist/src/rules/html-no-duplicate-ids.js +9 -3
- package/dist/src/rules/html-no-duplicate-ids.js.map +1 -1
- package/dist/src/rules/html-no-duplicate-meta-names.js +136 -0
- package/dist/src/rules/html-no-duplicate-meta-names.js.map +1 -0
- package/dist/src/rules/html-no-empty-attributes.js +45 -7
- package/dist/src/rules/html-no-empty-attributes.js.map +1 -1
- package/dist/src/rules/html-no-empty-headings.js +7 -6
- package/dist/src/rules/html-no-empty-headings.js.map +1 -1
- package/dist/src/rules/html-no-nested-links.js +7 -1
- package/dist/src/rules/html-no-nested-links.js.map +1 -1
- package/dist/src/rules/html-no-positive-tab-index.js +7 -1
- package/dist/src/rules/html-no-positive-tab-index.js.map +1 -1
- package/dist/src/rules/html-no-self-closing.js +48 -3
- package/dist/src/rules/html-no-self-closing.js.map +1 -1
- package/dist/src/rules/html-no-space-in-tag.js +173 -0
- package/dist/src/rules/html-no-space-in-tag.js.map +1 -0
- package/dist/src/rules/html-no-title-attribute.js +7 -1
- package/dist/src/rules/html-no-title-attribute.js.map +1 -1
- package/dist/src/rules/html-no-underscores-in-attribute-names.js +7 -1
- package/dist/src/rules/html-no-underscores-in-attribute-names.js.map +1 -1
- package/dist/src/rules/html-tag-name-lowercase.js +23 -5
- package/dist/src/rules/html-tag-name-lowercase.js.map +1 -1
- package/dist/src/rules/index.js +20 -2
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/parser-no-errors.js +6 -0
- package/dist/src/rules/parser-no-errors.js.map +1 -1
- package/dist/src/rules/rule-utils.js +211 -31
- package/dist/src/rules/rule-utils.js.map +1 -1
- package/dist/src/rules/svg-tag-name-capitalization.js +22 -2
- package/dist/src/rules/svg-tag-name-capitalization.js.map +1 -1
- package/dist/src/{default-rules.js → rules.js} +46 -14
- package/dist/src/rules.js.map +1 -0
- package/dist/src/types.js +34 -1
- package/dist/src/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/cli/argument-parser.d.ts +8 -2
- package/dist/types/cli/file-processor.d.ts +15 -0
- package/dist/types/cli/formatters/json-formatter.d.ts +6 -0
- package/dist/types/cli/formatters/simple-formatter.d.ts +1 -0
- package/dist/types/cli/summary-reporter.d.ts +6 -0
- package/dist/types/cli.d.ts +9 -4
- package/dist/types/custom-rule-loader.d.ts +62 -0
- package/dist/types/herb-disable-comment-utils.d.ts +69 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/linter.d.ts +99 -3
- package/dist/types/loader.d.ts +20 -0
- package/dist/types/rules/erb-comment-syntax.d.ts +14 -0
- package/dist/types/rules/erb-no-case-node-children.d.ts +8 -0
- package/dist/types/rules/erb-no-empty-tags.d.ts +3 -2
- package/dist/types/rules/erb-no-extra-newline.d.ts +14 -0
- package/dist/types/rules/erb-no-extra-whitespace-inside-tags.d.ts +18 -0
- package/dist/types/rules/erb-no-output-control-flow.d.ts +3 -2
- package/dist/types/rules/erb-no-silent-tag-in-attribute-name.d.ts +3 -2
- package/dist/types/rules/erb-prefer-image-tag-helper.d.ts +3 -2
- package/dist/types/rules/erb-require-trailing-newline.d.ts +9 -0
- package/dist/types/rules/erb-require-whitespace-inside-tags.d.ts +16 -5
- package/dist/types/rules/erb-right-trim.d.ts +14 -0
- package/dist/types/rules/herb-disable-comment-base.d.ts +37 -0
- package/dist/types/rules/herb-disable-comment-malformed.d.ts +8 -0
- package/dist/types/rules/herb-disable-comment-missing-rules.d.ts +8 -0
- package/dist/types/rules/herb-disable-comment-no-duplicate-rules.d.ts +8 -0
- package/dist/types/rules/herb-disable-comment-no-redundant-all.d.ts +8 -0
- package/dist/types/rules/herb-disable-comment-unnecessary.d.ts +8 -0
- package/dist/types/rules/herb-disable-comment-valid-rule-name.d.ts +8 -0
- package/dist/types/rules/html-anchor-require-href.d.ts +3 -2
- package/dist/types/rules/html-aria-attribute-must-be-valid.d.ts +3 -2
- package/dist/types/rules/html-aria-label-is-well-formatted.d.ts +3 -2
- package/dist/types/rules/html-aria-level-must-be-valid.d.ts +3 -2
- package/dist/types/rules/html-aria-role-heading-requires-level.d.ts +3 -2
- package/dist/types/rules/html-aria-role-must-be-valid.d.ts +3 -2
- package/dist/types/rules/html-attribute-double-quotes.d.ts +13 -5
- package/dist/types/rules/html-attribute-equals-spacing.d.ts +12 -5
- package/dist/types/rules/html-attribute-values-require-quotes.d.ts +13 -5
- package/dist/types/rules/html-avoid-both-disabled-and-aria-disabled.d.ts +3 -2
- package/dist/types/rules/html-body-only-elements.d.ts +9 -0
- package/dist/types/rules/html-boolean-attributes-no-value.d.ts +12 -5
- package/dist/types/rules/html-head-only-elements.d.ts +9 -0
- package/dist/types/rules/html-iframe-has-title.d.ts +3 -2
- package/dist/types/rules/html-img-require-alt.d.ts +3 -2
- package/dist/types/rules/html-input-require-autocomplete.d.ts +8 -0
- package/dist/types/rules/html-navigation-has-label.d.ts +3 -2
- package/dist/types/rules/html-no-aria-hidden-on-focusable.d.ts +3 -2
- package/dist/types/rules/html-no-block-inside-inline.d.ts +3 -2
- package/dist/types/rules/html-no-duplicate-attributes.d.ts +3 -2
- package/dist/types/rules/html-no-duplicate-ids.d.ts +3 -2
- package/dist/types/rules/html-no-duplicate-meta-names.d.ts +9 -0
- package/dist/types/rules/html-no-empty-attributes.d.ts +3 -2
- package/dist/types/rules/html-no-empty-headings.d.ts +3 -2
- package/dist/types/rules/html-no-nested-links.d.ts +3 -2
- package/dist/types/rules/html-no-positive-tab-index.d.ts +3 -2
- package/dist/types/rules/html-no-self-closing.d.ts +14 -5
- package/dist/types/rules/html-no-space-in-tag.d.ts +16 -0
- package/dist/types/rules/html-no-title-attribute.d.ts +3 -2
- package/dist/types/rules/html-no-underscores-in-attribute-names.d.ts +3 -2
- package/dist/types/rules/html-tag-name-lowercase.d.ts +16 -6
- package/dist/types/rules/index.d.ts +20 -2
- package/dist/types/rules/parser-no-errors.d.ts +2 -1
- package/dist/types/rules/rule-utils.d.ts +72 -25
- package/dist/types/rules/svg-tag-name-capitalization.d.ts +13 -4
- package/dist/types/rules.d.ts +2 -0
- package/dist/types/src/cli/argument-parser.d.ts +8 -2
- package/dist/types/src/cli/file-processor.d.ts +15 -0
- package/dist/types/src/cli/formatters/json-formatter.d.ts +6 -0
- package/dist/types/src/cli/formatters/simple-formatter.d.ts +1 -0
- package/dist/types/src/cli/summary-reporter.d.ts +6 -0
- package/dist/types/src/cli.d.ts +9 -4
- package/dist/types/src/custom-rule-loader.d.ts +62 -0
- package/dist/types/src/herb-disable-comment-utils.d.ts +69 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/linter.d.ts +99 -3
- package/dist/types/src/loader.d.ts +20 -0
- package/dist/types/src/rules/erb-comment-syntax.d.ts +14 -0
- package/dist/types/src/rules/erb-no-case-node-children.d.ts +8 -0
- package/dist/types/src/rules/erb-no-empty-tags.d.ts +3 -2
- package/dist/types/src/rules/erb-no-extra-newline.d.ts +14 -0
- package/dist/types/src/rules/erb-no-extra-whitespace-inside-tags.d.ts +18 -0
- package/dist/types/src/rules/erb-no-output-control-flow.d.ts +3 -2
- package/dist/types/src/rules/erb-no-silent-tag-in-attribute-name.d.ts +3 -2
- package/dist/types/src/rules/erb-prefer-image-tag-helper.d.ts +3 -2
- package/dist/types/src/rules/erb-require-trailing-newline.d.ts +9 -0
- package/dist/types/src/rules/erb-require-whitespace-inside-tags.d.ts +16 -5
- package/dist/types/src/rules/erb-right-trim.d.ts +14 -0
- package/dist/types/src/rules/herb-disable-comment-base.d.ts +37 -0
- package/dist/types/src/rules/herb-disable-comment-malformed.d.ts +8 -0
- package/dist/types/src/rules/herb-disable-comment-missing-rules.d.ts +8 -0
- package/dist/types/src/rules/herb-disable-comment-no-duplicate-rules.d.ts +8 -0
- package/dist/types/src/rules/herb-disable-comment-no-redundant-all.d.ts +8 -0
- package/dist/types/src/rules/herb-disable-comment-unnecessary.d.ts +8 -0
- package/dist/types/src/rules/herb-disable-comment-valid-rule-name.d.ts +8 -0
- package/dist/types/src/rules/html-anchor-require-href.d.ts +3 -2
- package/dist/types/src/rules/html-aria-attribute-must-be-valid.d.ts +3 -2
- package/dist/types/src/rules/html-aria-label-is-well-formatted.d.ts +3 -2
- package/dist/types/src/rules/html-aria-level-must-be-valid.d.ts +3 -2
- package/dist/types/src/rules/html-aria-role-heading-requires-level.d.ts +3 -2
- package/dist/types/src/rules/html-aria-role-must-be-valid.d.ts +3 -2
- package/dist/types/src/rules/html-attribute-double-quotes.d.ts +13 -5
- package/dist/types/src/rules/html-attribute-equals-spacing.d.ts +12 -5
- package/dist/types/src/rules/html-attribute-values-require-quotes.d.ts +13 -5
- package/dist/types/src/rules/html-avoid-both-disabled-and-aria-disabled.d.ts +3 -2
- package/dist/types/src/rules/html-body-only-elements.d.ts +9 -0
- package/dist/types/src/rules/html-boolean-attributes-no-value.d.ts +12 -5
- package/dist/types/src/rules/html-head-only-elements.d.ts +9 -0
- package/dist/types/src/rules/html-iframe-has-title.d.ts +3 -2
- package/dist/types/src/rules/html-img-require-alt.d.ts +3 -2
- package/dist/types/src/rules/html-input-require-autocomplete.d.ts +8 -0
- package/dist/types/src/rules/html-navigation-has-label.d.ts +3 -2
- package/dist/types/src/rules/html-no-aria-hidden-on-focusable.d.ts +3 -2
- package/dist/types/src/rules/html-no-block-inside-inline.d.ts +3 -2
- package/dist/types/src/rules/html-no-duplicate-attributes.d.ts +3 -2
- package/dist/types/src/rules/html-no-duplicate-ids.d.ts +3 -2
- package/dist/types/src/rules/html-no-duplicate-meta-names.d.ts +9 -0
- package/dist/types/src/rules/html-no-empty-attributes.d.ts +3 -2
- package/dist/types/src/rules/html-no-empty-headings.d.ts +3 -2
- package/dist/types/src/rules/html-no-nested-links.d.ts +3 -2
- package/dist/types/src/rules/html-no-positive-tab-index.d.ts +3 -2
- package/dist/types/src/rules/html-no-self-closing.d.ts +14 -5
- package/dist/types/src/rules/html-no-space-in-tag.d.ts +16 -0
- package/dist/types/src/rules/html-no-title-attribute.d.ts +3 -2
- package/dist/types/src/rules/html-no-underscores-in-attribute-names.d.ts +3 -2
- package/dist/types/src/rules/html-tag-name-lowercase.d.ts +16 -6
- package/dist/types/src/rules/index.d.ts +20 -2
- package/dist/types/src/rules/parser-no-errors.d.ts +2 -1
- package/dist/types/src/rules/rule-utils.d.ts +72 -25
- package/dist/types/src/rules/svg-tag-name-capitalization.d.ts +13 -4
- package/dist/types/src/rules.d.ts +2 -0
- package/dist/types/src/types.d.ts +102 -11
- package/dist/types/types.d.ts +102 -11
- package/docs/rules/README.md +19 -3
- package/docs/rules/erb-comment-syntax.md +44 -0
- package/docs/rules/erb-no-case-node-children.md +50 -0
- package/docs/rules/erb-no-extra-newline.md +74 -0
- package/docs/rules/erb-no-extra-whitespace-inside-tags.md +39 -0
- package/docs/rules/{erb-requires-trailing-newline.md → erb-require-trailing-newline.md} +1 -1
- package/docs/rules/erb-right-trim.md +52 -0
- package/docs/rules/herb-disable-comment-malformed.md +45 -0
- package/docs/rules/herb-disable-comment-missing-rules.md +60 -0
- package/docs/rules/herb-disable-comment-no-duplicate-rules.md +49 -0
- package/docs/rules/herb-disable-comment-no-redundant-all.md +53 -0
- package/docs/rules/herb-disable-comment-unnecessary.md +44 -0
- package/docs/rules/herb-disable-comment-valid-rule-name.md +41 -0
- package/docs/rules/html-aria-attribute-must-be-valid.md +2 -5
- package/docs/rules/html-aria-label-is-well-formatted.md +1 -1
- package/docs/rules/html-attribute-double-quotes.md +2 -2
- package/docs/rules/html-attribute-equals-spacing.md +2 -2
- package/docs/rules/html-attribute-values-require-quotes.md +3 -3
- package/docs/rules/html-avoid-both-disabled-and-aria-disabled.md +2 -2
- package/docs/rules/html-body-only-elements.md +99 -0
- package/docs/rules/html-boolean-attributes-no-value.md +2 -2
- package/docs/rules/html-head-only-elements.md +81 -0
- package/docs/rules/html-input-require-autocomplete.md +64 -0
- package/docs/rules/html-no-aria-hidden-on-focusable.md +2 -2
- package/docs/rules/html-no-duplicate-attributes.md +2 -2
- package/docs/rules/html-no-duplicate-meta-names.md +64 -0
- package/docs/rules/html-no-empty-attributes.md +3 -3
- package/docs/rules/html-no-empty-headings.md +4 -26
- package/docs/rules/html-no-positive-tab-index.md +1 -2
- package/docs/rules/html-no-self-closing.md +17 -2
- package/docs/rules/html-no-space-in-tag.md +66 -0
- package/docs/rules/html-no-title-attribute.md +2 -2
- package/docs/rules/html-no-underscores-in-attribute-names.md +2 -2
- package/docs/rules/html-tag-name-lowercase.md +2 -2
- package/package.json +13 -5
- package/src/cli/argument-parser.ts +50 -39
- package/src/cli/file-processor.ts +159 -28
- package/src/cli/formatters/detailed-formatter.ts +21 -3
- package/src/cli/formatters/github-actions-formatter.ts +17 -1
- package/src/cli/formatters/json-formatter.ts +9 -0
- package/src/cli/formatters/simple-formatter.ts +24 -8
- package/src/cli/output-manager.ts +23 -3
- package/src/cli/summary-reporter.ts +40 -3
- package/src/cli.ts +137 -52
- package/src/custom-rule-loader.ts +189 -0
- package/src/herb-disable-comment-utils.ts +175 -0
- package/src/index.ts +2 -0
- package/src/linter.ts +501 -36
- package/src/loader.ts +30 -0
- package/src/rules/erb-comment-syntax.ts +73 -0
- package/src/rules/erb-no-case-node-children.ts +68 -0
- package/src/rules/erb-no-empty-tags.ts +9 -3
- package/src/rules/erb-no-extra-newline.ts +91 -0
- package/src/rules/erb-no-extra-whitespace-inside-tags.ts +147 -0
- package/src/rules/erb-no-output-control-flow.ts +9 -3
- package/src/rules/erb-no-silent-tag-in-attribute-name.ts +9 -3
- package/src/rules/erb-prefer-image-tag-helper.ts +9 -3
- package/src/rules/erb-require-trailing-newline.ts +47 -0
- package/src/rules/erb-require-whitespace-inside-tags.ts +96 -26
- package/src/rules/erb-right-trim.ts +67 -0
- package/src/rules/herb-disable-comment-base.ts +76 -0
- package/src/rules/herb-disable-comment-malformed.ts +66 -0
- package/src/rules/herb-disable-comment-missing-rules.ts +41 -0
- package/src/rules/herb-disable-comment-no-duplicate-rules.ts +46 -0
- package/src/rules/herb-disable-comment-no-redundant-all.ts +40 -0
- package/src/rules/herb-disable-comment-unnecessary.ts +103 -0
- package/src/rules/herb-disable-comment-valid-rule-name.ts +62 -0
- package/src/rules/html-anchor-require-href.ts +9 -3
- package/src/rules/html-aria-attribute-must-be-valid.ts +9 -3
- package/src/rules/html-aria-label-is-well-formatted.ts +9 -5
- package/src/rules/html-aria-level-must-be-valid.ts +9 -2
- package/src/rules/html-aria-role-heading-requires-level.ts +9 -3
- package/src/rules/html-aria-role-must-be-valid.ts +9 -3
- package/src/rules/html-attribute-double-quotes.ts +42 -8
- package/src/rules/html-attribute-equals-spacing.ts +31 -7
- package/src/rules/html-attribute-values-require-quotes.ts +56 -10
- package/src/rules/html-avoid-both-disabled-and-aria-disabled.ts +9 -3
- package/src/rules/html-body-only-elements.ts +60 -0
- package/src/rules/html-boolean-attributes-no-value.ts +31 -6
- package/src/rules/html-head-only-elements.ts +65 -0
- package/src/rules/html-iframe-has-title.ts +9 -4
- package/src/rules/html-img-require-alt.ts +10 -4
- package/src/rules/html-input-require-autocomplete.ts +85 -0
- package/src/rules/html-navigation-has-label.ts +9 -3
- package/src/rules/html-no-aria-hidden-on-focusable.ts +9 -3
- package/src/rules/html-no-block-inside-inline.ts +9 -3
- package/src/rules/html-no-duplicate-attributes.ts +9 -3
- package/src/rules/html-no-duplicate-ids.ts +11 -7
- package/src/rules/html-no-duplicate-meta-names.ts +188 -0
- package/src/rules/html-no-empty-attributes.ts +58 -10
- package/src/rules/html-no-empty-headings.ts +10 -8
- package/src/rules/html-no-nested-links.ts +10 -4
- package/src/rules/html-no-positive-tab-index.ts +9 -3
- package/src/rules/html-no-self-closing.ts +69 -9
- package/src/rules/html-no-space-in-tag.ts +221 -0
- package/src/rules/html-no-title-attribute.ts +9 -3
- package/src/rules/html-no-underscores-in-attribute-names.ts +12 -4
- package/src/rules/html-tag-name-lowercase.ts +41 -10
- package/src/rules/index.ts +24 -2
- package/src/rules/parser-no-errors.ts +8 -1
- package/src/rules/rule-utils.ts +250 -44
- package/src/rules/svg-tag-name-capitalization.ts +39 -6
- package/src/{default-rules.ts → rules.ts} +53 -13
- package/src/types.ts +133 -15
- package/dist/src/default-rules.js.map +0 -1
- package/dist/src/rules/erb-requires-trailing-newline.js +0 -22
- package/dist/src/rules/erb-requires-trailing-newline.js.map +0 -1
- package/dist/types/default-rules.d.ts +0 -2
- package/dist/types/rules/erb-requires-trailing-newline.d.ts +0 -6
- package/dist/types/src/default-rules.d.ts +0 -2
- package/dist/types/src/rules/erb-requires-trailing-newline.d.ts +0 -6
- package/src/rules/erb-requires-trailing-newline.ts +0 -29
package/dist/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAsEA;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAmB;IACjD,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,OAAO;IACjB,OAAO,EAAE,EAAE;CACZ,CAAA;AAED;;GAEG;AACH,MAAM,OAAgB,UAAU;IAC9B,MAAM,CAAC,IAAI,GAAG,QAAiB,CAAA;IAC/B,uEAAuE;IACvE,MAAM,CAAC,eAAe,GAAG,KAAK,CAAA;IAG9B,IAAI,aAAa;QACf,OAAO,mBAAmB,CAAA;IAC5B,CAAC;;AAuBH;;GAEG;AACH,MAAM,OAAgB,SAAS;IAC7B,MAAM,CAAC,IAAI,GAAG,OAAgB,CAAA;IAC9B,uEAAuE;IACvE,MAAM,CAAC,eAAe,GAAG,KAAK,CAAA;IAG9B,IAAI,aAAa;QACf,OAAO,mBAAmB,CAAA;IAC5B,CAAC;;AAuCH;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgB;IAC/C,QAAQ,EAAE,SAAS;IACnB,cAAc,EAAE,SAAS;IACzB,qBAAqB,EAAE,SAAS;IAChC,qBAAqB,EAAE,SAAS;CACxB,CAAA;AAEV,MAAM,OAAgB,UAAU;IAC9B,MAAM,CAAC,IAAI,GAAG,QAAiB,CAAA;IAC/B,uEAAuE;IACvE,MAAM,CAAC,eAAe,GAAG,KAAK,CAAA;IAG9B,IAAI,aAAa;QACf,OAAO,mBAAmB,CAAA;IAC5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/cli.ts","../src/
|
|
1
|
+
{"root":["../src/cli.ts","../src/custom-rule-loader.ts","../src/herb-disable-comment-utils.ts","../src/herb-lint.ts","../src/index.ts","../src/linter.ts","../src/loader.ts","../src/rules.ts","../src/types.ts","../src/cli/argument-parser.ts","../src/cli/file-processor.ts","../src/cli/index.ts","../src/cli/output-manager.ts","../src/cli/summary-reporter.ts","../src/cli/formatters/base-formatter.ts","../src/cli/formatters/detailed-formatter.ts","../src/cli/formatters/github-actions-formatter.ts","../src/cli/formatters/index.ts","../src/cli/formatters/json-formatter.ts","../src/cli/formatters/simple-formatter.ts","../src/rules/erb-comment-syntax.ts","../src/rules/erb-no-case-node-children.ts","../src/rules/erb-no-empty-tags.ts","../src/rules/erb-no-extra-newline.ts","../src/rules/erb-no-extra-whitespace-inside-tags.ts","../src/rules/erb-no-output-control-flow.ts","../src/rules/erb-no-silent-tag-in-attribute-name.ts","../src/rules/erb-prefer-image-tag-helper.ts","../src/rules/erb-require-trailing-newline.ts","../src/rules/erb-require-whitespace-inside-tags.ts","../src/rules/erb-right-trim.ts","../src/rules/herb-disable-comment-base.ts","../src/rules/herb-disable-comment-malformed.ts","../src/rules/herb-disable-comment-missing-rules.ts","../src/rules/herb-disable-comment-no-duplicate-rules.ts","../src/rules/herb-disable-comment-no-redundant-all.ts","../src/rules/herb-disable-comment-unnecessary.ts","../src/rules/herb-disable-comment-valid-rule-name.ts","../src/rules/html-anchor-require-href.ts","../src/rules/html-aria-attribute-must-be-valid.ts","../src/rules/html-aria-label-is-well-formatted.ts","../src/rules/html-aria-level-must-be-valid.ts","../src/rules/html-aria-role-heading-requires-level.ts","../src/rules/html-aria-role-must-be-valid.ts","../src/rules/html-attribute-double-quotes.ts","../src/rules/html-attribute-equals-spacing.ts","../src/rules/html-attribute-values-require-quotes.ts","../src/rules/html-avoid-both-disabled-and-aria-disabled.ts","../src/rules/html-body-only-elements.ts","../src/rules/html-boolean-attributes-no-value.ts","../src/rules/html-head-only-elements.ts","../src/rules/html-iframe-has-title.ts","../src/rules/html-img-require-alt.ts","../src/rules/html-input-require-autocomplete.ts","../src/rules/html-navigation-has-label.ts","../src/rules/html-no-aria-hidden-on-focusable.ts","../src/rules/html-no-block-inside-inline.ts","../src/rules/html-no-duplicate-attributes.ts","../src/rules/html-no-duplicate-ids.ts","../src/rules/html-no-duplicate-meta-names.ts","../src/rules/html-no-empty-attributes.ts","../src/rules/html-no-empty-headings.ts","../src/rules/html-no-nested-links.ts","../src/rules/html-no-positive-tab-index.ts","../src/rules/html-no-self-closing.ts","../src/rules/html-no-space-in-tag.ts","../src/rules/html-no-title-attribute.ts","../src/rules/html-no-underscores-in-attribute-names.ts","../src/rules/html-tag-name-lowercase.ts","../src/rules/index.ts","../src/rules/parser-no-errors.ts","../src/rules/rule-utils.ts","../src/rules/svg-tag-name-capitalization.ts"],"version":"5.9.2"}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import type { ThemeInput } from "@herb-tools/highlighter";
|
|
2
2
|
export type FormatOption = "simple" | "detailed" | "json";
|
|
3
3
|
export interface ParsedArguments {
|
|
4
|
-
|
|
4
|
+
patterns: string[];
|
|
5
|
+
configFile?: string;
|
|
5
6
|
formatOption: FormatOption;
|
|
6
7
|
showTiming: boolean;
|
|
7
8
|
theme: ThemeInput;
|
|
8
9
|
wrapLines: boolean;
|
|
9
10
|
truncateLines: boolean;
|
|
10
11
|
useGitHubActions: boolean;
|
|
12
|
+
fix: boolean;
|
|
13
|
+
ignoreDisableComments: boolean;
|
|
14
|
+
force: boolean;
|
|
15
|
+
init: boolean;
|
|
16
|
+
loadCustomRules: boolean;
|
|
11
17
|
}
|
|
12
18
|
export declare class ArgumentParser {
|
|
13
19
|
private readonly usage;
|
|
14
20
|
parse(argv: string[]): ParsedArguments;
|
|
15
|
-
private
|
|
21
|
+
private getFilePatterns;
|
|
16
22
|
}
|
|
@@ -1,18 +1,31 @@
|
|
|
1
|
+
import { Config } from "@herb-tools/config";
|
|
1
2
|
import type { Diagnostic } from "@herb-tools/core";
|
|
2
3
|
import type { FormatOption } from "./argument-parser.js";
|
|
4
|
+
import type { HerbConfigOptions } from "@herb-tools/config";
|
|
3
5
|
export interface ProcessedFile {
|
|
4
6
|
filename: string;
|
|
5
7
|
offense: Diagnostic;
|
|
6
8
|
content: string;
|
|
9
|
+
autocorrectable?: boolean;
|
|
7
10
|
}
|
|
8
11
|
export interface ProcessingContext {
|
|
9
12
|
projectPath?: string;
|
|
10
13
|
pattern?: string;
|
|
14
|
+
fix?: boolean;
|
|
15
|
+
ignoreDisableComments?: boolean;
|
|
16
|
+
linterConfig?: HerbConfigOptions['linter'];
|
|
17
|
+
config?: Config;
|
|
18
|
+
loadCustomRules?: boolean;
|
|
11
19
|
}
|
|
12
20
|
export interface ProcessingResult {
|
|
13
21
|
totalErrors: number;
|
|
14
22
|
totalWarnings: number;
|
|
23
|
+
totalInfo: number;
|
|
24
|
+
totalHints: number;
|
|
25
|
+
totalIgnored: number;
|
|
26
|
+
totalWouldBeIgnored?: number;
|
|
15
27
|
filesWithOffenses: number;
|
|
28
|
+
filesFixed: number;
|
|
16
29
|
ruleCount: number;
|
|
17
30
|
allOffenses: ProcessedFile[];
|
|
18
31
|
ruleOffenses: Map<string, {
|
|
@@ -23,5 +36,7 @@ export interface ProcessingResult {
|
|
|
23
36
|
}
|
|
24
37
|
export declare class FileProcessor {
|
|
25
38
|
private linter;
|
|
39
|
+
private customRulesLoaded;
|
|
40
|
+
private isRuleAutocorrectable;
|
|
26
41
|
processFiles(files: string[], formatOption?: FormatOption, context?: ProcessingContext): Promise<ProcessingResult>;
|
|
27
42
|
}
|
|
@@ -9,6 +9,9 @@ interface JSONSummary {
|
|
|
9
9
|
filesWithOffenses: number;
|
|
10
10
|
totalErrors: number;
|
|
11
11
|
totalWarnings: number;
|
|
12
|
+
totalInfo: number;
|
|
13
|
+
totalHints: number;
|
|
14
|
+
totalIgnored: number;
|
|
12
15
|
totalOffenses: number;
|
|
13
16
|
ruleCount: number;
|
|
14
17
|
}
|
|
@@ -28,6 +31,9 @@ interface JSONFormatOptions {
|
|
|
28
31
|
files: string[];
|
|
29
32
|
totalErrors: number;
|
|
30
33
|
totalWarnings: number;
|
|
34
|
+
totalInfo: number;
|
|
35
|
+
totalHints: number;
|
|
36
|
+
totalIgnored: number;
|
|
31
37
|
filesWithOffenses: number;
|
|
32
38
|
ruleCount: number;
|
|
33
39
|
startTime: number;
|
|
@@ -4,4 +4,5 @@ import type { ProcessedFile } from "../file-processor.js";
|
|
|
4
4
|
export declare class SimpleFormatter extends BaseFormatter {
|
|
5
5
|
format(allOffenses: ProcessedFile[]): Promise<void>;
|
|
6
6
|
formatFile(filename: string, offenses: Diagnostic[]): void;
|
|
7
|
+
formatFileProcessed(filename: string, processedFiles: ProcessedFile[]): void;
|
|
7
8
|
}
|
|
@@ -2,6 +2,10 @@ export interface SummaryData {
|
|
|
2
2
|
files: string[];
|
|
3
3
|
totalErrors: number;
|
|
4
4
|
totalWarnings: number;
|
|
5
|
+
totalInfo?: number;
|
|
6
|
+
totalHints?: number;
|
|
7
|
+
totalIgnored: number;
|
|
8
|
+
totalWouldBeIgnored?: number;
|
|
5
9
|
filesWithOffenses: number;
|
|
6
10
|
ruleCount: number;
|
|
7
11
|
startTime: number;
|
|
@@ -11,6 +15,8 @@ export interface SummaryData {
|
|
|
11
15
|
count: number;
|
|
12
16
|
files: Set<string>;
|
|
13
17
|
}>;
|
|
18
|
+
autofixableCount: number;
|
|
19
|
+
ignoreDisableComments?: boolean;
|
|
14
20
|
}
|
|
15
21
|
export declare class SummaryReporter {
|
|
16
22
|
private pluralize;
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Config } from "@herb-tools/config";
|
|
2
|
+
import { ArgumentParser } from "./cli/argument-parser.js";
|
|
2
3
|
import { FileProcessor } from "./cli/file-processor.js";
|
|
3
4
|
import { OutputManager } from "./cli/output-manager.js";
|
|
5
|
+
import type { FormatOption } from "./cli/argument-parser.js";
|
|
4
6
|
export * from "./cli/index.js";
|
|
5
7
|
export declare class CLI {
|
|
6
8
|
protected argumentParser: ArgumentParser;
|
|
@@ -8,15 +10,18 @@ export declare class CLI {
|
|
|
8
10
|
protected outputManager: OutputManager;
|
|
9
11
|
protected projectPath: string;
|
|
10
12
|
getProjectPath(): string;
|
|
11
|
-
protected findProjectRoot(startPath: string): string;
|
|
12
13
|
protected exitWithError(message: string, formatOption: FormatOption, exitCode?: number): void;
|
|
13
14
|
protected exitWithInfo(message: string, formatOption: FormatOption, exitCode?: number, timingData?: {
|
|
14
15
|
startTime: number;
|
|
15
16
|
startDate: Date;
|
|
16
17
|
showTiming: boolean;
|
|
17
18
|
}): void;
|
|
18
|
-
protected determineProjectPath(
|
|
19
|
-
protected adjustPattern(pattern: string | undefined): string;
|
|
19
|
+
protected determineProjectPath(patterns: string[]): void;
|
|
20
|
+
protected adjustPattern(pattern: string | undefined, configGlobPattern: string): string;
|
|
21
|
+
protected resolvePatternToFiles(pattern: string, config: Config, force: boolean): Promise<{
|
|
22
|
+
files: string[];
|
|
23
|
+
explicitFile: string | undefined;
|
|
24
|
+
}>;
|
|
20
25
|
protected beforeProcess(): Promise<void>;
|
|
21
26
|
protected afterProcess(_results: any, _outputOptions: any): Promise<void>;
|
|
22
27
|
run(): Promise<void>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { RuleClass } from "./types.js";
|
|
2
|
+
export interface CustomRuleLoaderOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Base directory to search for custom rules
|
|
5
|
+
* Defaults to current working directory
|
|
6
|
+
*/
|
|
7
|
+
baseDir?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Glob patterns to search for custom rule files
|
|
10
|
+
* Defaults to looking in common locations
|
|
11
|
+
*/
|
|
12
|
+
patterns?: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Whether to suppress errors when loading custom rules
|
|
15
|
+
* Defaults to false
|
|
16
|
+
*/
|
|
17
|
+
silent?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Loads custom linter rules from the user's project
|
|
21
|
+
*/
|
|
22
|
+
export declare class CustomRuleLoader {
|
|
23
|
+
private baseDir;
|
|
24
|
+
private patterns;
|
|
25
|
+
private silent;
|
|
26
|
+
constructor(options?: CustomRuleLoaderOptions);
|
|
27
|
+
/**
|
|
28
|
+
* Discovers custom rule files in the project
|
|
29
|
+
*/
|
|
30
|
+
discoverRuleFiles(): Promise<string[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Loads a single rule file
|
|
33
|
+
*/
|
|
34
|
+
loadRuleFile(filePath: string): Promise<RuleClass[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Type guard to check if an export is a valid rule class
|
|
37
|
+
*/
|
|
38
|
+
private isValidRuleClass;
|
|
39
|
+
/**
|
|
40
|
+
* Loads all custom rules from the project
|
|
41
|
+
*/
|
|
42
|
+
loadRules(): Promise<RuleClass[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Loads all custom rules and returns detailed information about each rule
|
|
45
|
+
*/
|
|
46
|
+
loadRulesWithInfo(): Promise<{
|
|
47
|
+
rules: RuleClass[];
|
|
48
|
+
ruleInfo: Array<{
|
|
49
|
+
name: string;
|
|
50
|
+
path: string;
|
|
51
|
+
}>;
|
|
52
|
+
duplicateWarnings: string[];
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Static helper to check if custom rules exist in a project
|
|
56
|
+
*/
|
|
57
|
+
static hasCustomRules(baseDir?: string): Promise<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Static helper to load custom rules and merge with default rules
|
|
60
|
+
*/
|
|
61
|
+
static loadAndMergeRules(defaultRules: RuleClass[], options?: CustomRuleLoaderOptions): Promise<RuleClass[]>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for parsing herb:disable comments
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Information about a single rule name in a herb:disable comment
|
|
6
|
+
*/
|
|
7
|
+
export interface HerbDisableRuleName {
|
|
8
|
+
/** The rule name */
|
|
9
|
+
name: string;
|
|
10
|
+
/** The starting offset of this rule name within the content/line */
|
|
11
|
+
offset: number;
|
|
12
|
+
/** The length of the rule name */
|
|
13
|
+
length: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Result of parsing a herb:disable comment
|
|
17
|
+
*/
|
|
18
|
+
export interface HerbDisableComment {
|
|
19
|
+
/** The full matched string */
|
|
20
|
+
match: string;
|
|
21
|
+
/** Array of rule names specified in the comment */
|
|
22
|
+
ruleNames: string[];
|
|
23
|
+
/** Array of rule name information with positions */
|
|
24
|
+
ruleNameDetails: HerbDisableRuleName[];
|
|
25
|
+
/** The original rules string (e.g., "rule1, rule2") */
|
|
26
|
+
rulesString: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse a herb:disable comment from ERB comment content.
|
|
30
|
+
* Use this when you have the content inside <%# ... %> (e.g., from ERBContentNode.content.value)
|
|
31
|
+
*
|
|
32
|
+
* @param content - The content string (without <%# %> delimiters)
|
|
33
|
+
* @returns Parsed comment data or null if not a valid herb:disable comment
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const result = parseHerbDisableContent("herb:disable rule1, rule2")
|
|
38
|
+
* // { match: "herb:disable rule1, rule2", ruleNames: ["rule1", "rule2"], rulesString: "rule1, rule2" }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function parseHerbDisableContent(content: string): HerbDisableComment | null;
|
|
42
|
+
/**
|
|
43
|
+
* Parse a herb:disable comment from a full source line.
|
|
44
|
+
* Use this when you have a complete line that may contain <%# herb:disable ... %>
|
|
45
|
+
*
|
|
46
|
+
* @param line - The source line that may contain a herb:disable comment
|
|
47
|
+
* @returns Parsed comment data or null if not a valid herb:disable comment
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const result = parseHerbDisableLine("<div>test</div> <%# herb:disable rule1, rule2 %>")
|
|
52
|
+
* // { match: "<%# herb:disable rule1, rule2 %>", ruleNames: ["rule1", "rule2"], rulesString: "rule1, rule2" }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseHerbDisableLine(line: string): HerbDisableComment | null;
|
|
56
|
+
/**
|
|
57
|
+
* Check if an ERB comment content contains a herb:disable directive.
|
|
58
|
+
*
|
|
59
|
+
* @param content - The content string (without <%# %> delimiters)
|
|
60
|
+
* @returns true if the content contains a herb:disable directive
|
|
61
|
+
*/
|
|
62
|
+
export declare function isHerbDisableContent(content: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Check if a source line contains a herb:disable comment.
|
|
65
|
+
*
|
|
66
|
+
* @param line - The source line
|
|
67
|
+
* @returns true if the line contains a herb:disable comment
|
|
68
|
+
*/
|
|
69
|
+
export declare function isHerbDisableLine(line: string): boolean;
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/linter.d.ts
CHANGED
|
@@ -1,20 +1,89 @@
|
|
|
1
|
-
import type { RuleClass, Rule, LexerRule, SourceRule, LintResult, LintOffense, LintContext } from "./types.js";
|
|
1
|
+
import type { RuleClass, Rule, LexerRule, SourceRule, LintResult, LintOffense, UnboundLintOffense, LintContext, AutofixResult } from "./types.js";
|
|
2
2
|
import type { HerbBackend } from "@herb-tools/core";
|
|
3
|
+
import type { RuleConfig, Config } from "@herb-tools/config";
|
|
4
|
+
export interface LinterOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Array of rule classes to use. If not provided, uses default rules.
|
|
7
|
+
*/
|
|
8
|
+
rules?: RuleClass[];
|
|
9
|
+
/**
|
|
10
|
+
* Whether to load custom rules from the project.
|
|
11
|
+
* Defaults to false for backward compatibility.
|
|
12
|
+
*/
|
|
13
|
+
loadCustomRules?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Base directory to search for custom rules.
|
|
16
|
+
* Defaults to current working directory.
|
|
17
|
+
*/
|
|
18
|
+
customRulesBaseDir?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Custom glob patterns to search for rule files.
|
|
21
|
+
*/
|
|
22
|
+
customRulesPatterns?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Whether to suppress custom rule loading errors.
|
|
25
|
+
* Defaults to false.
|
|
26
|
+
*/
|
|
27
|
+
silentCustomRules?: boolean;
|
|
28
|
+
}
|
|
3
29
|
export declare class Linter {
|
|
4
30
|
protected rules: RuleClass[];
|
|
31
|
+
protected allAvailableRules: RuleClass[];
|
|
5
32
|
protected herb: HerbBackend;
|
|
6
33
|
protected offenses: LintOffense[];
|
|
34
|
+
protected config?: Config;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new Linter instance with automatic rule filtering based on config.
|
|
37
|
+
*
|
|
38
|
+
* @param herb - The Herb backend instance for parsing and lexing
|
|
39
|
+
* @param config - Optional full Config instance for rule filtering, severity overrides, and path-based filtering
|
|
40
|
+
* @param customRules - Optional array of custom rules to include alongside built-in rules
|
|
41
|
+
* @returns A configured Linter instance
|
|
42
|
+
*/
|
|
43
|
+
static from(herb: HerbBackend, config?: Config, customRules?: RuleClass[]): Linter;
|
|
7
44
|
/**
|
|
8
45
|
* Creates a new Linter instance.
|
|
46
|
+
*
|
|
47
|
+
* For most use cases, prefer `Linter.from()` which handles config-based filtering.
|
|
48
|
+
* Use this constructor directly when you need explicit control over rules.
|
|
49
|
+
*
|
|
9
50
|
* @param herb - The Herb backend instance for parsing and lexing
|
|
10
51
|
* @param rules - Array of rule classes (Parser/AST or Lexer) to use. If not provided, uses default rules.
|
|
52
|
+
* @param config - Optional full Config instance for severity overrides and path-based rule filtering
|
|
53
|
+
* @param allAvailableRules - Optional array of ALL available rules (including disabled) for herb:disable validation
|
|
54
|
+
*/
|
|
55
|
+
constructor(herb: HerbBackend, rules?: RuleClass[], config?: Config, allAvailableRules?: RuleClass[]);
|
|
56
|
+
/**
|
|
57
|
+
* Filters rules based on default config and optional user config overrides.
|
|
58
|
+
*
|
|
59
|
+
* Priority:
|
|
60
|
+
* 1. User config override (if rule config exists in userRulesConfig)
|
|
61
|
+
* 2. Default config from rule's defaultConfig getter
|
|
62
|
+
*
|
|
63
|
+
* @param allRules - All available rule classes to filter from
|
|
64
|
+
* @param userRulesConfig - Optional user configuration for rules
|
|
65
|
+
* @returns Filtered array of rule classes that should be enabled
|
|
11
66
|
*/
|
|
12
|
-
|
|
67
|
+
static filterRulesByConfig(allRules: RuleClass[], userRulesConfig?: Record<string, RuleConfig>): RuleClass[];
|
|
13
68
|
/**
|
|
14
69
|
* Returns the default set of rule classes used by the linter.
|
|
15
|
-
*
|
|
70
|
+
* These are the rules enabled when no custom rules are provided.
|
|
71
|
+
* Filters all available rules to only include those enabled by default.
|
|
72
|
+
* @returns Array of default rule classes
|
|
16
73
|
*/
|
|
17
74
|
protected getDefaultRules(): RuleClass[];
|
|
75
|
+
/**
|
|
76
|
+
* Returns all available rule classes that can be referenced in herb:disable comments.
|
|
77
|
+
* This includes all rules that exist, regardless of whether they're currently enabled.
|
|
78
|
+
* Includes both built-in rules and any loaded custom rules.
|
|
79
|
+
* @returns Array of all available rule classes
|
|
80
|
+
*/
|
|
81
|
+
protected getAvailableRules(): RuleClass[];
|
|
82
|
+
/**
|
|
83
|
+
* Meta-linting rules for herb:disable comments cannot be disabled
|
|
84
|
+
* This ensures that invalid herb:disable comments are always caught
|
|
85
|
+
*/
|
|
86
|
+
protected get nonExcludableRules(): string[];
|
|
18
87
|
getRuleCount(): number;
|
|
19
88
|
/**
|
|
20
89
|
* Type guard to check if a rule is a LexerRule
|
|
@@ -24,10 +93,37 @@ export declare class Linter {
|
|
|
24
93
|
* Type guard to check if a rule is a SourceRule
|
|
25
94
|
*/
|
|
26
95
|
protected isSourceRule(rule: Rule): rule is SourceRule;
|
|
96
|
+
/**
|
|
97
|
+
* Execute a single rule and return its unbound offenses.
|
|
98
|
+
* Handles rule type checking (Lexer/Parser/Source) and isEnabled checks.
|
|
99
|
+
*/
|
|
100
|
+
private executeRule;
|
|
101
|
+
private filterOffenses;
|
|
27
102
|
/**
|
|
28
103
|
* Lint source code using Parser/AST, Lexer, and Source rules.
|
|
29
104
|
* @param source - The source code to lint
|
|
30
105
|
* @param context - Optional context for linting (e.g., fileName for distinguishing files vs snippets)
|
|
31
106
|
*/
|
|
32
107
|
lint(source: string, context?: Partial<LintContext>): LintResult;
|
|
108
|
+
/**
|
|
109
|
+
* Bind severity to unbound offenses based on rule's defaultConfig and user config overrides.
|
|
110
|
+
*
|
|
111
|
+
* Priority:
|
|
112
|
+
* 1. User config severity override (if specified in config)
|
|
113
|
+
* 2. Rule's default severity (from defaultConfig.severity)
|
|
114
|
+
*
|
|
115
|
+
* @param unboundOffenses - Array of offenses without severity
|
|
116
|
+
* @param ruleName - Name of the rule that produced the offenses
|
|
117
|
+
* @returns Array of offenses with severity bound
|
|
118
|
+
*/
|
|
119
|
+
protected bindSeverity(unboundOffenses: UnboundLintOffense[], ruleName: string): LintOffense[];
|
|
120
|
+
/**
|
|
121
|
+
* Automatically fix offenses in the source code.
|
|
122
|
+
* Uses AST mutation for parser rules and token mutation for lexer rules.
|
|
123
|
+
* @param source - The source code to fix
|
|
124
|
+
* @param context - Optional context for linting (e.g., fileName)
|
|
125
|
+
* @param offensesToFix - Optional array of specific offenses to fix. If not provided, all fixable offenses will be fixed.
|
|
126
|
+
* @returns AutofixResult containing the corrected source and lists of fixed/unfixed offenses
|
|
127
|
+
*/
|
|
128
|
+
autofix(source: string, context?: Partial<LintContext>, offensesToFix?: LintOffense[]): AutofixResult;
|
|
33
129
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from "./index.js";
|
|
2
|
+
export { CustomRuleLoader } from "./custom-rule-loader.js";
|
|
3
|
+
export type { CustomRuleLoaderOptions } from "./custom-rule-loader.js";
|
|
4
|
+
import type { RuleClass } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Loads custom rules from the filesystem.
|
|
7
|
+
* Only available in Node.js environments.
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadCustomRules(options?: {
|
|
10
|
+
baseDir?: string;
|
|
11
|
+
patterns?: string[];
|
|
12
|
+
silent?: boolean;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
rules: RuleClass[];
|
|
15
|
+
ruleInfo: Array<{
|
|
16
|
+
name: string;
|
|
17
|
+
path: string;
|
|
18
|
+
}>;
|
|
19
|
+
warnings: string[];
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ParserRule, BaseAutofixContext, Mutable } from "../types.js";
|
|
2
|
+
import type { UnboundLintOffense, LintOffense, LintContext, FullRuleConfig } from "../types.js";
|
|
3
|
+
import type { ParseResult, ERBContentNode } from "@herb-tools/core";
|
|
4
|
+
interface ERBCommentSyntaxAutofixContext extends BaseAutofixContext {
|
|
5
|
+
node: Mutable<ERBContentNode>;
|
|
6
|
+
}
|
|
7
|
+
export declare class ERBCommentSyntax extends ParserRule<ERBCommentSyntaxAutofixContext> {
|
|
8
|
+
static autocorrectable: boolean;
|
|
9
|
+
name: string;
|
|
10
|
+
get defaultConfig(): FullRuleConfig;
|
|
11
|
+
check(result: ParseResult, context?: Partial<LintContext>): UnboundLintOffense<ERBCommentSyntaxAutofixContext>[];
|
|
12
|
+
autofix(offense: LintOffense<ERBCommentSyntaxAutofixContext>, result: ParseResult, _context?: Partial<LintContext>): ParseResult | null;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ParserRule } from "../types.js";
|
|
2
|
+
import type { UnboundLintOffense, LintContext, FullRuleConfig } from "../types.js";
|
|
3
|
+
import type { ParseResult } from "@herb-tools/core";
|
|
4
|
+
export declare class ERBNoCaseNodeChildrenRule extends ParserRule {
|
|
5
|
+
name: string;
|
|
6
|
+
get defaultConfig(): FullRuleConfig;
|
|
7
|
+
check(result: ParseResult, context?: Partial<LintContext>): UnboundLintOffense[];
|
|
8
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ParserRule } from "../types.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { UnboundLintOffense, LintContext, FullRuleConfig } from "../types.js";
|
|
3
3
|
import type { ParseResult } from "@herb-tools/core";
|
|
4
4
|
export declare class ERBNoEmptyTagsRule extends ParserRule {
|
|
5
5
|
name: string;
|
|
6
|
-
|
|
6
|
+
get defaultConfig(): FullRuleConfig;
|
|
7
|
+
check(result: ParseResult, context?: Partial<LintContext>): UnboundLintOffense[];
|
|
7
8
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SourceRule } from "../types.js";
|
|
2
|
+
import type { UnboundLintOffense, LintOffense, LintContext, BaseAutofixContext, FullRuleConfig } from "../types.js";
|
|
3
|
+
interface ERBNoExtraNewLineAutofixContext extends BaseAutofixContext {
|
|
4
|
+
startOffset: number;
|
|
5
|
+
endOffset: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class ERBNoExtraNewLineRule extends SourceRule {
|
|
8
|
+
static autocorrectable: boolean;
|
|
9
|
+
name: string;
|
|
10
|
+
get defaultConfig(): FullRuleConfig;
|
|
11
|
+
check(source: string, context?: Partial<LintContext>): UnboundLintOffense[];
|
|
12
|
+
autofix(offense: LintOffense<ERBNoExtraNewLineAutofixContext>, source: string, _context?: Partial<LintContext>): string | null;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ParserRule, BaseAutofixContext, Mutable } from "../types.js";
|
|
2
|
+
import type { ParseResult, Token, ERBNode } from "@herb-tools/core";
|
|
3
|
+
import type { UnboundLintOffense, LintOffense, LintContext, FullRuleConfig } from "../types.js";
|
|
4
|
+
interface ERBNoExtraWhitespaceAutofixContext extends BaseAutofixContext {
|
|
5
|
+
node: Mutable<ERBNode>;
|
|
6
|
+
openTag: Token;
|
|
7
|
+
closeTag: Token;
|
|
8
|
+
content: string;
|
|
9
|
+
fixType: "after-open" | "before-close" | "after-comment-equals";
|
|
10
|
+
}
|
|
11
|
+
export declare class ERBNoExtraWhitespaceRule extends ParserRule<ERBNoExtraWhitespaceAutofixContext> {
|
|
12
|
+
static autocorrectable: boolean;
|
|
13
|
+
name: string;
|
|
14
|
+
get defaultConfig(): FullRuleConfig;
|
|
15
|
+
check(result: ParseResult, context?: Partial<LintContext>): UnboundLintOffense<ERBNoExtraWhitespaceAutofixContext>[];
|
|
16
|
+
autofix(offense: LintOffense<ERBNoExtraWhitespaceAutofixContext>, result: ParseResult, _context?: Partial<LintContext>): ParseResult | null;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ParseResult } from "@herb-tools/core";
|
|
2
2
|
import { ParserRule } from "../types.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { UnboundLintOffense, LintContext, FullRuleConfig } from "../types.js";
|
|
4
4
|
export declare class ERBNoOutputControlFlowRule extends ParserRule {
|
|
5
5
|
name: string;
|
|
6
|
-
|
|
6
|
+
get defaultConfig(): FullRuleConfig;
|
|
7
|
+
check(result: ParseResult, context?: Partial<LintContext>): UnboundLintOffense[];
|
|
7
8
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ParserRule } from "../types.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { UnboundLintOffense, LintContext, FullRuleConfig } from "../types.js";
|
|
3
3
|
import type { ParseResult } from "@herb-tools/core";
|
|
4
4
|
export declare class ERBNoSilentTagInAttributeNameRule extends ParserRule {
|
|
5
5
|
name: string;
|
|
6
|
-
|
|
6
|
+
get defaultConfig(): FullRuleConfig;
|
|
7
|
+
check(result: ParseResult, context?: Partial<LintContext>): UnboundLintOffense[];
|
|
7
8
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ParserRule } from "../types.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { UnboundLintOffense, LintContext, FullRuleConfig } from "../types.js";
|
|
3
3
|
import type { ParseResult } from "@herb-tools/core";
|
|
4
4
|
export declare class ERBPreferImageTagHelperRule extends ParserRule {
|
|
5
5
|
name: string;
|
|
6
|
-
|
|
6
|
+
get defaultConfig(): FullRuleConfig;
|
|
7
|
+
check(result: ParseResult, context?: Partial<LintContext>): UnboundLintOffense[];
|
|
7
8
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SourceRule } from "../types.js";
|
|
2
|
+
import type { UnboundLintOffense, LintOffense, LintContext, FullRuleConfig } from "../types.js";
|
|
3
|
+
export declare class ERBRequireTrailingNewlineRule extends SourceRule {
|
|
4
|
+
static autocorrectable: boolean;
|
|
5
|
+
name: string;
|
|
6
|
+
get defaultConfig(): FullRuleConfig;
|
|
7
|
+
check(source: string, context?: Partial<LintContext>): UnboundLintOffense[];
|
|
8
|
+
autofix(_offense: LintOffense, source: string, _context?: Partial<LintContext>): string | null;
|
|
9
|
+
}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import type { LintOffense, LintContext } from "../types.js";
|
|
4
|
-
|
|
1
|
+
import { ParserRule, BaseAutofixContext, Mutable } from "../types.js";
|
|
2
|
+
import type { ParseResult, Token, ERBNode } from "@herb-tools/core";
|
|
3
|
+
import type { UnboundLintOffense, LintOffense, LintContext, FullRuleConfig } from "../types.js";
|
|
4
|
+
interface ERBRequireWhitespaceAutofixContext extends BaseAutofixContext {
|
|
5
|
+
node: Mutable<ERBNode>;
|
|
6
|
+
openTag: Token;
|
|
7
|
+
closeTag: Token;
|
|
8
|
+
content: string;
|
|
9
|
+
fixType: "after-open" | "before-close" | "after-comment-equals";
|
|
10
|
+
}
|
|
11
|
+
export declare class ERBRequireWhitespaceRule extends ParserRule<ERBRequireWhitespaceAutofixContext> {
|
|
12
|
+
static autocorrectable: boolean;
|
|
5
13
|
name: string;
|
|
6
|
-
|
|
14
|
+
get defaultConfig(): FullRuleConfig;
|
|
15
|
+
check(result: ParseResult, context?: Partial<LintContext>): UnboundLintOffense<ERBRequireWhitespaceAutofixContext>[];
|
|
16
|
+
autofix(offense: LintOffense<ERBRequireWhitespaceAutofixContext>, result: ParseResult, _context?: Partial<LintContext>): ParseResult | null;
|
|
7
17
|
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ParserRule, BaseAutofixContext, Mutable } from "../types.js";
|
|
2
|
+
import type { UnboundLintOffense, LintOffense, LintContext, FullRuleConfig } from "../types.js";
|
|
3
|
+
import type { ERBNode, ParseResult } from "@herb-tools/core";
|
|
4
|
+
interface ERBRightTrimAutofixContext extends BaseAutofixContext {
|
|
5
|
+
node: Mutable<ERBNode>;
|
|
6
|
+
}
|
|
7
|
+
export declare class ERBRightTrimRule extends ParserRule<ERBRightTrimAutofixContext> {
|
|
8
|
+
static autocorrectable: boolean;
|
|
9
|
+
name: string;
|
|
10
|
+
get defaultConfig(): FullRuleConfig;
|
|
11
|
+
check(result: ParseResult, context?: Partial<LintContext>): UnboundLintOffense<ERBRightTrimAutofixContext>[];
|
|
12
|
+
autofix(offense: LintOffense<ERBRightTrimAutofixContext>, result: ParseResult, _context?: Partial<LintContext>): ParseResult | null;
|
|
13
|
+
}
|
|
14
|
+
export {};
|