eslint-plugin-zappie
v0.10.4
Published
Flat ESLint rules for Zappie storefront projects.
Readme
eslint-plugin-zappie
ESLint rules for Zappie storefronts. They catch the mistakes that break a storefront quietly: pricing outside the SDK, calling Zappie around it, building your own sign-in or checkout, sending analytics elsewhere, or leaving out the markers zappie verify looks for.
npm install --save-dev eslint-plugin-zappie eslintESLint 9 is a peer dependency. The plugin uses flat config.
Use it
// eslint.config.js
import zappie from "eslint-plugin-zappie";
export default [...zappie.configs.recommended];recommended makes literal unlisted request hosts errors. Computed request
URLs use the companion no-unlisted-fetch-dynamic diagnostic at warning
severity because their hosts cannot be proved statically. verify-markers
and cacheable-menu-routes also warn. strict makes every warning an error.
Rules
| Rule | What it asks for |
| ---------------------------------- | ------------------------------------------------------------------ |
| zappie/no-direct-api | Call Zappie through the SDK. |
| zappie/no-money-literals | Use SDK prices and totals in your storefront. |
| zappie/use-format-money | Format SDK Money with format.money() or <Money>. Fixable. |
| zappie/cart-via-sdk | Keep your cart state in the SDK. |
| zappie/checkout-via-sdk | Open checkout through the Zappie SDK. |
| zappie/no-custom-auth | Sign customers in through the Zappie SDK. |
| zappie/no-tracking-scripts | Forward analytics through Zappie. |
| zappie/overlay-primitive | Use Overlay to keep dialogs and sheets in the URL. |
| zappie/verify-markers | Mark shopping actions so verify can find them. Fixable. |
| zappie/no-lazy-overlay | Load overlays with deferred(), not React.lazy or Suspense. |
| zappie/no-unsafe-html | Sanitize rich text before inserting HTML. |
| zappie/no-eval | Do not execute strings as code. |
| zappie/no-external-scripts | Ship scripts in the storefront bundle. |
| zappie/safe-external-links | Protect new tabs and validate redirect targets. Fixable. |
| zappie/no-unlisted-fetch | List external request hosts in outbound.allow. |
| zappie/no-unlisted-fetch-dynamic | Review computed request hosts. |
| zappie/no-server-env-in-client | Keep server environment values out of client bundles. |
| zappie/cacheable-menu-routes | Keep the session out of menu page loaders so caches can keep them. |
| zappie/no-offsite-navigation | Keep shoppers on the site unless they follow a link themselves. |
| zappie/no-global-indirection | Reach window, document and location by name. |
| zappie/no-document-write | Render markup with React, not document.write. |
| zappie/no-remote-import | Load code from the storefront bundle only. |
Security rules
zappie check runs the security rules as errors on every source file outside
build, dist and node_modules, with only Zappie's security config. Your
eslint.config.mjs, its ignores and eslint-disable comments can't turn them
off. They are no-offsite-navigation, no-global-indirection,
no-document-write, no-remote-import, no-eval, no-external-scripts,
no-unsafe-html and safe-external-links.
Code may send the shopper to a path on the site, to a URL from safeRedirect
in @zappie/sdk/redirect, or to Zappie's checkout and accounts. Open a checkout
session with redirectToCheckout from @zappie/sdk/redirect. Link to
any other site with an <a href> the shopper clicks.
recommended also turns on the recommended jsx-a11y rules as the accessibility baseline. zappie check fails a project that turns any of them down.
Typed rules use TypeScript's project service when it's available, and fall back to syntax checks when it isn't.
The rules give early feedback. They aren't a security boundary. Server-side validation, response headers and runtime network policy must still enforce the same constraints.
The zappie-internal config disables no-external-scripts only for
packages/foundations/src/branch-map/loader.ts. That reviewed Google Maps
loader must create the provider script from a runtime browser key; general
storefront code does not get the exemption. Phase 3 CSP must allow its provider
host explicitly.
Docs
Status
The plugin is at 0.x. Rules can be added or tightened in a minor release while it settles. Each change is listed in CHANGELOG.md.
License
MIT
