Skip to content

Commit 6593482

Browse files
authored
[v4] drop support of Node.js 12/14/16, GraphQL 14/15 (#1793)
1 parent 804f8b6 commit 6593482

25 files changed

+342
-2043
lines changed

.changeset/rare-planes-love.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': major
3+
---
4+
5+
drop support of Node.js 12/14/16, GraphQL 14/15

.eslintrc.cjs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ module.exports = {
6969
node: true,
7070
},
7171
},
72-
{
73-
files: ['packages/plugin/src/**'],
74-
rules: {
75-
// remove in v4 major
76-
'unicorn/prefer-node-protocol': 'off',
77-
},
78-
},
7972
{
8073
files: ['packages/plugin/src/rules/index.ts'],
8174
rules: {

.github/workflows/tests.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ jobs:
3535
nodeVersion: 18
3636
packageManager: pnpm
3737

38-
- name: Use GraphQL v${{matrix.graphql_version}}
39-
run: node scripts/match-graphql.js ${{matrix.graphql_version}}
40-
41-
- name: Install Dependencies
42-
run: pnpm i --no-frozen-lockfile
43-
4438
- name: Build
4539
run: pnpm build
4640

@@ -51,8 +45,8 @@ jobs:
5145
needs: [typecheck]
5246
strategy:
5347
matrix:
54-
node_version: [16, 18, 20]
55-
graphql_version: [15, 16]
48+
node_version: [18, 20]
49+
graphql_version: [16]
5650

5751
steps:
5852
- name: Checkout Master
@@ -66,12 +60,6 @@ jobs:
6660
nodeVersion: ${{matrix.node_version}}
6761
packageManager: pnpm
6862

69-
- name: Use GraphQL v${{matrix.graphql_version}}
70-
run: node scripts/match-graphql.js ${{matrix.graphql_version}}
71-
72-
- name: Install Dependencies
73-
run: pnpm i --no-frozen-lockfile
74-
7563
- name: Test
7664
run: pnpm test
7765
env:

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@
5050
"typescript": "5.1.6",
5151
"vitest": "0.30.1"
5252
},
53-
"resolutions": {
54-
"graphql": "16.7.1"
55-
},
5653
"pnpm": {
5754
"patchedDependencies": {
5855

packages/plugin/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"author": "Dotan Simha <[email protected]>",
77
"license": "MIT",
88
"engines": {
9-
"node": ">=12"
9+
"node": ">=18"
1010
},
1111
"main": "dist/cjs/index.js",
1212
"module": "dist/esm/index.js",
@@ -39,7 +39,7 @@
3939
"test": "vitest"
4040
},
4141
"peerDependencies": {
42-
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
42+
"graphql": "^16"
4343
},
4444
"dependencies": {
4545
"@graphql-tools/code-file-loader": "^7.3.6",

packages/plugin/src/documents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { resolve } from 'path';
1+
import { resolve } from 'node:path';
22
import { Source } from '@graphql-tools/utils';
33
import debugFactory from 'debug';
44
import fg from 'fast-glob';

packages/plugin/src/estree-converter/utils.ts

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-var-requires */
21
import { AST } from 'eslint';
32
import { Comment, SourceLocation } from 'estree';
43
import {
@@ -25,40 +24,14 @@ export function getBaseType(type: GraphQLOutputType): GraphQLNamedType {
2524
return type;
2625
}
2726

28-
// Hardcoded type because tests fails on graphql 15
29-
type TokenKindValue =
30-
| ':'
31-
| '!'
32-
| '...'
33-
| '('
34-
| ')'
35-
| '['
36-
| ']'
37-
| '{'
38-
| '}'
39-
| '@'
40-
| '&'
41-
// | '<EOF>'
42-
| '<SOF>'
43-
| '='
44-
| '|'
45-
| '$'
46-
| 'BlockString'
47-
| 'Comment'
48-
| 'Float'
49-
| 'Int'
50-
| 'Name'
51-
| 'String';
52-
53-
export function convertToken<T extends TokenKindValue | 'Block' | 'Line'>(
27+
export function convertToken<T extends TokenKind | 'Block' | 'Line'>(
5428
token: Token,
5529
type: T,
5630
): Omit<AST.Token, 'type'> & { type: T } {
5731
const { line, column, end, start, value } = token;
5832
return {
5933
type,
60-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- TODO: remove `!` when drop support of graphql@15
61-
value: value!,
34+
value,
6235
/*
6336
* ESLint has 0-based column number
6437
* https://eslint.org/docs/developer-guide/working-with-rules#contextreport
@@ -77,25 +50,9 @@ export function convertToken<T extends TokenKindValue | 'Block' | 'Line'>(
7750
};
7851
}
7952

80-
function getLexer(source: Source): Lexer {
81-
// GraphQL v14
82-
const gqlLanguage = require('graphql/language');
83-
if (gqlLanguage?.createLexer) {
84-
return gqlLanguage.createLexer(source, {});
85-
}
86-
87-
// GraphQL v15
88-
const { Lexer: LexerCls } = require('graphql');
89-
if (LexerCls && typeof LexerCls === 'function') {
90-
return new LexerCls(source);
91-
}
92-
93-
throw new Error('Unsupported GraphQL version! Please make sure to use GraphQL v14 or newer!');
94-
}
95-
9653
export function extractTokens(filePath: string, code: string): AST.Token[] {
9754
const source = new Source(code, filePath);
98-
const lexer = getLexer(source);
55+
const lexer = new Lexer(source);
9956
const tokens: AST.Token[] = [];
10057
let token = lexer.advance();
10158

@@ -120,8 +77,7 @@ export function extractComments(loc?: Location): Comment[] {
12077
const comment = convertToken(
12178
token,
12279
// `eslint-disable` directive works only with `Block` type comment
123-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- TODO: remove `!` when drop support of graphql@15
124-
token.value!.trimStart().startsWith('eslint') ? 'Block' : 'Line',
80+
token.value.trimStart().startsWith('eslint') ? 'Block' : 'Line',
12581
);
12682
comments.push(comment);
12783
}

packages/plugin/src/graphql-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { dirname } from 'path';
1+
import { dirname } from 'node:path';
22
import { CodeFileLoader } from '@graphql-tools/code-file-loader';
33
import debugFactory from 'debug';
44
import {

packages/plugin/src/processor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { relative } from 'path';
1+
import { relative } from 'node:path';
22
import {
33
gqlPluckFromCodeStringSync,
44
GraphQLTagPluckOptions,

0 commit comments

Comments
 (0)