Usage
spfx project doctor
Description
Validates correctness of SPFx solution
Options
none
Additional Info
Let's start with package.json validation.
Here are some thoughts:
Validate SPFx Versions
We can check that SPFx packages have correct versions and version reference:
- All versions should be equal, like all are 1.13.1
^ should not be used when referencing the version. It can lead to complete versions’ mismatch
Dependencies vs DevDependencies
We can check that none of devDependencies appear in dependencies block. Examples:
- @types dependencies should not be included “dependencies”
- @microsoft/sp-build-web should be in “devDependencies” (I can provide the whole list of SPFx modules that should be in dev deps)
- Gulp, ajv
- rush-stack-compiler
Multiple Instances of rush-stack-compiler
As rush-stack-compiler modules are prefixed with the TypeScript version they’re used for, it’s easy to have multiple modules installed.
We can check for @microsoft/rush-stack-compiler-* and see if there are >1 matches.
We can even go further and check what of the versions is used in tsconfig to display this helpful info too.
Duplicating References in Dependencies and DevDependencies
Sometimes modules can be referenced in both (I’m skipping peers to simplify it). We can easily detect it.
Duplicating Modules
This is mostly related to Fluent UI/OUIFR and PnPJS. Due to renaming, package.json can contain reference to both fluentui and office-ui-fabric-react, as well as sp-pnp-js and @pnp/js.
We can notify the developer that he should consider removing such duplicates.
Check React and OUIFR Versions
We can validate if referenced versions of React and OUIFR are supported by the current version of SPFx.
Usage
spfx project doctorDescription
Validates correctness of SPFx solution
Options
none
Additional Info
Let's start with
package.jsonvalidation.Here are some thoughts:
Validate SPFx Versions
We can check that SPFx packages have correct versions and version reference:
^should not be used when referencing the version. It can lead to complete versions’ mismatchDependencies vs DevDependencies
We can check that none of devDependencies appear in dependencies block. Examples:
Multiple Instances of rush-stack-compiler
As rush-stack-compiler modules are prefixed with the TypeScript version they’re used for, it’s easy to have multiple modules installed.
We can check for @microsoft/rush-stack-compiler-* and see if there are >1 matches.
We can even go further and check what of the versions is used in
tsconfigto display this helpful info too.Duplicating References in Dependencies and DevDependencies
Sometimes modules can be referenced in both (I’m skipping peers to simplify it). We can easily detect it.
Duplicating Modules
This is mostly related to Fluent UI/OUIFR and PnPJS. Due to renaming,
package.jsoncan contain reference to both fluentui and office-ui-fabric-react, as well as sp-pnp-js and @pnp/js.We can notify the developer that he should consider removing such duplicates.
Check React and OUIFR Versions
We can validate if referenced versions of React and OUIFR are supported by the current version of SPFx.