Skip to content

Commit

Permalink
Upgrade to prettier@latest (#1138)
Browse files Browse the repository at this point in the history
Running latest version of prettier
  • Loading branch information
luisrudge committed Oct 11, 2017
1 parent bef98a4 commit 7d83f91
Show file tree
Hide file tree
Showing 81 changed files with 2,299 additions and 1,990 deletions.
11 changes: 4 additions & 7 deletions .eslintrc
@@ -1,9 +1,5 @@
{
"extends": [
"plugin:react/recommended",
"prettier",
"prettier/react"
],
"extends": ["plugin:react/recommended", "prettier", "prettier/react"],
"env": {
"browser": true,
"es6": true
Expand All @@ -12,6 +8,7 @@
"rules": {
"react/display-name": 0,
"react/prop-types": 1,
"react/no-find-dom-node": 1
"react/no-find-dom-node": 1,
"react/no-string-refs": 1
}
}
}
15 changes: 8 additions & 7 deletions package.json
Expand Up @@ -50,9 +50,9 @@
"dotenv": "^4.0.0",
"enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.1",
"eslint": "^3.19.0",
"eslint-config-prettier": "^1.7.0",
"eslint-plugin-react": "^6.10.3",
"eslint": "^4.8.0",
"eslint-config-prettier": "^2.6.0",
"eslint-plugin-react": "^7.4.0",
"expect.js": "^0.3.1",
"flat": "^2.0.1",
"grunt": "^0.4.5",
Expand All @@ -63,13 +63,13 @@
"grunt-env": "^0.4.4",
"grunt-exec": "^0.4.6",
"grunt-webpack": "^2.0.1",
"husky": "^0.13.3",
"husky": "^0.14.3",
"jest": "^21.2.1",
"json-beautify": "^1.0.1",
"jsonwebtoken": "^7.3.0",
"lint-staged": "^3.4.0",
"lint-staged": "^4.2.3",
"mochify": "^3.3.0",
"prettier": "^1.2.2",
"prettier": "^1.7.4",
"react-test-renderer": "^16.0.0",
"semver": "^5.3.0",
"sinon": "^1.15.4",
Expand Down Expand Up @@ -128,6 +128,7 @@
"coverageReporters": ["lcov", "text-summary"]
},
"lint-staged": {
"*.{js,jsx}": ["npm run lint", "prettier --write --print-width 100 --single-quote", "git add"]
"*.{js,jsx}": ["npm run lint"],
"*.{js,jsx,json,html}": ["prettier --write --print-width 100 --single-quote", "git add"]
}
}
7 changes: 6 additions & 1 deletion src/__tests__/testUtils.js
Expand Up @@ -25,7 +25,12 @@ export const mockComponent = (type, domElement = 'div') => props =>
});

export const extractPropsFromWrapper = (wrapper, index = 0) =>
removeDataFromProps(wrapper.find('div').at(index).props());
removeDataFromProps(
wrapper
.find('div')
.at(index)
.props()
);

