sfcc/no-forms
Disallows SFCC and SFRA form APIs.
This rule is opt-in and is not part of the recommended config. It is enabled by the PWA and Storefront Next architecture presets.
What it checks
- Reports static access to the
dw/web/Form*module family, includingForm,Forms,FormElement, andFormField - Reports
server.formswhenserverresolves to a binding imported from the bare SFRAservermodule - Supports aliased and computed access such as
router["forms"] - Ignores unrelated objects with a
formsproperty and locally shadowedservervariables - Ignores dynamic module paths because their target cannot be determined statically
Form definition XML files are outside ESLint's JavaScript scope. This rule prevents JavaScript form dependencies but does not report XML definitions stored below cartridge/forms/.
Default behavior
- Severity: off (opt-in)
- Auto-fix: none
Examples
Invalid
js
const server = require("server")
const profileForm = server.forms.getForm("profile")
module.exports = profileFormInvalid
js
const FormElement = require("dw/web/FormElement")
module.exports = FormElement