Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions bin/prettier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const path = require("path");
const spawn = require("child_process").spawn;

const isWindows = /^win/.test(process.platform);
const prettierCmd = path.resolve(
__dirname,
`../node_modules/.bin/${isWindows ? "pretty-quick.cmd" : "pretty-quick"}`
);

const args = [
"--trailing-comma=none",
"--bracket-spacing=true",
"--write",
"*.js",
"*.json",
"packages/**/src/*.js",
"src/*.js",
"src/*/*.js",
"src/components/**/*.css",
"src/test/mochitest/*.js",
"src/test/mochitest/!(examples)/**/*.js"
];

const prettierArgs = process.argv.slice(2).concat(args);

const prettierProc = spawn(prettierCmd, prettierArgs);

prettierProc.stdout.on("data", data => console.log(`${data}`));
prettierProc.stderr.on("data", data => console.log(`stderr: ${data}`));
prettierProc.on("close", code =>
console.log(`prettier ${code === 0 ? "succeeded" : "failed"}`)
);
prettierProc.on("error", error => {
if (error.code == "ENOENT") {
console.log(`Hmm, could not find the path ${cmd}.`);
return;
}
console.log(error);
});
5 changes: 2 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ test:
override:
- mkdir -p $CIRCLE_TEST_REPORTS/flow-coverage
- mkdir -p $CIRCLE_TEST_REPORTS/jest-coverage
- yarn test:js -i --no-colors --testResultsProcessor="jest-junit" --coverage --coverageDirectory=$CIRCLE_TEST_REPORTS/jest-coverage
- yarn test -i --no-colors --testResultsProcessor="jest-junit" --coverage --coverageDirectory=$CIRCLE_TEST_REPORTS/jest-coverage
- yarn license-check
- yarn lint:jest --no-colors
- yarn lint:md
- yarn lint
- yarn flow
post:
- yarn flow-coverage -- -t json -o $CIRCLE_TEST_REPORTS/flow-coverage
Expand Down
38 changes: 21 additions & 17 deletions docs/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
* [Testing](#testing)
* [Unit Tests](#unit-tests)
* [Linting](#linting)
* [Lint Jest](#lint-jest)
* [Lint JS](#lint-js)
* [Lint CSS](#lint-css)
* [Performance](#performance)
* [Colors](#colors)
* [Configs](#configs)
Expand Down Expand Up @@ -485,8 +486,7 @@ yarn run test:all

#### Unit Tests

`yarn test` - Run all tests and lints with [jest].
`yarn test:js` - Run the unit tests with [jest].
`yarn test` - Run tests with [jest].

* [matchers][jest-matchers]
* [mock functions][jest-mock]
Expand Down Expand Up @@ -515,7 +515,7 @@ We shallow render the component and simulate an UI interaction like `click`.

```js
it("should call handleClick function", () => {
const onClick = jest.genMockFunction();
const onClick = jest.fn();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

genMockFunction was removed and was an undocumented API. Removing it from our examples and code.

jestjs/jest#6173

const wrapper = shallow(new CloseButton({ handleClick: onClick }));

wrapper.simulate("click");
Expand All @@ -529,7 +529,7 @@ We shallow render the component to a JSON and save it to a fixture. Subsequent r

```js
it("should render a button", () => {
const onClick = jest.genMockFunction();
const onClick = jest.fn();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

genMockFunction was removed and was an undocumented API. Removing it from our examples and code.

jestjs/jest#6173

const buttonClass = "class";
const wrapper = shallow(
new CloseButton({
Expand Down Expand Up @@ -580,27 +580,31 @@ index a3b2ba6..cd5a8e7 100644

### Linting

| Type | Command |
| -------- | -------------------- |
| all | `yarn run lint` |
| css | `yarn run lint:jest` |
| js | `yarn run lint:jest` |
| markdown | `yarn run lint-md` |
| Type | Command |
| -------- | ------------------- |
| all | `yarn run lint` |
| css | `yarn run lint:css` |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We swapped back and forth on using - and : in the config so I just settled on :

| js | `yarn run lint:js` |
| markdown | `yarn run lint:md` |

#### Lint Jest
#### Lint CSS

We use Jest Runners to do the linting for our JS and CSS.
We use [Stylelint](http://stylelint.io/) to maintain our CSS styles. The [.stylelintrc](../.stylelintrc) file contains the style definitions, please adhere to those styles when making changes.

Underlying the Jest Runners
To test your CSS changes run the command:

We use [eslint](http://eslint.org/) to maintain our JavaScript styles. The [.eslintrc](../.eslintrc) file contains our style definitions, please adhere to those styles when making changes.
```bash
yarn run lint:css
```

We use [Stylelint](http://stylelint.io/) to maintain our CSS styles. The [.stylelintrc](../.stylelintrc) file contains the style definitions, please adhere to those styles when making changes.
#### Lint JS

We use [eslint](http://eslint.org/) to maintain our JavaScript styles. The [.eslintrc](../.eslintrc) file contains our style definitions, please adhere to those styles when making changes.

To automatically fix many errors run the command:

```bash
yarn run lint:jest
yarn run lint:js
```

#### Lint Markdown
Expand Down
Loading