Skip to content
This repository has been archived by the owner on May 15, 2021. It is now read-only.

Commit

Permalink
Remove Validation Logic (#4)
Browse files Browse the repository at this point in the history
* Initial attempt with tsdx

* Bump to latest share-kit and prep release
  • Loading branch information
JaceHensley authored Jun 20, 2019
1 parent be5b6d6 commit 850d0fa
Show file tree
Hide file tree
Showing 24 changed files with 4,930 additions and 5,766 deletions.
75 changes: 75 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
rules: {
// Turn off certain typescript-eslint rules
'@typescript-eslint/no-unused-vars': 0, // This is enabled in our tsconfig file becuase the lint doens't support JSX usage
'@typescript-eslint/array-type': 0,
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/prefer-interface': 0,
'@typescript-eslint/prefer-namespace-keyword': 0,
'@typescript-eslint/camelcase': 0,
'@typescript-eslint/no-parameter-properties': 0,
// https://github.com/typescript-eslint/typescript-eslint/issues/249
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/no-object-literal-type-assertion': 0,
'@typescript-eslint/indent': 0,

// Override certain typescript-eslint rules
'@typescript-eslint/member-delimiter-style': [
2,
{
multiline: {
delimiter: 'none',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
},
],
'@typescript-eslint/explicit-member-accessibility': [
2,
{
accessibility: 'no-public',
overrides: {parameterProperties: 'explicit'},
},
],
'@typescript-eslint/interface-name-prefix': [2, 'always'],

// Turn off certain react rules
'react/prop-types': 0,

// Turn on the prettier rules
'prettier/prettier': 'error',
// This is a weird one and needs to be duped here and .prettierrc
// https://github.com/prettier/eslint-config-prettier#max-len
'max-len': [
2,
{
code: 140,
tabWidth: 2,
ignoreUrls: true,
ignoreComments: true,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
},
],
},
settings: {
react: {
version: 'detect',
},
},
}
91 changes: 7 additions & 84 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,84 +1,7 @@
# https://raw.githubusercontent.com/Microsoft/TypeScript/master/.gitignore

node_modules/
.node_modules/
built/*
tests/cases/rwc/*
tests/cases/test262/*
tests/cases/perf/*
!tests/cases/webharness/compilerToString.js
test-args.txt
~*.docx
\#*\#
.\#*
tests/baselines/local/*
tests/baselines/local.old/*
tests/services/baselines/local/*
tests/baselines/prototyping/local/*
tests/baselines/rwc/*
tests/baselines/test262/*
tests/baselines/reference/projectOutput/*
tests/baselines/local/projectOutput/*
tests/baselines/reference/testresults.tap
tests/services/baselines/prototyping/local/*
tests/services/browser/typescriptServices.js
src/harness/*.js
src/compiler/diagnosticInformationMap.generated.ts
src/compiler/diagnosticMessages.generated.json
src/parser/diagnosticInformationMap.generated.ts
src/parser/diagnosticMessages.generated.json
rwc-report.html
*.swp
build.json
*.actual
tests/webTestServer.js
tests/webTestServer.js.map
tests/webhost/*.d.ts
tests/webhost/webtsc.js
tests/cases/**/*.js
tests/cases/**/*.js.map
*.config
scripts/debug.bat
scripts/run.bat
scripts/word2md.js
scripts/buildProtocol.js
scripts/ior.js
scripts/authors.js
scripts/configurePrerelease.js
scripts/open-user-pr.js
scripts/processDiagnosticMessages.d.ts
scripts/processDiagnosticMessages.js
scripts/produceLKG.js
scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
scripts/generateLocalizedDiagnosticMessages.js
scripts/*.js.map
scripts/typings/
coverage/
internal/
**/.DS_Store
.settings
**/.vs
**/.vscode
!**/.vscode/tasks.json
!tests/cases/projects/projectOption/**/node_modules
!tests/cases/projects/NodeModulesSearch/**/*
!tests/baselines/reference/project/nodeModules*/**/*
.idea
yarn.lock
yarn-error.log
.parallelperf.*
tests/cases/user/*/package-lock.json
tests/cases/user/*/node_modules/
tests/cases/user/*/**/*.js
tests/cases/user/*/**/*.js.map
tests/cases/user/*/**/*.d.ts
!tests/cases/user/zone.js/
!tests/cases/user/bignumber.js/
!tests/cases/user/discord.js/
tests/baselines/reference/dt
.failed-tests

# bloom additions
dist/
*.tgz
package/
*.log
.DS_Store
node_modules
.rts2_cache_cjs
.rts2_cache_esm
.rts2_cache_umd
dist
8 changes: 0 additions & 8 deletions .prettierrc

This file was deleted.

8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
semi: false,
singleQuote: true,
printWidth: 140,
trailingComma: 'all',
jsxBracketSameLine: false,
bracketSpacing: false,
}
2 changes: 1 addition & 1 deletion .storybook/Logo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'

import {RequestElement} from '../index'
import {RequestElement} from '../src/index'

