@zokugun/eslint-toolkit
v0.3.0
Published
Build ESLint configs with some configuration types and pre-configured common rules.
Readme
@zokugun/eslint-toolkit
This toolkit ships a configurator pattern for building ESLint setups with EditorConfig and override support. It comes with some pre-configured common rules.
Features
- Configurator Pattern: A functional approach to build ESLint configurations programmatically with resolution and registration helpers.
- Ignore Patterns: Exclude files from linting using the
ignoresconfiguration array. - File Matching: Specify which files each configuration applies to through the
filesoption. - Override Support: Configure different rules for specific file patterns using the override system.
- EditorConfig Type: A type for
.editorconfigcompatibility.
Installation
npm add @zokugun/eslint-toolkitQuick Start
import type {Configurator, OptionFiles, OptionIgnores, OptionOverrideFiles, OptionOverrideIgnores, OptionRules} from '@zokugun/eslint-toolkit'
import plugin from "eslint-plugin-regexp";
import { RuleOptions } from './typegens/regexp.js';
import { rules } from './rules/regexp.js';
type Options = OptionRules<RuleOptions> & OptionFiles & OptionIgnores & OptionOverrideFiles & OptionOverrideIgnores;
function regexp(options: Options = {}): Configurator {
return (resolve) => {
const sources = resolve<string[]>('javascript/sources') ?? []
const files = options.overrides?.files ?? [
...sources,
...(options.files ?? [])
]
const ignores = options.overrides?.ignores ?? options.ignores ?? []
return {
name: 'regexp',
files,
ignores,
plugins: {
regexp: plugin,
},
rules: {
...rules,
...options.rules,
}
};
};
}API reference
type Configurator = (resolve: Resolver, register: Registrator) => Linter.Config[] | Linter.Config | undefined;
type EditorConfigOptions = {
charset?: 'latin1' | 'utf-8' | 'utf-8-bom' | 'utf-16be' | 'utf-16le' | 'unset';
end_of_line?: 'lf' | 'crlf' | 'unset';
indent_size?: number | 'tab' | 'unset';
indent_style?: 'tab' | 'space' | 'unset';
insert_final_newline?: 'true' | 'false' | 'unset';
tab_width?: number | 'unset';
trim_trailing_whitespace?: 'true' | 'false' | 'unset';
};
type OptionFiles = {
files?: string[];
};
type OptionIgnores = {
ignores?: string[];
};
type OptionOverridesFiles = {
overrides?: {
files?: string[];
};
};
type OptionOverridesIgnores = {
overrides?: {
ignores?: string[];
};
};
type OptionOverridesRules<R> = {
overrides?: {
rules?: Partial<R>;
};
};
type OptionRules<R> = {
rules?: Partial<R>;
};
type Registrator = (name: string, value: unknown) => void;
type Resolver = {
(name: string, defaultValue: []): unknown[];
<T>(name: string, defaultValue: T[]): T[];
<T>(name: string, defaultValue: T): | T;
<T>(name: string, defaultValue?: undefined): T | undefined;
};
interface CommonsRuleOptions {
'accessor-pairs'?: Linter.RuleEntry<AccessorPairs>
...
}
const commonsRules: Partial<CommonsRuleOptions>Contributions
Contributions are most welcome. Please:
- Open issues and feature requests under the repository discussions.
- Follow the
CONTRIBUTING.md.
Donations
Support this project by becoming a financial contributor.
License
Copyright © 2026-present Baptiste Augrain
Licensed under the MIT license.
