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

@@ -1,10 +1,5 @@
import Parse from 'parse/node';
import {
GraphQLSchema,
GraphQLObjectType,
DocumentNode,
GraphQLNamedType,
} from 'graphql';
import { GraphQLSchema, GraphQLObjectType, DocumentNode, GraphQLNamedType } from 'graphql';
import { stitchSchemas } from '@graphql-tools/stitch';
import { SchemaDirectiveVisitor } from '@graphql-tools/utils';
import requiredParameter from '../requiredParameter';
@@ -14,9 +9,7 @@ import * as parseClassQueries from './loaders/parseClassQueries';
import * as parseClassMutations from './loaders/parseClassMutations';
import * as defaultGraphQLQueries from './loaders/defaultGraphQLQueries';
import * as defaultGraphQLMutations from './loaders/defaultGraphQLMutations';
import ParseGraphQLController, {
ParseGraphQLConfig,
} from '../Controllers/ParseGraphQLController';
import ParseGraphQLController, { ParseGraphQLConfig } from '../Controllers/ParseGraphQLController';
import DatabaseController from '../Controllers/DatabaseController';
import { toGraphQLError } from './parseGraphQLUtils';
import * as schemaDirectives from './loaders/schemaDirectives';
@@ -72,12 +65,7 @@ class ParseGraphQLSchema {
parseGraphQLConfig: ParseGraphQLConfig;
log: any;
appId: string;
graphQLCustomTypeDefs: ?(
| string
| GraphQLSchema
| DocumentNode
| GraphQLNamedType[]
);
graphQLCustomTypeDefs: ?(string | GraphQLSchema | DocumentNode | GraphQLNamedType[]);
constructor(
params: {
@@ -85,12 +73,7 @@ class ParseGraphQLSchema {
parseGraphQLController: ParseGraphQLController,
log: any,
appId: string,
graphQLCustomTypeDefs: ?(
| string
| GraphQLSchema
| DocumentNode
| GraphQLNamedType[]
),
graphQLCustomTypeDefs: ?(string | GraphQLSchema | DocumentNode | GraphQLNamedType[]),
} = {}
) {
this.parseGraphQLController =
@@ -99,11 +82,9 @@ class ParseGraphQLSchema {
this.databaseController =
params.databaseController ||
requiredParameter('You must provide a databaseController instance!');
this.log =
params.log || requiredParameter('You must provide a log instance!');
this.log = params.log || requiredParameter('You must provide a log instance!');
this.graphQLCustomTypeDefs = params.graphQLCustomTypeDefs;
this.appId =
params.appId || requiredParameter('You must provide the appId!');
this.appId = params.appId || requiredParameter('You must provide the appId!');
}
async load() {
@@ -216,59 +197,45 @@ class ParseGraphQLSchema {
}
}
};
Object.values(customGraphQLSchemaTypeMap).forEach(
customGraphQLSchemaType => {
if (
!customGraphQLSchemaType ||
!customGraphQLSchemaType.name ||
customGraphQLSchemaType.name.startsWith('__')
) {
return;
}
const autoGraphQLSchemaType = this.graphQLAutoSchema.getType(
customGraphQLSchemaType.name
);
if (!autoGraphQLSchemaType) {
this.graphQLAutoSchema._typeMap[
customGraphQLSchemaType.name
] = customGraphQLSchemaType;
}
Object.values(customGraphQLSchemaTypeMap).forEach(customGraphQLSchemaType => {
if (
!customGraphQLSchemaType ||
!customGraphQLSchemaType.name ||
customGraphQLSchemaType.name.startsWith('__')
) {
return;
}
);
Object.values(customGraphQLSchemaTypeMap).forEach(
customGraphQLSchemaType => {
if (
!customGraphQLSchemaType ||
!customGraphQLSchemaType.name ||
customGraphQLSchemaType.name.startsWith('__')
) {
return;
}
const autoGraphQLSchemaType = this.graphQLAutoSchema.getType(
customGraphQLSchemaType.name
);
const autoGraphQLSchemaType = this.graphQLAutoSchema.getType(
customGraphQLSchemaType.name
);
if (!autoGraphQLSchemaType) {
this.graphQLAutoSchema._typeMap[customGraphQLSchemaType.name] = customGraphQLSchemaType;
}
});
Object.values(customGraphQLSchemaTypeMap).forEach(customGraphQLSchemaType => {
if (
!customGraphQLSchemaType ||
!customGraphQLSchemaType.name ||
customGraphQLSchemaType.name.startsWith('__')
) {
return;
}
const autoGraphQLSchemaType = this.graphQLAutoSchema.getType(
customGraphQLSchemaType.name
);
if (
autoGraphQLSchemaType &&
typeof customGraphQLSchemaType.getFields === 'function'
) {
Object.values(customGraphQLSchemaType.getFields()).forEach(
field => {
findAndReplaceLastType(field, 'type');
}
);
autoGraphQLSchemaType._fields = {
...autoGraphQLSchemaType.getFields(),
...customGraphQLSchemaType.getFields(),
};
}
if (autoGraphQLSchemaType && typeof customGraphQLSchemaType.getFields === 'function') {
Object.values(customGraphQLSchemaType.getFields()).forEach(field => {
findAndReplaceLastType(field, 'type');
});
autoGraphQLSchemaType._fields = {
...autoGraphQLSchemaType.getFields(),
...customGraphQLSchemaType.getFields(),
};
}
);
});
this.graphQLSchema = stitchSchemas({
schemas: [
this.graphQLSchemaDirectivesDefinitions,
this.graphQLAutoSchema,
],
schemas: [this.graphQLSchemaDirectivesDefinitions, this.graphQLAutoSchema],
mergeDirectives: true,
});
} else if (typeof this.graphQLCustomTypeDefs === 'function') {
@@ -300,20 +267,17 @@ class ParseGraphQLSchema {
);
if (graphQLCustomTypeDef) {
const graphQLSchemaTypeFieldMap = graphQLSchemaType.getFields();
Object.keys(graphQLSchemaTypeFieldMap).forEach(
graphQLSchemaTypeFieldName => {
const graphQLSchemaTypeField =
graphQLSchemaTypeFieldMap[graphQLSchemaTypeFieldName];
if (!graphQLSchemaTypeField.astNode) {
const astNode = graphQLCustomTypeDef.fields.find(
field => field.name.value === graphQLSchemaTypeFieldName
);
if (astNode) {
graphQLSchemaTypeField.astNode = astNode;
}
Object.keys(graphQLSchemaTypeFieldMap).forEach(graphQLSchemaTypeFieldName => {
const graphQLSchemaTypeField = graphQLSchemaTypeFieldMap[graphQLSchemaTypeFieldName];
if (!graphQLSchemaTypeField.astNode) {
const astNode = graphQLCustomTypeDef.fields.find(
field => field.name.value === graphQLSchemaTypeFieldName
);
if (astNode) {
graphQLSchemaTypeField.astNode = astNode;
}
}
);
});
}
}
});
@@ -329,12 +293,7 @@ class ParseGraphQLSchema {
return this.graphQLSchema;
}
addGraphQLType(
type,
throwError = false,
ignoreReserved = false,
ignoreConnection = false
) {
addGraphQLType(type, throwError = false, ignoreReserved = false, ignoreConnection = false) {
if (
(!ignoreReserved && RESERVED_GRAPHQL_TYPE_NAMES.includes(type.name)) ||
this.graphQLTypes.find(existingType => existingType.name === type.name) ||
@@ -351,12 +310,7 @@ class ParseGraphQLSchema {
return type;
}
addGraphQLQuery(
fieldName,
field,
throwError = false,
ignoreReserved = false
) {
addGraphQLQuery(fieldName, field, throwError = false, ignoreReserved = false) {
if (
(!ignoreReserved && RESERVED_GRAPHQL_QUERY_NAMES.includes(fieldName)) ||
this.graphQLQueries[fieldName]
@@ -372,15 +326,9 @@ class ParseGraphQLSchema {
return field;
}
addGraphQLMutation(
fieldName,
field,
throwError = false,
ignoreReserved = false
) {
addGraphQLMutation(fieldName, field, throwError = false, ignoreReserved = false) {
if (
(!ignoreReserved &&
RESERVED_GRAPHQL_MUTATION_NAMES.includes(fieldName)) ||
(!ignoreReserved && RESERVED_GRAPHQL_MUTATION_NAMES.includes(fieldName)) ||
this.graphQLMutations[fieldName]
) {
const message = `Mutation ${fieldName} could not be added to the auto schema because it collided with an existing field.`;
@@ -455,10 +403,7 @@ class ParseGraphQLSchema {
* that provide the parseClass along with
* its parseClassConfig where provided.
*/
_getParseClassesWithConfig(
parseClasses,
parseGraphQLConfig: ParseGraphQLConfig
) {
_getParseClassesWithConfig(parseClasses, parseGraphQLConfig: ParseGraphQLConfig) {
const { classConfigs } = parseGraphQLConfig;
// Make sures that the default classes and classes that
@@ -488,9 +433,7 @@ class ParseGraphQLSchema {
return parseClasses.sort(sortClasses).map(parseClass => {
let parseClassConfig;
if (classConfigs) {
parseClassConfig = classConfigs.find(
c => c.className === parseClass.className
);
parseClassConfig = classConfigs.find(c => c.className === parseClass.className);
}
return [parseClass, parseClassConfig];
});
@@ -521,16 +464,10 @@ class ParseGraphQLSchema {
parseGraphQLConfig: ?ParseGraphQLConfig,
functionNamesString: string,
}): boolean {
const {
parseClasses,
parseClassesString,
parseGraphQLConfig,
functionNamesString,
} = params;
const { parseClasses, parseClassesString, parseGraphQLConfig, functionNamesString } = params;
if (
JSON.stringify(this.parseGraphQLConfig) ===
JSON.stringify(parseGraphQLConfig) &&
JSON.stringify(this.parseGraphQLConfig) === JSON.stringify(parseGraphQLConfig) &&
this.functionNamesString === functionNamesString
) {
if (this.parseClasses === parseClasses) {