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

Fix eslint issues #25352

Closed
wants to merge 3 commits into from
Closed

Fix eslint issues #25352

wants to merge 3 commits into from

Conversation

renatho
Copy link
Contributor

@renatho renatho commented Sep 15, 2020

Description

This PR fixes some Eslint issues related to PR #25300.
It still contains some issues related to tests (tests without assertion and jasmine global - see screenshots) which I preferred don't touch for now because we could follow different approaches and I'm not sure what would fit better.

I separated the changes in different commits, where the first one is about indentation only. In the second one, I also added some arguments that were missing with their types. I identified the type through the code interpretation, so I'd appreciate a more detailed check here: 598aea5

How has this been tested?

Running npm run lint-js in Gutenberg code.

Screenshots

The remaining issues (warnings that were present before the changes too):

Screen Shot 2020-09-15 at 19 33 52

Types of changes

Eslint fixes related to JSDoc.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

Copy link
Member

@noahtallen noahtallen left a comment

Choose a reason for hiding this comment

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

This looks fine just looking at /components/env

* @property {string} workDirectoryPath Path to the work directory located in ~/.wp-env.
* @property {string} dockerComposeConfigPath Path to the docker-compose.yml file.
* @property {boolean} detectedLocalConfig If true, wp-env detected local config and used it.
* @property {Object.<string, WPServiceConfig>} env Specific config for different environments.
Copy link
Member

Choose a reason for hiding this comment

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

this seems like a weird fix. Why it is aligning the variables with the type parameter? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch @noahtallen! It's an issue with the plugin that I haven't seen before. For now, I just updated removing the space, but I'll submit a PR to the eslint-jsdoc-plugin with a fix in the next few days.

Copy link
Member

@ntwb ntwb left a comment

Choose a reason for hiding this comment

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

Thanks, left a few comments, as we are touching these lines now, helping our future selves for Git blame, maybe adding the trailing . period to the @param descriptions now that are missing them would be good (It appears there are not many instances where these are missing)

I got through around ~25% of the files, can we make those changes noted in the review and then I can come back for a full review pass of all the files

Edit: It may in fact we worthwhile trying to use Prettier prettier-plugin-jsdoc here to update the docs s mentioned here in #24984 (comment) as this may be signifantly quicker for both this PR and future code written will be formatted automatically rather than a devloper pushing up code that then fails linting

Comment on lines +22 to 23
* @param {string} file File name
* @return {string} Package name
Copy link
Member

Choose a reason for hiding this comment

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

If @return descriptions are not destined to be aligned with @param descriptions then I think this also requires some changes:

This aligns the descriptions of both lines:

Suggested change
* @param {string} file File name
* @return {string} Package name
* @param {string} file File name
* @return {string} Package name

Or, this removes the additional whitespece preceding the @return description

 * @param {string} file File name
 * @return {string} Package name

Possibly, another convention observed further below is a blank line between the last @param and the @Raturn:

 * @param {string} file File name
 *
 * @return {string} Package name

Comment on lines +9 to 12
* @property {string} versionMilestoneFormat printf template for milestone
* version name. Expected to be called
* with a merged object of the config
* and semver-parsed version parts.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @property {string} versionMilestoneFormat printf template for milestone
* version name. Expected to be called
* with a merged object of the config
* and semver-parsed version parts.
* @property {string} versionMilestoneFormat printf template for milestone
* version name. Expected to be called
* with a merged object of the config
* and semver-parsed version parts.

Identation of the subsequent lines should align with the start of the first comment

@@ -47,7 +47,7 @@ async function commit( gitWorkingDirectoryPath, message, filesToAdd = [] ) {
* Creates a local branch.
*
* @param {string} gitWorkingDirectoryPath Local repository path.
* @param {string} branchName Branch Name
* @param {string} branchName Branch Name
Copy link
Member

Choose a reason for hiding this comment

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

Not a blocker, but we should look at standardizing either including or excluding the . period at the end of the @param description, PHP Coding Standards require this, so I'd lean toward that also for JS (A goal is to align the CS between languages as best we can when suited)

* @param {Object} record The record to apply annotations to.
* @param {Array} annotations The annotation to apply.
* @param {Object} record The record to apply annotations to.
* @param {Array} annotations The annotation to apply.
* @return {Object} A record with the annotations applied.
Copy link
Member

Choose a reason for hiding this comment

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

FYI Only: An example where there's no blank line between the last @param and the @return and the @return description is not aligned with the @param descriptions

Comment on lines +127 to 128
* @param {boolean} br Optional. If set, will convert all remaining line-
* breaks after paragraphing. Default true.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param {boolean} br Optional. If set, will convert all remaining line-
* breaks after paragraphing. Default true.
* @param {boolean} br Optional. If set, will convert all remaining line-
* breaks after paragraphing. Default true.

The original second line aligned with the start of the original description, seems like this should be updated here also

Comment on lines +20 to +22
* @param {string} clientId The block client ID.
* @param {Object} template The template to match.
* @param {string} templateLock The template lock state for the inner blocks. For
Copy link
Member

Choose a reason for hiding this comment

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

This needs updating and the lines below to line 31, looks like autofix missed the @param on line 28

* @param {string=} rootClientId Insertion's root client ID.
* @param {Function} onInsert function called when inserter a list of blocks.
* @param {string=} rootClientId Insertion's root client ID.
* @param {Function} onInsert function called when inserter a list of blocks.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param {Function} onInsert function called when inserter a list of blocks.
* @param {Function} onInsert Function called when inserter a list of blocks.

Should descriptions always begin with a Capital letter? It appears to be the convention and is also a PHP coding standard

@@ -40,25 +40,25 @@ import { useRegistry } from '@wordpress/data';
* controllers.
Copy link
Member

Choose a reason for hiding this comment

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

More examples in this file of second line descriptions not aligned with the first line

@@ -80,7 +80,7 @@ export function getValidAlignments(
/**
* Filters registered block settings, extending attributes to include `align`.
*
* @param {Object} settings Original block settings
* @param {Object} settings Original block settings
* @return {Object} Filtered block settings
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @return {Object} Filtered block settings
* @return {Object} Filtered block settings

Remove additional whitespace for @return descriptions

Comment on lines +141 to 142
* @param {Object} blocksOrder Object that maps block client IDs to a list of
* nested block client IDs.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param {Object} blocksOrder Object that maps block client IDs to a list of
* nested block client IDs.
* @param {Object} blocksOrder Object that maps block client IDs to a list of
* nested block client IDs.

@renatho
Copy link
Contributor Author

renatho commented Sep 16, 2020

Thank you so much for the review @ntwb!!

As I mentioned here: #25300 (comment), I think I'll keep this PR in stand by for now until going with that fixes.

But it worthed a lot to get some more cases and maybe include some of them in the rule logic.

I'm closing this for now and I'll open a new one when it's ready. It'll be easier because it'll have a lot of conflicts.

@renatho renatho closed this Sep 16, 2020
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.

3 participants