Files
mkstack/eslint-rules
Alex Gleason 4efc3c7273 Modernize ESLint setup to v10 with defineConfig
Replaces the deprecated `tseslint.config(...)` helper with ESLint core's
`defineConfig()` (available since ESLint 9.22, recommended in 10.x) and
upgrades the lint stack to the latest majors:

  eslint                      9.39  -> 10.2
  @eslint/js                  10.0  -> 10.0
  typescript-eslint            8.0  -> 8.59
  eslint-plugin-react-hooks    5.1  -> 7.1
  eslint-plugin-react-refresh  0.4  -> 0.5
  @html-eslint/{eslint-plugin,parser}  0.41 -> 0.59
  globals                     15.9  -> 17.5

Config changes:
- Use `defineConfig` + `globalIgnores()` instead of `tseslint.config`.
- Adopt `reactHooks.configs.flat.recommended` (adds React Compiler rules:
  purity, refs, set-state-in-effect, etc.).
- Adopt `reactRefresh.configs.vite` (matches the Vite setup exactly).
- Adopt `@html-eslint` `flat/recommended` (adds indent, quotes,
  use-baseline, require-closing-tags, etc.).
- Disable `@html-eslint/use-baseline` for the `rel="manifest"` false
  positive.

Custom rule fixes for ESLint 10:
- `context.getSourceCode()` -> `context.sourceCode`
- `context.getFilename()`   -> `context.filename`

Code fixes for the stricter new presets:
- NostrProvider: lazy-init NPool via `useState(() => new NPool(...))` and
  move `ref.current = x` assignments into effects to satisfy the new
  `react-hooks/refs` rule.
- useIsMobile: drop the redundant setState-in-effect by initialising
  `useState` from the media query synchronously.
- AuthDialog: move `loginRef.current = login` into an effect.
- sidebar.tsx: derive skeleton width from `useId()` instead of
  `Math.random()` so the render is pure.
- index.html: reindent to 4 spaces to satisfy `@html-eslint/indent`.
- .agents/skills/**: add `{ cause: err }` to `throw new Error(...)` calls
  inside catch blocks (new `preserve-caught-error` rule) and a handful
  of targeted `eslint-disable` comments for legitimate external-system
  sync / state-reset-on-prop-change patterns.

The six intentional template failures (missing manifest, missing title /
description / OG tags, two FIXME comments) are unchanged -- they're the
template's way of nudging downstream users to fill the site in.

Re: "someday maybe tseslint won't be needed" -- still in the future.
ESLint 10 now loads `eslint.config.ts` natively (via jiti or Node's
`--experimental-strip-types`), but that only parses the config file. For
linting .ts/.tsx source you still need @typescript-eslint/parser and its
rules, which the `typescript-eslint` package bundles together. So the
"typescript" prefix is gone from rule names in practice, but the package
stays.
2026-04-26 22:33:39 -05:00
..
2025-06-07 10:56:52 -05:00
2025-06-07 10:56:52 -05:00

Custom ESLint Rules

This directory contains custom ESLint rules for the project.

no-inline-script

This rule prevents the use of inline script tags in HTML files. Inline scripts can pose security risks and violate Content Security Policy (CSP) directives.

Examples

❌ Bad - These will trigger the rule:

<!-- Inline JavaScript code -->
<script>
  console.log("This is inline JavaScript");
</script>

<!-- Inline JSON-LD structured data -->
<script type="application/ld+json">
  {"@context": "https://schema.org", "@type": "Organization"}
</script>

✅ Good - These are fine:

<!-- External script files -->
<script src="/js/app.js"></script>
<script type="module" src="/src/main.tsx"></script>

<!-- Empty script tags (no content) -->
<script id="data-container"></script>

Configuration

The rule is configured in eslint.config.js as:

"custom/no-inline-script": "error"

Purpose

This rule helps maintain security best practices by:

  • Preventing XSS vulnerabilities from inline scripts
  • Enforcing Content Security Policy compliance
  • Encouraging separation of concerns (HTML structure vs JavaScript logic)
  • Making code easier to maintain and debug

no-placeholder-comments

This rule detects and flags comments that start with "// In a real" (case-insensitive). These comments typically indicate placeholder implementations that should be replaced with real code.

Examples

❌ Bad - These will trigger the rule:

// In a real application, this would connect to a database
const data = [];

// in a real world scenario, this would be different
const config = {};

/* In a real implementation, we would handle errors */
const handleError = () => {};

✅ Good - These are fine:

// This is a regular comment
const data = [];

// TODO: Implement database connection
const config = {};

// Note: In a real application, consider using a database
const handleError = () => {};

Configuration

The rule is configured in eslint.config.js as:

"custom/no-placeholder-comments": "error"

You can change the severity level to:

  • "off" - Disable the rule
  • "warn" - Show as warning
  • "error" - Show as error (current setting)

Purpose

This rule helps ensure that placeholder comments used during development are replaced with actual implementations before code is committed or deployed to production.

require-webmanifest

This rule ensures that HTML files include a proper web manifest link tag and that the referenced manifest file exists. Web manifests are essential for Progressive Web Apps (PWAs) and provide metadata about the application.

Examples

❌ Bad - These will trigger the rule:

<!-- Missing manifest link entirely -->
<head>
  <title>My App</title>
</head>

<!-- Manifest file doesn't exist -->
<head>
  <link rel="manifest" href="/nonexistent-manifest.json">
</head>

<!-- Invalid manifest link (missing rel or href) -->
<head>
  <link href="/manifest.json">
</head>

✅ Good - These are fine:

<!-- Proper manifest link with existing file -->
<head>
  <link rel="manifest" href="/manifest.json">
</head>

<!-- Alternative valid manifest link -->
<head>
  <link rel="manifest" href="/public/site.webmanifest">
</head>

Configuration

The rule is configured in eslint.config.js as:

"custom/require-webmanifest": "error"

Purpose

This rule helps ensure:

  • PWA compliance by requiring a web manifest
  • Proper manifest file structure and accessibility
  • Better user experience on mobile devices
  • App installation capabilities
  • Consistent branding and metadata across platforms