@hyperfrontend/linter
v0.3.4
Published
A linter for TypeScript, JavaScript, JSX, JSON and Markdown with its own parsers and no external runtime packages.
Maintainers
Readme
A linter for TypeScript, JavaScript, JSX, JSON and Markdown with its own parsers and no external runtime packages.
• 👉 See documentation
• 👉 See guides & tutorials
What is @hyperfrontend/linter?
@hyperfrontend/linter checks TypeScript, JavaScript, JSX, JSON and Markdown against rules you choose, and fixes what the rules know how to fix. It parses every file with parsers of its own and installs no dependencies.
It is not a drop-in ESLint. It reimplements a selection of rules from ESLint and well-known plugins, under a configuration that reads like ESLint's flat config, and it does not load ESLint plugins, parsers or shareable configs.
Key Features
- Packaged rules - Core JavaScript, TypeScript, JSDoc, React, React hooks and package.json rules, and a set of conventions
- Presets to start from - The rules the upstream recommended configurations turn on, as plain objects you spread into a block
- One parse, one traversal - The listeners of every rule in effect for a file run in a single walk of its tree
- Rules of your own - Register them under a prefix with
familiesand test them withtestRule - Fixes and suggestions -
--fixapplies fixes; suggestions, for changes that need your judgement, appear in the JSON report - No dependencies - The package is self-contained; linting loads nothing from npm
Architecture Highlights
Every file is parsed once and every rule's listeners run in one traversal of it; the services rules share, such as scopes and code paths, are computed once per file and never rebuilt. The architecture guide covers the parsers, the shared services and the fix loop.
Why Use @hyperfrontend/linter?
Fewer packages in the toolchain
A linting setup built on ESLint brings a parser, plugins and their dependencies into every install. This package is one dependency with nothing beneath it, for a project whose checks fit its rules.
Rules you can read and own
Each rule is one module with its specification beside it. When the packaged rules stop short, write and test a rule of your own with the same API they use.
Installation
npm install --save-dev @hyperfrontend/linterRequires Node.js 24 or later, which loads the TypeScript configuration file without a compiler.
Quick Start
Create lint.config.ts at the project root:
import { CODE, CODE_RULES, on } from '@hyperfrontend/linter'
export default [
{ ignores: ['dist/', 'coverage/'] },
{ files: CODE, rules: CODE_RULES },
{ files: ['src/**/*.ts'], rules: on('no-enum import-order') },
]Then lint and fix from the project root:
npx hf-lint
npx hf-lint src --fixLint a project with @hyperfrontend/linter covers configuration, directives, exit codes, CI and linting from code with lint.
API Overview
| Entry | What it is |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| @hyperfrontend/linter | Running, configuration types and presets, defineRule and the rule types |
| /helpers | Tokens, scopes, JSON properties and positions, for rules of your own |
| /testing | testRule, which turns a rule's cases into node:test tests |
| hf-lint | The command line |
Every rule, with its options and examples, is in the rule catalogue. Moving from ESLint? Replace ESLint with @hyperfrontend/linter starts with what does and does not carry over.
Limitations
- No rule uses type information, and every packaged rule reads only the file it lints.
- No editor integration: run it from the terminal, a hook or CI.
- No result cache between runs.
- YAML files are read as plain lines for rules of your own; no packaged rule reads them.
Acknowledgements
The packaged rules reimplement rules from ESLint, typescript-eslint, eslint-plugin-jsdoc, eslint-plugin-react, eslint-plugin-react-hooks and eslint-plugin-package-json, whose messages, options and test cases they follow; a few of its tables derive from those projects, from globals and from safe-regex. Their licences and the details are in NOTICE.md. How the linter came to be written is told in I Replaced ESLint. The First Attempt Worked. I Threw It Away.
Compatibility
Requires Node.js 24 or later. There is no browser build.
| Operating System | Supported | | ---------------- | :-------: | | Linux | ✅ | | macOS | ✅ | | Windows | ✅ |
Output Formats
| Format | File | Tree-Shakeable |
| ------ | ----------------- | :------------: |
| ESM | index.mjs | ✅ |
| CJS | index.cjs | ❌ |
| Bin | bin/hf-lint.mjs | ❌ |
Part of hyperfrontend
This library is part of the hyperfrontend monorepo.
