-
Notifications
You must be signed in to change notification settings - Fork 22
Home
The Program Management Module team plans to accept pull requests, provided they are:
- Non-trivial: That pull request that just has a comment with your name in it? Notsomuch.
- Support an open architecture: We want to support an open ecosystem. So integrating with a particular 3rd party service is great, but lets make sure we can integrate with every service, not just one.
- Non-superfluous: I've always wanted to build a version of Pacman in Apex/VF, but lets face it, probably not a great fit for the PMM, right?
Easiest way to make sure your pull request will be accepted is to just ask! Log an issue, or comment on an existing issue. Make mention of what you'd like to work on, and a member of the core contributor team will be happy to help vet your proposal, make suggestion or provide guidance throughout the process. Below, you'll find resources on how to get started, links to our code documentation, and a technical overview of the NPSP build system. Good luck, and happy coding!
- Cumulus CI Infrastructure Documentation (https://cumulusci.readthedocs.io/en/latest/)
- Cumulus CI Build Instructions (https://github.com/SalesforceFoundation/Cumulus/wiki/Cumulus-CI-Build-Instructions)
- Cumulus Build Server (https://mrbelvedereci.herokuapp.com/)
Use the following commands to create a PMM scratch org with or without the following options:
- PMM only:
cci flow run dev_org --org dev
- PMM namespaced only:
cci flow run dev_org_namespaced --org dev_namespaced
- PMM + NPSP:
cci flow run dev_org --org npsp
- PMM namespaced + NPSP:
cci flow run dev_org_namespaced --org npsp_namespaced
We are in trial to use prettier and prettier-plugin-apex to format our classes
, lwc
, and aura
.
By far the biggest reason for adopting Prettier is to stop all the on-going debates over styles. It is generally accepted that having a common style guide is valuable for a project and team but getting there is a very painful and unrewarding process. People get very emotional around particular ways of writing code and nobody likes spending time writing and receiving nits.
So why choose the "Prettier style guide" over any other random style guide? Because Prettier is the only "style guide" that is fully automatic. Even if Prettier does not format all code 100% the way you'd like, it's worth the "sacrifice" given the unique benefits of Prettier, don't you think?
Plus, check out Prettier's Option Philosophy and Rationale.
- Call
yarn install
in the terminal.
See yarn install documentation for more options. For example, calling
yarn install --check-files
verifies that already installed files innode_modules
did not get removed. If you've already calledyarn install
and you want to "reinstall", delete thenode_modules
directory (e.g.rm -rf node_modules
) and callyarn install
again.
And that's it! 🎉
Behind the scenes the following packages are also installed:
- eslint: JavaScript linting
- babel-eslint: JavaScript linting
- eslint-config-prettier: eslint with prettier
- eslint-plugin-prettier: eslint with prettier
- @lwc/eslint-plugin-lwc: eslint for lwc
- @salesforce/eslint-config-lwc: eslint for lwc
- @salesforce/sfdx-lwc-jest: lwc jest tests
- @salesforce/sa11y: Salesforce Accessibility Automated Testing Libraries and Tools
Our (very few) prettier configurations are stored in .prettierrc.yml
. tl;dr:
- Our print width is
90
: not too big, not too small. - We want to use
prettier-plugin-apex
to format Apex Classes, Trigger, and Execute Anonymous Scripts. - Use the correct, associated prettier parser for our
lwc
,aura
,classes
, and*.apex
Execute Anonymousscripts
.
- Call
prettier --write path/to/**/*.{cls,apex,js,html}
to format the files specified in the path. - Call
prettier --check path/to/**/*.{cls,apex,js,html}
to check if the files specified in the path will change if formatted. - Call
prettier --debug-check path/to/**/*.{cls,apex,js,html}
to check if formatting will change the correctness of the files specified in the path.
Prettier offers an escape hatch to ignore a block of code or prevent entire files from being formatted.
To exclude files from formatting, add entries to a .prettierignore
file in the project root or set the --ignore-path
CLI option. .prettierignore
uses gitignore syntax.
A JavaScript comment of // prettier-ignore
will exclude the next node in the abstract syntax tree from formatting.
For example:
matrix(
1, 0, 0,
0, 1, 0,
0, 0, 1
)
// prettier-ignore
matrix(
1, 0, 0,
0, 1, 0,
0, 0, 1
)
will be transformed to:
matrix(1, 0, 0, 0, 1, 0, 0, 0, 1);
// prettier-ignore
matrix(
1, 0, 0,
0, 1, 0,
0, 0, 1
)
<div>
{/* prettier-ignore */}
<span ugly format='' />
</div>
<!-- prettier-ignore -->
<div class="x" >hello world</div >
<!-- prettier-ignore-attribute -->
<div
(mousedown)=" onStart ( ) "
(mouseup)=" onEnd ( ) "
></div>
<!-- prettier-ignore-attribute (mouseup) -->
<div
(mousedown)="onStart()"
(mouseup)=" onEnd ( ) "
></div>
/* prettier-ignore */
.my ugly rule
{
}
<!-- prettier-ignore -->
Do not format this
Probably. 👍
See the instructions below. Please contribute how you automatically format files with prettier
every time you save a file in your text editor.
- Install the Prettier - Code formatter VS Code Extension.
- Change the Editor: Default Formatter to
esbenp.prettier-vscode
- Or add
"editor.defaultFormatter": "esbenp.prettier-vscode"
to yoursettings.json
- Or add
- Check Editor: Format On Save
- Or add
"editor.formatOnSave": true
to yoursettings.json
- Or add
- Prettifying files can take ~1 s. Update Editor: Format On Save Timeout to
2000
.- Or add
"editor.formatOnSaveTimeout": 5000
to yoursettings.json
- If you notice files not formatting after saving, try increasing upir Editor: Format On Save Timeout. Maybe,
prettier
is completing before timing out.
- Or add
- Save a file. . Our prettier configuration at
.prettierrc.yml
should be honored.
- Even though we've configured VS Code to format each file upon save, there is a VS Code command if you want to save a file without formatting. Press Command + Shift + P to search for commands, then search for
Files: Save without Formatting
.
If you are trying to call command Format Document
an Apex Class in VS Code but get an error similar to "parser not found", try the following:
- In the terminal, call
yarn install --check-files
. Yarn will make surenode_modules
contains the necessary files. - Quit VS Code and restart for VS Code to refresh it's configuration and our
.prettierrc.yml
configuration.
When trying the Format Document command on an Apex Anonymous file, e.g. scripts/*.apex
, I get an error:
There is no formatter for 'apex-anon'-files installed.
I can't figure out how to associate Apex Anonymous (apex-anon
) files with the esbenp.prettier-vscode
formatter, i.e. update settings.json
with
"[apex-anon]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
Workarounds
- Use the command line:
prettier --write scripts/[file name].apex
- In VS Code, change the file format to Apex (which will give linting errors), execute Format Document which honors our
.prettierrc.yml
to prettify withapexAnonymous: true
, then change the file format back to Apex Anonymous.
Attempt to associate Apex Anonymous (apex-anon
) with a formatter in settings.json
The Salesforce-focused plugin for IntelliJ called Illuminated Cloud has its own code formatting tools, but to keep consistency with other IDEs, we will use the separate IntelliJ plugin for Prettier. Initial setup instructions to install the plugin are here.
If you've followed the initial setup steps above, the Prettier application is in /node_modules/prettier
within your local repo directory.
To manually apply rules to a file, press ⇧⌥⌘P.
To auto-apply rules on save, first install the File Watchers plugin. Then follow these instructions to create two File Watcher configs using the Prettier template, one for Apex Classes files and one for Javascript files.