@tada5hi/eslint-plugin
v1.3.0
Published
ESLint rules for type locations, directory barrel boundaries and agent docs
Maintainers
Readme
@tada5hi/eslint-plugin
ESLint rules for the @tada5hi source conventions and for agent documentation (CLAUDE.md, AGENTS.md, .agents/).
Usage
npm install --save-dev eslint typescript typescript-eslint @tada5hi/eslint-pluginimport tada5hi from '@tada5hi/eslint-plugin';
import tseslint from 'typescript-eslint';
export default [
{
files: ['**/*.{ts,tsx,mts,cts}'],
languageOptions: { parser: tseslint.parser },
},
tada5hi.configs.conventions,
];The preset does not configure or depend on a TypeScript parser. Supply your own parser configuration, as above, or use your existing TypeScript ESLint config.
The preset applies the custom rules to **/src/**/*.{ts,tsx,mts,cts} (not Vue or build/test configuration files). For manual use, including plain JavaScript import rules with ESLint's default parser:
import tada5hi from '@tada5hi/eslint-plugin';
export default [{
plugins: { '@tada5hi': tada5hi },
rules: {
'@tada5hi/no-reexport-shims': 'error',
'@tada5hi/no-root-barrel-import': 'error',
},
}];Rules
lines-between-class-members— autofixable Stylistic class-member spacing with support for TypeScript abstract properties and auto-accessors in itsfieldselector. Accepts the same options as@stylistic/lines-between-class-members; the shared config and conventions preset require a blank line after fields only (prev: 'field',next: '*'), leaving method-to-method spacing unchanged. Does not mutate the parser AST.no-collection-call-in-condition— extract collection operations into named variables rather than putting them inif/else if,while,do…while,fortests, or ternary conditions. Matchesmap,filter,flatMap,some,every,find,findIndex,findLast,findLastIndex,reduce, andreduceRightby method name, including chains, optional calls, and static computed method names. Simple predicates,includes, andhasremain allowed. This syntax-only rule also matches unrelated methods with these names. Deferred function bodies (including IIFEs) and deferred instance-field initializers inside conditions are not inspected, nor are Vue template expressions. No autofix: preserve short-circuiting and loop re-evaluation when extracting a value.
const hasActiveItems = items.some(isActive);
if (hasActiveItems) {
process(items);
}type-declaration-location— exported top-level interfaces and type aliases belong intypes.ts,types.mts,types.cts, ortypes.tsx. This includes declarations exported later or by a default export. Private top-level types and local types are allowed. Ambient declaration files (.d.ts,.d.mts,.d.cts) are exempt. Namespace and module-local declarations are not top-level and are allowed; no interface-versus-alias semantics are enforced.no-reexport-shims— top-level export-from declarations are allowed only inindexdirectory barrels, includingindex.d.ts,index.d.mts, andindex.d.cts. Ambient module re-exports are not file barrels and are exempt. Their source must begin with./and normalize within that barrel directory's subtree. Named local exports are allowed.no-root-barrel-import— internal relative static imports, dynamic imports, unshadowed CommonJSrequire()calls, TypeScript import-equals declarations, and TypeScript import types may not target the nearestsrcroot or its explicitindexfile. Nested and sibling barrels remain allowed. For Windows absolute filenames (drive-letter or UNC paths), CommonJSrequire()and TypeScript import-equals requests also recognize backslash separators; ESM and POSIX requests are unchanged.agent-docs-max-size— an agent document (CLAUDE.md,AGENTS.md,.agents/**/*.md) stays undermaxBytes(default 40000).agent-docs-no-history— no phrase that narrates history instead of stating the current rule. Defaultpatterns(case-insensitive regular expressions,\s+between words so a phrase wrapped onto the next line still matches):plan NNN,used to(not after a form of "be" or "get", the passive voice),before #N,no longer,pinned by. A match touching a code span, a code block (fenced or indented) or HTML is skipped.agent-docs-import-budget— a root document (CLAUDE.md,AGENTS.md) and everything its@imports load, followed breadth first relative to the importing file up to five hops like Claude Code does, each file counted once, stays undermaxBytes(default 60000). Relative, absolute and non-ASCII paths are recognized. An@...mdimport that cannot be read is reported, also inside an imported file, where the report sits on the root import that leads to it and names both files; other@tokens such as@scope/packageare ignored unless they name a file.
The agent-docs-* rules are written for Markdown: code and HTML regions come from a CommonMark parse
(mdast-util-from-markdown), and @tada5hi/eslint-config wires the rules to @eslint/markdown. Apart from the import
budget, the rules do not resolve files or use a TypeScript program. Only lines-between-class-members provides autofixes;
the other rules require manual changes. Filename-based checks are skipped when ESLint provides an unknown filename.
Exceptions
Place overrides after tada5hi.configs.conventions (or after the shared config). Use the exact rule IDs to disable
individual policies, optionally adding files to limit an exception:
{
rules: {
'@tada5hi/lines-between-class-members': 'off',
'@tada5hi/no-collection-call-in-condition': 'off',
'@tada5hi/type-declaration-location': 'off',
'@tada5hi/no-reexport-shims': 'off',
'@tada5hi/no-root-barrel-import': 'off',
'@tada5hi/agent-docs-max-size': ['error', { maxBytes: 60000 }],
'@tada5hi/agent-docs-no-history': 'off',
'@tada5hi/agent-docs-import-budget': ['error', { maxBytes: 180000 }],
},
}