Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework: Use Prettier #12479

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
8 changes: 6 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
root: true,
'extends': 'wpcalypso/react',
'extends': [
'wpcalypso/react',
'prettier',
'prettier/react'
],
parser: 'babel-eslint',
env: {
browser: true,
Expand All @@ -17,4 +21,4 @@ module.exports = {
'no-restricted-modules': [ 2, 'lib/sites-list', 'lib/mixins/data-observe' ],
'no-unused-expressions': 0, // Allows Chai `expect` expressions
}
};
};
6 changes: 6 additions & 0 deletions bin/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ fi

pass=true

printf "\nFormatting .jsx and .js:\n"

for file in ${files}; do
./bin/prettify-file.sh ${file}
done

printf "\nValidating .jsx and .js:\n"

./bin/run-lint $(git diff --cached --name-only client/ server/ test/ | grep ".jsx*$") -- --diff=index
Expand Down
15 changes: 15 additions & 0 deletions bin/prettify-file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

file="$1"
printf $file
if [[ ! $file =~ ^client/[^\.]+\.jsx?$ ]]; then
printf "\nNot a prettifiable file\n"
exit 0
fi

if [ ! -f ./node_modules/.bin/prettier ]; then
printf "\n'Prettier' not found, please run 'npm install' first\n"
exit 1
fi

./node_modules/.bin/prettier --print-width=100 --single-quote --tab-width=4 --trailing-comma=es5 --write ${file}
96 changes: 48 additions & 48 deletions client/account-recovery/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,73 +17,73 @@ import TransactionIdForm from 'account-recovery/reset-password/transaction-id-fo
import ResetPasswordConfirmForm from 'account-recovery/reset-password/reset-password-confirm-form';
import { getCurrentUser } from 'state/current-user/selectors';

export function lostPassword( context, next ) {
context.primary = <LostPasswordPage basePath={ context.path } />;
next();
export function lostPassword(context, next) {
context.primary = <LostPasswordPage basePath={context.path} />;
next();
}

export function forgotUsername( context, next ) {
context.primary = <ForgotUsernamePage basePath={ context.path } />;
next();
export function forgotUsername(context, next) {
context.primary = <ForgotUsernamePage basePath={context.path} />;
next();
}

export function resetPassword( context, next ) {
context.primary = (
<ResetPasswordPage basePath={ context.path }>
<ResetPasswordForm />
</ResetPasswordPage>
);
export function resetPassword(context, next) {
context.primary = (
<ResetPasswordPage basePath={context.path}>
<ResetPasswordForm />
</ResetPasswordPage>
);

next();
next();
}

export function resetPasswordSmsForm( context, next ) {
context.primary = (
<ResetPasswordPage basePath={ context.path }>
<ResetPasswordSmsForm />
</ResetPasswordPage>
);
export function resetPasswordSmsForm(context, next) {
context.primary = (
<ResetPasswordPage basePath={context.path}>
<ResetPasswordSmsForm />
</ResetPasswordPage>
);

next();
next();
}

export function resetPasswordEmailForm( context, next ) {
context.primary = (
<ResetPasswordPage basePath={ context.path }>
<ResetPasswordEmailForm />
</ResetPasswordPage>
);
export function resetPasswordEmailForm(context, next) {
context.primary = (
<ResetPasswordPage basePath={context.path}>
<ResetPasswordEmailForm />
</ResetPasswordPage>
);

next();
next();
}

export function resetPasswordByTransactionId( context, next ) {
context.primary = (
<ResetPasswordPage basePath={ context.path }>
<TransactionIdForm />
</ResetPasswordPage>
);
export function resetPasswordByTransactionId(context, next) {
context.primary = (
<ResetPasswordPage basePath={context.path}>
<TransactionIdForm />
</ResetPasswordPage>
);

next();
next();
}

export function resetPasswordConfirmForm( context, next ) {
context.primary = (
<ResetPasswordPage basePath={ context.path }>
<ResetPasswordConfirmForm />
</ResetPasswordPage>
);
export function resetPasswordConfirmForm(context, next) {
context.primary = (
<ResetPasswordPage basePath={context.path}>
<ResetPasswordConfirmForm />
</ResetPasswordPage>
);

next();
next();
}

export function redirectLoggedIn( context, next ) {
const currentUser = getCurrentUser( context.store.getState() );
export function redirectLoggedIn(context, next) {
const currentUser = getCurrentUser(context.store.getState());

if ( currentUser ) {
page.redirect( '/' );
return;
}
if (currentUser) {
page.redirect('/');
return;
}

next();
next();
}
Loading