Skip to content

Commit

Permalink
add linter/prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
kuldeepkeshwar committed Aug 26, 2019
1 parent 77ad9e6 commit b6975bf
Show file tree
Hide file tree
Showing 21 changed files with 810 additions and 599 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
"extends": "airbnb-base"
};
extends: 'airbnb-base',
}
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
16 changes: 0 additions & 16 deletions .vscode/launch.json

This file was deleted.

20 changes: 20 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"editor.minimap.enabled": false,
"editor.wordWrap": "off",
// Turns on auto format on save for all files types.
// This is also required to allow Prettier to auto format files on save.
"editor.formatOnSave": true,
// Turns it off for JavaScript since we use Prettier to auto format on save.
"javascript.format.enable": false,
"javascript.validate.enable": true,
"json.format.enable": false,
// Required to allow auto format on save with Prettier + ESLint + Vetur.
"eslint.autoFixOnSave": true,
"eslint.alwaysShowStatus": true,
"prettier.eslintIntegration": true,
"prettier.stylelintIntegration": true,
"sort-imports.suppress-warnings": true,
"search.exclude": {
"**/node_modules*": true
}
}
27 changes: 13 additions & 14 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ religion, or sexual identity and orientation.
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 Expand Up @@ -71,4 +71,3 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage], versi
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ We'd also love PRs. If you're thinking of a large PR, we advise opening up an is

Here are a few things you can do that will increase the likelihood of your pull request being accepted:

- Follow the [style guide][style] which is using standard. Any linting errors should be shown when running `npm test`.
- Write and update tests.
- Keep your changes as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
- Follow the [style guide][style] which is using standard. Any linting errors should be shown when running `npm test`.
- Write and update tests.
- Keep your changes as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).

Work in Progress pull requests are also welcome to get feedback early on, or if there is something blocked you.

## Resources

- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
- [GitHub Help](https://help.github.com)
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
- [GitHub Help](https://help.github.com)
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@

[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)

<p align="center">
<img src="https://github.com/kuldeepkeshwar/size-plugin-bot/blob/master/static/images/icon.png?raw=true" alt="size-plugin" >
</p>
<p align="center">
<h1 align="center">size-plugin</h1>
</p>


> A GitHub 🤖 built with Probot that helps you to keep an 👁️ on static assert 📦 sizes of your application and gives instant feedback 📝 for developer whenever they make change.
##### 🤖 comments the gzipped sizes of your webpack assets and the changes since the last build into the relevant PR

## Usage

First add an instance of the [size-plugin](https://github.com/GoogleChromeLabs/size-plugin) to your webpack configuration:

```diff
Expand All @@ -26,16 +26,15 @@ module.exports = {
}
```

Second Simply [install the app](https://github.com/apps/size-plugin) and make some changes, open a pr and watch the magic happen 😊
Second Simply [install the app](https://github.com/apps/size-plugin) and make some changes, open a pr and watch the magic happen 😊

<p align="center">
<img src="https://github.com/kuldeepkeshwar/size-plugin-bot/blob/master/static/images/sample.png?raw=true" alt="size-plugin commenting on a PR with bundle stats" width="760">
</p>

Currently works with [Travis CI](https://travis-ci.org), [CircleCI](https://circleci.com/), [Wercker](http://www.wercker.com), and [Drone](http://readme.drone.io/).

Using a different CI? Under the hood, [size-plugin](https://github.com/GoogleChromeLabs/size-plugin) uses [ci-env](https://github.com/siddharthkp/ci-env) to extract meta information which works perfectly with Custom CI 🙃

Using a different CI? Under the hood, [size-plugin](https://github.com/GoogleChromeLabs/size-plugin) uses [ci-env](https://github.com/siddharthkp/ci-env) to extract meta information which works perfectly with Custom CI 🙃

## Contributing

Expand All @@ -48,6 +47,7 @@ For more, check out the [Contributing Guide](CONTRIBUTING.md).
⭐️ this repo

&nbsp;

## License

[ISC](LICENSE) © 2019 kuldeepkeshwar <kuldeepkeshwar@gmail.com>
Expand Down
130 changes: 67 additions & 63 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,69 @@
{
"name": "size-plugin-bot",
"version": "1.0.0",
"description": "A Github bot for size-plugin",
"author": "kuldeepkeshwar <kuldeepkeshwar@gmail.com>",
"license": "ISC",
"repository": "https://github.com/kuldeepkeshwar/size-plugin-bot.git",
"homepage": "https://github.com/kuldeepkeshwar/size-plugin-bot",
"bugs": "https://github.com/kuldeepkeshwar/size-plugin-bot/issues",
"keywords": [
"size-plugin",
"size-plugin-bot"
],
"scripts": {
"dev": "nodemon",
"start": "probot run ./src/index.js",
"lint": "standard --fix",
"test": "jest && standard",
"test:watch": "jest --watch --notify --notifyMode=change --coverage"
},
"dependencies": {
"axios": "^0.19.0",
"emojis-list": "^3.0.0",
"fs-extra": "^8.0.1",
"pretty-bytes": "^5.2.0",
"probot": "^9.2.20",
"probot-config": "^1.1.0"
},
"devDependencies": {
"dotenv": "^8.0.0",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^13.2.0",
"eslint-plugin-import": "^2.18.0",
"execa": "^1.0.0",
"jest": "^24.0.0",
"nock": "^10.0.0",
"nodemon": "^1.17.2",
"smee-client": "^1.0.2",
"standard": "^12.0.1"
},
"engines": {
"node": ">= 8.3.0"
},
"standard": {
"env": [
"jest"
]
},
"prettier": {
"singleQuote": true,
"trailingComma": "none",
"useTabs": true,
"tabWidth": 2
},
"nodemonConfig": {
"exec": "npm start",
"watch": [
".env",
"."
]
},
"jest": {
"testEnvironment": "node"
}
"name": "size-plugin-bot",
"version": "1.0.0",
"description": "A Github bot for size-plugin",
"author": "kuldeepkeshwar <kuldeepkeshwar@gmail.com>",
"license": "ISC",
"repository": "https://github.com/kuldeepkeshwar/size-plugin-bot.git",
"homepage": "https://github.com/kuldeepkeshwar/size-plugin-bot",
"bugs": "https://github.com/kuldeepkeshwar/size-plugin-bot/issues",
"keywords": [
"size-plugin",
"size-plugin-bot"
],
"scripts": {
"dev": "nodemon",
"start": "probot run ./src/index.js",
"lint": "eslint src --fix",
"format": "prettier --write '**/*.{js,scss,jsx,md}'",
"test": "jest",
"test:watch": "jest --watch --notify --notifyMode=change --coverage"
},
"dependencies": {
"axios": "^0.19.0",
"emojis-list": "^3.0.0",
"fs-extra": "^8.0.1",
"pretty-bytes": "^5.2.0",
"probot": "^9.2.20",
"probot-config": "^1.1.0"
},
"devDependencies": {
"dotenv": "^8.0.0",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^13.2.0",
"eslint-plugin-import": "^2.18.0",
"execa": "^1.0.0",
"jest": "^24.0.0",
"lint-staged": "^9.2.4",
"nock": "^10.0.0",
"nodemon": "^1.17.2",
"prettier": "^1.18.2",
"smee-client": "^1.0.2"
},
"engines": {
"node": ">= 8.3.0"
},
"lint-staged": {
"linters": {
"*.{js,jsx}": [
"eslint --fix",
"prettier --write",
"git add"
]
},
"ignore": [
"**/dist/*",
"**/public/*"
]
},
"nodemonConfig": {
"exec": "npm start",
"watch": [
".env",
"."
]
},
"jest": {
"testEnvironment": "node"
}
}
6 changes: 6 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
trailingComma: 'es5',
tabWidth: 4,
semi: false,
singleQuote: true,
}
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const MAX_RETRY = 20;
const RETRY_INTERVAL = 30 * 1000;

const SIZE_STORE_ENDPOINT = process.env.SIZE_STORE_ENDPOINT || 'https://size-plugin-store.now.sh';
const SIZE_STORE_ENDPOINT = process.env.SIZE_STORE_ENDPOINT || 'https://size-plugin-store.now.sh';

module.exports = { MAX_RETRY, RETRY_INTERVAL, SIZE_STORE_ENDPOINT };
6 changes: 4 additions & 2 deletions src/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ${decorateComment(files)}
\`\`\`
`;
}, '');
}, '');
}
// eslint-disable-next-line consistent-return
async function get(context) {
Expand Down Expand Up @@ -89,7 +89,9 @@ async function get(context) {
let counter = 0;
for (const filename of Object.keys(sizeFileNameMap)) {
if (sizeMap[filename]) {
const message = commentMessageTemplate(sizeMap[filename]);
const message = commentMessageTemplate(
sizeMap[filename],
);
commentPullRequest(context, message).then(
console.log,
console.error,
Expand Down
9 changes: 6 additions & 3 deletions src/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ function register(app) {
app.on(['push'], async (context) => {
setTimeout(size.get, 0, context);
});
app.on(['pull_request.opened', 'pull_request.synchronize'], async (context) => {
setTimeout(diff.get, 0, context);
});
app.on(
['pull_request.opened', 'pull_request.synchronize'],
async (context) => {
setTimeout(diff.get, 0, context);
},
);
}
module.exports = { register };
Loading

0 comments on commit b6975bf

Please sign in to comment.