//set urls with jest: https://github.com/facebook/jest/issues/890#issuecomment-298594389
export const setURL = url => {
Expand Down
8 changes: 6 additions & 2 deletions src/connection/database/index.js
Expand Up @@ -101,7 +101,9 @@ function processDatabaseOptions(opts) {
) {
l.warn(
opts,
`Ignoring an element of \`additionalSignUpFields\` because it does not contain valid \`name\` property. Every element of \`additionalSignUpFields\` must be an object with a \`name\` property that is a non-empty string consisting of letters, numbers and underscores. The following names are reserved, and therefore, cannot be used: ${reservedNames.join(', ')}.`
`Ignoring an element of \`additionalSignUpFields\` because it does not contain valid \`name\` property. Every element of \`additionalSignUpFields\` must be an object with a \`name\` property that is a non-empty string consisting of letters, numbers and underscores. The following names are reserved, and therefore, cannot be used: ${reservedNames.join(
', '
)}.`
);
filter = false;
}
Expand Down Expand Up @@ -138,7 +140,9 @@ function processDatabaseOptions(opts) {
if (type != undefined && (typeof type != 'string' || types.indexOf(type) === -1)) {
l.warn(
opts,
`When provided, the \`type\` property of an element of \`additionalSignUpFields\` must be one of the following strings: "${types.join('", "')}".`
`When provided, the \`type\` property of an element of \`additionalSignUpFields\` must be one of the following strings: "${types.join(
'", "'
)}".`
);
type = undefined;
}
Expand Down
33 changes: 22 additions & 11 deletions src/connection/database/login_pane.jsx
Expand Up @@ -31,27 +31,31 @@ export default class LoginPane extends React.Component {
const header = headerText && <p>{headerText}</p>;

// Should never validate format on login because of custom db connection and import mode
const fieldPane = usernameStyle === 'email'
? <EmailPane
const fieldPane =
usernameStyle === 'email' ? (
<EmailPane
i18n={i18n}
lock={lock}
forceInvalidVisibility={!showPassword}
placeholder={emailInputPlaceholder}
/>
: <UsernamePane
) : (
<UsernamePane
i18n={i18n}
lock={lock}
placeholder={usernameInputPlaceholder}
usernameStyle={usernameStyle}
validateFormat={false}
/>;
/>
);

const passwordPane = showPassword
? <PasswordPane i18n={i18n} lock={lock} placeholder={passwordInputPlaceholder} />
: null;
const passwordPane = showPassword ? (
<PasswordPane i18n={i18n} lock={lock} placeholder={passwordInputPlaceholder} />
) : null;

const dontRememberPassword = showForgotPasswordLink && hasScreen(lock, 'forgotPassword')
? <p className="auth0-lock-alternative">
const dontRememberPassword =
showForgotPasswordLink && hasScreen(lock, 'forgotPassword') ? (
<p className="auth0-lock-alternative">
<a
className="auth0-lock-alternative-link"
href={forgotPasswordLink(lock, 'javascript:void(0)')}
Expand All @@ -60,9 +64,16 @@ export default class LoginPane extends React.Component {
{forgotPasswordAction}
</a>
</p>
: null;
) : null;

return <div>{header}{fieldPane}{passwordPane}{dontRememberPassword}</div>;
return (
<div>
{header}
{fieldPane}
{passwordPane}
{dontRememberPassword}
</div>
);
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/connection/database/mfa_pane.jsx
Expand Up @@ -13,7 +13,13 @@ export default class MFAPane extends React.Component {

const titleElement = title && <h2>{title}</h2>;

return <div>{titleElement}{header}{pane}</div>;
return (
<div>
{titleElement}
{header}
{pane}
</div>
);
}
}

Expand Down
18 changes: 10 additions & 8 deletions src/connection/database/sign_up_terms.jsx
@@ -1,14 +1,16 @@
import React from 'react';

const SignUpTerms = ({ checkHandler, checked, children }) => {
return checkHandler
? <span className="auth0-lock-sign-up-terms-agreement">
<label>
<input type="checkbox" onChange={checkHandler} checked={checked} />
{children}
</label>
</span>
: children;
return checkHandler ? (
<span className="auth0-lock-sign-up-terms-agreement">
<label>
<input type="checkbox" onChange={checkHandler} checked={checked} />
{children}
</label>
</span>
) : (
children
);
};

export default SignUpTerms;
21 changes: 12 additions & 9 deletions src/connection/passwordless/email_sent_confirmation.jsx
Expand Up @@ -27,21 +27,24 @@ class Resend extends React.Component {
render() {
const { labels, lock } = this.props;

const resendLink =
m.resendAvailable(lock) &&
const resendLink = m.resendAvailable(lock) && (
<ResendLink
onClick={::this.handleClick}
label={m.resendFailed(lock) ? labels.retry : labels.resend}
/>;
/>
);

const resendingLabel =
m.resendOngoing(lock) && <a className="auth0-lock-resend-link">{labels.resending}</a>;
const resendingLabel = m.resendOngoing(lock) && (
<a className="auth0-lock-resend-link">{labels.resending}</a>
);

const resendSuccessLabel =
m.resendSuccess(lock) && <span className="auth0-lock-sent-label">{labels.sent}</span>;
const resendSuccessLabel = m.resendSuccess(lock) && (
<span className="auth0-lock-sent-label">{labels.sent}</span>
);

const resendFailedLabel =
m.resendFailed(lock) && <span className="auth0-lock-sent-failed-label">{labels.failed}</span>;
const resendFailedLabel = m.resendFailed(lock) && (
<span className="auth0-lock-sent-failed-label">{labels.failed}</span>
);

return (
<span>
Expand Down
2 changes: 1 addition & 1 deletion src/connection/social/index.js
Expand Up @@ -25,7 +25,7 @@ export const STRATEGIES = {
linkedin: 'LinkedIn',
miicard: 'miiCard',
paypal: 'PayPal',
"paypal-sandbox": "PayPal Sandbox",
'paypal-sandbox': 'PayPal Sandbox',
planningcenter: 'Planning Center',
renren: '人人',
salesforce: 'Salesforce',
Expand Down
5 changes: 2 additions & 3 deletions src/core/client/index.js
Expand Up @@ -119,9 +119,8 @@ function formatClientConnection(connectionType, strategyName, connection) {
result.passwordPolicy = connection.passwordPolicy || 'none';
result.allowSignup = typeof connection.showSignup === 'boolean' ? connection.showSignup : true;
result.allowForgot = typeof connection.showForgot === 'boolean' ? connection.showForgot : true;
result.requireUsername = typeof connection.requires_username === 'boolean'
? connection.requires_username
: false;
result.requireUsername =
typeof connection.requires_username === 'boolean' ? connection.requires_username : false;
result.validation = formatConnectionValidation(connection.validation);
}

Expand Down
38 changes: 23 additions & 15 deletions src/core/index.js
Expand Up @@ -31,9 +31,8 @@ export function setup(id, clientID, domain, options, hookRunner, emitEventFn) {
hashCleanup: options.hashCleanup === false ? false : true,
allowedConnections: Immutable.fromJS(options.allowedConnections || []),
ui: extractUIOptions(id, options),
defaultADUsernameFromEmailPrefix: options.defaultADUsernameFromEmailPrefix === false
? false
: true,
defaultADUsernameFromEmailPrefix:
options.defaultADUsernameFromEmailPrefix === false ? false : true,
prefill: options.prefill || {},
connectionResolver: options.connectionResolver
})
Expand Down Expand Up @@ -167,9 +166,10 @@ function extractUIOptions(id, options) {
containerID: options.container || `auth0-lock-container-${id}`,
appendContainer: !options.container,
autoclose: undefined === options.autoclose ? false : closable && options.autoclose,
autofocus: undefined === options.autofocus
? !(options.container || isSmallScreen())
: !!options.autofocus,
autofocus:
undefined === options.autofocus
? !(options.container || isSmallScreen())
: !!options.autofocus,
avatar: avatar,
avatarProvider: avatarProvider,
logo: typeof logo === 'string' ? logo : undefined,
Expand All @@ -186,9 +186,10 @@ function extractUIOptions(id, options) {
allowAutocomplete: !!options.allowAutocomplete,
authButtonsTheme: typeof authButtons === 'object' ? authButtons : {},
allowShowPassword: !!options.allowShowPassword,
scrollGlobalMessagesIntoView: undefined === options.scrollGlobalMessagesIntoView
? true
: !!options.scrollGlobalMessagesIntoView
scrollGlobalMessagesIntoView:
undefined === options.scrollGlobalMessagesIntoView
? true
: !!options.scrollGlobalMessagesIntoView
});
}

Expand Down Expand Up @@ -249,7 +250,8 @@ function extractAuthOptions(options) {
sso,
state,
nonce
} = options.auth || {};
} =
options.auth || {};

let { oidcConformant } = options;

Expand Down Expand Up @@ -308,7 +310,9 @@ function extractAuthOptions(options) {
}

export function withAuthOptions(m, opts) {
return Immutable.fromJS(opts).merge(get(m, 'auth')).toJS();
return Immutable.fromJS(opts)
.merge(get(m, 'auth'))
.toJS();
}

function extractClientBaseUrlOption(opts, domain) {
Expand Down Expand Up @@ -357,9 +361,10 @@ export function extractTenantBaseUrlOption(opts, domain) {
var domain;

if (endsWith(hostname, DOT_AUTH0_DOT_COM)) {
domain = parts.length > 3
? 'https://cdn.' + parts[parts.length - 3] + DOT_AUTH0_DOT_COM
: AUTH0_US_CDN_URL;
domain =
parts.length > 3
? 'https://cdn.' + parts[parts.length - 3] + DOT_AUTH0_DOT_COM
: AUTH0_US_CDN_URL;

return urljoin(domain, 'tenants', 'v1', `${tenant_name}.js`);
} else {
Expand Down Expand Up @@ -423,7 +428,10 @@ export function allowedConnections(m) {

export function connections(m, type = undefined, ...strategies) {
if (arguments.length === 1) {
return tget(m, 'connections', Map()).filter((v, k) => k !== 'unknown').valueSeq().flatten(true);
return tget(m, 'connections', Map())
.filter((v, k) => k !== 'unknown')
.valueSeq()
.flatten(true);
}

const xs = tget(m, ['connections', type], List());
Expand Down
15 changes: 6 additions & 9 deletions src/core/tenant/index.js
Expand Up @@ -82,17 +82,14 @@ function formatTenantConnection(connectionType, connection) {

result.passwordPolicy = result.passwordPolicy || 'none';

result.allowSignup = typeof connection.allowSignup === 'boolean'
? connection.allowSignup
: true;
result.allowSignup =
typeof connection.allowSignup === 'boolean' ? connection.allowSignup : true;

result.allowForgot = typeof connection.allowForgot === 'boolean'
? connection.allowForgot
: true;
result.allowForgot =
typeof connection.allowForgot === 'boolean' ? connection.allowForgot : true;

result.requireUsername = typeof connection.requiresUsername === 'boolean'
? connection.requiresUsername
: false;
result.requireUsername =
typeof connection.requiresUsername === 'boolean' ? connection.requiresUsername : false;

result.validation = formatConnectionValidation(connection.validation);
}
Expand Down
8 changes: 6 additions & 2 deletions src/engine/classic.js
Expand Up @@ -94,14 +94,18 @@ function validateAllowedConnections(m) {
if (defaultDatabaseConnectionName(m) && !defaultDatabaseConnection(m)) {
l.warn(
m,
`The provided default database connection "${defaultDatabaseConnectionName(m)}" is not enabled.`
`The provided default database connection "${defaultDatabaseConnectionName(
m
)}" is not enabled.`
);
}

if (defaultEnterpriseConnectionName(m) && !defaultEnterpriseConnection(m)) {
l.warn(
m,
`The provided default enterprise connection "${defaultEnterpriseConnectionName(m)}" is not enabled or does not allow email/password authentication.`
`The provided default enterprise connection "${defaultEnterpriseConnectionName(
m
)}" is not enabled or does not allow email/password authentication.`
);
}

Expand Down

0 comments on commit 7d83f91

Please sign in to comment.