@herb-tools/linter 0.7.5 → 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 +26023 -3424
- package/dist/herb-lint.js.map +1 -1
- package/dist/index.cjs +5759 -1583
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5727 -1584
- 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 +38 -33
- 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 +107 -42
- 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 +31 -2
- package/dist/src/rules/erb-comment-syntax.js.map +1 -1
- 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 +69 -11
- package/dist/src/rules/erb-require-whitespace-inside-tags.js.map +1 -1
- package/dist/src/rules/erb-right-trim.js +26 -9
- package/dist/src/rules/erb-right-trim.js.map +1 -1
- 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 +19 -3
- 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} +44 -16
- 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 +12 -5
- 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 +12 -5
- 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 +19 -3
- 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 +12 -5
- 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 +12 -5
- 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 +19 -3
- 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 +16 -2
- 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 +5 -10
- 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 +46 -37
- 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 +134 -51
- 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 +53 -10
- 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 +94 -16
- package/src/rules/erb-right-trim.ts +45 -22
- 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 +23 -3
- package/src/rules/parser-no-errors.ts +8 -1
- package/src/rules/rule-utils.ts +248 -42
- package/src/rules/svg-tag-name-capitalization.ts +39 -6
- package/src/{default-rules.ts → rules.ts} +51 -15
- 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/README.md
CHANGED
|
@@ -30,11 +30,6 @@ bun add -g @herb-tools/linter
|
|
|
30
30
|
|
|
31
31
|
:::
|
|
32
32
|
|
|
33
|
-
Then run directly:
|
|
34
|
-
```bash
|
|
35
|
-
herb-lint template.html.erb
|
|
36
|
-
```
|
|
37
|
-
|
|
38
33
|
### One-time Usage
|
|
39
34
|
For occasional use without installing:
|
|
40
35
|
```bash
|
|
@@ -63,11 +58,33 @@ bun add -D @herb-tools/linter
|
|
|
63
58
|
|
|
64
59
|
:::
|
|
65
60
|
|
|
66
|
-
After installing as a dev dependency,
|
|
67
|
-
|
|
61
|
+
After installing as a dev dependency, initialize the configuration:
|
|
62
|
+
|
|
63
|
+
:::code-group
|
|
64
|
+
|
|
65
|
+
```shell [npm]
|
|
66
|
+
npx herb-lint --init
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```shell [pnpm]
|
|
70
|
+
pnpm herb-lint --init
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```shell [yarn]
|
|
74
|
+
yarn herb-lint --init
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```shell [bun]
|
|
78
|
+
bunx herb-lint --init
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
:::
|
|
82
|
+
|
|
83
|
+
Then add a lint NPM script to your `package.json`:
|
|
84
|
+
```json [package.json]
|
|
68
85
|
{
|
|
69
86
|
"scripts": {
|
|
70
|
-
"herb:lint": "herb-lint
|
|
87
|
+
"herb:lint": "herb-lint"
|
|
71
88
|
}
|
|
72
89
|
}
|
|
73
90
|
```
|
|
@@ -100,9 +117,17 @@ bun run herb:lint
|
|
|
100
117
|
|
|
101
118
|
Basic usage:
|
|
102
119
|
```bash
|
|
120
|
+
npx @herb-tools/linter
|
|
121
|
+
npx @herb-tools/linter app/views/
|
|
103
122
|
npx @herb-tools/linter template.html.erb
|
|
104
|
-
npx @herb-tools/linter "**/*.
|
|
105
|
-
npx @herb-tools/linter
|
|
123
|
+
npx @herb-tools/linter "**/*.rhtml"
|
|
124
|
+
npx @herb-tools/linter "**/*.xml.erb"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Initialize configuration:**
|
|
128
|
+
```bash
|
|
129
|
+
# Create a .herb.yml configuration file
|
|
130
|
+
npx @herb-tools/linter --init
|
|
106
131
|
```
|
|
107
132
|
|
|
108
133
|
#### Options
|
|
@@ -184,7 +209,7 @@ npx @herb-tools/linter --format=simple --github
|
|
|
184
209
|
|
|
185
210
|
**Example: `--github` (GitHub annotations + detailed format)**
|
|
186
211
|
```
|
|
187
|
-
::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.
|
|
212
|
+
::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.8.0::Missing required `alt` attribute on `<img>` tag [html-img-require-alt]%0A%0A%0Atemplate.html.erb:3:3%0A%0A 1 │ <div>%0A 2 │ <span>Test content</span>%0A → 3 │ <img src="test.jpg">%0A │ ~~~%0A 4 │ </div>%0A
|
|
188
213
|
|
|
189
214
|
[error] Missing required `alt` attribute on `<img>` tag [html-img-require-alt]
|
|
190
215
|
|
|
@@ -199,7 +224,7 @@ template.html.erb:3:3
|
|
|
199
224
|
|
|
200
225
|
**Example: `--format=simple --github` (GitHub annotations + simple format)**
|
|
201
226
|
```
|
|
202
|
-
::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.
|
|
227
|
+
::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.8.0::Missing required `alt` attribute on `<img>` tag [html-img-require-alt]%0A%0A%0Atemplate.html.erb:3:3%0A%0A 1 │ <div>%0A 2 │ <span>Test content</span>%0A → 3 │ <img src="test.jpg">%0A │ ~~~%0A 4 │ </div>%0A
|
|
203
228
|
|
|
204
229
|
template.html.erb:
|
|
205
230
|
3:3 ✗ Missing required `alt` attribute on `<img>` tag [html-img-require-alt]
|
|
@@ -250,7 +275,7 @@ npx @herb-tools/linter template.html.erb --json
|
|
|
250
275
|
"end": { "line": 1, "column": 22 }
|
|
251
276
|
},
|
|
252
277
|
"severity": "error",
|
|
253
|
-
"code": "erb-
|
|
278
|
+
"code": "erb-require-trailing-newline",
|
|
254
279
|
"source": "Herb Linter"
|
|
255
280
|
}
|
|
256
281
|
],
|
|
@@ -282,6 +307,221 @@ JSON output fields:
|
|
|
282
307
|
- `clean`: Whether there were no offenses (`null` when `completed=false`)
|
|
283
308
|
- `message`: Error or informational message (`null` on success)
|
|
284
309
|
|
|
310
|
+
### Disabling Rules Inline <Badge type="info" text="v0.8.0+" />
|
|
311
|
+
|
|
312
|
+
You can disable linting rules for specific lines using inline comments. This is useful when you need to allow certain code that would otherwise trigger a linting offense.
|
|
313
|
+
|
|
314
|
+
#### Disabling a Single Rule
|
|
315
|
+
|
|
316
|
+
Add a comment at the end of the line with `herb:disable` followed by the rule name:
|
|
317
|
+
|
|
318
|
+
```erb
|
|
319
|
+
<DIV>test</DIV> <%# herb:disable html-tag-name-lowercase %>
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
#### Disabling Multiple Rules
|
|
323
|
+
|
|
324
|
+
You can disable multiple rules on the same line by separating rule names with commas:
|
|
325
|
+
|
|
326
|
+
```erb
|
|
327
|
+
<DIV id='test' class="<%= "hello" %>">test</DIV> <%# herb:disable html-tag-name-lowercase, html-attribute-double-quotes %>
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
#### Disabling All Rules
|
|
331
|
+
|
|
332
|
+
To disable all linting rules for a specific line, use `all`:
|
|
333
|
+
|
|
334
|
+
```erb
|
|
335
|
+
<DIV id='test' class="<%= "hello" %>">test</DIV> <%# herb:disable all %>
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
::: warning Important
|
|
339
|
+
Inline disable comments only affect the line they appear on. Each line that needs linting disabled must have its own disable comment.
|
|
340
|
+
:::
|
|
341
|
+
|
|
342
|
+
## Configuration
|
|
343
|
+
|
|
344
|
+
Create a `.herb.yml` file in your project root to configure the linter:
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
npx @herb-tools/linter --init
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Basic Configuration
|
|
351
|
+
|
|
352
|
+
```yaml [.herb.yml]
|
|
353
|
+
linter:
|
|
354
|
+
enabled: true
|
|
355
|
+
|
|
356
|
+
# Additional glob patterns to include (additive to defaults)
|
|
357
|
+
include:
|
|
358
|
+
- '**/*.xml.erb'
|
|
359
|
+
|
|
360
|
+
# Glob patterns to exclude from linting
|
|
361
|
+
exclude:
|
|
362
|
+
- 'vendor/**/*'
|
|
363
|
+
- 'node_modules/**/*'
|
|
364
|
+
|
|
365
|
+
rules:
|
|
366
|
+
# Disable a rule
|
|
367
|
+
erb-no-extra-newline:
|
|
368
|
+
enabled: false
|
|
369
|
+
|
|
370
|
+
# Change rule severity
|
|
371
|
+
html-tag-name-lowercase:
|
|
372
|
+
severity: warning # error, warning, info, or hint
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Rule-Level File Patterns
|
|
376
|
+
|
|
377
|
+
Apply rules to specific files using `include`, `only`, and `exclude` patterns:
|
|
378
|
+
|
|
379
|
+
```yaml [.herb.yml]
|
|
380
|
+
linter:
|
|
381
|
+
rules:
|
|
382
|
+
# Apply rule only to component files
|
|
383
|
+
html-img-require-alt:
|
|
384
|
+
include:
|
|
385
|
+
- 'app/components/**/*'
|
|
386
|
+
exclude:
|
|
387
|
+
- 'app/components/legacy/**/*'
|
|
388
|
+
|
|
389
|
+
# Restrict rule to specific directory (overrides include)
|
|
390
|
+
html-tag-name-lowercase:
|
|
391
|
+
only:
|
|
392
|
+
- 'app/views/**/*'
|
|
393
|
+
exclude:
|
|
394
|
+
- 'app/views/admin/**/*'
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**Pattern precedence:**
|
|
398
|
+
1. `only` - When present, rule applies ONLY to these files (ignores all `include`)
|
|
399
|
+
2. `include` - When `only` is absent, rule applies only to these files (additive)
|
|
400
|
+
3. `exclude` - Always applied regardless of `include` or `only`
|
|
401
|
+
|
|
402
|
+
### Force Flag
|
|
403
|
+
|
|
404
|
+
Process files even when excluded or when linter is disabled:
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
# Force linting when disabled in config
|
|
408
|
+
herb-lint --force
|
|
409
|
+
|
|
410
|
+
# Force linting on an excluded file
|
|
411
|
+
herb-lint --force app/views/excluded-file.html.erb
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
When using `--force` on an excluded file, the linter will show a warning but proceed with linting.
|
|
415
|
+
|
|
416
|
+
### Custom Rules
|
|
417
|
+
|
|
418
|
+
Create custom linter rules for project-specific requirements by placing ES module files (`.mjs`) in `.herb/rules/`:
|
|
419
|
+
|
|
420
|
+
::: info File Extension
|
|
421
|
+
Custom rules must use the `.mjs` extension to avoid Node.js module type warnings. The `.mjs` extension explicitly marks files as ES modules.
|
|
422
|
+
:::
|
|
423
|
+
|
|
424
|
+
::: code-group
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
```js [.herb/rules/no-inline-styles.mjs]
|
|
428
|
+
import { BaseRuleVisitor, ParserRule } from "@herb-tools/linter"
|
|
429
|
+
|
|
430
|
+
class NoDivTagsVisitor extends BaseRuleVisitor {
|
|
431
|
+
visitHTMLOpenTagNode(node) {
|
|
432
|
+
if (!node.tag_name) return
|
|
433
|
+
if (node.tag_name.value !== "div") return
|
|
434
|
+
|
|
435
|
+
this.addOffense(
|
|
436
|
+
`Avoid using \`<div>\` tags. Consider using semantic HTML elements like \`<section>\`, \`<article>\`, \`<nav>\`, \`<main>\`, \`<header>\`, \`<footer>\`, or \`<aside>\` instead.`,
|
|
437
|
+
node.tag_name.location
|
|
438
|
+
)
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export default class NoDivTagsRule extends ParserRule {
|
|
443
|
+
name = "no-div-tags"
|
|
444
|
+
|
|
445
|
+
check(result, context) {
|
|
446
|
+
const visitor = new NoDivTagsVisitor(this.name, context)
|
|
447
|
+
visitor.visit(result.value)
|
|
448
|
+
return visitor.offenses
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
```js [.herb/rules/no-inline-styles.mjs]
|
|
454
|
+
import { BaseRuleVisitor, getAttributes, getAttributeName } from "@herb-tools/linter"
|
|
455
|
+
|
|
456
|
+
class NoInlineStylesVisitor extends BaseRuleVisitor {
|
|
457
|
+
visitHTMLOpenTagNode(node) {
|
|
458
|
+
const attributes = getAttributes(node)
|
|
459
|
+
|
|
460
|
+
for (const attribute of attributes) {
|
|
461
|
+
const attributeName = getAttributeName(attribute)
|
|
462
|
+
|
|
463
|
+
if (attributeName === "style") {
|
|
464
|
+
this.addOffense(
|
|
465
|
+
`Avoid using inline \`style\` attributes. Use CSS classes instead.`,
|
|
466
|
+
attribute.location,
|
|
467
|
+
"warning"
|
|
468
|
+
)
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
super.visitHTMLOpenTagNode(node)
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export default class NoInlineStylesRule {
|
|
477
|
+
name = "no-inline-styles"
|
|
478
|
+
|
|
479
|
+
check(parseResult, context) {
|
|
480
|
+
const visitor = new NoInlineStylesVisitor(this.name, context)
|
|
481
|
+
visitor.visit(parseResult.value)
|
|
482
|
+
return visitor.offenses
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
:::
|
|
488
|
+
|
|
489
|
+
**Rule Configuration:**
|
|
490
|
+
|
|
491
|
+
The `defaultConfig` getter is optional. If not specified, custom rules default to:
|
|
492
|
+
- `enabled: true` - Rule is enabled by default
|
|
493
|
+
- `severity: "error"` - Offenses are reported as errors
|
|
494
|
+
- `exclude: []` - No files are excluded
|
|
495
|
+
|
|
496
|
+
You can override the `defaultConfig` getter to customize these defaults, as shown in the example above where severity is set to `"warning"`.
|
|
497
|
+
|
|
498
|
+
**Rule Properties:**
|
|
499
|
+
|
|
500
|
+
- `static type` - Optional, defaults to `"parser"`. Can be `"parser"`, `"lexer"`, or `"source"`
|
|
501
|
+
- `name` - Required, the rule identifier used in configuration and output
|
|
502
|
+
- `check()` - Required, the method that checks for offenses
|
|
503
|
+
- `defaultConfig` - Optional, returns the default configuration for the rule
|
|
504
|
+
- `isEnabled()` - Optional, dynamically determines if the rule should run
|
|
505
|
+
- `autofix()` - Optional, implements automatic fixing for the rule
|
|
506
|
+
|
|
507
|
+
Custom rules are loaded automatically by default. Use `--no-custom-rules` to disable them.
|
|
508
|
+
|
|
509
|
+
When custom rules are loaded, the linter will display them:
|
|
510
|
+
|
|
511
|
+
```
|
|
512
|
+
Loaded 2 custom rules:
|
|
513
|
+
• no-inline-styles (.herb/rules/no-inline-styles.mjs)
|
|
514
|
+
• require-aria-labels (.herb/rules/require-aria-labels.mjs)
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
::: warning Rule Name Clashes
|
|
518
|
+
If a custom rule has the same name as a built-in rule or another custom rule, you'll see a warning. The custom rule will override the built-in rule.
|
|
519
|
+
:::
|
|
520
|
+
|
|
521
|
+
::: tip Hot Reload
|
|
522
|
+
Custom rules are automatically reloaded when changed in editors with the Herb Language Server. No need to restart your editor!
|
|
523
|
+
:::
|
|
524
|
+
|
|
285
525
|
### Language Server Integration
|
|
286
526
|
|
|
287
527
|
The linter is automatically integrated into the [Herb Language Server](https://herb-tools.dev/projects/language-server), providing real-time validation in supported editors like VS Code, Zed, and Neovim.
|