@qpqjs/eslint-config
v0.10.0
Published
eslint config for quidproquo projects.
Readme
@qpqjs/eslint-config
The shared ESLint configuration for quidproquo projects, bundled with a small plugin that enforces the
framework's ask naming contract.
npm install --save-dev @qpqjs/eslint-config// eslint.config.mjs
import qpqConfig from '@qpqjs/eslint-config';
export default [...qpqConfig];eslint and prettier are peer dependencies. Beyond the qpq rules below, the config sets the house style, including import sorting that groups
quidproquo packages separately from external dependencies.
qpq rules
The shared config bundles a small ESLint plugin (plugin/index.mjs, namespace qpq) that enforces the framework's ask naming contract.
Using the shared config gets you the rules automatically. To use the plugin on its own, without the rest of the config:
// eslint.config.mjs
import qpqPlugin from '@qpqjs/eslint-config/plugin';
export default [
qpqPlugin.configs.recommended,
// or pick rules individually:
// { plugins: { qpq: qpqPlugin }, rules: { 'qpq/require-yield-star': 'error' } },
];The rules:
qpq/require-yield-star
Inside a generator, a call to any ask* function (including obj.askX()) must be delegated with yield*. A bare call or a plain yield creates a
generator that never runs. Auto-fixable: the fix inserts yield* (adding parentheses where a bare yield expression is not allowed), upgrades yield
to yield*, and replaces a wrong await.
function* askExample() {
askDateNow(); // error, fixed to: yield* askDateNow()
yield askDateNow(); // error, fixed to: yield* askDateNow()
const now = yield* askDateNow(); // correct
}Allowed without yield*:
- ask calls passed as arguments, that's how stories compose:
yield* askRunParallel([askA(), askB()]),runStory(askDateNow(), mocks) - ask calls outside generator functions (test drivers, forwarding wrappers), since yielding is not possible there anyway
qpq/ask-prefix-generator-only
The ask prefix is reserved for qpq stories, the same way use is reserved for React hooks. Any function literal named ask* (declaration, arrow,
method, class property) must be a generator. Aliases and factory results like const askRead = createContextReader(ctx) are fine because they are not
function literals. Not auto-fixable, rename the function or make it a generator.
qpq/no-history-comments
Comments carry no em dashes and never narrate what the code used to do ("used to be", "no longer", "previously", "moved from"). Warns.
qpq/one-export-per-file
One main export per file, with a few types or constants that belong to it allowed alongside (G1). Barrels (index.ts), declaration
files and tests are exempt, and the two sanctioned pairs count as one concept: askXBase with its askX wrapper, and an XEffect type
with its XPayload type. The rule cannot tell a helper type from a second main export, so it counts: { max } is the export count a
file may reach before it warns (default 1). The shared config sets 10, so only files well past G1 warn and the rest is left to review.
Warns.
qpq/filename-matches-export
A file is named after its export. A SCREAMING_CASE constant's file takes either its exact name (MAX_ITEMS.ts) or the camelCase form
(maxItems.ts). Two-export files are named after the wrapper or the effect. Warns.
Tests live next to the rules (plugin/rules/*.test.mjs) and run with the repo's vitest suite: npx vitest run --project @qpqjs/eslint-config.
Status
Pre-1.0 and under active development. Rules and settings change between releases.
Documentation
License
MIT. See LICENSE.
