Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a command to install eslint plugin #62

Merged
merged 18 commits into from
Mar 8, 2024

Conversation

sfdctaka
Copy link
Collaborator

This command will add an item in devDependencies of package.json. That item is eslint-plugin-lwc-graph-analyzer.

If there is no .eslintrc.json or is missing to add configuration there that would be added too.

@sfdctaka sfdctaka requested a review from a team as a code owner February 29, 2024 00:30
package.json Outdated Show resolved Hide resolved
@sfdctaka
Copy link
Collaborator Author

@maliroteh-sf @dbreese @khawkins May I get help from you on the text copies please?

src/commands/lint/configureLintingToolsCommand.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/utils/workspaceUtils.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
Copy link
Collaborator

@maliroteh-sf maliroteh-sf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"commandPalette": [
{
"command": "salesforcedx-vscode-offline-app.configureLintingTools",
"when": "sfdx_project_opened"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh cool, I didn't know about this functionality. That's a clean way to specify a precondition here.

package.json Outdated
{
"command": "salesforcedx-vscode-offline-app.configureLintingTools",
"title": "%extension.commands.config-linting-tools.title%",
"category": "%extension.commands.config-wizard.category%"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I'm not sure about this. In theory this doesn't just apply to the Starter Kit—or really at all, because the Starter Kit already has the linting rules configured out of the box. I wonder if we should define a new category, perhaps called "Salesforce Mobile Offline"?

const configureLintingToolsCommand =
'salesforcedx-vscode-offline-app.configureLintingTools';
const eslintDependencies = [
['@salesforce/eslint-plugin-lwc-graph-analyzer', '^0.9.0'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are configuration items where at least the version values would be better represented in contributes.configuration settings. That way a) we take hard-coded data out of the code, and b) users can update these values in their own personal configuration settings, to override the versions we select.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

static async configure(): Promise<boolean> {
try {
if (!WorkspaceUtils.lwcFolderExists()) {
await this.showMessage('LWC folder does not exist.');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these messages need any further context? I don't know what the message title/header will look like, if any. But on their own, these messages seem a little sparse/ambiguous.

}

try {
this.updateEslintrc();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be tracking whether this file was updated or not too, and reporting to the user accordingly—even if the report is built into a single message. We could be updating this but not the devDependencies, and vice versa. We should be clear to the user, exactly what's being updated and what is not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Showing 3 messages now at a maximum, one for updating devdependencies, one for updating .eslintrc.json, and one for running npm. I thought maybe I should mash the three. But localizing string was going to be tricky so instead went with three.

image

src/utils/constants.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@khawkins khawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's all the feedback I have. Looks good over all!

"configuration": {
"title": "%salesforce.mobile.extensions%",
"properties": {
"mobileOfflineLinting.eslint-plugin-lwc-graph-analyzer": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without preceding mobileOfflineLinting separated by a dot the configuration doesn't get rendered in the settings page of VSCode. With it it becomes category name separated by a colon.

image

Copy link
Collaborator

@khawkins khawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I had a couple more message edit suggestions, but overall this looks good to me. 👍

@sfdctaka sfdctaka merged commit cd0e746 into salesforce:main Mar 8, 2024
9 checks passed
@sfdctaka sfdctaka deleted the eslintCommand branch March 8, 2024 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants