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 prettier to format js files #1418
add prettier to format js files #1418
Conversation
* Update webpack.config.renderer.dev.dll.js * update webpack to support sass files * update webpack to support sass files
Good stuff! 🎉 Will merge this in soon after some testing |
Can you update the |
OK. I will update it. It's my pleasure. |
I have not idea which changelog is better. A# 0.13.3 (2018.2.8)
- Add git precommit hook, when commit will use prettier to format git add code
- Add `format` npm script which use prettier to format project js code B# 0.13.3 (2018.2.8)
- Add prettier to format js files |
A is better. Also I think the lint and format scripts should be the same. |
I combed the scripts again. |
package.json
Outdated
@@ -12,6 +12,8 @@ | |||
"electron-rebuild": "electron-rebuild --parallel --force --types prod,dev,optional --module-dir app", | |||
"flow": "flow", | |||
"flow-typed": "rimraf flow-typed/npm && flow-typed install --overwrite || true", | |||
"format": "prettier --single-quote --list-different '**/*.js'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the "format"
script should be removed and the "format-fix"
should be merged into the "lint-fix"
script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will make it easier for existing users to upgrade without changing their workflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
….com for new add package
…ch files need to format
@amilajack I have done the request change. Please review. Thanks. |
Thanks! I will review this soon and merge |
@@ -31,6 +32,12 @@ | |||
"test-watch": "npm test -- --watch" | |||
}, | |||
"browserslist": "electron 1.6", | |||
"lint-staged": { | |||
"*.js": [ | |||
"prettier --single-quote --write", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't lint-staged
auto fix with eslint as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can add eslint --fix
.
But I think what eslint --fix
can do as same as prettier(something like add semicolon
or double quotes to single quote
) .
I don't known what error eslint can auto-fix but prettier can't.
This is the eslint official doc said, but I don't understand what it mean.
If eslint --fix
has the same effect as prettier, I think keep only prettier is better.
@@ -13,14 +13,15 @@ | |||
"flow": "flow", | |||
"flow-typed": "rimraf flow-typed/npm && flow-typed install --overwrite || true", | |||
"lint": "cross-env NODE_ENV=development eslint --cache --format=node_modules/eslint-formatter-pretty .", | |||
"lint-fix": "npm run lint -- --fix", | |||
"lint-fix": "npm run lint -- --fix && prettier --single-quote --write '**/*.js'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're linting **/*.js
but files in the **/**/*.js
glob are linted as well. Hmm interesting. For example, app/components/*.js
files are listed. Just wondering why this is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prettier use glob syntax from the glob module.
**
matches zero or more directories and subdirectories.
The following characters have special magic meaning when used in a path portion:
- ...
- ** If a "globstar" is alone in a path portion, then it matches zero or more directories and subdirectories searching for matches. It does not crawl symlinked directories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe put the prettier before eslint --fix is better? What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well if eslint auto fixes through the prettier eslint config then shouldn't we just need to eslint auto fix? Not sure 100% how this works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think eslint --fix
and prettier have some different. There is a example show the different in this discuss.
Now I think the original way is better. Use eslint --fix
first and then use prettier to format fixed code. Please forgive my capricious personality.
"lint-fix": "npm run lint -- --fix && prettier --single-quote --write '**/*.js'",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good 👍
* Misc code style changes to menu.js * v0.13.3 * More consistent node path * Allowed node_modules to be checked by flow * add prettier to format js files (#1418) * Remove jsdom dep (#1411) * Remove dynamic import dep (#1408) * Add .sass files support (#1412) * Update webpack.config.renderer.dev.dll.js * update webpack to support sass files * update webpack to support sass files * Misc code style changes to menu.js * chore: add perttier husky lint-stage eslint-config-prettier and add scripts * refactor: use prettier to format code * fix: fix lint error and add eslint prettier config * fix: replace registry url from registry.npmjs.org to registry.yarnpkg.com for new add package * docs: update changelog * chore: add format-fix script and make format script just to check which files need to format * format: use prettier to format webpack files * docs: update change log - add format-fix script * feat: add prettier in `lint-fix` script * Removed unnecessary deps * Updated deps * Upgraded to webpack 4 * Run prettier even if eslint fails * createBrowserHistory to createHashHistory for prod (#1184) * Filter deps without entrypoint from dll * Bumped deps * Temporary hack to get flow working with webpack-cli * Use module property from dev webpack config in DLL webpack config (#1497) * Remove jsdom dep (#1411) * Remove dynamic import dep (#1408) * Add .sass files support (#1412) * Update webpack.config.renderer.dev.dll.js * update webpack to support sass files * update webpack to support sass files * Misc code style changes to menu.js * Use module property from dev webpack config in DLL webpack config Fixes #1468 To avoid a circular dependency, this relies on a check against the parent module's filename for `webpack.config.renderer.dev.dll.js`. It's expected that developers who rename config files will hopefully grep the codebase for this filename before changing it. This change also includes this check again when configuring `DllReferencePlugin`, because it is no longer guaranteed that the DLL manifest file exists by the time the renderer config specifies plugins. I played around with the idea of creating a `webpack-merge` strategy that plucks the value of `module` from the dev webpack config, but it wouldn't help much because, in `webpack.config.renderer.dev.js`, the `DllReferencePlugin` would still try to require the manifest (which would not exist). * Use includes() rather than indexOf() * Updated all deps to latest semver * Bumped deps * Bumped all deps to latest semver * Update changelog * Increased delay for e2e counter test * Updated lock file * Bumped ci node versions * Reverted version change in CHANGELOG [ci skip]
* Misc code style changes to menu.js * v0.13.3 * More consistent node path * Allowed node_modules to be checked by flow * add prettier to format js files (electron-react-boilerplate#1418) * Remove jsdom dep (electron-react-boilerplate#1411) * Remove dynamic import dep (electron-react-boilerplate#1408) * Add .sass files support (electron-react-boilerplate#1412) * Update webpack.config.renderer.dev.dll.js * update webpack to support sass files * update webpack to support sass files * Misc code style changes to menu.js * chore: add perttier husky lint-stage eslint-config-prettier and add scripts * refactor: use prettier to format code * fix: fix lint error and add eslint prettier config * fix: replace registry url from registry.npmjs.org to registry.yarnpkg.com for new add package * docs: update changelog * chore: add format-fix script and make format script just to check which files need to format * format: use prettier to format webpack files * docs: update change log - add format-fix script * feat: add prettier in `lint-fix` script * Removed unnecessary deps * Updated deps * Upgraded to webpack 4 * Run prettier even if eslint fails * createBrowserHistory to createHashHistory for prod (electron-react-boilerplate#1184) * Filter deps without entrypoint from dll * Bumped deps * Temporary hack to get flow working with webpack-cli * Use module property from dev webpack config in DLL webpack config (electron-react-boilerplate#1497) * Remove jsdom dep (electron-react-boilerplate#1411) * Remove dynamic import dep (electron-react-boilerplate#1408) * Add .sass files support (electron-react-boilerplate#1412) * Update webpack.config.renderer.dev.dll.js * update webpack to support sass files * update webpack to support sass files * Misc code style changes to menu.js * Use module property from dev webpack config in DLL webpack config Fixes electron-react-boilerplate#1468 To avoid a circular dependency, this relies on a check against the parent module's filename for `webpack.config.renderer.dev.dll.js`. It's expected that developers who rename config files will hopefully grep the codebase for this filename before changing it. This change also includes this check again when configuring `DllReferencePlugin`, because it is no longer guaranteed that the DLL manifest file exists by the time the renderer config specifies plugins. I played around with the idea of creating a `webpack-merge` strategy that plucks the value of `module` from the dev webpack config, but it wouldn't help much because, in `webpack.config.renderer.dev.js`, the `DllReferencePlugin` would still try to require the manifest (which would not exist). * Use includes() rather than indexOf() * Updated all deps to latest semver * Bumped deps * Bumped all deps to latest semver * Update changelog * Increased delay for e2e counter test * Updated lock file * Bumped ci node versions * Reverted version change in CHANGELOG [ci skip]
lint-fix
script to use prettier to format project js code