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

[markdown] Fix lint errors in client #45804

Merged

Conversation

scinos
Copy link
Contributor

@scinos scinos commented Sep 22, 2020

Background

We want to lint the code blocks inside Markdown files to follow our coding style.

Changes

This PR fixes all markdown errors in client

Testing instructions

Run ./node_modules/.bin/eslint --ext .md --ext .md.js --ext .md.javascript --ext .md.jsx client, there should be no errors

@scinos scinos requested review from a team as code owners September 22, 2020 09:33
@matticbot
Copy link
Contributor

@matticbot matticbot added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Sep 22, 2020
@scinos scinos requested a review from a team September 22, 2020 09:48
@scinos scinos removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 22, 2020
@scinos scinos self-assigned this Sep 22, 2020
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 22, 2020
@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@scinos scinos added Expedited Review Markdown and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Sep 22, 2020
Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Left several nits, nothing blocking though. Feel free to address or not before shipping.

client/blocks/calendar-button/README.md Outdated Show resolved Hide resolved
client/blocks/calendar-popover/README.md Outdated Show resolved Hide resolved
client/blocks/like-button/README.md Outdated Show resolved Hide resolved
client/blocks/post-likes/README.md Outdated Show resolved Hide resolved
client/components/action-card/README.md Outdated Show resolved Hide resolved
<NavItem path="/posts/drafts" selected={ false }>Drafts</NavItem>
<NavItem path="/posts/scheduled" selected={ false }>Scheduled</NavItem>
<NavItem path="/posts/trashed" selected={ false }>Trashed</NavItem>
<NavItem path="/posts" selected={ true }>
Copy link
Member

Choose a reason for hiding this comment

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

I'd love to write a codemod for those.

Suggested change
<NavItem path="/posts" selected={ true }>
<NavItem path="/posts" selected>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I don't see why not 😉

@@ -57,19 +57,18 @@ Now we're ready to actually start writing our tour.
First we'll need to create a directory tour, under `tours`. In there, we create two files: `meta.js` and `index.js`.
`meta.js` contains the metadata for a tour. Here's an empty boilerplate:

```JavaScript
```javascript
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should be consistent and just use ```js everywhere.

Copy link
Contributor Author

@scinos scinos Sep 22, 2020

Choose a reason for hiding this comment

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

It is not the exactly same, but if/when leo-buneev/eslint-plugin-md#8 is merged, we will be able to enable https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-fenced-code-flag that can limit the list of valid languages.

Copy link
Member

Choose a reason for hiding this comment

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

TIL 👍

client/state/sites/vouchers/README.md Outdated Show resolved Hide resolved
client/state/sites/vouchers/README.md Outdated Show resolved Hide resolved
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 22, 2020
@scinos
Copy link
Contributor Author

scinos commented Sep 22, 2020

@tyxla Thanks for the exhaustive review!

Could you please have a look to the usage of React.createRef() and check it is correct? I must admit I've never used it for real :(

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

Could you please have a look to the usage of React.createRef() and check it is correct? I must admit I've never used it for real :(

Sure, I've left some comments.

In general, usage looks good. To completely fix it, we'd have to define a React.Component to wrap those 2 examples, so the usage makes complete sense - because the ref object receives the mounted instance of the component as its current. Since you didn't introduce these examples, feel free to ship already, I don't consider this a blocker.

@@ -11,12 +11,12 @@ import { Button } from '@automattic/components';
import CalendarPopover from 'blocks/calendar-popover';

const toggle = () => this.setState( { show: ! this.state.show } );
let buttonRef;
const buttonRef = React.createRef();
Copy link
Member

Choose a reason for hiding this comment

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

I'm assuming this code is in a React.Component context (because it has a render() function), so those const here are a bit odd. If we disregard this, usage seems good 👍

@@ -57,25 +57,26 @@ that can trigger the opening and closing of the InfoPopover then you need to pas
```

```js
const refs = {};
const infoPopRef = React.createRef();
Copy link
Member

Choose a reason for hiding this comment

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

The same thing as above for the const here. Usually we define those as class instance properties, like this:

class ExampleComponent extends Component {
	buttonRef = React.createRef();

	render() {
		return (
			<Button ref={ this.buttonRef }>Something</Button>
		);
	}
}

@scinos scinos merged commit e903289 into fix/disable-lint-rules-for-markdown-codeblocks Sep 22, 2020
@scinos scinos deleted the fix/markdown-lint-client branch September 22, 2020 18:00
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 22, 2020
scinos added a commit that referenced this pull request Sep 22, 2020
* Disable some lint rules for codeblocks in markdown files

* [markdown] Fix lint errors in `apps/notifications` (#45803)
* [markdown] Fix lint errors in `client` (#45804)
* [markdown] Fix lint errors in `packages/babel-plugin-transform-wpcalypso-async` (#45805)
* [markdown] Fix lint errors in `packages/calypso-color-schemes` (#45807)
* [markdown] Fix lint errors in `packages/calypso-polyfills` (#45808)
* [markdown] Fix lint errors in `packages/components` (#45809)
* [markdown] Fix lint errors in `packages/data-stores` (#45810)
* [markdown] Fix lint errors in `packages/eslint-plugin-wpcalypso` (#45811)
* [markdown] Fix lint errors in `packages/i18n-calypso` (#45812)
* [markdown] Fix lint errors in `packages/i18n-calypso-cli` (#45813)
* [markdown] Fix lint errors in `packages/material-design-icons` (#45814)
* [markdown] Fix lint errors in `packages/media-library` (#45815)
* [markdown] Fix lint errors in `packages/photon` (#45816)
* [markdown] Fix lint errors in `packages/popup-monitor` (#45817)
* [markdown] Fix lint errors in `packages/react-i18n` (#45818)
* [markdown] Fix lint errors in `packages/request-external-access` (#45819)
* [markdown] Fix lint errors in `packages/social-previews` (#45820)
* [markdown] Fix lint errors in `packages/viewport` (#45821)
* [markdown] Fix lint errors in `packages/viewport-react` (#45822)
* [markdown] Fix lint errors in `packages/webpack-extensive-lodash-replacement-plugin` (#45823)
* [markdown] Fix lint errors in `packages/webpack-inline-constant-exports-plugin` (#45824)
* [markdown] Fix lint errors in `packages/wpcom.js` (#45825)
* [markdown] Fix lint errors in `packages/wpcom-proxy-request` (#45826)
* [markdown] Fix lint errors in `packages/calypso-build` (#45806)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants