Available Rules

The --fix option on the command line automatically fixes problems reported by rules which have a wrench 🔧 below.
The rules with the following star ⭐ are included in the plugin:astro/recommended config.

Doesn’t the rule you want exist? Share your idea of that rule with us.

Possible Errors

These rules relate to possible syntax or logic errors in Astro component code:

Rule IDDescription
astro/missing-client-only-directive-valuethe client:only directive is missing the correct component’s framework value
astro/no-conflict-set-directivesdisallow conflicting set directives and child contents
astro/no-deprecated-astro-canonicalurldisallow using deprecated Astro.canonicalURL
astro/no-deprecated-astro-fetchcontentdisallow using deprecated Astro.fetchContent()⭐🔧
astro/no-deprecated-astro-resolvedisallow using deprecated Astro.resolve()
astro/no-deprecated-getentrybyslugdisallow using deprecated getEntryBySlug()
astro/no-exports-from-componentsdisallow value export
astro/no-unused-define-vars-in-styledisallow unused define:vars={...} in style tag
astro/valid-compiledisallow warnings when compiling.

Security Vulnerability

These rules relate to security vulnerabilities in Astro component code:

Rule IDDescription
astro/no-set-html-directivedisallow use of set:html to prevent XSS attack

Best Practices

These rules relate to better ways of doing things to help you avoid problems:

Rule IDDescription
astro/no-set-text-directivedisallow use of set:text🔧
astro/no-unused-css-selectordisallow selectors defined in style tag that don’t use in HTML

Stylistic Issues

These rules relate to style guidelines, and are therefore quite subjective:

Rule IDDescription
astro/prefer-class-list-directiverequire class:list directives instead of class with expressions🔧
astro/prefer-object-class-listrequire use object instead of ternary expression in class:list🔧
astro/prefer-split-class-listrequire use split array elements in class:list🔧

A11Y Extension Rules

These rules extend the rules provided by eslint-plugin-jsx-a11y to work well in Astro component:
(You need to install eslint-plugin-jsx-a11y to use the rules.)

Rule IDDescription
astro/jsx-a11y/alt-textapply jsx-a11y/alt-text rule to Astro components
astro/jsx-a11y/anchor-ambiguous-textapply jsx-a11y/anchor-ambiguous-text rule to Astro components
astro/jsx-a11y/anchor-has-contentapply jsx-a11y/anchor-has-content rule to Astro components
astro/jsx-a11y/anchor-is-validapply jsx-a11y/anchor-is-valid rule to Astro components
astro/jsx-a11y/aria-activedescendant-has-tabindexapply jsx-a11y/aria-activedescendant-has-tabindex rule to Astro components
astro/jsx-a11y/aria-propsapply jsx-a11y/aria-props rule to Astro components
astro/jsx-a11y/aria-proptypesapply jsx-a11y/aria-proptypes rule to Astro components
astro/jsx-a11y/aria-roleapply jsx-a11y/aria-role rule to Astro components
astro/jsx-a11y/aria-unsupported-elementsapply jsx-a11y/aria-unsupported-elements rule to Astro components
astro/jsx-a11y/autocomplete-validapply jsx-a11y/autocomplete-valid rule to Astro components
astro/jsx-a11y/click-events-have-key-eventsapply jsx-a11y/click-events-have-key-events rule to Astro components
astro/jsx-a11y/control-has-associated-labelapply jsx-a11y/control-has-associated-label rule to Astro components
astro/jsx-a11y/heading-has-contentapply jsx-a11y/heading-has-content rule to Astro components
astro/jsx-a11y/html-has-langapply jsx-a11y/html-has-lang rule to Astro components
astro/jsx-a11y/iframe-has-titleapply jsx-a11y/iframe-has-title rule to Astro components
astro/jsx-a11y/img-redundant-altapply jsx-a11y/img-redundant-alt rule to Astro components
astro/jsx-a11y/interactive-supports-focusapply jsx-a11y/interactive-supports-focus rule to Astro components
astro/jsx-a11y/label-has-associated-controlapply jsx-a11y/label-has-associated-control rule to Astro components
astro/jsx-a11y/langapply jsx-a11y/lang rule to Astro components
astro/jsx-a11y/media-has-captionapply jsx-a11y/media-has-caption rule to Astro components
astro/jsx-a11y/mouse-events-have-key-eventsapply jsx-a11y/mouse-events-have-key-events rule to Astro components
astro/jsx-a11y/no-access-keyapply jsx-a11y/no-access-key rule to Astro components
astro/jsx-a11y/no-aria-hidden-on-focusableapply jsx-a11y/no-aria-hidden-on-focusable rule to Astro components
astro/jsx-a11y/no-autofocusapply jsx-a11y/no-autofocus rule to Astro components
astro/jsx-a11y/no-distracting-elementsapply jsx-a11y/no-distracting-elements rule to Astro components
astro/jsx-a11y/no-interactive-element-to-noninteractive-roleapply jsx-a11y/no-interactive-element-to-noninteractive-role rule to Astro components
astro/jsx-a11y/no-noninteractive-element-interactionsapply jsx-a11y/no-noninteractive-element-interactions rule to Astro components
astro/jsx-a11y/no-noninteractive-element-to-interactive-roleapply jsx-a11y/no-noninteractive-element-to-interactive-role rule to Astro components
astro/jsx-a11y/no-noninteractive-tabindexapply jsx-a11y/no-noninteractive-tabindex rule to Astro components
astro/jsx-a11y/no-redundant-rolesapply jsx-a11y/no-redundant-roles rule to Astro components
astro/jsx-a11y/no-static-element-interactionsapply jsx-a11y/no-static-element-interactions rule to Astro components
astro/jsx-a11y/prefer-tag-over-roleapply jsx-a11y/prefer-tag-over-role rule to Astro components
astro/jsx-a11y/role-has-required-aria-propsapply jsx-a11y/role-has-required-aria-props rule to Astro components
astro/jsx-a11y/role-supports-aria-propsapply jsx-a11y/role-supports-aria-props rule to Astro components
astro/jsx-a11y/scopeapply jsx-a11y/scope rule to Astro components
astro/jsx-a11y/tabindex-no-positiveapply jsx-a11y/tabindex-no-positive rule to Astro components

Extension Rules

These rules extend the rules provided by ESLint itself to work well in Astro component:

Rule IDDescription
astro/semiRequire or disallow semicolons instead of ASI🔧


Edit this page