fix(prettier): Properly handle lint-stage files (#6970)

Now handles top level files and recursive files in folders.

Set max line length to be 100
This commit is contained in:
Diamond Lewis
2020-10-25 15:06:58 -05:00
committed by GitHub
parent c2f2281e6d
commit e6ac3b6932
178 changed files with 5585 additions and 10688 deletions

View File

@@ -50,26 +50,17 @@ export class UsersRouter extends ClassesRouter {
// TODO: use the right error codes / descriptions.
if (!username && !email) {
throw new Parse.Error(
Parse.Error.USERNAME_MISSING,
'username/email is required.'
);
throw new Parse.Error(Parse.Error.USERNAME_MISSING, 'username/email is required.');
}
if (!password) {
throw new Parse.Error(
Parse.Error.PASSWORD_MISSING,
'password is required.'
);
throw new Parse.Error(Parse.Error.PASSWORD_MISSING, 'password is required.');
}
if (
typeof password !== 'string' ||
(email && typeof email !== 'string') ||
(username && typeof username !== 'string')
) {
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Invalid username/password.'
);
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Invalid username/password.');
}
let user;
@@ -86,10 +77,7 @@ export class UsersRouter extends ClassesRouter {
.find('_User', query)
.then(results => {
if (!results.length) {
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Invalid username/password.'
);
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Invalid username/password.');
}
if (results.length > 1) {
@@ -111,34 +99,21 @@ export class UsersRouter extends ClassesRouter {
})
.then(() => {
if (!isValidPassword) {
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Invalid username/password.'
);
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Invalid username/password.');
}
// Ensure the user isn't locked out
// A locked out user won't be able to login
// To lock a user out, just set the ACL to `masterKey` only ({}).
// Empty ACL is OK
if (
!req.auth.isMaster &&
user.ACL &&
Object.keys(user.ACL).length == 0
) {
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Invalid username/password.'
);
if (!req.auth.isMaster && user.ACL && Object.keys(user.ACL).length == 0) {
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Invalid username/password.');
}
if (
req.config.verifyUserEmails &&
req.config.preventLoginWithUnverifiedEmail &&
!user.emailVerified
) {
throw new Parse.Error(
Parse.Error.EMAIL_NOT_FOUND,
'User email is not verified.'
);
throw new Parse.Error(Parse.Error.EMAIL_NOT_FOUND, 'User email is not verified.');
}
delete user.password;
@@ -166,10 +141,7 @@ export class UsersRouter extends ClassesRouter {
handleMe(req) {
if (!req.info || !req.info.sessionToken) {
throw new Parse.Error(
Parse.Error.INVALID_SESSION_TOKEN,
'Invalid session token'
);
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid session token');
}
const sessionToken = req.info.sessionToken;
return rest
@@ -183,15 +155,8 @@ export class UsersRouter extends ClassesRouter {
req.info.context
)
.then(response => {
if (
!response.results ||
response.results.length == 0 ||
!response.results[0].user
) {
throw new Parse.Error(
Parse.Error.INVALID_SESSION_TOKEN,
'Invalid session token'
);
if (!response.results || response.results.length == 0 || !response.results[0].user) {
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid session token');
} else {
const user = response.results[0].user;
// Send token back on the login, because SDKs expect that.
@@ -228,8 +193,7 @@ export class UsersRouter extends ClassesRouter {
}
// Calculate the expiry time.
const expiresAt = new Date(
changedAt.getTime() +
86400000 * req.config.passwordPolicy.maxPasswordAge
changedAt.getTime() + 86400000 * req.config.passwordPolicy.maxPasswordAge
);
if (expiresAt < new Date())
// fail of current time is past password expiry time
@@ -267,9 +231,7 @@ export class UsersRouter extends ClassesRouter {
await createSession();
const afterLoginUser = Parse.User.fromJSON(
Object.assign({ className: '_User' }, user)
);
const afterLoginUser = Parse.User.fromJSON(Object.assign({ className: '_User' }, user));
maybeRunTrigger(
TriggerTypes.afterLogin,
{ ...req.auth, user: afterLoginUser },
@@ -345,8 +307,7 @@ export class UsersRouter extends ClassesRouter {
emailAdapter: req.config.userController.adapter,
appName: req.config.appName,
publicServerURL: req.config.publicServerURL,
emailVerifyTokenValidityDuration:
req.config.emailVerifyTokenValidityDuration,
emailVerifyTokenValidityDuration: req.config.emailVerifyTokenValidityDuration,
});
} catch (e) {
if (typeof e === 'string') {
@@ -366,10 +327,7 @@ export class UsersRouter extends ClassesRouter {
const { email } = req.body;
if (!email) {
throw new Parse.Error(
Parse.Error.EMAIL_MISSING,
'you must provide an email'
);
throw new Parse.Error(Parse.Error.EMAIL_MISSING, 'you must provide an email');
}
if (typeof email !== 'string') {
throw new Parse.Error(
@@ -403,10 +361,7 @@ export class UsersRouter extends ClassesRouter {
const { email } = req.body;
if (!email) {
throw new Parse.Error(
Parse.Error.EMAIL_MISSING,
'you must provide an email'
);
throw new Parse.Error(Parse.Error.EMAIL_MISSING, 'you must provide an email');
}
if (typeof email !== 'string') {
throw new Parse.Error(
@@ -417,10 +372,7 @@ export class UsersRouter extends ClassesRouter {
return req.config.database.find('_User', { email: email }).then(results => {
if (!results.length || results.length < 1) {
throw new Parse.Error(
Parse.Error.EMAIL_NOT_FOUND,
`No user found with email ${email}`
);
throw new Parse.Error(Parse.Error.EMAIL_NOT_FOUND, `No user found with email ${email}`);
}
const user = results[0];
@@ -428,10 +380,7 @@ export class UsersRouter extends ClassesRouter {
delete user.password;
if (user.emailVerified) {
throw new Parse.Error(
Parse.Error.OTHER_CAUSE,
`Email ${email} is already verified.`
);
throw new Parse.Error(Parse.Error.OTHER_CAUSE, `Email ${email} is already verified.`);
}
const userController = req.config.userController;