class Logo extends React.Component {
state = {hideLogo: false}
Expand Down
2 changes: 1 addition & 1 deletion .storybook/Updating.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'

import {RequestElement, Action} from '../index'
import {RequestElement, Action} from '../src/index'

class Updating extends React.Component {
state = {counter: 0}
Expand Down
16 changes: 7 additions & 9 deletions .storybook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {storiesOf} from '@storybook/react'

import {Logo} from './Logo'
import {Updating} from './Updating'
import {Action, RequestElement} from '../index'
import {Action, RequestElement} from '../src/index'

const defaultData = {
action: Action.attestation,
Expand All @@ -19,21 +19,19 @@ const defaultData = {
const buttonCallbackUrl = 'https://mysite.com/bloom-callback'

storiesOf('RequestElement', module)
.add('Base', () => <RequestElement requestData={defaultData} buttonCallbackUrl={buttonCallbackUrl} />)
.add('Base', () => <RequestElement requestData={defaultData} buttonOptions={{callbackUrl: buttonCallbackUrl}} />)
.add('Colors', () => (
<RequestElement
requestData={defaultData}
buttonCallbackUrl={buttonCallbackUrl}
buttonOptions={{callbackUrl: buttonCallbackUrl}}
qrOptions={{bgColor: '#EBF0F1', fgColor: '#3C3C3D'}}
/>
))
.add('Logo', () => <Logo requestData={defaultData} buttonCallbackUrl={buttonCallbackUrl} />)
.add('Size', () => (
<RequestElement requestData={defaultData} buttonCallbackUrl={buttonCallbackUrl} qrOptions={{size: 300}} />
))
.add('Updating', () => <Updating buttonCallbackUrl={buttonCallbackUrl} />)
.add('Logo', () => <Logo requestData={defaultData} buttonOptions={{callbackUrl: buttonCallbackUrl}} />)
.add('Size', () => <RequestElement requestData={defaultData} buttonOptions={{callbackUrl: buttonCallbackUrl}} qrOptions={{size: 300}} />)
.add('Updating', () => <Updating buttonOptions={{callbackUrl: buttonCallbackUrl}} />)
.add('Button', () => (
<div style={{width: '335px'}}>
<RequestElement requestData={defaultData} buttonCallbackUrl={buttonCallbackUrl} shouldRenderButton={() => true} />
<RequestElement requestData={defaultData} buttonOptions={{callbackUrl: buttonCallbackUrl}} shouldRenderButton={() => true} />
</div>
))
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 4.0.0

**Improvements**

- Use [tsdx](https://github.com/palmerhq/tsdx) to build
- Expand support of react to "^15.0.0 || ^16.0.0"

**Breaking**

- This package no longer provides validation utils, instead use [verify-kit](https://github.com/hellobloom/verify-kit)
- Remove `RequestElementProps.buttonCallbackUrl` in favor of `RequestElementProps.buttonOptions`
- This will be expanded to include options for button type (signin/signup/verify/etc.) among other things
- React is now a peer dependency, you will need to specify react as a dependency in your `package.json` moving forward

## 2.0.0

**Breaking**
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ npm install --save @bloomprotocol/share-kit-react

```tsx
import * as React from 'react'
import {RequestElement, RequestData, QROptions} from '@bloomprotocol/share-kit-react'
import {RequestElement, RequestData, QROptions, ButtonOptions} from '@bloomprotocol/share-kit-react'

const requestData: RequestData = {...}
const buttonCallbackUrl = 'https://mysite.com/bloom-callback'
const buttonOptions: ButtonOptions = {
callbackUrl: 'https://mysite.com/bloom-callback',
}

<RequestElement
requestData={requestData}
buttonCallbackUrl={buttonCallbackUrl}
buttonOptions={buttonOptions}
/>

// Setting QR Options
Expand All @@ -39,14 +41,14 @@ const qrOptions: Partial<QROptions> = {

<RequestElement
requestData={requestData}
buttonCallbackUrl={buttonCallbackUrl}
buttonOptions={buttonOptions}
qrOptions={qrOptions}
/>

// Overriding shouldRenderButton
<RequestElement
requestData={requestData}
buttonCallbackUrl={buttonCallbackUrl}
buttonOptions={buttonOptions}
shouldRenderButton={(parsedResult) => {
if (parsedResult.platform.type === 'mobile') return true

Expand All @@ -57,7 +59,7 @@ const qrOptions: Partial<QROptions> = {
// Passing props to the container
<RequestElement
requestData={requestData}
buttonCallbackUrl={buttonCallbackUrl}
buttonOptions={buttonOptions}
className="request-element-container"
/>
```
Expand Down
3 changes: 0 additions & 3 deletions bin/build

This file was deleted.

34 changes: 34 additions & 0 deletions bin/eslint
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Pass in the project config file and directory to run eslint
#
# 1. Passes in project file, enabling type-based linting
# 2. Uses verbose formatter so we know which lint rule failed
# 3. Excludes test files
# 4. Passes in flags from command line to eslint. `bin/eslint --fix` should work
eslint_project() {
local config_file="$1"
local directory1="$2"
local directory2="$3"

# Remove the function arguments
shift 3

# Use the verbose formatter which includes the rule name
./node_modules/.bin/eslint \
--format table \
"$directory1/**/*.{ts,tsx}" \
"$directory2/**/*.{ts,tsx}" \
"$@" # Pass in commands passed to our executable
}

# Track if either task failed.
linting_passed="true"

if ! eslint_project tsconfig.json src test "$@"; then
linting_passed="false"
fi

if [ "$linting_passed" == "false" ]; then
exit 1
fi
11 changes: 0 additions & 11 deletions bin/prettier

This file was deleted.

1 change: 0 additions & 1 deletion bin/tslint

This file was deleted.

4 changes: 0 additions & 4 deletions index.ts

This file was deleted.

9 changes: 0 additions & 9 deletions jest.config.js

This file was deleted.

Loading

0 comments on commit 850d0fa

Please sign in to comment.