Skip to content

Commit

Permalink
chore(deps): update dependency @theguild/eslint-config to v0.8.0 (#2244)
Browse files Browse the repository at this point in the history
* chore(deps): update dependency @theguild/eslint-config to v0.8.0

* fixes

* fixes

* fixes

* fixes

* prettier

* fixes

* yarn lock

* fixes

* prettier

* Update packages/core/src/coverage/index.ts

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com>
  • Loading branch information
renovate[bot] and dimaMachina authored Feb 7, 2023
1 parent 2fecab7 commit bd0cb29
Show file tree
Hide file tree
Showing 31 changed files with 512 additions and 358 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
{
files: ['**'],
rules: {
'simple-import-sort/imports': 'off',
'prefer-object-has-own': 'off', // enable in next major
// TODO: enable following rules
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
Expand All @@ -23,7 +23,6 @@ module.exports = {
'import/extensions': 'off',
'no-console': 'off',
'import/no-default-export': 'off',
'no-inner-declarations': 'off',
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { pathsToModuleNameMapper } = require('ts-jest/utils');
const ROOT_DIR = __dirname;
const TSCONFIG = resolve(ROOT_DIR, 'tsconfig.json');
const tsconfig = require(TSCONFIG);
const CI = Boolean(process.env.CI);
const CI = !!process.env.CI;

module.exports = {
transform: { '^.+\\.tsx?$': 'ts-jest' },
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
],
"scripts": {
"action": "ncc build packages/action/src/action.ts --out action --minify --transpile-only",
"build": "tsc --project tsconfig.json && bob build",
"build": "tsc && bob build",
"bundle": "webpack",
"lint": "eslint --cache --ignore-path .gitignore .",
"lint:prettier": "prettier --cache --check .",
Expand All @@ -50,7 +50,7 @@
"devDependencies": {
"@changesets/changelog-github": "0.4.8",
"@changesets/cli": "2.26.0",
"@theguild/eslint-config": "0.4.1",
"@theguild/eslint-config": "0.8.0",
"@theguild/prettier-config": "1.1.1",
"@types/body-parser": "1.19.2",
"@types/cors": "2.8.13",
Expand Down
1 change: 1 addition & 0 deletions packages/ci/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async function main() {
},
});

// eslint-disable-next-line @typescript-eslint/no-unused-expressions
commands
.reduce((cli, cmd) => cli.command(cmd), root)
.demandCommand()
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import config from '../../jest.config';

export default config;
export { default } from '../../jest.config';
1 change: 1 addition & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async function main() {
},
});

// eslint-disable-next-line @typescript-eslint/no-unused-expressions
commands
.reduce((cli, cmd) => cli.command(cmd), root)
.help()
Expand Down
2 changes: 1 addition & 1 deletion packages/commands/serve/src/fake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function fake(schema: GraphQLSchema): void {
context,
info,
);
if (!interfaceMockObj || !interfaceMockObj.__typename) {
if (!interfaceMockObj?.__typename) {
return Error(`Please return a __typename in "${fieldType.name}"`);
}
implementationType = schema.getType(interfaceMockObj.__typename);
Expand Down
66 changes: 33 additions & 33 deletions packages/commands/similar/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,45 +29,45 @@ export function handler({

if (!Object.keys(similarMap).length) {
Logger.info('No similar types found');
} else {
for (const typeName in similarMap) {
if (Object.prototype.hasOwnProperty.call(similarMap, typeName)) {
const matches = similarMap[typeName];
const prefix = getTypePrefix(schema.getType(typeName) as GraphQLNamedType);
const sourceType = chalk.bold(typeName);
const name = matches.bestMatch.target.typeId;

Logger.log('');
Logger.log(`${prefix} ${sourceType}`);
Logger.log(printResult(name, matches.bestMatch.rating));

matches.ratings.forEach(match => {
Logger.log(printResult(match.target.typeId, match.rating));
});
}
return;
}
for (const typeName in similarMap) {
if (Object.prototype.hasOwnProperty.call(similarMap, typeName)) {
const matches = similarMap[typeName];
const prefix = getTypePrefix(schema.getType(typeName) as GraphQLNamedType);
const sourceType = chalk.bold(typeName);
const name = matches.bestMatch.target.typeId;

Logger.log('');
Logger.log(`${prefix} ${sourceType}`);
Logger.log(printResult(name, matches.bestMatch.rating));

matches.ratings.forEach(match => {
Logger.log(printResult(match.target.typeId, match.rating));
});
}
}

if (shouldWrite) {
if (typeof writePath !== 'string') {
throw new Error(`--write is not valid file path: ${writePath}`);
}
if (shouldWrite) {
if (typeof writePath !== 'string') {
throw new Error(`--write is not valid file path: ${writePath}`);
}

const absPath = ensureAbsolute(writePath);
const ext = extname(absPath).replace('.', '').toLocaleLowerCase();
const absPath = ensureAbsolute(writePath);
const ext = extname(absPath).replace('.', '').toLocaleLowerCase();

let output: string | undefined = undefined;
const results = transformMap(similarMap);
let output: string | undefined = undefined;
const results = transformMap(similarMap);

if (ext === 'json') {
output = outputJSON(results);
}
if (ext === 'json') {
output = outputJSON(results);
}

if (output) {
writeFileSync(absPath, output, 'utf8');
Logger.success(`Available at ${absPath}\n`);
} else {
throw new Error(`Extension ${ext} is not supported`);
}
if (output) {
writeFileSync(absPath, output, 'utf8');
Logger.success(`Available at ${absPath}\n`);
} else {
throw new Error(`Extension ${ext} is not supported`);
}
}
}
Expand Down
98 changes: 49 additions & 49 deletions packages/commands/validate/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,57 +62,57 @@ export function handler({

if (!invalidDocuments.length) {
Logger.success('All documents are valid');
} else {
if (failOnDeprecated) {
invalidDocuments = moveDeprecatedToErrors(invalidDocuments);
}

if (relativePaths) {
invalidDocuments = useRelativePaths(invalidDocuments);
}
return;
}
if (failOnDeprecated) {
invalidDocuments = moveDeprecatedToErrors(invalidDocuments);
}

const errorsCount = countErrors(invalidDocuments);
const deprecated = countDeprecated(invalidDocuments);
const shouldFailProcess = errorsCount > 0;
if (relativePaths) {
invalidDocuments = useRelativePaths(invalidDocuments);
}

if (errorsCount) {
if (!silent) {
Logger.log(`\nDetected ${errorsCount} invalid document${errorsCount > 1 ? 's' : ''}:\n`);
}
const errorsCount = countErrors(invalidDocuments);
const deprecated = countDeprecated(invalidDocuments);
const shouldFailProcess = errorsCount > 0;

printInvalidDocuments(useFilter(invalidDocuments, filter), 'errors', true, silent);
} else {
Logger.success('All documents are valid');
if (errorsCount) {
if (!silent) {
Logger.log(`\nDetected ${errorsCount} invalid document${errorsCount > 1 ? 's' : ''}:\n`);
}

if (deprecated && !onlyErrors) {
if (!silent) {
Logger.info(
`\nDetected ${deprecated} document${deprecated > 1 ? 's' : ''} with deprecated fields:\n`,
);
}

printInvalidDocuments(useFilter(invalidDocuments, filter), 'deprecated', false, silent);
}
printInvalidDocuments(useFilter(invalidDocuments, filter), 'errors', true, silent);
} else {
Logger.success('All documents are valid');
}

if (output) {
writeFileSync(
output,
JSON.stringify(
{
status: !shouldFailProcess,
documents: useFilter(invalidDocuments, filter),
},
null,
2,
),
'utf8',
if (deprecated && !onlyErrors) {
if (!silent) {
Logger.info(
`\nDetected ${deprecated} document${deprecated > 1 ? 's' : ''} with deprecated fields:\n`,
);
}

if (shouldFailProcess) {
process.exit(1);
}
printInvalidDocuments(useFilter(invalidDocuments, filter), 'deprecated', false, silent);
}

if (output) {
writeFileSync(
output,
JSON.stringify(
{
status: !shouldFailProcess,
documents: useFilter(invalidDocuments, filter),
},
null,
2,
),
'utf8',
);
}

if (shouldFailProcess) {
process.exit(1);
}
}

Expand All @@ -132,7 +132,7 @@ function useRelativePaths(docs: InvalidDocument[]) {
}

function useFilter(docs: InvalidDocument[], patterns?: string[]) {
if (!patterns || !patterns.length) {
if (!patterns?.length) {
return docs;
}

Expand Down Expand Up @@ -252,10 +252,10 @@ export default createCommand<
const aws = args.aws || false;
const apolloFederation = args.federation || false;
const method = args.method?.toUpperCase() || 'POST';
const maxDepth = args.maxDepth != null ? args.maxDepth : undefined;
const maxAliasCount = args.maxAliasCount != null ? args.maxAliasCount : undefined;
const maxDirectiveCount = args.maxDirectiveCount != null ? args.maxDirectiveCount : undefined;
const maxTokenCount = args.maxTokenCount != null ? args.maxTokenCount : undefined;
const maxDepth = args.maxDepth == null ? undefined : args.maxDepth;
const maxAliasCount = args.maxAliasCount == null ? undefined : args.maxAliasCount;
const maxDirectiveCount = args.maxDirectiveCount == null ? undefined : args.maxDirectiveCount;
const maxTokenCount = args.maxTokenCount == null ? undefined : args.maxTokenCount;
const strictFragments = !args.noStrictFragments;
const keepClientFields = args.keepClientFields || false;
const failOnDeprecated = args.deprecated;
Expand Down Expand Up @@ -302,15 +302,15 @@ export default createCommand<

function countErrors(invalidDocuments: InvalidDocument[]): number {
if (invalidDocuments.length) {
return invalidDocuments.filter(doc => doc.errors && doc.errors.length).length;
return invalidDocuments.filter(doc => doc.errors?.length).length;
}

return 0;
}

function countDeprecated(invalidDocuments: InvalidDocument[]): number {
if (invalidDocuments.length) {
return invalidDocuments.filter(doc => doc.deprecated && doc.deprecated.length).length;
return invalidDocuments.filter(doc => doc.deprecated?.length).length;
}

return 0;
Expand Down
4 changes: 1 addition & 3 deletions packages/core/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import config from '../../jest.config';

export default config;
export { default } from '../../jest.config';
6 changes: 2 additions & 4 deletions packages/core/src/coverage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ export function coverage(schema: GraphQLSchema, sources: Source[]): SchemaCovera
const parent = typeInfo.getParentType();

if (
parent &&
parent.name &&
parent?.name &&
!isForIntrospection(parent.name) &&
fieldDef &&
fieldDef.name &&
fieldDef?.name &&
fieldDef.name !== '__typename' &&
fieldDef.name !== '__schema'
) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/diff/changes/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export function fieldArgumentAdded(
arg: GraphQLArgument,
): Change {
const isBreaking = isNonNullType(arg.type) && typeof arg.defaultValue === 'undefined';
const defaultValueMsg = typeof arg.defaultValue !== 'undefined' ? ' (with default value) ' : ' ';
const defaultValueMsg = typeof arg.defaultValue === 'undefined' ? ' ' : ' (with default value) ';

return {
criticality: isBreaking
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function safeChangeForInputValue(

export function getKind(type: GraphQLNamedType): KindEnum {
const node = type.astNode as any;
return (node && node.kind) || '';
return node?.kind || '';
}

export function getTypePrefix(type: GraphQLNamedType): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/validate/alias-count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function validateAliasCount({
`Too many aliases (${aliasCount}). Maximum allowed is ${maxAliasCount}`,
[definition],
source,
definition.loc && definition.loc.start ? [definition.loc.start] : undefined,
definition.loc?.start ? [definition.loc.start] : undefined,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/validate/complexity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function validateComplexity({
`Too high complexity score (${complexityScore}). Maximum allowed is ${maxComplexityScore}`,
[definition],
source,
definition.loc && definition.loc.start ? [definition.loc.start] : undefined,
definition.loc?.start ? [definition.loc.start] : undefined,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/validate/directive-count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function validateDirectiveCount({
`Too many directives (${directiveCount}). Maximum allowed is ${maxDirectiveCount}`,
[definition],
source,
definition.loc && definition.loc.start ? [definition.loc.start] : undefined,
definition.loc?.start ? [definition.loc.start] : undefined,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/validate/query-depth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function validateQueryDepth({
`Query exceeds maximum depth of ${maxDepth}`,
node,
source,
node.loc && node.loc.start ? [node.loc.start] : undefined,
node.loc?.start ? [node.loc.start] : undefined,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/validate/token-count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function validateTokenCount(args: {
`Query exceeds maximum token count of ${args.maxTokenCount} (actual: ${tokenCount})`,
args.document,
args.source,
args.document.loc && args.document.loc.start ? [args.document.loc.start] : undefined,
args.document.loc?.start ? [args.document.loc.start] : undefined,
);
}
}
4 changes: 1 addition & 3 deletions packages/github/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import config from '../../jest.config';

export default config;
export { default } from '../../jest.config';
Loading

0 comments on commit bd0cb29

Please # to comment.