@graphql-eslint/eslint-plugin 4.0.0-alpha-20230801163310-8bc4340 → 4.0.0-alpha-20230810160036-304c2c0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/cjs/cache.js +10 -19
- package/cjs/configs/index.d.ts +42 -16
- package/cjs/configs/index.js +10 -19
- package/cjs/configs/operations-all.d.ts +4 -3
- package/cjs/configs/operations-all.js +5 -4
- package/cjs/configs/operations-recommended.d.ts +3 -1
- package/cjs/configs/operations-recommended.js +3 -1
- package/cjs/configs/schema-all.d.ts +6 -1
- package/cjs/configs/schema-all.js +5 -2
- package/cjs/configs/schema-recommended.d.ts +19 -1
- package/cjs/configs/schema-recommended.js +22 -2
- package/cjs/documents.js +17 -32
- package/cjs/estree-converter/converter.js +14 -27
- package/cjs/estree-converter/index.js +4 -7
- package/cjs/estree-converter/types.js +3 -5
- package/cjs/estree-converter/utils.d.ts +2 -3
- package/cjs/estree-converter/utils.js +15 -45
- package/cjs/flat-configs.d.ts +59 -12
- package/cjs/flat-configs.js +9 -14
- package/cjs/graphql-config.d.ts +4 -3
- package/cjs/graphql-config.js +23 -44
- package/cjs/index.d.ts +10 -4
- package/cjs/index.js +8 -16
- package/cjs/parser.d.ts +4 -3
- package/cjs/parser.js +38 -45
- package/cjs/processor.d.ts +5 -1
- package/cjs/processor.js +25 -57
- package/cjs/rules/alphabetize.d.ts +6 -16
- package/cjs/rules/alphabetize.js +60 -132
- package/cjs/rules/description-style.d.ts +4 -3
- package/cjs/rules/description-style.js +11 -18
- package/cjs/rules/graphql-js-validation.d.ts +4 -3
- package/cjs/rules/graphql-js-validation.js +151 -225
- package/cjs/rules/index.d.ts +15 -13
- package/cjs/rules/index.js +8 -45
- package/cjs/rules/input-name.d.ts +4 -3
- package/cjs/rules/input-name.js +43 -59
- package/cjs/rules/lone-executable-definition.d.ts +6 -5
- package/cjs/rules/lone-executable-definition.js +14 -28
- package/cjs/rules/match-document-filename.d.ts +4 -3
- package/cjs/rules/match-document-filename.js +39 -70
- package/cjs/rules/naming-convention.d.ts +4 -3
- package/cjs/rules/naming-convention.js +56 -74
- package/cjs/rules/no-anonymous-operations.d.ts +4 -3
- package/cjs/rules/no-anonymous-operations.js +11 -18
- package/cjs/rules/no-deprecated.d.ts +4 -3
- package/cjs/rules/no-deprecated.js +15 -29
- package/cjs/rules/no-duplicate-fields.d.ts +4 -3
- package/cjs/rules/no-duplicate-fields.js +13 -23
- package/cjs/rules/no-hashtag-description.d.ts +4 -3
- package/cjs/rules/no-hashtag-description.js +16 -29
- package/cjs/rules/no-one-place-fragments.d.ts +4 -3
- package/cjs/rules/no-one-place-fragments.js +17 -29
- package/cjs/rules/no-root-type.d.ts +4 -3
- package/cjs/rules/no-root-type.js +15 -25
- package/cjs/rules/no-scalar-result-type-on-mutation.d.ts +4 -3
- package/cjs/rules/no-scalar-result-type-on-mutation.js +18 -30
- package/cjs/rules/no-typename-prefix.d.ts +4 -3
- package/cjs/rules/no-typename-prefix.js +26 -33
- package/cjs/rules/no-unreachable-types.d.ts +4 -3
- package/cjs/rules/no-unreachable-types.js +25 -47
- package/cjs/rules/no-unused-fields.d.ts +4 -3
- package/cjs/rules/no-unused-fields.js +24 -49
- package/cjs/rules/relay-arguments.d.ts +4 -3
- package/cjs/rules/relay-arguments.js +20 -43
- package/cjs/rules/relay-connection-types.d.ts +4 -3
- package/cjs/rules/relay-connection-types.js +14 -45
- package/cjs/rules/relay-edge-types.d.ts +4 -3
- package/cjs/rules/relay-edge-types.js +48 -99
- package/cjs/rules/relay-page-info.d.ts +4 -3
- package/cjs/rules/relay-page-info.js +21 -44
- package/cjs/rules/require-deprecation-date.d.ts +4 -3
- package/cjs/rules/require-deprecation-date.js +15 -31
- package/cjs/rules/require-deprecation-reason.d.ts +4 -3
- package/cjs/rules/require-deprecation-reason.js +12 -20
- package/cjs/rules/require-description.d.ts +4 -3
- package/cjs/rules/require-description.js +39 -65
- package/cjs/rules/require-field-of-type-query-in-mutation-result.d.ts +4 -3
- package/cjs/rules/require-field-of-type-query-in-mutation-result.js +16 -31
- package/cjs/rules/require-import-fragment.d.ts +4 -3
- package/cjs/rules/require-import-fragment.js +22 -40
- package/cjs/rules/require-nullable-fields-with-oneof.d.ts +4 -3
- package/cjs/rules/require-nullable-fields-with-oneof.js +11 -22
- package/cjs/rules/require-nullable-result-in-root.d.ts +4 -3
- package/cjs/rules/require-nullable-result-in-root.js +34 -44
- package/cjs/rules/{require-id-when-available.d.ts → require-selections.d.ts} +4 -3
- package/cjs/rules/require-selections.js +198 -0
- package/cjs/rules/require-type-pattern-with-oneof.d.ts +4 -3
- package/cjs/rules/require-type-pattern-with-oneof.js +15 -23
- package/cjs/rules/selection-set-depth.d.ts +4 -3
- package/cjs/rules/selection-set-depth.js +18 -34
- package/cjs/rules/strict-id-in-types.d.ts +4 -3
- package/cjs/rules/strict-id-in-types.js +25 -43
- package/cjs/rules/{no-case-insensitive-enum-values-duplicates.d.ts → unique-enum-value-names.d.ts} +4 -3
- package/cjs/rules/{no-case-insensitive-enum-values-duplicates.js → unique-enum-value-names.js} +16 -21
- package/cjs/rules/unique-fragment-name.d.ts +3 -2
- package/cjs/rules/unique-fragment-name.js +24 -36
- package/cjs/rules/unique-operation-name.d.ts +4 -3
- package/cjs/rules/unique-operation-name.js +10 -12
- package/cjs/schema.d.ts +4 -3
- package/cjs/schema.js +14 -27
- package/cjs/siblings.d.ts +24 -8
- package/cjs/siblings.js +42 -82
- package/cjs/types.d.ts +74 -7
- package/cjs/types.js +3 -5
- package/cjs/utils.d.ts +3 -2
- package/cjs/utils.js +27 -44
- package/esm/cache.js +4 -8
- package/esm/{chunk-BMTV3EA2.js → chunk-U3TKCM4X.js} +1 -1
- package/esm/configs/index.d.mts +42 -16
- package/esm/configs/index.js +4 -4
- package/esm/configs/operations-all.d.mts +4 -3
- package/esm/configs/operations-all.js +6 -5
- package/esm/configs/operations-recommended.d.mts +3 -1
- package/esm/configs/operations-recommended.js +4 -2
- package/esm/configs/schema-all.d.mts +6 -1
- package/esm/configs/schema-all.js +6 -3
- package/esm/configs/schema-recommended.d.mts +19 -1
- package/esm/configs/schema-recommended.js +23 -3
- package/esm/configs/{relay.js → schema-relay.js} +4 -4
- package/esm/documents.js +10 -17
- package/esm/estree-converter/converter.js +9 -18
- package/esm/estree-converter/utils.d.mts +2 -3
- package/esm/estree-converter/utils.js +11 -38
- package/esm/flat-configs.d.mts +59 -12
- package/esm/flat-configs.js +4 -5
- package/esm/graphql-config.d.mts +4 -3
- package/esm/graphql-config.js +18 -34
- package/esm/index.d.mts +10 -4
- package/esm/index.js +1 -1
- package/esm/parser.d.mts +4 -3
- package/esm/parser.js +33 -27
- package/esm/processor.d.mts +5 -1
- package/esm/processor.js +21 -46
- package/esm/rules/alphabetize.d.mts +6 -16
- package/esm/rules/alphabetize.js +53 -118
- package/esm/rules/description-style.d.mts +4 -3
- package/esm/rules/description-style.js +7 -11
- package/esm/rules/graphql-js-validation.d.mts +4 -3
- package/esm/rules/graphql-js-validation.js +178 -218
- package/esm/rules/index.d.mts +15 -13
- package/esm/rules/index.js +5 -5
- package/esm/rules/input-name.d.mts +4 -3
- package/esm/rules/input-name.js +39 -52
- package/esm/rules/lone-executable-definition.d.mts +6 -5
- package/esm/rules/lone-executable-definition.js +10 -20
- package/esm/rules/match-document-filename.d.mts +4 -3
- package/esm/rules/match-document-filename.js +35 -61
- package/esm/rules/naming-convention.d.mts +4 -3
- package/esm/rules/naming-convention.js +51 -65
- package/esm/rules/no-anonymous-operations.d.mts +4 -3
- package/esm/rules/no-anonymous-operations.js +6 -9
- package/esm/rules/no-deprecated.d.mts +4 -3
- package/esm/rules/no-deprecated.js +10 -20
- package/esm/rules/no-duplicate-fields.d.mts +4 -3
- package/esm/rules/no-duplicate-fields.js +9 -16
- package/esm/rules/no-hashtag-description.d.mts +4 -3
- package/esm/rules/no-hashtag-description.js +11 -20
- package/esm/rules/no-one-place-fragments.d.mts +4 -3
- package/esm/rules/no-one-place-fragments.js +12 -19
- package/esm/rules/no-root-type.d.mts +4 -3
- package/esm/rules/no-root-type.js +11 -18
- package/esm/rules/no-scalar-result-type-on-mutation.d.mts +4 -3
- package/esm/rules/no-scalar-result-type-on-mutation.js +13 -21
- package/esm/rules/no-typename-prefix.d.mts +4 -3
- package/esm/rules/no-typename-prefix.js +22 -26
- package/esm/rules/no-unreachable-types.d.mts +4 -3
- package/esm/rules/no-unreachable-types.js +18 -33
- package/esm/rules/no-unused-fields.d.mts +4 -3
- package/esm/rules/no-unused-fields.js +19 -40
- package/esm/rules/relay-arguments.d.mts +4 -3
- package/esm/rules/relay-arguments.js +15 -34
- package/esm/rules/relay-connection-types.d.mts +4 -3
- package/esm/rules/relay-connection-types.js +10 -38
- package/esm/rules/relay-edge-types.d.mts +4 -3
- package/esm/rules/relay-edge-types.js +43 -89
- package/esm/rules/relay-page-info.d.mts +4 -3
- package/esm/rules/relay-page-info.js +16 -34
- package/esm/rules/require-deprecation-date.d.mts +4 -3
- package/esm/rules/require-deprecation-date.js +10 -22
- package/esm/rules/require-deprecation-reason.d.mts +4 -3
- package/esm/rules/require-deprecation-reason.js +7 -11
- package/esm/rules/require-description.d.mts +4 -3
- package/esm/rules/require-description.js +34 -55
- package/esm/rules/require-field-of-type-query-in-mutation-result.d.mts +4 -3
- package/esm/rules/require-field-of-type-query-in-mutation-result.js +11 -22
- package/esm/rules/require-import-fragment.d.mts +4 -3
- package/esm/rules/require-import-fragment.js +14 -26
- package/esm/rules/require-nullable-fields-with-oneof.d.mts +4 -3
- package/esm/rules/require-nullable-fields-with-oneof.js +6 -13
- package/esm/rules/require-nullable-result-in-root.d.mts +4 -3
- package/esm/rules/require-nullable-result-in-root.js +29 -35
- package/esm/rules/{require-id-when-available.d.mts → require-selections.d.mts} +4 -3
- package/esm/rules/{require-id-when-available.js → require-selections.js} +43 -80
- package/esm/rules/require-type-pattern-with-oneof.d.mts +4 -3
- package/esm/rules/require-type-pattern-with-oneof.js +11 -16
- package/esm/rules/selection-set-depth.d.mts +4 -3
- package/esm/rules/selection-set-depth.js +11 -20
- package/esm/rules/strict-id-in-types.d.mts +4 -3
- package/esm/rules/strict-id-in-types.js +20 -34
- package/esm/rules/{no-case-insensitive-enum-values-duplicates.d.mts → unique-enum-value-names.d.mts} +4 -3
- package/esm/rules/{no-case-insensitive-enum-values-duplicates.js → unique-enum-value-names.js} +8 -9
- package/esm/rules/unique-fragment-name.d.mts +3 -2
- package/esm/rules/unique-fragment-name.js +20 -27
- package/esm/rules/unique-operation-name.d.mts +4 -3
- package/esm/rules/unique-operation-name.js +6 -5
- package/esm/schema.d.mts +4 -3
- package/esm/schema.js +7 -12
- package/esm/siblings.d.mts +24 -8
- package/esm/siblings.js +37 -73
- package/esm/types.d.mts +74 -7
- package/esm/utils.d.mts +3 -2
- package/esm/utils.js +20 -31
- package/index.browser.mjs +5323 -0
- package/package.json +8 -13
- package/cjs/rules/require-id-when-available.js +0 -241
- package/cjs/types-8d5f4ae0.d.ts +0 -107
- package/esm/types-ace77d86.d.ts +0 -107
- /package/cjs/configs/{relay.d.ts → schema-relay.d.ts} +0 -0
- /package/cjs/configs/{relay.js → schema-relay.js} +0 -0
- /package/esm/configs/{relay.d.mts → schema-relay.d.mts} +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
import "../chunk-
|
1
|
+
import "../chunk-U3TKCM4X.js";
|
2
2
|
import {
|
3
3
|
Kind,
|
4
4
|
TypeInfo,
|
@@ -7,16 +7,14 @@ import {
|
|
7
7
|
} from "graphql";
|
8
8
|
import { convertLocation } from "./utils.js";
|
9
9
|
function convertToESTree(node, schema) {
|
10
|
-
const typeInfo = schema && new TypeInfo(schema)
|
11
|
-
const visitor = {
|
10
|
+
const typeInfo = schema && new TypeInfo(schema), visitor = {
|
12
11
|
leave(node2, key, parent) {
|
13
12
|
const leadingComments = "description" in node2 && node2.description ? [
|
14
13
|
{
|
15
14
|
type: node2.description.block ? "Block" : "Line",
|
16
15
|
value: node2.description.value
|
17
16
|
}
|
18
|
-
] : []
|
19
|
-
const calculatedTypeInfo = typeInfo ? {
|
17
|
+
] : [], calculatedTypeInfo = typeInfo ? {
|
20
18
|
argument: typeInfo.getArgument(),
|
21
19
|
defaultValue: typeInfo.getDefaultValue(),
|
22
20
|
directive: typeInfo.getDirective(),
|
@@ -26,19 +24,12 @@ function convertToESTree(node, schema) {
|
|
26
24
|
parentInputType: typeInfo.getParentInputType(),
|
27
25
|
parentType: typeInfo.getParentType(),
|
28
26
|
gqlType: typeInfo.getType()
|
29
|
-
} : {}
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
...node2,
|
36
|
-
definitions: node2.definitions.map(
|
37
|
-
(definition) => definition.rawNode()
|
38
|
-
)
|
39
|
-
} : node2;
|
40
|
-
};
|
41
|
-
const commonFields = {
|
27
|
+
} : {}, rawNode = () => parent && key !== void 0 ? parent[key] : node2.kind === Kind.DOCUMENT ? {
|
28
|
+
...node2,
|
29
|
+
definitions: node2.definitions.map(
|
30
|
+
(definition) => definition.rawNode()
|
31
|
+
)
|
32
|
+
} : node2, commonFields = {
|
42
33
|
...node2,
|
43
34
|
type: node2.kind,
|
44
35
|
loc: convertLocation(node2.loc),
|
@@ -1,14 +1,13 @@
|
|
1
1
|
import * as graphql_jsutils_Maybe from 'graphql/jsutils/Maybe';
|
2
2
|
import * as graphql_jsutils_ObjMap from 'graphql/jsutils/ObjMap';
|
3
3
|
import * as graphql from 'graphql';
|
4
|
-
import { GraphQLOutputType, GraphQLNamedType, Token, Location } from 'graphql';
|
4
|
+
import { GraphQLOutputType, GraphQLNamedType, TokenKind, Token, Location } from 'graphql';
|
5
5
|
import { AST } from 'eslint';
|
6
6
|
import { Comment, SourceLocation } from 'estree';
|
7
7
|
|
8
8
|
declare const valueFromNode: (valueNode: graphql.ValueNode, variables?: graphql_jsutils_Maybe.Maybe<graphql_jsutils_ObjMap.ObjMap<unknown>>) => any;
|
9
9
|
declare function getBaseType(type: GraphQLOutputType): GraphQLNamedType;
|
10
|
-
|
11
|
-
declare function convertToken<T extends TokenKindValue | 'Block' | 'Line'>(token: Token, type: T): Omit<AST.Token, 'type'> & {
|
10
|
+
declare function convertToken<T extends TokenKind | 'Block' | 'Line'>(token: Token, type: T): Omit<AST.Token, 'type'> & {
|
12
11
|
type: T;
|
13
12
|
};
|
14
13
|
declare function extractTokens(filePath: string, code: string): AST.Token[];
|
@@ -1,27 +1,20 @@
|
|
1
|
-
import
|
2
|
-
const require = createRequire(import.meta.url);
|
3
|
-
import "../chunk-BMTV3EA2.js";
|
1
|
+
import "../chunk-U3TKCM4X.js";
|
4
2
|
import {
|
5
3
|
isListType,
|
6
4
|
isNonNullType,
|
5
|
+
Lexer,
|
7
6
|
Source,
|
8
7
|
TokenKind
|
9
8
|
} from "graphql";
|
10
9
|
import { valueFromASTUntyped } from "graphql/utilities/valueFromASTUntyped.js";
|
11
|
-
const valueFromNode = (...args) =>
|
12
|
-
return valueFromASTUntyped(...args);
|
13
|
-
};
|
10
|
+
const valueFromNode = (...args) => valueFromASTUntyped(...args);
|
14
11
|
function getBaseType(type) {
|
15
|
-
|
16
|
-
return getBaseType(type.ofType);
|
17
|
-
}
|
18
|
-
return type;
|
12
|
+
return isNonNullType(type) || isListType(type) ? getBaseType(type.ofType) : type;
|
19
13
|
}
|
20
14
|
function convertToken(token, type) {
|
21
15
|
const { line, column, end, start, value } = token;
|
22
16
|
return {
|
23
17
|
type,
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- TODO: remove `!` when drop support of graphql@15
|
25
18
|
value,
|
26
19
|
/*
|
27
20
|
* ESLint has 0-based column number
|
@@ -40,41 +33,25 @@ function convertToken(token, type) {
|
|
40
33
|
range: [start, end]
|
41
34
|
};
|
42
35
|
}
|
43
|
-
function getLexer(source) {
|
44
|
-
const gqlLanguage = require("graphql/language");
|
45
|
-
if (gqlLanguage == null ? void 0 : gqlLanguage.createLexer) {
|
46
|
-
return gqlLanguage.createLexer(source, {});
|
47
|
-
}
|
48
|
-
const { Lexer: LexerCls } = require("graphql");
|
49
|
-
if (LexerCls && typeof LexerCls === "function") {
|
50
|
-
return new LexerCls(source);
|
51
|
-
}
|
52
|
-
throw new Error("Unsupported GraphQL version! Please make sure to use GraphQL v14 or newer!");
|
53
|
-
}
|
54
36
|
function extractTokens(filePath, code) {
|
55
|
-
const source = new Source(code, filePath);
|
56
|
-
const lexer = getLexer(source);
|
57
|
-
const tokens = [];
|
37
|
+
const source = new Source(code, filePath), lexer = new Lexer(source), tokens = [];
|
58
38
|
let token = lexer.advance();
|
59
|
-
|
39
|
+
for (; token && token.kind !== TokenKind.EOF; ) {
|
60
40
|
const result = convertToken(token, token.kind);
|
61
|
-
tokens.push(result);
|
62
|
-
token = lexer.advance();
|
41
|
+
tokens.push(result), token = lexer.advance();
|
63
42
|
}
|
64
43
|
return tokens;
|
65
44
|
}
|
66
45
|
function extractComments(loc) {
|
67
|
-
if (!loc)
|
46
|
+
if (!loc)
|
68
47
|
return [];
|
69
|
-
}
|
70
48
|
const comments = [];
|
71
49
|
let token = loc.startToken;
|
72
|
-
|
50
|
+
for (; token; ) {
|
73
51
|
if (token.kind === TokenKind.COMMENT) {
|
74
52
|
const comment = convertToken(
|
75
53
|
token,
|
76
54
|
// `eslint-disable` directive works only with `Block` type comment
|
77
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- TODO: remove `!` when drop support of graphql@15
|
78
55
|
token.value.trimStart().startsWith("eslint") ? "Block" : "Line"
|
79
56
|
);
|
80
57
|
comments.push(comment);
|
@@ -84,8 +61,7 @@ function extractComments(loc) {
|
|
84
61
|
return comments;
|
85
62
|
}
|
86
63
|
function convertLocation(location) {
|
87
|
-
const { startToken, endToken, source, start, end } = location
|
88
|
-
const loc = {
|
64
|
+
const { startToken, endToken, source, start, end } = location, loc = {
|
89
65
|
start: {
|
90
66
|
/*
|
91
67
|
* Kind.Document has startToken: { line: 0, column: 0 }, we set line as 1 and column as 0
|
@@ -99,10 +75,7 @@ function convertLocation(location) {
|
|
99
75
|
},
|
100
76
|
source: source.body
|
101
77
|
};
|
102
|
-
|
103
|
-
loc.end.column += end - start;
|
104
|
-
}
|
105
|
-
return loc;
|
78
|
+
return loc.start.column === loc.end.column && (loc.end.column += end - start), loc;
|
106
79
|
}
|
107
80
|
export {
|
108
81
|
convertLocation,
|
package/esm/flat-configs.d.mts
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
import { parseForESLint } from './parser.mjs';
|
2
|
-
import './types
|
3
|
-
import '@graphql-tools/utils';
|
2
|
+
import './types.mjs';
|
4
3
|
import 'eslint';
|
5
4
|
import 'estree';
|
6
5
|
import 'graphql';
|
7
|
-
import 'graphql-config';
|
8
6
|
import 'json-schema-to-ts';
|
7
|
+
import './siblings.mjs';
|
8
|
+
import '@graphql-tools/utils';
|
9
9
|
import './estree-converter/types.mjs';
|
10
|
+
import 'graphql-config';
|
10
11
|
|
11
12
|
declare const flatConfigs: {
|
12
13
|
'operations-all': {
|
@@ -17,9 +18,11 @@ declare const flatConfigs: {
|
|
17
18
|
};
|
18
19
|
rules: {
|
19
20
|
'@graphql-eslint/alphabetize': (string | {
|
21
|
+
definitions: boolean;
|
20
22
|
selections: string[];
|
21
|
-
variables:
|
23
|
+
variables: boolean;
|
22
24
|
arguments: string[];
|
25
|
+
groups: string[];
|
23
26
|
})[];
|
24
27
|
'@graphql-eslint/lone-executable-definition': string;
|
25
28
|
'@graphql-eslint/match-document-filename': (string | {
|
@@ -29,8 +32,7 @@ declare const flatConfigs: {
|
|
29
32
|
fragment: string;
|
30
33
|
})[];
|
31
34
|
'@graphql-eslint/no-one-place-fragments': string;
|
32
|
-
'@graphql-eslint/
|
33
|
-
'@graphql-eslint/unique-operation-name': string;
|
35
|
+
'@graphql-eslint/require-import-fragment': string;
|
34
36
|
'@graphql-eslint/executable-definitions': string;
|
35
37
|
'@graphql-eslint/fields-on-correct-type': string;
|
36
38
|
'@graphql-eslint/fragments-on-composite-type': string;
|
@@ -63,14 +65,16 @@ declare const flatConfigs: {
|
|
63
65
|
'@graphql-eslint/overlapping-fields-can-be-merged': string;
|
64
66
|
'@graphql-eslint/possible-fragment-spread': string;
|
65
67
|
'@graphql-eslint/provided-required-arguments': string;
|
66
|
-
'@graphql-eslint/require-
|
68
|
+
'@graphql-eslint/require-selections': string;
|
67
69
|
'@graphql-eslint/scalar-leafs': string;
|
68
70
|
'@graphql-eslint/selection-set-depth': (string | {
|
69
71
|
maxDepth: number;
|
70
72
|
})[];
|
71
73
|
'@graphql-eslint/unique-argument-names': string;
|
72
74
|
'@graphql-eslint/unique-directive-names-per-location': string;
|
75
|
+
'@graphql-eslint/unique-fragment-name': string;
|
73
76
|
'@graphql-eslint/unique-input-field-names': string;
|
77
|
+
'@graphql-eslint/unique-operation-name': string;
|
74
78
|
'@graphql-eslint/unique-variable-names': string;
|
75
79
|
'@graphql-eslint/value-literals-of-correct-type': string;
|
76
80
|
'@graphql-eslint/variables-are-input-types': string;
|
@@ -116,21 +120,23 @@ declare const flatConfigs: {
|
|
116
120
|
'@graphql-eslint/overlapping-fields-can-be-merged': string;
|
117
121
|
'@graphql-eslint/possible-fragment-spread': string;
|
118
122
|
'@graphql-eslint/provided-required-arguments': string;
|
119
|
-
'@graphql-eslint/require-
|
123
|
+
'@graphql-eslint/require-selections': string;
|
120
124
|
'@graphql-eslint/scalar-leafs': string;
|
121
125
|
'@graphql-eslint/selection-set-depth': (string | {
|
122
126
|
maxDepth: number;
|
123
127
|
})[];
|
124
128
|
'@graphql-eslint/unique-argument-names': string;
|
125
129
|
'@graphql-eslint/unique-directive-names-per-location': string;
|
130
|
+
'@graphql-eslint/unique-fragment-name': string;
|
126
131
|
'@graphql-eslint/unique-input-field-names': string;
|
132
|
+
'@graphql-eslint/unique-operation-name': string;
|
127
133
|
'@graphql-eslint/unique-variable-names': string;
|
128
134
|
'@graphql-eslint/value-literals-of-correct-type': string;
|
129
135
|
'@graphql-eslint/variables-are-input-types': string;
|
130
136
|
'@graphql-eslint/variables-in-allowed-position': string;
|
131
137
|
};
|
132
138
|
};
|
133
|
-
relay: {
|
139
|
+
'schema-relay': {
|
134
140
|
languageOptions: {
|
135
141
|
parser: {
|
136
142
|
parseForESLint: typeof parseForESLint;
|
@@ -151,11 +157,16 @@ declare const flatConfigs: {
|
|
151
157
|
};
|
152
158
|
rules: {
|
153
159
|
'@graphql-eslint/alphabetize': (string | {
|
160
|
+
definitions: boolean;
|
154
161
|
fields: string[];
|
155
|
-
values:
|
162
|
+
values: boolean;
|
156
163
|
arguments: string[];
|
164
|
+
groups: string[];
|
157
165
|
})[];
|
158
166
|
'@graphql-eslint/input-name': string;
|
167
|
+
'@graphql-eslint/no-root-type': (string | {
|
168
|
+
disallow: string[];
|
169
|
+
})[];
|
159
170
|
'@graphql-eslint/no-scalar-result-type-on-mutation': string;
|
160
171
|
'@graphql-eslint/require-deprecation-date': string;
|
161
172
|
'@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
|
@@ -186,20 +197,38 @@ declare const flatConfigs: {
|
|
186
197
|
forbiddenPrefixes: string[];
|
187
198
|
forbiddenSuffixes: string[];
|
188
199
|
};
|
200
|
+
'EnumTypeDefinition,EnumTypeExtension': {
|
201
|
+
forbiddenPrefixes: string[];
|
202
|
+
forbiddenSuffixes: string[];
|
203
|
+
};
|
204
|
+
'InterfaceTypeDefinition,InterfaceTypeExtension': {
|
205
|
+
forbiddenPrefixes: string[];
|
206
|
+
forbiddenSuffixes: string[];
|
207
|
+
};
|
208
|
+
'UnionTypeDefinition,UnionTypeExtension': {
|
209
|
+
forbiddenPrefixes: string[];
|
210
|
+
forbiddenSuffixes: string[];
|
211
|
+
};
|
212
|
+
'ObjectTypeDefinition,ObjectTypeExtension': {
|
213
|
+
forbiddenPrefixes: string[];
|
214
|
+
forbiddenSuffixes: string[];
|
215
|
+
};
|
189
216
|
})[];
|
190
|
-
'@graphql-eslint/no-case-insensitive-enum-values-duplicates': string;
|
191
217
|
'@graphql-eslint/no-hashtag-description': string;
|
192
218
|
'@graphql-eslint/no-typename-prefix': string;
|
193
219
|
'@graphql-eslint/no-unreachable-types': string;
|
220
|
+
'@graphql-eslint/possible-type-extension': string;
|
194
221
|
'@graphql-eslint/provided-required-arguments': string;
|
195
222
|
'@graphql-eslint/require-deprecation-reason': string;
|
196
223
|
'@graphql-eslint/require-description': (string | {
|
197
224
|
types: boolean;
|
198
225
|
DirectiveDefinition: boolean;
|
226
|
+
rootField: boolean;
|
199
227
|
})[];
|
200
228
|
'@graphql-eslint/strict-id-in-types': string;
|
201
229
|
'@graphql-eslint/unique-directive-names': string;
|
202
230
|
'@graphql-eslint/unique-directive-names-per-location': string;
|
231
|
+
'@graphql-eslint/unique-enum-value-names': string;
|
203
232
|
'@graphql-eslint/unique-field-definition-names': string;
|
204
233
|
'@graphql-eslint/unique-operation-types': string;
|
205
234
|
'@graphql-eslint/unique-type-names': string;
|
@@ -236,20 +265,38 @@ declare const flatConfigs: {
|
|
236
265
|
forbiddenPrefixes: string[];
|
237
266
|
forbiddenSuffixes: string[];
|
238
267
|
};
|
268
|
+
'EnumTypeDefinition,EnumTypeExtension': {
|
269
|
+
forbiddenPrefixes: string[];
|
270
|
+
forbiddenSuffixes: string[];
|
271
|
+
};
|
272
|
+
'InterfaceTypeDefinition,InterfaceTypeExtension': {
|
273
|
+
forbiddenPrefixes: string[];
|
274
|
+
forbiddenSuffixes: string[];
|
275
|
+
};
|
276
|
+
'UnionTypeDefinition,UnionTypeExtension': {
|
277
|
+
forbiddenPrefixes: string[];
|
278
|
+
forbiddenSuffixes: string[];
|
279
|
+
};
|
280
|
+
'ObjectTypeDefinition,ObjectTypeExtension': {
|
281
|
+
forbiddenPrefixes: string[];
|
282
|
+
forbiddenSuffixes: string[];
|
283
|
+
};
|
239
284
|
})[];
|
240
|
-
'@graphql-eslint/no-case-insensitive-enum-values-duplicates': string;
|
241
285
|
'@graphql-eslint/no-hashtag-description': string;
|
242
286
|
'@graphql-eslint/no-typename-prefix': string;
|
243
287
|
'@graphql-eslint/no-unreachable-types': string;
|
288
|
+
'@graphql-eslint/possible-type-extension': string;
|
244
289
|
'@graphql-eslint/provided-required-arguments': string;
|
245
290
|
'@graphql-eslint/require-deprecation-reason': string;
|
246
291
|
'@graphql-eslint/require-description': (string | {
|
247
292
|
types: boolean;
|
248
293
|
DirectiveDefinition: boolean;
|
294
|
+
rootField: boolean;
|
249
295
|
})[];
|
250
296
|
'@graphql-eslint/strict-id-in-types': string;
|
251
297
|
'@graphql-eslint/unique-directive-names': string;
|
252
298
|
'@graphql-eslint/unique-directive-names-per-location': string;
|
299
|
+
'@graphql-eslint/unique-enum-value-names': string;
|
253
300
|
'@graphql-eslint/unique-field-definition-names': string;
|
254
301
|
'@graphql-eslint/unique-operation-types': string;
|
255
302
|
'@graphql-eslint/unique-type-names': string;
|
package/esm/flat-configs.js
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
import "./chunk-
|
1
|
+
import "./chunk-U3TKCM4X.js";
|
2
2
|
import { configs } from "./configs/index.js";
|
3
3
|
import { parseForESLint } from "./parser.js";
|
4
4
|
const languageOptions = {
|
5
5
|
parser: { parseForESLint }
|
6
|
-
}
|
7
|
-
const flatConfigs = {
|
6
|
+
}, flatConfigs = {
|
8
7
|
"operations-all": {
|
9
8
|
languageOptions,
|
10
9
|
rules: {
|
@@ -16,9 +15,9 @@ const flatConfigs = {
|
|
16
15
|
languageOptions,
|
17
16
|
rules: configs["operations-recommended"].rules
|
18
17
|
},
|
19
|
-
relay: {
|
18
|
+
"schema-relay": {
|
20
19
|
languageOptions,
|
21
|
-
rules: configs
|
20
|
+
rules: configs["schema-relay"].rules
|
22
21
|
},
|
23
22
|
"schema-all": {
|
24
23
|
languageOptions,
|
package/esm/graphql-config.d.mts
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
import { GraphQLConfig } from 'graphql-config';
|
2
|
-
import {
|
3
|
-
import '@graphql-tools/utils';
|
2
|
+
import { ParserOptions } from './types.mjs';
|
4
3
|
import 'eslint';
|
5
4
|
import 'estree';
|
6
5
|
import 'graphql';
|
7
6
|
import 'json-schema-to-ts';
|
7
|
+
import './siblings.mjs';
|
8
|
+
import '@graphql-tools/utils';
|
8
9
|
import './estree-converter/types.mjs';
|
9
10
|
|
10
11
|
declare function loadOnDiskGraphQLConfig(filePath: string): GraphQLConfig;
|
11
|
-
declare function loadGraphQLConfig(
|
12
|
+
declare function loadGraphQLConfig({ graphQLConfig: config, filePath, }: ParserOptions): GraphQLConfig;
|
12
13
|
|
13
14
|
export { loadGraphQLConfig, loadOnDiskGraphQLConfig };
|
package/esm/graphql-config.js
CHANGED
@@ -1,53 +1,37 @@
|
|
1
|
-
import "./chunk-
|
2
|
-
import
|
1
|
+
import "./chunk-U3TKCM4X.js";
|
2
|
+
import path from "node:path";
|
3
3
|
import { CodeFileLoader } from "@graphql-tools/code-file-loader";
|
4
4
|
import debugFactory from "debug";
|
5
|
-
import {
|
6
|
-
GraphQLConfig,
|
7
|
-
loadConfigSync
|
8
|
-
} from "graphql-config";
|
5
|
+
import { GraphQLConfig, loadConfigSync } from "graphql-config";
|
9
6
|
const debug = debugFactory("graphql-eslint:graphql-config");
|
10
7
|
let graphQLConfig;
|
11
8
|
function loadOnDiskGraphQLConfig(filePath) {
|
12
9
|
return loadConfigSync({
|
13
10
|
// load config relative to the file being linted
|
14
|
-
rootDir: dirname(filePath),
|
15
|
-
|
16
|
-
throwOnMissing: false,
|
11
|
+
rootDir: path.dirname(filePath),
|
12
|
+
throwOnMissing: !1,
|
17
13
|
extensions: [codeFileLoaderExtension]
|
18
14
|
});
|
19
15
|
}
|
20
|
-
function loadGraphQLConfig(
|
21
|
-
|
16
|
+
function loadGraphQLConfig({
|
17
|
+
graphQLConfig: config,
|
18
|
+
filePath
|
19
|
+
}) {
|
20
|
+
if (graphQLConfig)
|
22
21
|
return graphQLConfig;
|
23
|
-
|
24
|
-
const onDiskConfig = !
|
25
|
-
debug("
|
26
|
-
|
27
|
-
debug("Graphql-config path %o", onDiskConfig.filepath);
|
28
|
-
}
|
29
|
-
const configOptions = options.projects ? { projects: options.projects } : {
|
30
|
-
schema: options.schema || "",
|
22
|
+
debug("parserOptions.graphQLConfig: %o", config);
|
23
|
+
const onDiskConfig = !config && loadOnDiskGraphQLConfig(filePath);
|
24
|
+
onDiskConfig && debug("GraphQL-Config path %o", onDiskConfig.filepath);
|
25
|
+
const configOptions = config && ("projects" in config || "schemaPath" in config) ? config : {
|
31
26
|
// if `schema` is `undefined` will throw error `Project 'default' not found`
|
32
|
-
|
33
|
-
|
34
|
-
include: options.include,
|
35
|
-
exclude: options.exclude
|
27
|
+
schema: config?.schema ?? "",
|
28
|
+
...config
|
36
29
|
};
|
37
|
-
graphQLConfig = onDiskConfig || new GraphQLConfig(
|
38
|
-
{
|
39
|
-
config: configOptions,
|
40
|
-
filepath: "virtual-config"
|
41
|
-
},
|
42
|
-
[codeFileLoaderExtension]
|
43
|
-
);
|
44
|
-
return graphQLConfig;
|
30
|
+
return graphQLConfig = onDiskConfig || new GraphQLConfig({ config: configOptions, filepath: "" }, [codeFileLoaderExtension]), graphQLConfig;
|
45
31
|
}
|
46
32
|
const codeFileLoaderExtension = (api) => {
|
47
33
|
const { schema, documents } = api.loaders;
|
48
|
-
schema.register(new CodeFileLoader());
|
49
|
-
documents.register(new CodeFileLoader());
|
50
|
-
return { name: "graphql-eslint-loaders" };
|
34
|
+
return schema.register(new CodeFileLoader()), documents.register(new CodeFileLoader()), { name: "code-file-loaders" };
|
51
35
|
};
|
52
36
|
export {
|
53
37
|
loadGraphQLConfig,
|
package/esm/index.d.mts
CHANGED
@@ -2,21 +2,27 @@ import * as eslint from 'eslint';
|
|
2
2
|
import { Block } from './processor.mjs';
|
3
3
|
export { parseForESLint } from './parser.mjs';
|
4
4
|
export { rules } from './rules/index.mjs';
|
5
|
-
export {
|
5
|
+
export { CategoryType, ConfigName, GraphQLESLintParseResult, GraphQLESLintRule, GraphQLESLintRuleContext, GraphQLESLintRuleListener, OmitRecursively, ParserOptions, ParserServices, Pointer, ReportDescriptor, RuleDocsInfo, Schema, ValueOf } from './types.mjs';
|
6
6
|
export { requireGraphQLSchemaFromContext, requireSiblingsOperations } from './utils.mjs';
|
7
7
|
export { configs } from './configs/index.mjs';
|
8
8
|
export { flatConfigs } from './flat-configs.mjs';
|
9
9
|
import './rules/require-description.mjs';
|
10
10
|
import 'graphql';
|
11
|
+
import 'graphql/language/ast.js';
|
11
12
|
import 'json-schema-to-ts/lib/types/type-utils/writable.js';
|
12
|
-
import '@graphql-tools/utils';
|
13
13
|
import 'estree';
|
14
|
-
import 'graphql-config';
|
15
14
|
import 'json-schema-to-ts';
|
15
|
+
import './siblings.mjs';
|
16
|
+
import '@graphql-tools/utils';
|
16
17
|
import './estree-converter/types.mjs';
|
18
|
+
import 'graphql-config';
|
17
19
|
|
18
20
|
declare const processors: {
|
19
|
-
graphql:
|
21
|
+
graphql: {
|
22
|
+
supportsAutofix: true;
|
23
|
+
preprocess(code: string, filePath: string): (string | Block)[];
|
24
|
+
postprocess(messages: eslint.Linter.LintMessage[][], filePath: string): eslint.Linter.LintMessage[];
|
25
|
+
};
|
20
26
|
};
|
21
27
|
|
22
28
|
export { processors };
|
package/esm/index.js
CHANGED
package/esm/parser.d.mts
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import '@graphql-tools/utils';
|
1
|
+
import { ParserOptions, GraphQLESLintParseResult } from './types.mjs';
|
3
2
|
import 'eslint';
|
4
3
|
import 'estree';
|
5
4
|
import 'graphql';
|
6
|
-
import 'graphql-config';
|
7
5
|
import 'json-schema-to-ts';
|
6
|
+
import './siblings.mjs';
|
7
|
+
import '@graphql-tools/utils';
|
8
8
|
import './estree-converter/types.mjs';
|
9
|
+
import 'graphql-config';
|
9
10
|
|
10
11
|
declare function parseForESLint(code: string, options: ParserOptions): GraphQLESLintParseResult;
|
11
12
|
|
package/esm/parser.js
CHANGED
@@ -1,40 +1,50 @@
|
|
1
|
-
import "./chunk-
|
1
|
+
import "./chunk-U3TKCM4X.js";
|
2
2
|
import { parseGraphQLSDL } from "@graphql-tools/utils";
|
3
3
|
import debugFactory from "debug";
|
4
|
-
import {
|
4
|
+
import { GraphQLError } from "graphql";
|
5
5
|
import { convertToESTree, extractComments, extractTokens } from "./estree-converter/index.js";
|
6
6
|
import { loadGraphQLConfig } from "./graphql-config.js";
|
7
7
|
import { getSchema } from "./schema.js";
|
8
8
|
import { getSiblings } from "./siblings.js";
|
9
9
|
import { CWD, VIRTUAL_DOCUMENT_REGEX } from "./utils.js";
|
10
|
+
import { getDocuments } from "./documents.js";
|
10
11
|
const debug = debugFactory("graphql-eslint:parser");
|
11
12
|
debug("cwd %o", CWD);
|
13
|
+
const LEGACY_PARSER_OPTIONS_KEYS = [
|
14
|
+
"schema",
|
15
|
+
"documents",
|
16
|
+
"extensions",
|
17
|
+
"include",
|
18
|
+
"exclude",
|
19
|
+
"projects",
|
20
|
+
"schemaOptions",
|
21
|
+
"graphQLParserOptions",
|
22
|
+
"skipGraphQLConfig",
|
23
|
+
"operations"
|
24
|
+
];
|
12
25
|
function parseForESLint(code, options) {
|
13
|
-
|
26
|
+
for (const key of LEGACY_PARSER_OPTIONS_KEYS)
|
27
|
+
if (key in options)
|
28
|
+
throw new Error(
|
29
|
+
`\`parserOptions.${key}\` was removed in graphql-eslint@4. Use physical graphql-config for setting schema and documents or \`parserOptions.graphQLConfig\` for programmatic usage.`
|
30
|
+
);
|
14
31
|
try {
|
15
|
-
const { filePath } = options;
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
21
|
-
const gqlConfig = loadGraphQLConfig(options);
|
22
|
-
const realFilepath = filePath.replace(VIRTUAL_DOCUMENT_REGEX, "");
|
23
|
-
const project = gqlConfig.getProjectForFile(realFilepath);
|
24
|
-
let schema = null;
|
32
|
+
const { filePath } = options, { document } = parseGraphQLSDL(filePath, code, { noLocation: !1 });
|
33
|
+
let project, schema, documents;
|
34
|
+
{
|
35
|
+
const gqlConfig = loadGraphQLConfig(options), realFilepath = filePath.replace(VIRTUAL_DOCUMENT_REGEX, "");
|
36
|
+
project = gqlConfig.getProjectForFile(realFilepath), documents = getDocuments(project);
|
37
|
+
}
|
25
38
|
try {
|
26
|
-
schema =
|
39
|
+
schema = getSchema(project);
|
27
40
|
} catch (error) {
|
28
|
-
|
29
|
-
error.message = `Error while loading schema: ${error.message}`;
|
30
|
-
}
|
31
|
-
throw error;
|
41
|
+
throw error instanceof Error && (error.message = `Error while loading schema: ${error.message}`), error;
|
32
42
|
}
|
33
43
|
const rootTree = convertToESTree(document, schema);
|
34
44
|
return {
|
35
45
|
services: {
|
36
46
|
schema,
|
37
|
-
siblingOperations: getSiblings(
|
47
|
+
siblingOperations: getSiblings(documents)
|
38
48
|
},
|
39
49
|
ast: {
|
40
50
|
comments: extractComments(document.loc),
|
@@ -47,20 +57,16 @@ function parseForESLint(code, options) {
|
|
47
57
|
}
|
48
58
|
};
|
49
59
|
} catch (error) {
|
50
|
-
if (error instanceof Error) {
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
const location = (_a = error.locations) == null ? void 0 : _a[0];
|
55
|
-
const eslintError = {
|
56
|
-
index: (_b = error.positions) == null ? void 0 : _b[0],
|
60
|
+
if (error instanceof Error && (error.message = `[graphql-eslint] ${error.message}`), error instanceof GraphQLError) {
|
61
|
+
const location = error.locations?.[0];
|
62
|
+
throw {
|
63
|
+
index: error.positions?.[0],
|
57
64
|
...location && {
|
58
65
|
lineNumber: location.line,
|
59
66
|
column: location.column - 1
|
60
67
|
},
|
61
68
|
message: error.message
|
62
69
|
};
|
63
|
-
throw eslintError;
|
64
70
|
}
|
65
71
|
throw error;
|
66
72
|
}
|
package/esm/processor.d.mts
CHANGED
@@ -4,6 +4,10 @@ type Block = Linter.ProcessorFile & {
|
|
4
4
|
lineOffset: number;
|
5
5
|
offset: number;
|
6
6
|
};
|
7
|
-
declare const processor:
|
7
|
+
declare const processor: {
|
8
|
+
supportsAutofix: true;
|
9
|
+
preprocess(code: string, filePath: string): (string | Block)[];
|
10
|
+
postprocess(messages: Linter.LintMessage[][], filePath: string): Linter.LintMessage[];
|
11
|
+
};
|
8
12
|
|
9
13
|
export { Block, processor };
|