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

@@ -15,31 +15,16 @@ var triggers = require('./triggers');
function checkTriggers(className, config, types) {
return types.some(triggerType => {
return triggers.getTrigger(
className,
triggers.Types[triggerType],
config.applicationId
);
return triggers.getTrigger(className, triggers.Types[triggerType], config.applicationId);
});
}
function checkLiveQuery(className, config) {
return (
config.liveQueryController &&
config.liveQueryController.hasLiveQuery(className)
);
return config.liveQueryController && config.liveQueryController.hasLiveQuery(className);
}
// Returns a promise for an object with optional keys 'results' and 'count'.
function find(
config,
auth,
className,
restWhere,
restOptions,
clientSDK,
context
) {
function find(config, auth, className, restWhere, restOptions, clientSDK, context) {
enforceRoleSecurity('find', className, auth);
return triggers
.maybeRunQueryTrigger(
@@ -54,28 +39,13 @@ function find(
.then(result => {
restWhere = result.restWhere || restWhere;
restOptions = result.restOptions || restOptions;
const query = new RestQuery(
config,
auth,
className,
restWhere,
restOptions,
clientSDK
);
const query = new RestQuery(config, auth, className, restWhere, restOptions, clientSDK);
return query.execute();
});
}
// get is just like find but only queries an objectId.
const get = (
config,
auth,
className,
objectId,
restOptions,
clientSDK,
context
) => {
const get = (config, auth, className, objectId, restOptions, clientSDK, context) => {
var restWhere = { objectId };
enforceRoleSecurity('get', className, auth);
return triggers
@@ -92,14 +62,7 @@ const get = (
.then(result => {
restWhere = result.restWhere || restWhere;
restOptions = result.restOptions || restOptions;
const query = new RestQuery(
config,
auth,
className,
restWhere,
restOptions,
clientSDK
);
const query = new RestQuery(config, auth, className, restWhere, restOptions, clientSDK);
return query.execute();
});
};
@@ -111,10 +74,7 @@ function del(config, auth, className, objectId, context) {
}
if (className === '_User' && auth.isUnauthenticated()) {
throw new Parse.Error(
Parse.Error.SESSION_MISSING,
'Insufficient auth to delete user'
);
throw new Parse.Error(Parse.Error.SESSION_MISSING, 'Insufficient auth to delete user');
}
enforceRoleSecurity('delete', className, auth);
@@ -124,10 +84,7 @@ function del(config, auth, className, objectId, context) {
return Promise.resolve()
.then(() => {
const hasTriggers = checkTriggers(className, config, [
'beforeDelete',
'afterDelete',
]);
const hasTriggers = checkTriggers(className, config, ['beforeDelete', 'afterDelete']);
const hasLiveQuery = checkLiveQuery(className, config);
if (hasTriggers || hasLiveQuery || className == '_Session') {
return new RestQuery(config, auth, className, { objectId })
@@ -138,10 +95,7 @@ function del(config, auth, className, objectId, context) {
firstResult.className = className;
if (className === '_Session' && !auth.isMaster) {
if (!auth.user || firstResult.user.objectId !== auth.user.id) {
throw new Parse.Error(
Parse.Error.INVALID_SESSION_TOKEN,
'Invalid session token'
);
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid session token');
}
}
var cacheAdapter = config.cacheController;
@@ -156,10 +110,7 @@ function del(config, auth, className, objectId, context) {
context
);
}
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Object not found for delete.'
);
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Object not found for delete.');
});
}
return Promise.resolve({});
@@ -195,12 +146,7 @@ function del(config, auth, className, objectId, context) {
.then(() => {
// Notify LiveQuery server if possible
const perms = schemaController.getClassLevelPermissions(className);
config.liveQueryController.onAfterDelete(
className,
inflatedObject,
null,
perms
);
config.liveQueryController.onAfterDelete(className, inflatedObject, null, perms);
return triggers.maybeRunTrigger(
triggers.Types.afterDelete,
auth,
@@ -218,39 +164,19 @@ function del(config, auth, className, objectId, context) {
// Returns a promise for a {response, status, location} object.
function create(config, auth, className, restObject, clientSDK, context) {
enforceRoleSecurity('create', className, auth);
var write = new RestWrite(
config,
auth,
className,
null,
restObject,
null,
clientSDK,
context
);
var write = new RestWrite(config, auth, className, null, restObject, null, clientSDK, context);
return write.execute();
}
// Returns a promise that contains the fields of the update that the
// REST API is supposed to return.
// Usually, this is just updatedAt.
function update(
config,
auth,
className,
restWhere,
restObject,
clientSDK,
context
) {
function update(config, auth, className, restWhere, restObject, clientSDK, context) {
enforceRoleSecurity('update', className, auth);
return Promise.resolve()
.then(() => {
const hasTriggers = checkTriggers(className, config, [
'beforeSave',
'afterSave',
]);
const hasTriggers = checkTriggers(className, config, ['beforeSave', 'afterSave']);
const hasLiveQuery = checkLiveQuery(className, config);
if (hasTriggers || hasLiveQuery) {
// Do not use find, as it runs the before finds
@@ -292,11 +218,7 @@ function update(
function handleSessionMissingError(error, className, auth) {
// If we're trying to update a user without / with bad session token
if (
className === '_User' &&
error.code === Parse.Error.OBJECT_NOT_FOUND &&
!auth.isMaster
) {
if (className === '_User' && error.code === Parse.Error.OBJECT_NOT_FOUND && !auth.isMaster) {
throw new Parse.Error(Parse.Error.SESSION_MISSING, 'Insufficient auth.');
}
throw error;
@@ -326,10 +248,7 @@ function enforceRoleSecurity(method, className, auth) {
}
// readOnly masterKey is not allowed
if (
auth.isReadOnly &&
(method === 'delete' || method === 'create' || method === 'update')
) {
if (auth.isReadOnly && (method === 'delete' || method === 'create' || method === 'update')) {
const error = `read-only masterKey isn't allowed to perform the ${method} operation.`;
throw new Parse.Error(Parse.Error.OPERATION_FORBIDDEN, error);
}