Forge lint cannot validate the tutorial code from the UI Kit page

I followed the tutorials for Atlassian Forge: install docker, WSL 2 and npm, then install @forge/cli globally and forge create in my project directory, both done using Visual Studio Code. I’ve managed to deploy the app created by “Build Jira Hello World app” at Build a Jira hello world app (atlassian.com), and it works, but when I then try to recreate the very simple UI Kit examples at UI kit (atlassian.com), Forge lint complains in the tutorial about hooks, on code that I didn’t modify in the slightest:

const App = () => {
  const [issue, setIssue] = useState(async () => {
    const response = await api.asUser().requestJira(route'/rest/api/3/issue/{issueIdOrKey}'); 
    ^ERROR HERE: ',' expected
    const issueData = response.text(); //... extract issueKey from response
    return issueData;
});

Again, this is with default node.Js setup. I noticed that during the setup, it told me to use Node.js v10.0.0 or later. My node.js version is v16.14.2.

I have tried copying the devDependencies and dependencies packages from an example project and running npm install afterwards in hope of having the right version, but it didn’t fix anything. I’m unable to run forge deploy or forge tunnel because both of these require a linter without errors.

This is a pretty big problem. My boss has given me a deadline yesterday to figure out if we can use Forge for a client request by tomorrow (call an authenticated REST API on a different platform from a button in Jira), but while I’m optimistic about the chances of that working, I would like to test whether I can at least make such a request (meaning authenticating with the API and making a request while authenticated), and I cannot test this functionality before I have something I can start from. And I currently have nothing I can start from.

Hello @NateKerkhofs ,

Upon checking the code snippet, it seems the use of single quotes ('') instead of backticks (``) caused the linter problem - changing that should remedy the linter error

Error: ',' expected.

After changing this, running forge lint will result in errors requiring you to add the necessary scope/s (IF you haven’t already); to fix this, you can either add the scopes manually in the manifest or run forge lint --fix.

Stepping back a bit, if you are more interested with UI Kit, hooks, and calling Jira REST APIs using forge, you can check this sample app to have a base reference. For other Forge examples, you can see them here.

Hope this helps.

Cheers,
Ian

1 Like

Hi Ian,

Thank you for the help. Note that the REST API I’m intending to call is NOT a Jira REST API. It is the REST API of our own product, which generally is self-hosted and runs on an intranet. I’m still trying to figure out how to make that work. Among other things, I need to read a cookie from a first request response (the login) to send along with a second response (the actual API call), and I need to read text input to include in the body. I think I’ll eventually be able to figure that out, but I need to do further research.

I have replaced the single quotes with backticks (note that the official documentation for UI Kit uses single quotes and not backticks, so that should probably be fixed) and now the warning is gone.

Thanks for the help,

Nate

You’re welcome, @NateKerkhofs .

Thank you, I raised a PR to fix the documentation.