Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Flat config (ESLint 9). Deliberately close to the recommended presets: this
// package is ~1k lines of library code, and a bespoke rule set would be a
// second opinion to maintain for no benefit. The floor is "lint runs and can
// fail", not "lint encodes taste".
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{
// dist/ is generated by `tsc`; examples/ is a standalone Next.js app with
// its own toolchain and is not part of this package's published `files`.
ignores: ['dist/**', 'examples/**', 'node_modules/**'],
},
js.configs.recommended,
...tseslint.configs.recommended,
{
files: ['**/*.ts'],
languageOptions: { globals: globals.node },
rules: {
// The public API intentionally accepts arbitrary user-supplied form
// shapes, so a handful of `any`s are load-bearing rather than lazy.
// Warn, so they stay visible without failing the gate on existing code.
'@typescript-eslint/no-explicit-any': 'warn',
},
},
{
// src/react.ts exports a hook, and already carries an
// `eslint-disable-next-line react-hooks/exhaustive-deps`. Without the
// plugin installed that directive is itself an ESLint error ("rule not
// found") — the comment was writing a cheque the config could not cash.
// Installing it makes the suppression meaningful AND lints the hook.
files: ['src/react.ts'],
plugins: { 'react-hooks': reactHooks },
rules: reactHooks.configs.recommended.rules,
},
{
// Tests and scripts are plain Node under `node --test`. `Request`/`URL`
// are Node 18+ globals, so they need the node globals set to resolve.
files: ['test/**/*.js', 'scripts/**/*.{js,mjs}'],
languageOptions: { globals: { ...globals.node, ...globals.nodeBuiltin } },
},
)
Loading
Loading