Skip to content

Commit

Permalink
chore: use prettier for code formatting (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
westeezy authored Jun 28, 2022
1 parent 780e21f commit 1530832
Show file tree
Hide file tree
Showing 23 changed files with 194 additions and 179 deletions.
10 changes: 5 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* @flow */

module.exports = {
'extends': './node_modules/@krakenjs/grumbler-scripts/config/.eslintrc.js',
extends: "./node_modules/@krakenjs/grumbler-scripts/config/.eslintrc.js",

'globals': {
__sdk__: true,
__lebowski_pay__: true
}
globals: {
__sdk__: true,
__lebowski_pay__: true,
},
};
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: ⎔ Setup node
uses: actions/setup-node@v2
with:
node-version: '14'
node-version: "14"

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
Expand Down
52 changes: 26 additions & 26 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
name: "publish to npm"
on: workflow_dispatch
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v2
with:
token: ${{ secrets.ACCESS_TOKEN }}
fetch-depth: 0
main:
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v2
with:
token: ${{ secrets.ACCESS_TOKEN }}
fetch-depth: 0

- name: ⎔ Setup node
# sets up the .npmrc file to publish to npm
uses: actions/setup-node@v2
with:
node-version: "14"
registry-url: "https://registry.npmjs.org"
- name: ⎔ Setup node
# sets up the .npmrc file to publish to npm
uses: actions/setup-node@v2
with:
node-version: "14"
registry-url: "https://registry.npmjs.org"

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false
- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: Configure git user
run: |
git config --global user.email ${{ github.actor }}@users.noreply.github.com
git config --global user.name ${{ github.actor }}
- name: ▶️ Run release
run: npm run release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Configure git user
run: |
git config --global user.email ${{ github.actor }}@users.noreply.github.com
git config --global user.name ${{ github.actor }}
- name: ▶️ Run release
run: npm run release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
npx lint-staged
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
dist
coverage
flow-typed
CHANGELOG.md
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
PayPal/Braintree Example Component
----------------------------------
## PayPal/Braintree Example Component

[![build status][build-badge]][build]
[![code coverage][coverage-badge]][coverage]
Expand Down Expand Up @@ -84,25 +83,22 @@ paypal.LebowskiPay.render({ ... });

```javascript
export default {
/**
* Define the lebowski-pay component
* Now developers can include paypal.com/sdk/js?components=lebowski-pay
*/

"lebowski-pay": {
/**
* Define the lebowski-pay component
* Now developers can include paypal.com/sdk/js?components=lebowski-pay
* Entry point. Everything exported from this module will be exported
* in the `window.paypal` namespace.
*/

'lebowski-pay': {

/**
* Entry point. Everything exported from this module will be exported
* in the `window.paypal` namespace.
*/

entry: './src/index'
}
entry: "./src/index",
},
};
```


### FAQ

- **Why is there no webpack config, dist folder, or npm build command?**
Expand Down
6 changes: 3 additions & 3 deletions __sdk__.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint import/no-commonjs: 0 */

module.exports = {
'example-pay': {
entry: './src/component'
}
"example-pay": {
entry: "./src/component",
},
};
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

// eslint-disable-next-line import/no-commonjs
module.exports = {
extends: '@krakenjs/grumbler-scripts/config/.babelrc-node'
extends: "@krakenjs/grumbler-scripts/config/.babelrc-node",
};
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
/* eslint import/no-commonjs: off */

module.exports = {
extends: [ '@commitlint/config-conventional' ]
extends: ["@commitlint/config-conventional"],
};
78 changes: 39 additions & 39 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
/* @flow */
/* eslint import/no-default-export: off */

import { getKarmaConfig } from '@krakenjs/grumbler-scripts/config/karma.conf';
import { getWebpackConfig } from '@krakenjs/grumbler-scripts/config/webpack.config';
import { getKarmaConfig } from "@krakenjs/grumbler-scripts/config/karma.conf";
import { getWebpackConfig } from "@krakenjs/grumbler-scripts/config/webpack.config";

import type { ExamplePayGlobalType } from './src/types';
import type { ExamplePayGlobalType } from "./src/types";

const examplePayGlobal : ExamplePayGlobalType = {
serverConfig: {
assetsUrl: 'https://paypal.com/assets/'
}
const examplePayGlobal: ExamplePayGlobalType = {
serverConfig: {
assetsUrl: "https://paypal.com/assets/",
},
};

export default (karma : Object) => {
const karmaConfig = getKarmaConfig(karma, {
basePath: __dirname,
webpack: getWebpackConfig({
vars: {
__example_pay__: examplePayGlobal,

__PORT__: 8000,
__SDK_HOST__: 'test.paypal.com',
__STAGE_HOST__: 'msmaster.qa.paypal.com',
__HOST__: 'test.paypal.com',
__HOSTNAME__: 'test.paypal.com',
__PATH__: '/sdk/js',
__VERSION__: '1.0.55',
__NAMESPACE__: 'testpaypal'
}
})
});

karma.set({
...karmaConfig,

files: [
{
pattern: 'test/paypal.js',
included: true,
served: true
},

...karmaConfig.files
]
});
export default (karma: Object) => {
const karmaConfig = getKarmaConfig(karma, {
basePath: __dirname,
webpack: getWebpackConfig({
vars: {
__example_pay__: examplePayGlobal,

__PORT__: 8000,
__SDK_HOST__: "test.paypal.com",
__STAGE_HOST__: "msmaster.qa.paypal.com",
__HOST__: "test.paypal.com",
__HOSTNAME__: "test.paypal.com",
__PATH__: "/sdk/js",
__VERSION__: "1.0.55",
__NAMESPACE__: "testpaypal",
},
}),
});

karma.set({
...karmaConfig,

files: [
{
pattern: "test/paypal.js",
included: true,
served: true,
},

...karmaConfig.files,
],
});
};
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"flow": "flow",
"flow:build": "flow gen-flow-files ./src/index.js --out-dir ./dist/module",
"lint": "eslint src/ test/ *.js",
"test": "npm run lint && npm run flow && npm run karma",
"format": "prettier --write --ignore-unknown .",
"format:check": "prettier --check .",
"test": "npm run format:check && npm run lint && npm run flow && npm run karma",
"karma": "cross-env NODE_ENV=test babel-node $(npm bin)/karma start",
"prepare": "husky install",
"release": "standard-version",
Expand Down Expand Up @@ -71,13 +73,18 @@
"devDependencies": {
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@krakenjs/grumbler-scripts": "^6",
"@krakenjs/grumbler-scripts": "^7.0.0",
"flow-bin": "0.155.0",
"husky": "^7.0.4",
"lint-staged": "^13.0.3",
"mocha": "^4",
"prettier": "2.7.1",
"standard-version": "^9.3.2"
},
"dependencies": {
"@paypal/sdk-client": "^4.0.166"
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
}
}
4 changes: 1 addition & 3 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"extends": [
"config:base"
]
"extends": ["config:base"]
}
2 changes: 1 addition & 1 deletion src/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

// eslint-disable-next-line import/no-commonjs
module.exports = {
extends: 'grumbler-scripts/config/.babelrc-browser'
extends: "grumbler-scripts/config/.babelrc-browser",
};
29 changes: 15 additions & 14 deletions src/component.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
/* @flow */

import { getClientID } from '@paypal/sdk-client/src';
import { getClientID } from "@paypal/sdk-client/src";

export const ExamplePay = {
render(options : {| buttonText : string |}, container : string) {

if (!options.buttonText) {
throw new Error(`Expected options.buttonText`);
}

const el = document.querySelector(container);
render(options: {| buttonText: string |}, container: string) {
if (!options.buttonText) {
throw new Error(`Expected options.buttonText`);
}

if (!el) {
throw new Error(`Can not find element: ${ container }`);
}
const el = document.querySelector(container);

el.innerHTML = `<button client-id=${ getClientID() }>${ options.buttonText }</button>`;
if (!el) {
throw new Error(`Can not find element: ${container}`);
}

el.innerHTML = `<button client-id=${getClientID()}>${
options.buttonText
}</button>`;
},
};

export const EXAMPLE_CONSTANTS = {
FOO: 'FOO',
BAR: 'BAR'
FOO: "FOO",
BAR: "BAR",
};
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/* @flow */

export * from './component';
export * from "./component";
8 changes: 3 additions & 5 deletions src/types.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/* @flow */

export type ExamplePayServerConfigType = {|
assetsUrl : string
assetsUrl: string,
|};


export type ExamplePayGlobalType = {|
serverConfig : ExamplePayServerConfigType
serverConfig: ExamplePayServerConfigType,
|};


declare var __example_pay__ : ExamplePayGlobalType;
declare var __example_pay__: ExamplePayGlobalType;
9 changes: 4 additions & 5 deletions test/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

// eslint-disable-next-line import/no-commonjs
module.exports = {
'extends': '../.eslintrc.js',
extends: "../.eslintrc.js",

'rules': {
'import/export': 'off'
}
rules: {
"import/export": "off",
},
};

2 changes: 1 addition & 1 deletion test/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

// eslint-disable-next-line import/no-commonjs
module.exports = {
extends: '@krakenjs/grumbler-scripts/config/.babelrc-browser'
extends: "@krakenjs/grumbler-scripts/config/.babelrc-browser",
};
Loading

0 comments on commit 1530832

Please sign in to comment.