ESLint
eslint-plugin-absolute ships 27 rules that enforce AbsoluteJS conventions — SSR-safe paths, react-spring-friendly styling, leaner TypeScript, and consistent project structure. Each rule has its own page with examples, options, and guidance below.
View on GitHub#Installation
Install the plugin, register it under the absolute namespace, and enable the rules you want:
bun add --dev eslint-plugin-absolute// eslint.config.js
import absolute from 'eslint-plugin-absolute';
export default [
{
plugins: { absolute },
rules: {
'absolute/no-import-meta-path': 'error',
'absolute/sort-keys-fixable': 'error',
'absolute/no-explicit-return-type': 'error'
}
}
];#Legend
#React & JSX
7 rules.
| Rule | Notes |
|---|---|
Disallow variables that are only passed to a single custom child component; move them into that component instead. | — |
Warn when JSX elements are nested too deeply, suggesting refactoring into a separate component. | — |
Enforce using anchor tags for navigation instead of buttons whose onClick handlers change the path. | — |
Disallow nested functions that return non-component, non-singular JSX, to enforce one component per file. | — |
Prefer the logical && operator over a ternary with null/undefined for conditional JSX rendering. | — |
Flag unnecessary <div> wrappers that enclose a single JSX element. | — |
Enforce that the key prop is only used on elements rendered as part of an array mapping. | — |
#Styling
4 rules.
| Rule | Notes |
|---|---|
Disallow inline style objects with too many keys and encourage extracting them. | — |
Disallow grouping CSS style objects in a single export; export each style separately. | — |
Objects typed as CSSProperties must not include a 'transition' property, which conflicts with react-spring. | — |
Warn when a component file (.tsx/.jsx) contains a style object typed as CSSProperties; move it to a style file. | — |
#react-spring
1 rule.
| Rule | Notes |
|---|---|
Enforce correct naming for useSpring and useSprings hook destructuring ( | — |
#TypeScript
5 rules.
| Rule | Notes |
|---|---|
Require explicit type annotations for object literals and arrays of object literals. | — |
Disallow explicit return type annotations on functions, except for type-predicate guards and inline object-literal returns. | — |
Disallow inline object type literals on annotations; prefer extracting them to a named type alias. | — |
Disallow type annotations on variable declarations whose initializer already has the same inferred type. | FixTypes |
Disallow identity aliases that rename a type or value without transforming it. | — |
#Angular
2 rules.
| Rule | Notes |
|---|---|
Disallow defining more than one Angular feature class (@Component, @Directive, @Pipe, @Injectable, @NgModule) per file. | — |
Disallow nondeterministic values in Angular render paths that can cause SSR hydration mismatches. | — |
#Imports & Exports
3 rules.
| Rule | Notes |
|---|---|
Prefer inlining export at a declaration site over a trailing export { name } statement for local declarations. | Fix |
Enforce that top-level export declarations are sorted by exported name, optionally variables before functions. | Fix |
Enforce sorted keys in object literals with a comment-preserving auto-fix for provably safe cases. | Fix |
#Code Quality
5 rules.
| Rule | Notes |
|---|---|
Disallow too many nested blocks, except when the block only contains an early exit (return or throw). | — |
Disallow variable names shorter than the configured minimum length, unless an outer variable with a longer name starting with the same characters exists. | — |
Disallow deriving filesystem paths from a module's own location, which break when the server is bundled. | — |
Disallow catch blocks that contain only comments or no-op statements. | — |
Disallow functions that take no parameters and just return an object literal, unless used as a callback. | — |