Enabling Code Completion for Controllers
To allow for syntax checking and code completion for controllers, you must convert your projects into Tern projects.
Tern is a third-party plugin that supplies code completion and linting.
Convert the Cartridge to a Tern Project
- Right-click the cartridge in the Eclipse in the Cartridge
sidebar. Note: If you don't see the Cartridge sidebar, change your perspective to the Salesforce B2C Commerce Development perspective.
- In the popup menu, select Configure > Convert to Tern
Project. Important: Each cartridge in your workspace must be a separate project in order for it to be converted into a Tern project.
- In the dialog, select the Commerce Cloud module.
If the dialog doesn't appear in the last step, you must make sure that the B2C Commerce API is associated with the cartridge so that content assist works in the Eclipse JavaScript editor (JSDT).
To associate the B2C Commerce API with the cartridge:
- Right-click the cartridge in the Eclipse in the Navigation sidebar.
- In the popup menu, select Properties.
- Expand Tern node and select Modules.
- Select the Commerce Cloud checkbox in the Modules list.
- Click OK.
Enable Linting Support for Tern
Note: eslint is
the standard linter used by B2C Commerce for the project, but Tern does not
support all of the rules used by the project when the linter is run from
the command line, because the version of eslint included with Tern is
different from that used from the command line. If you intend to
contribute to the SiteGenesis project, use the command line configuration
for eslint.
- Right-click the Tern project.
- In the popup menu, select Properties >Tern > Validation.
- From the list of linters, select the linter you want to use.