Skip to content

Commit

Permalink
Merge pull request #151 from alecmev/tseslint-8
Browse files Browse the repository at this point in the history
Make compatible with typescript-eslint 8
  • Loading branch information
captbaritone authored Aug 27, 2024
2 parents f74143f + e37dd9f commit 24fd162
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 99 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
Expand All @@ -32,7 +32,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
node-version: 22.x
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
Expand All @@ -50,7 +50,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
node-version: 22.x
registry-url: https://registry.npmjs.org/
cache: 'yarn'
- name: Build latest (main) version
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"bracketSpacing": false,
"jsxBracketSameLine": true,
"bracketSameLine": true,
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"LICENSE"
],
"dependencies": {
"graphql": "^14.0.0 || ^15.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
},
"devDependencies": {
"@typescript-eslint/parser": "^5.4.0",
"@typescript-eslint/parser": "^6.21.0",
"babel-eslint": "^10.1.0",
"eslint": "^7.8.0",
"eslint-config-prettier": "^6.11.0",
Expand Down
32 changes: 16 additions & 16 deletions src/rule-generated-typescript-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,12 @@ function extractReadOnlyType(genericType) {
currentType != null &&
currentType.type === 'TSTypeReference' &&
currentType.id.name === '$ReadOnly' &&
currentType.typeParameters &&
currentType.typeParameters.type === 'TypeParameterInstantiation' &&
Array.isArray(currentType.typeParameters.params) &&
currentType.typeParameters.params.length === 1
currentType.typeArguments &&
currentType.typeArguments.type === 'TSTypeParameterInstantiation' &&
Array.isArray(currentType.typeArguments.params) &&
currentType.typeArguments.params.length === 1
) {
currentType = currentType.typeParameters.params[0];
currentType = currentType.typeArguments.params[0];
}
return currentType;
}
Expand Down Expand Up @@ -468,7 +468,7 @@ module.exports = {
/**
* Find useQuery() calls without type arguments.
*/
'CallExpression[callee.name=useQuery]:not([typeParameters])'(node) {
'CallExpression[callee.name=useQuery]:not([typeArguments])'(node) {
const firstArg = node.arguments[0];
if (firstArg == null) {
return;
Expand All @@ -491,7 +491,7 @@ module.exports = {
/**
* Find useLazyLoadQuery() calls without type arguments.
*/
'CallExpression[callee.name=useLazyLoadQuery]:not([typeParameters])'(
'CallExpression[callee.name=useLazyLoadQuery]:not([typeArguments])'(
node
) {
const firstArg = node.arguments[0];
Expand All @@ -516,7 +516,7 @@ module.exports = {
/**
* Find commitMutation() calls without type arguments.
*/
'CallExpression[callee.name=commitMutation]:not([typeParameters])'(node) {
'CallExpression[callee.name=commitMutation]:not([typeArguments])'(node) {
// Get mutation config. It should be second argument of the `commitMutation`
const mutationConfig = node.arguments && node.arguments[1];
if (
Expand Down Expand Up @@ -553,7 +553,7 @@ module.exports = {
/**
* Find requestSubscription() calls without type arguments.
*/
'CallExpression[callee.name=requestSubscription]:not([typeParameters])'(
'CallExpression[callee.name=requestSubscription]:not([typeArguments])'(
node
) {
const subscriptionConfig = node.arguments && node.arguments[1];
Expand Down Expand Up @@ -593,7 +593,7 @@ module.exports = {
/**
* Find useMutation() calls without type arguments.
*/
'CallExpression[callee.name=useMutation]:not([typeParameters])'(node) {
'CallExpression[callee.name=useMutation]:not([typeArguments])'(node) {
const queryName = getDefinitionName(node.arguments[0]);
context.report({
node,
Expand All @@ -610,7 +610,7 @@ module.exports = {
/**
* Find usePaginationFragment() calls without type arguments.
*/
'CallExpression[callee.name=usePaginationFragment]:not([typeParameters])'(
'CallExpression[callee.name=usePaginationFragment]:not([typeArguments])'(
node
) {
reportAndFixRefetchableType(
Expand All @@ -623,7 +623,7 @@ module.exports = {
/**
* Find useBlockingPaginationFragment() calls without type arguments.
*/
'CallExpression[callee.name=useBlockingPaginationFragment]:not([typeParameters])'(
'CallExpression[callee.name=useBlockingPaginationFragment]:not([typeArguments])'(
node
) {
reportAndFixRefetchableType(
Expand All @@ -636,7 +636,7 @@ module.exports = {
/**
* Find useLegacyPaginationFragment() calls without type arguments.
*/
'CallExpression[callee.name=useLegacyPaginationFragment]:not([typeParameters])'(
'CallExpression[callee.name=useLegacyPaginationFragment]:not([typeArguments])'(
node
) {
reportAndFixRefetchableType(
Expand All @@ -649,7 +649,7 @@ module.exports = {
/**
* Find useRefetchableFragment() calls without type arguments.
*/
'CallExpression[callee.name=useRefetchableFragment]:not([typeParameters])'(
'CallExpression[callee.name=useRefetchableFragment]:not([typeArguments])'(
node
) {
reportAndFixRefetchableType(
Expand Down Expand Up @@ -700,9 +700,9 @@ module.exports = {
Component: node.id
};
// new style React.Component accepts 'props' as the first parameter
if (node.superTypeParameters && node.superTypeParameters.params[0]) {
if (node.superTypeArguments && node.superTypeArguments.params[0]) {
componentMap[componentName].propType =
node.superTypeParameters.params[0];
node.superTypeArguments.params[0];
}
},
TaggedTemplateExpression(node) {
Expand Down
Loading

0 comments on commit 24fd162

Please sign in to comment.