Skip to content

Commit

Permalink
chore: use prettier (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
westeezy authored Jun 30, 2022
1 parent b7576df commit 250fea3
Show file tree
Hide file tree
Showing 45 changed files with 1,145 additions and 1,026 deletions.
57 changes: 29 additions & 28 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
/* @flow */

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

'globals': {
'Promise': false,
'__PAYPAL_CHECKOUT__': true,
'__paypal_checkout__': true,
'__sdk__': true,
'__LOCALE__': true,
'__CLIENT_ID__': true,
'__MERCHANT_ID__': true,
'__INTENT__': true,
'__COMMIT__': true,
'__VAULT__': true,
'__PORT__': true,
'__STAGE_HOST__': true,
'__HOST__': true,
'__PATH__': true,
'__COMPONENTS__': true
},
globals: {
Promise: false,
__PAYPAL_CHECKOUT__: true,
__paypal_checkout__: true,
__sdk__: true,
__LOCALE__: true,
__CLIENT_ID__: true,
__MERCHANT_ID__: true,
__INTENT__: true,
__COMMIT__: true,
__VAULT__: true,
__PORT__: true,
__STAGE_HOST__: true,
__HOST__: true,
__PATH__: true,
__COMPONENTS__: true,
},

'rules': {
'complexity': 'off',
'max-nested-callbacks': [ 'error', 5 ],
'react/prop-types': 'off',
'react/style-prop-object': 'off',
'react/display-name': 'off',
'react/require-default-props': 'off',
'react/forbid-component-props': 'off'
}
};
rules: {
complexity: "off",
"max-nested-callbacks": ["error", 5],
"react/prop-types": "off",
"react/style-prop-object": "off",
"react/display-name": "off",
"react/require-default-props": "off",
"react/forbid-component-props": "off",
},
};
9 changes: 2 additions & 7 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
{
"extends": [
"config:base",
":preserveSemverRanges"
],
"extends": ["config:base", ":preserveSemverRanges"],
"prCreation": "immediate",
"prHourlyLimit": 0,
"rangeStrategy": "status-success",
"separateMajorMinor": false,
"semanticCommits": true,
"timezone": "America/Los_Angeles",
"rebaseStalePrs": true,
"labels": [
":christmas_tree: dependencies"
],
"labels": [":christmas_tree: dependencies"],
"packageRules": [
{
"packagePatterns": "^babel",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
# sets up the .npmrc file to publish to npm
uses: actions/setup-node@v2
with:
node-version: '14'
registry-url: 'https://registry.npmjs.org'
node-version: "14"
registry-url: "https://registry.npmjs.org"

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

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 @@
{}
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Feel free to raise a pull request to us. Our team would review your proposed mod
your changes into our code. Ideas and other comments are also welcome.

## Getting Started

1. Create your own [fork](https://help.github.com/articles/fork-a-repo) of this [repository](../../fork).

```bash
# Clone it
$ git clone [email protected]:me/paypal-checkout.git
Expand All @@ -28,10 +30,12 @@ $ npm test
```

## Making Changes

1. Make sure that your changes adhere to the current coding conventions used throughout the project, indentation, accurate comments, etc.
2. Ensure existing tests pass (`$ npm test`) and include test cases which fail without your change and succeed with it.

## Submitting Changes

1. Ensure that no errors are generated by ESLint (run during `$ npm test`).
2. Commit your changes in logical chunks, i.e. keep your changes small per single commit.
3. Locally merge (or rebase) the upstream branch into your topic branch: `$ git pull upstream && git merge`.
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
PayPal Common Components
------------------------
## PayPal Common Components

[![build status][build-badge]][build]
[![code coverage][coverage-badge]][coverage]
Expand Down Expand Up @@ -42,13 +41,14 @@ npm run dev
```

## Test Tasks

```
npm test
```

| Flags | Description |
| ------------- | ------------- |
| --clear-cache | Clear Babel Loader and PhantomJS cache |
| --debug | Debug mode. PhantomJS, Karma, and CheckoutJS |
| --quick | Fastest testing. Minimal output, no coverage |
| --browser | Choose Browser |
| Flags | Description |
| ------------- | -------------------------------------------- |
| --clear-cache | Clear Babel Loader and PhantomJS cache |
| --debug | Debug mode. PhantomJS, Karma, and CheckoutJS |
| --quick | Fastest testing. Minimal output, no coverage |
| --browser | Choose Browser |
12 changes: 6 additions & 6 deletions __sdk__.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* @flow */
/* eslint unicorn/filename-case: 0, import/unambiguous: 0, import/no-commonjs: 0 */

const globals = require('./globals');
const globals = require("./globals");

module.exports = {
common: {
automatic: true,
entry: './src/interface',
globals
}
common: {
automatic: true,
entry: "./src/interface",
globals,
},
};
2 changes: 1 addition & 1 deletion babel.config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@krakenjs/grumbler-scripts/config/.babelrc-node"
}
}
31 changes: 15 additions & 16 deletions globals.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
/* eslint import/no-commonjs: off, flowtype/require-valid-file-annotation: off, flowtype/require-return-type: off */

const postRobotGlobals = require('@krakenjs/post-robot/globals');
const zoidGlobals = require('@krakenjs/zoid/globals');
const postRobotGlobals = require("@krakenjs/post-robot/globals");
const zoidGlobals = require("@krakenjs/zoid/globals");

module.exports = {
__ZOID__: {
...zoidGlobals.__ZOID__,
__DEFAULT_CONTAINER__: true,
__DEFAULT_PRERENDER__: true,
__FRAMEWORK_SUPPORT__: true,
},

__ZOID__: {
...zoidGlobals.__ZOID__,
__DEFAULT_CONTAINER__: true,
__DEFAULT_PRERENDER__: true,
__FRAMEWORK_SUPPORT__: true
},
__POST_ROBOT__: {
...postRobotGlobals.__POST_ROBOT__,
__IE_POPUP_SUPPORT__: false,
},

__POST_ROBOT__: {
...postRobotGlobals.__POST_ROBOT__,
__IE_POPUP_SUPPORT__: false
},

__PAYPAL_CHECKOUT__: {
__REMEMBERED_FUNDING__: []
}
__PAYPAL_CHECKOUT__: {
__REMEMBERED_FUNDING__: [],
},
};
4 changes: 1 addition & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint import/no-commonjs: off, flowtype/require-valid-file-annotation: off */

module.exports = {

};
module.exports = {};
79 changes: 39 additions & 40 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
/* @flow */
/* eslint import/no-default-export: off */

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

import { WEBPACK_CONFIG_TEST } from './webpack.config';

export default function configKarma(karma : Object) {

const karmaConfig = getKarmaConfig(karma, {
basePath: __dirname,
testDir: 'test',
windowDir: 'test/integration/windows',
entry: 'test/integration/index.js',
webpack: WEBPACK_CONFIG_TEST
});

karma.set({
...karmaConfig,

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

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

...karmaConfig.files
],

preprocessors: {
...karmaConfig.preprocessors,

'src/index.js': [ 'webpack', 'sourcemap' ],
'src/**/*.js': [ 'sourcemap' ]
}
});
import { getKarmaConfig } from "@krakenjs/grumbler-scripts/config/karma.conf";

import { WEBPACK_CONFIG_TEST } from "./webpack.config";

export default function configKarma(karma: Object) {
const karmaConfig = getKarmaConfig(karma, {
basePath: __dirname,
testDir: "test",
windowDir: "test/integration/windows",
entry: "test/integration/index.js",
webpack: WEBPACK_CONFIG_TEST,
});

karma.set({
...karmaConfig,

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

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

...karmaConfig.files,
],

preprocessors: {
...karmaConfig.preprocessors,

"src/index.js": ["webpack", "sourcemap"],
"src/**/*.js": ["sourcemap"],
},
});
}
15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"flow-typed": "rm -rf flow-typed && flow-typed install",
"flow": "flow",
"karma": "cross-env NODE_ENV=test babel-node $(npm bin)/karma start",
"test": "npm run lint && npm run flow-typed && 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-typed && npm run flow && npm run karma",
"build": "npm run test && npm run webpack",
"release": "./scripts/publish.sh",
"release:patch": "./scripts/publish.sh patch",
Expand All @@ -21,7 +23,8 @@
"reinstall": "rimraf flow-typed && rimraf node_modules && npm install && flow-typed install",
"debug": "cross-env NODE_ENV=debug",
"webpack": "babel-node --plugins=transform-es2015-modules-commonjs ./node_modules/.bin/webpack --progress",
"eslint-find-rules": "eslint-find-rules --current .eslintrc.js --unused --plugin"
"eslint-find-rules": "eslint-find-rules --current .eslintrc.js --unused --plugin",
"prepare": "husky install"
},
"files": [
"src/",
Expand Down Expand Up @@ -52,19 +55,22 @@
"license": "Apache-2.0",
"readmeFilename": "README.md",
"devDependencies": {
"@krakenjs/grumbler-scripts": "^6.0.2",
"@krakenjs/grumbler-scripts": "^7.0.0",
"@krakenjs/sync-browser-mocks": "^3.0.0",
"babel-core": "^7.0.0-bridge.0",
"conventional-changelog-cli": "^2.0.11",
"flow-bin": "0.135.0",
"fs-extra": "^4.0.2",
"husky": "^8.0.1",
"imagemagick": "^0.1.3",
"imgur": "^0.2.1",
"lint-staged": "^13.0.3",
"memory-fs": "^0.4.1",
"mocha": "^4",
"mocketeer": "^0.3.0",
"pixelmatch": "^4.0.2",
"pngjs": "^3.3.0",
"prettier": "2.7.1",
"serve": "^10.1.2"
},
"dependencies": {
Expand All @@ -76,5 +82,8 @@
"@krakenjs/post-robot": "^11.0.0",
"@krakenjs/zalgo-promise": "^2.0.0",
"@krakenjs/zoid": "^10.0.0"
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
}
}
Loading

0 comments on commit 250fea3

Please sign in to comment.