@adaptif/eslint-plugin
v0.1.0
Published
ESLint rule requiring Adaptif capture names to be literal.
Maintainers
Readme
@adaptif/eslint-plugin
An ESLint rule for apps using @adaptif/capture and @adaptif/react.
npm install --save-dev @adaptif/eslint-plugin// eslint.config.js
import adaptif from "@adaptif/eslint-plugin";
export default [...adaptif.configs.recommended];The rule reads JSX, so lint .tsx/.jsx files with a parser that supports it, such as typescript-eslint's.
literal-capture-names
Capture names are sent to the model as timeline identifiers, so they must be literals matching /^[a-z][a-z0-9_.-]{0,39}$/i, never built from user data. That covers useCaptureRef(name), useCaptureForm(name), captureElement(el, name), captureForm(form, name), and the data-adaptif-capture/data-adaptif-capture-form attributes. Goal names are sent with outcome events and follow the same rule: track(goal) from useTrack() (from @adaptif/react or an app's typed re-export) and the goal prop on <When>/<Match>. Included in recommended.
// Bad: a customer's name would end up in the timeline.
<button data-adaptif-capture={customer.name} />;
// Good
<button data-adaptif-capture="open_customer" />;