Loading...

'ComponentFramework' is not defined - eslint with pac pcf init

'ComponentFramework' is not defined - eslint with pac pcf init

At some point, over the last few months, a change was introduced to the Power Platform CLI such that if you have the ESLint VS Code add-in installed, after using pac pcf init, you may see an error in VS code:

  • 'ComponentFramework' is not defined.eslint(no-undef)

This might look something like this in the index.ts file:

The reason for this is that the pac pcf init template now includes an .eslintrc.json however, it is configured to use JavasScript rules rather than TypeScript ones.

To fix this you simply need to edit the .eslintrc.json  file.

Find the extends section and replace the standard ruleset with;

"extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended"
    ]

You also might see some other odd errors such as:

  • Unexpected tab character.eslint(no-tabs)
  • Mixed spaces and tabs.eslint(no-mixed-spaces-and-tabs)

The reason for this is that the template used to create the index.ts file contains a mix of tabs and spaces for indentation. eslint is warning about this - so you can either add the following lines to the top of the file, or you can change the indentation to use spaces using the Format Document command.

/* eslint-disable no-mixed-spaces-and-tabs */
/* eslint-disable no-tabs */

Hope this helps!

Published on:

Learn more
Develop 1 - Dynamics 365 Architecture Services
Develop 1 - Dynamics 365 Architecture Services

Share post:

Related posts

High severity vulnerability in pcf-scripts package due to dependency on xml2js

Have you noticed recently that when you run npm install on your PCF projects, you get a high severity vulnerabilities error (or maybe you...

3 years ago

First look at PCF dynamic schema object outputs

One of the new features now supported in PCF (Power Apps Component Framework) code components are 'object outputs'. A PCF component has a mani...

3 years ago

Power Fx delegation of 'in' operator against Davaverse

Delegation of queries in Canvas Apps/Custom Pages has long been a troublesome topic and we are always looking out for the triangle of doom, or...

3 years ago

Perform ExecuteMultiple in batches and changesets from TypeScript using dataverse-ify version 2

My free tutorial course on writing Dataverse web resources has been available for over a year now, and it has had over 1000 people enrol! The ...

3 years ago

Perform complex Dataverse FetchXml queries using Power Fx (from a Canvas App)

One of the constant challenges we face when writing canvas apps and custom pages using Power Fx is ensuring that the queries we use are always...

3 years ago

How to update multiple records in a model-driven app grid using Power Fx commanding

If you wanted to add a button to a command bar to perform an update on multiple records in a grid, you can easily create a formula that result...

3 years ago

Power Apps ESLint plugin replaces Solution Checker for TypeScript code

The Power Apps team have had a long-standing quality tool called the Solution Checker. This was built into the Dataverse solution management i...

4 years ago

Dataverse for Teams vs Canvas Apps - Part 1 - Checked vs Default Control Properties

If you were thinking that Power Apps Canvas Apps and Dataverse for Teams Canvas Apps are just the same – but with a different license an...

5 years ago

Canvas app code component error "Couldn't import components"

If you are developing code components (PCF) for canvas apps you'll be used to using the 'Get more components' panel. When adding the code-comp...

4 years ago

Debugging Canvas App PCF components with fiddler

Those of you who know me will also know that I am a massive Fiddler fan for removing the need to deploy each time you change your JavaScript s...

6 years ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy