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

Yarn Workspaces & Prettier #696

Merged
merged 6 commits into from
Jan 17, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 17 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
{
"extends": "eslint:recommended",
"extends": [
"eslint:recommended",
"prettier"
],
"parser": "babel-eslint",
"env": {
"jest": true,
"browser": true,
"node": true
},
"globals": {
"Promise": true,
"jasmine": true
"node": true,
"es6": true
},
"plugins": [
"react"
"babel",
"react",
"prettier"
],
"settings": {
"react": {
"pragma": "h"
"pragma": "h",
"version": "preact"
}
},
"parserOptions": {
"ecmaVersion": 2018,
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
Expand Down
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

**Did you add tests for your changes?**


**Summary**

<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
Expand Down
3 changes: 2 additions & 1 deletion .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- Please don't delete this template -->
<!-- Before creating an issue please make sure you are using the latest version of preact-cli. -->

**Do you want to request a *feature* or report a *bug*?**
**Do you want to request a _feature_ or report a _bug_?**

**What is the current behaviour?**

Expand All @@ -14,6 +14,7 @@
**If this is a feature request, what is motivation or use case for changing the behaviour?**

**Please mention other relevant information.**

- Node version
- npm version
- Operating system
Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/node_modules
**/tests/output
**/package.json
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"trailingComma": "es5",
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need this? (Not a huge fan of this cuz it is annoying at times) :P

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, prettier will do it for you and it's better for diffs

"tabWidth": 2,
"semi": true,
"useTabs": true,
"singleQuote": true,
"endOfLine": "lf"
}
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ cache:
- node_modules

before_script:
- export WITH_LOG=true
- export LIGHTHOUSE_CHROMIUM_PATH=`which google-chrome-stable`
- export WITH_LOG=true
- export LIGHTHOUSE_CHROMIUM_PATH=`which google-chrome-stable`

script:
- npm run test -- --verbose
- npm run test -- --verbose
20 changes: 10 additions & 10 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Expand Down
39 changes: 22 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ $ preact create <template-name> <project-name>
```

Example:

```sh
$ preact create default my-project
```
Expand Down Expand Up @@ -156,6 +157,7 @@ npm run serve -- --server config
Preact CLI in order to follow [PRPL] pattern renders initial route (`/`) into generated static `index.html` - this ensures that users get to see your page before any JavaScript is run, and thus providing users with slow devices or poor connection your website's content much faster.

Preact CLI does this by rendering your app inside node - this means that we don't have access to DOM or other global variables available in browsers, similar how it would be in server-side rendering scenarios. In case you need to rely on browser APIs you could:

- drop out of prerendering by passing `--no-prerender` flag to `preact build`,
- write your code in a way that supports server-side rendering by wrapping code that requires browser's APIs in conditional statements `if (typeof window !== "undefined") { ... }` ensuring that on server those lines of code are never reached. Alternatively you could use a helper library like [window-or-global](https://www.npmjs.com/package/window-or-global).

Expand Down Expand Up @@ -192,7 +194,7 @@ To customize Babel, you have two options:

#### Webpack

To customize webpack create ```preact.config.js``` file which exports function that will change webpack's config.
To customize webpack create `preact.config.js` file which exports function that will change webpack's config.

```js
/**
Expand All @@ -203,12 +205,12 @@ To customize webpack create ```preact.config.js``` file which exports function t
* @param {object} env - options passed to CLI.
* @param {WebpackConfigHelpers} helpers - object with useful helpers when working with config.
**/
export default function (config, env, helpers) {
/** you can change config here **/
export default function(config, env, helpers) {
/** you can change config here **/
}
```

See [WebpackConfigHelpers] docs for more info on ```helpers``` argument which contains methods to find various parts of configuration. Additionally see our [recipes wiki] containing examples on how to change webpack configuration.
See [WebpackConfigHelpers] docs for more info on `helpers` argument which contains methods to find various parts of configuration. Additionally see our [recipes wiki] containing examples on how to change webpack configuration.

#### Prerender multiple routes

Expand All @@ -218,12 +220,15 @@ The format required for defining your routes is an array of objects with a `url`

```js
// prerender-urls.json
[{
"url": "/",
"title": "Homepage"
}, {
"url": "/route/random"
}]
[
{
url: '/',
title: 'Homepage',
},
{
url: '/route/random',
},
];
```

You can customise the path of `prerender-urls.json` by using the flag `--prerenderUrls`.
Expand All @@ -247,10 +252,10 @@ preact build --template src/template.html
preact watch --template src/template.html
```

[Promise]: https://npm.im/promise-polyfill
[promise]: https://npm.im/promise-polyfill
[fetch]: https://github.com/developit/unfetch
[preact]: https://github.com/developit/preact
[WebpackConfigHelpers]: docs/webpack-helpers.md
[webpackconfighelpers]: docs/webpack-helpers.md
[`.babelrc`]: https://babeljs.io/docs/usage/babelrc
[simple]: https://github.com/preactjs-templates/simple
[`"browserslist"`]: https://github.com/ai/browserslist
Expand All @@ -260,14 +265,14 @@ preact watch --template src/template.html
[preact-router]: https://github.com/developit/preact-router
[material]: https://github.com/preactjs-templates/material
[widget]: https://github.com/preactjs-templates/widget
[Plugins wiki]: https://github.com/developit/preact-cli/wiki/Plugins
[plugins wiki]: https://github.com/developit/preact-cli/wiki/Plugins
[preactjs-templates organization]: https://github.com/preactjs-templates
[preactjs-templates/default]: https://github.com/preactjs-templates/default
[recipes wiki]: https://github.com/developit/preact-cli/wiki/Config-Recipes
[PRPL]: https://developers.google.com/web/fundamentals/performance/prpl-pattern
[prpl]: https://developers.google.com/web/fundamentals/performance/prpl-pattern
[`babel-preset-env`]: https://github.com/babel/babel-preset-env#targetsbrowsers
[proof]: https://googlechrome.github.io/lighthouse/viewer/?gist=142af6838482417af741d966e7804346
[Preact CLI preset]: https://github.com/developit/preact-cli/blob/master/src/lib/babel-config.js
[Service Workers]: https://developers.google.com/web/fundamentals/getting-started/primers/service-workers
[Customize Babel]: https://github.com/developit/preact-cli/wiki/Config-Recipes#customising-babel-options-using-loader-helpers
[preact cli preset]: https://github.com/developit/preact-cli/blob/master/src/lib/babel-config.js
[service workers]: https://developers.google.com/web/fundamentals/getting-started/primers/service-workers
[customize babel]: https://github.com/developit/preact-cli/wiki/Config-Recipes#customising-babel-options-using-loader-helpers
[`async!`]: https://github.com/developit/preact-cli/blob/222e7018dd360e40f7db622191aeca62d6ef0c9a/examples/full/src/components/app.js#L7