Comprehensive collection of 132+ linting rules covering accessibility, style, best practices, and Ember-specific patterns.
Built-in rules are organized into logical categories for different aspects of template quality.
// Available rule categories and their focus areas
type RuleCategory =
| "accessibility" // ARIA, semantic HTML, keyboard navigation
| "components" // Ember component best practices
| "style" // Formatting and code style
| "deprecated" // Deprecated Ember patterns
| "security" // Security-related checks
| "performance" // Performance optimizations
| "maintainability"; // Code maintainability
// Rule severity levels
type RuleSeverity = -1 | 0 | 1 | 2; // todo, ignore, warning, errorRules focused on web accessibility, ARIA compliance, and semantic HTML.
// Key accessibility rules
const AccessibilityRules = {
"no-abstract-roles": "Prevent abstract ARIA roles",
"no-accesskey-attribute": "Prevent accesskey attribute usage",
"no-aria-hidden-body": "Prevent aria-hidden on body element",
"no-aria-unsupported-elements": "Prevent ARIA attributes on unsupported elements",
"no-autofocus-attribute": "Prevent autofocus attribute",
"no-positive-tabindex": "Prevent positive tabindex values",
"require-aria-activedescendant-tabindex": "Require tabindex when using aria-activedescendant",
"require-input-label": "Require labels for input elements",
"require-lang-attribute": "Require lang attribute on html element",
"require-mandatory-role-attributes": "Require mandatory ARIA role attributes",
"require-valid-alt-text": "Require meaningful alt text for images"
};Rules for Ember component best practices and template organization.
// Key component rules
const ComponentRules = {
"no-curly-component-invocation": "Prefer angle bracket component syntax",
"no-implicit-this": "Require explicit this in template expressions",
"no-index-component-invocation": "Prevent index component invocations",
"builtin-component-arguments": "Validate built-in component arguments",
"require-each-key": "Require key attribute in each loops",
"require-strict-mode": "Require strict mode in templates",
"no-attrs-in-components": "Prevent @attrs usage in components",
"no-capital-arguments": "Prevent capitalized component arguments",
"no-arguments-for-html-elements": "Prevent arguments on HTML elements"
};Rules for consistent code style and formatting.
// Key style rules
const StyleRules = {
"attribute-indentation": "Enforce consistent attribute indentation",
"attribute-order": "Enforce consistent attribute ordering",
"block-indentation": "Enforce consistent block indentation",
"eol-last": "Require newline at end of file",
"linebreak-style": "Enforce consistent linebreak style",
"quotes": "Enforce consistent quote style",
"no-multiple-empty-lines": "Prevent multiple consecutive empty lines",
"no-trailing-spaces": "Prevent trailing whitespace",
"no-whitespace-for-layout": "Prevent whitespace for layout purposes"
};Rules for security, performance, and maintainability.
// Key security and best practice rules
const SecurityRules = {
"no-action": "Prevent action usage (deprecated)",
"no-debugger": "Prevent debugger statements",
"no-triple-curlies": "Prevent triple curly braces (unsafe HTML)",
"link-rel-noopener": "Require rel='noopener' on external links",
"no-bare-strings": "Prevent bare strings in templates",
"no-html-comments": "Prevent HTML comments in templates",
"no-inline-styles": "Prevent inline style attributes"
};Complete list of all 132+ built-in rules with descriptions.
// Complete rule registry (excerpt - showing pattern)
const AllRules = {
// Accessibility (11+ rules)
"no-abstract-roles": "Prevent abstract ARIA roles",
"no-accesskey-attribute": "Prevent accesskey attribute usage",
"no-aria-hidden-body": "Prevent aria-hidden on body element",
"no-aria-unsupported-elements": "Prevent ARIA attributes on unsupported elements",
"no-autofocus-attribute": "Prevent autofocus attribute",
"no-positive-tabindex": "Prevent positive tabindex values",
"require-aria-activedescendant-tabindex": "Require tabindex when using aria-activedescendant",
"require-input-label": "Require labels for input elements",
"require-lang-attribute": "Require lang attribute on html element",
"require-mandatory-role-attributes": "Require mandatory ARIA role attributes",
"require-valid-alt-text": "Require meaningful alt text for images",
// Component best practices (20+ rules)
"builtin-component-arguments": "Validate built-in component arguments",
"no-attrs-in-components": "Prevent @attrs usage in components",
"no-capital-arguments": "Prevent capitalized component arguments",
"no-curly-component-invocation": "Prefer angle bracket component syntax",
"no-implicit-this": "Require explicit this in template expressions",
"no-index-component-invocation": "Prevent index component invocations",
"require-each-key": "Require key attribute in each loops",
"require-strict-mode": "Require strict mode in templates",
// Style and formatting (15+ rules)
"attribute-indentation": "Enforce consistent attribute indentation",
"attribute-order": "Enforce consistent attribute ordering",
"block-indentation": "Enforce consistent block indentation",
"eol-last": "Require newline at end of file",
"linebreak-style": "Enforce consistent linebreak style",
"quotes": "Enforce consistent quote style",
// Security and best practices (20+ rules)
"no-action": "Prevent action usage (deprecated)",
"no-debugger": "Prevent debugger statements",
"no-triple-curlies": "Prevent triple curly braces (unsafe HTML)",
"link-rel-noopener": "Require rel='noopener' on external links",
// Performance optimizations (10+ rules)
"no-unnecessary-component-helper": "Prevent unnecessary component helper usage",
"no-unnecessary-concat": "Prevent unnecessary string concatenation",
"no-unused-block-params": "Prevent unused block parameters",
// Deprecated patterns (10+ rules)
"deprecated-inline-view-helper": "Prevent deprecated inline view helper",
"deprecated-render-helper": "Prevent deprecated render helper",
// Template structure (25+ rules)
"no-duplicate-attributes": "Prevent duplicate attributes",
"no-duplicate-id": "Prevent duplicate ID attributes",
"no-empty-headings": "Prevent empty heading elements",
"no-forbidden-elements": "Prevent usage of forbidden elements",
"no-nested-interactive": "Prevent nested interactive elements",
// And 50+ additional rules covering edge cases, specific patterns, etc...
};How to configure individual rules in project configuration.
// Rule configuration options
interface RuleConfig {
// Severity: -1=todo, 0=off, 1=warn, 2=error
severity: -1 | 0 | 1 | 2;
// Rule-specific configuration
config?: any;
}
// Example configurations for common rules
const ExampleConfigs = {
"no-bare-strings": {
severity: 2, // error
config: {
allowlist: [" ", "©", "(", ")", ",", ".", "&", "+", "-", "=", "*", "/", "#", "%", "!", "?", ":", "[", "]", "{", "}", "<", ">", "•"]
}
},
"no-implicit-this": {
severity: 2,
config: {
allow: ["can", "cannot", "is-array", "not-eq", "titleize"]
}
},
"quotes": {
severity: 1, // warning
config: "double" // or "single"
},
"attribute-indentation": {
severity: 2,
config: {
indentSize: 2,
alignAttributesVertically: false
}
}
};Usage Examples:
// .template-lintrc.js
module.exports = {
extends: ['recommended', 'a11y'],
rules: {
// Enable specific rules
'no-bare-strings': 'error',
'require-valid-alt-text': 'error',
// Configure rules with options
'no-implicit-this': ['error', {
allow: ['can', 'cannot']
}],
'quotes': ['warn', 'double'],
// Disable specific rules
'no-html-comments': 'off',
// Set as TODO (will be tracked but not fail builds)
'no-curly-component-invocation': 'todo'
},
// File-specific overrides
overrides: [
{
files: ['**/*-test.{js,ts}'],
rules: {
'no-bare-strings': 'off'
}
}
]
};Pre-configured rule collections for common use cases.
// Available preset configurations
const Presets = {
"recommended": "Core recommended rules for all Ember applications",
"a11y": "Accessibility-focused rules for inclusive applications",
"stylistic": "Code style and formatting rules",
"5-x-recommended": "Legacy compatibility rules for Ember 5.x projects"
};
// Usage in configuration
const configWithPresets = {
extends: ['recommended', 'a11y'],
rules: {
// Override specific preset rules if needed
'no-bare-strings': 'warn' // Override from 'error' in recommended
}
};