eslint-plugin-tera
v0.1.0
Published
First-class ESLint language, lint rules, and formatting for Tera templates
Maintainers
Readme
eslint-plugin-tera
First-class ESLint language support, correctness rules, and opt-in formatting for Tera templates. It runs independently of Tera Tools, VS Code, and Zola.
Requirements
- Node.js 20.19 or newer.
- ESLint 9.39 or ESLint 10.
- ESLint flat config (
eslint.config.js,.mjs, or.cjs).
Install
pnpm add --save-dev eslint eslint-plugin-teraFor standalone .tera files:
// eslint.config.mjs
import tera from 'eslint-plugin-tera'
export default [
...tera.configs.recommended,
]npx eslint "**/*.tera"Formatting is deliberately opt-in:
export default [
...tera.configs['recommended-with-formatting'],
]Run npx eslint --fix "**/*.tera" to apply it. The formatter changes only
Tera regions; it never reformats surrounding HTML.
Zola HTML templates
The built-in presets match only **/*.tera. Opt known template directories
into the Tera language instead of claiming every HTML file in a repository:
import tera from 'eslint-plugin-tera'
export default [
...tera.configs.recommended,
{
...tera.configs.recommended[0],
files: [
'templates/**/*.html',
'themes/*/templates/**/*.html',
],
},
]This analyzes Tera regions inside HTML, including regions embedded in
<script> text, while leaving HTML and JavaScript validation to their own
tools. Do not apply the Tera language to .vue, .jsx, or .tsx files.
Presets and rules
| Preset | Behavior |
| --- | --- |
| base | Registers tera/tera without rules. |
| recommended | Enables correctness rules, never formatting. |
| formatting | Enables only the fixable tera/format rule. |
| recommended-with-formatting | Enables correctness and formatting rules. |
| Rule | Default | Fixable | Purpose |
| --- | --- | --- | --- |
| tera/syntax-error | recommended | No | Invalid, unclosed, or dialect-incompatible Tera syntax. |
| tera/no-duplicate-arguments | recommended | No | Duplicate named arguments in calls. |
| tera/component-parameters | recommended | No | File-local Tera 2 Component declaration parameters. |
| tera/format | opt-in | Yes | Canonical formatting inside Tera regions. |
Component validation is currently file-local. Project-wide declaration resolution, completion, navigation, hover, and Zola-aware diagnostics remain the responsibility of Tera Tools until ESLint has an explicit project service.
Guides
- Standalone CLI and CI usage
- Presets, file matching, and language options
- VS Code, Tera Tools, HTML, Vue, and React integration
Architecture
The package bundles the runtime-neutral parser, analyzer, and Tera-region
formatter from @tera-tools/language-core. Consumers install only this plugin
and ESLint; no language server or unpublished workspace dependency is needed.
Both ESM import and CommonJS require entry points are provided.
