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

fix: remove source code for GraphQLESTreeNode #17

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@ const config: Config = {
preset: 'ts-jest',
testMatch: ['<rootDir>/test/**/*.ts'],
moduleFileExtensions: ['ts', 'js', 'json'],
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json'
}
},
testResultsProcessor: 'jest-sonar-reporter',
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/lib/', '<rootDir>/test/shared.ts'],
moduleDirectories: ['node_modules'],
collectCoverage: true,
collectCoverageFrom: ['src/**/*.ts', '!src/index.ts', '!src/configs/*.ts'],
coverageDirectory: 'reports/coverage',
moduleNameMapper: {
'^@graphql-eslint/eslint-plugin/(.*)$':
'<rootDir>/node_modules/@graphql-eslint/eslint-plugin/$1'
},
reporters: [
'default',
[
Expand Down
2 changes: 1 addition & 1 deletion src/rules/graphql/no-fiscal-date-filtering-supported.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ASTNode, Kind, ArgumentNode } from 'graphql';
import { GraphQLESLintRule, GraphQLESLintRuleContext } from '@graphql-eslint/eslint-plugin';
import { getDocUrl } from '../../util/rule-helpers';
import { getClosestAncestorByType } from '../../util/graphql-ast-utils';
import { GraphQLESTreeNode } from '../../util/types';
import { GraphQLESTreeNode } from '@graphql-eslint/eslint-plugin/estree-converter/types';
export const NO_FISCAL_DATE_FILTER_SUPPORTED_RULE_ID =
'offline-graphql-no-fiscal-date-filter-supported';

Expand Down
3 changes: 1 addition & 2 deletions src/rules/graphql/unsupported-scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export const SCOPE_SUPPORTED_FOR_CERTAIN_ENTITIES_ONLY = 'ASSIGNED_TO_ME__SERVIC
export const OTHER_UNSUPPORTED_SCOPE = 'OTHER_UNSUPPORTED_SCOPE';

import { getDocUrl } from '../../util/rule-helpers';

import { GraphQLESTreeNode } from '../../util/types';
import { GraphQLESTreeNode } from '@graphql-eslint/eslint-plugin/estree-converter/types';

// Record key is scope name, value is the array of supported entities. Empty array
// means that all entities are supported.
Expand Down
2 changes: 1 addition & 1 deletion src/util/entity-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { FieldNode } from 'graphql';
import { GraphQLESTreeNode } from './types';
import { GraphQLESTreeNode } from '@graphql-eslint/eslint-plugin/estree-converter/types';

import {
getEntityNodeForEdges,
Expand Down
4 changes: 2 additions & 2 deletions src/util/graphql-ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { Position } from 'estree';
import { AST } from 'eslint';
import { GraphQLESTreeNode, ParentNode } from './types';
import { GraphQLESTreeNode } from '@graphql-eslint/eslint-plugin/estree-converter/types';
import { ASTNode, FieldNode, Kind, DocumentNode, OperationDefinitionNode } from 'graphql';
import { DEFAULT_PAGE_SIZE } from './entity-stats';

Expand Down Expand Up @@ -41,7 +41,7 @@ export function getClosestAncestorByType<T extends ASTNode, W extends ASTNode>(
if (parentNode === null || parentNode === undefined) {
return undefined;
}
const astParentNode = parentNode as GraphQLESTreeNode<Exclude<ParentNode<T>, unknown>>;
const astParentNode = parentNode as any;
if (astParentNode.type === type) {
return astParentNode as GraphQLESTreeNode<W>;
}
Expand Down
169 changes: 0 additions & 169 deletions src/util/types.ts

This file was deleted.

3 changes: 2 additions & 1 deletion test/rules/graphql/entity-stats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { expect } from '@jest/globals';
import { FieldNode } from 'graphql';
import { GraphQLESTreeNode } from '../../../src/util/types';
// @ts-expect-error

Check failure on line 5 in test/rules/graphql/entity-stats.spec.ts

View workflow job for this annotation

GitHub Actions / Linting on Ubuntu with Node 18

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer

Check failure on line 5 in test/rules/graphql/entity-stats.spec.ts

View workflow job for this annotation

GitHub Actions / Linting on Ubuntu with Node 20

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer

Check failure on line 5 in test/rules/graphql/entity-stats.spec.ts

View workflow job for this annotation

GitHub Actions / Linting on Ubuntu with Node 18

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer

Check failure on line 5 in test/rules/graphql/entity-stats.spec.ts

View workflow job for this annotation

GitHub Actions / Linting on Ubuntu with Node 20

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer
import { GraphQLESTreeNode } from '@graphql-eslint/eslint-plugin/estree-converter/types';
import { mock } from 'jest-mock-extended';

import {
Expand Down
8 changes: 7 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@
"noUnusedLocals": true /* Enable error reporting when local variables aren't read. */,
"noUnusedParameters": true /* Raise an error when a function parameter isn't read. */,
"noImplicitReturns": true /* Enable error reporting for codepaths that do not explicitly return in a function. */,
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
"paths": {
/* TS complains not about to infer GraphQLESTreeNode */
"@graphql-eslint/eslint-plugin/estree-converter/*": [
"./node_modules/@graphql-eslint/eslint-plugin/cjs/estree-converter/*"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to point it out that using 'esm' instead of 'cjs' would not work. It would complain 'Could not find a declaration file'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look around bit more, lwc_mobile's "type" is "commonjs". graphql-eslint package.json has below.

"main": "cjs/index.js",  // for common.js
 "module": "esm/index.js",// for esm. 

commonjs consumer looks for commonjs dependency.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that was my intuition too. But this is a great start! I going to poke around a bit on my own with regards to our overall project configuration. I wish it wasn't quite so tenuous to configure TypeScript projects. 🙄

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I.e. I'm not sure if we need to be a "commonjs" type of project, vs. reconfiguring our transpilation and/or packaging. If I look at ten different projects, I see ten different approaches to project configurations for issues like these. I imagine someday I'm going to have to work myself from the ground floor of the ECMAScript and modules spec, up through TypeScript specs and consumption, to module bundlers, to fully grasp how this is all supposed to work. 😭

]
}
},
"include": ["src/**/*", "./package.json"]
}
Loading