@graphql-eslint/eslint-plugin 4.4.0 → 4.4.1

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/browser.js CHANGED
@@ -408,7 +408,7 @@ function convertToESTree(node, schema16) {
408
408
  }
409
409
 
410
410
  // src/meta.ts
411
- var version = "4.4.0";
411
+ var version = "4.4.1";
412
412
 
413
413
  // src/siblings.ts
414
414
  import {
@@ -988,7 +988,7 @@ var rule = {
988
988
  schema
989
989
  },
990
990
  create(context) {
991
- const sourceCode = context.getSourceCode();
991
+ const { sourceCode } = context;
992
992
  function isNodeAndCommentOnSameLine(node, comment) {
993
993
  return node.loc.end.line === comment.loc.start.line;
994
994
  }
@@ -1216,7 +1216,7 @@ var rule2 = {
1216
1216
  {
1217
1217
  desc: `Change to ${isBlock ? "block" : "inline"} style description`,
1218
1218
  fix(fixer) {
1219
- const sourceCode = context.getSourceCode();
1219
+ const { sourceCode } = context;
1220
1220
  const originalText = sourceCode.getText(node);
1221
1221
  const newText = isBlock ? originalText.replace(/(^")|("$)/g, '"""') : originalText.replace(/(^""")|("""$)/g, '"').replace(/\s+/g, " ");
1222
1222
  return fixer.replaceText(node, newText);
@@ -1282,7 +1282,7 @@ function validateDocument({
1282
1282
  const validationErrors = schema16 ? validate(schema16, documentNode, [rule35]) : validateSDL(documentNode, null, [rule35]);
1283
1283
  for (const error of validationErrors) {
1284
1284
  const { line, column } = error.locations[0];
1285
- const sourceCode = context.getSourceCode();
1285
+ const { sourceCode } = context;
1286
1286
  const { tokens } = sourceCode.ast;
1287
1287
  const token = tokens.find(
1288
1288
  (token2) => token2.loc.start.line === line && token2.loc.start.column === column - 1
@@ -2113,7 +2113,7 @@ var rule4 = {
2113
2113
  };
2114
2114
 
2115
2115
  // src/rules/match-document-filename/index.ts
2116
- import { basename, extname } from "node:path";
2116
+ import { basename, extname } from "path";
2117
2117
  import { Kind as Kind7 } from "graphql";
2118
2118
  var MATCH_EXTENSION = "MATCH_EXTENSION";
2119
2119
  var MATCH_STYLE = "MATCH_STYLE";
@@ -2967,7 +2967,7 @@ var rule7 = {
2967
2967
  {
2968
2968
  desc: `Rename to \`${suggestedName}\``,
2969
2969
  fix(fixer) {
2970
- const sourceCode = context.getSourceCode();
2970
+ const { sourceCode } = context;
2971
2971
  const hasQueryKeyword = sourceCode.getText({ range: [node.range[0], node.range[0] + 1] }) !== "{";
2972
2972
  return fixer.insertTextAfterRange(
2973
2973
  [node.range[0], node.range[0] + (hasQueryKeyword ? node.operation.length : 0)],
@@ -3325,7 +3325,7 @@ var rule10 = {
3325
3325
  const isEslintComment = value.trimStart().startsWith("eslint");
3326
3326
  const linesAfter = next.line - line;
3327
3327
  if (!isEslintComment && line !== prev.line && next.kind === TokenKind2.NAME && linesAfter < 2) {
3328
- const sourceCode = context.getSourceCode();
3328
+ const { sourceCode } = context;
3329
3329
  const { tokens } = sourceCode.ast;
3330
3330
  const t = tokens.find(
3331
3331
  (token2) => token2.loc.start.line === next.line && token2.loc.start.column === next.column - 1
@@ -3363,7 +3363,7 @@ var rule10 = {
3363
3363
  };
3364
3364
 
3365
3365
  // src/rules/no-one-place-fragments/index.ts
3366
- import { relative } from "node:path";
3366
+ import { relative } from "path";
3367
3367
  import { visit as visit4 } from "graphql";
3368
3368
  var RULE_ID7 = "no-one-place-fragments";
3369
3369
  var rule11 = {
@@ -4080,7 +4080,7 @@ var rule16 = {
4080
4080
  {
4081
4081
  desc: `Remove \`${fieldName}\` field`,
4082
4082
  fix(fixer) {
4083
- const sourceCode = context.getSourceCode();
4083
+ const sourceCode = context.sourceCode;
4084
4084
  const tokenBefore = sourceCode.getTokenBefore(node);
4085
4085
  const tokenAfter = sourceCode.getTokenAfter(node);
4086
4086
  const isEmptyType = tokenBefore.type === "{" && tokenAfter.type === "}";
@@ -5107,7 +5107,7 @@ var rule24 = {
5107
5107
  };
5108
5108
 
5109
5109
  // src/rules/require-import-fragment/index.ts
5110
- import path from "node:path";
5110
+ import path from "path";
5111
5111
  var RULE_ID16 = "require-import-fragment";
5112
5112
  var SUGGESTION_ID = "add-import-expression";
5113
5113
  var rule25 = {
@@ -5184,7 +5184,7 @@ var rule25 = {
5184
5184
  schema: []
5185
5185
  },
5186
5186
  create(context) {
5187
- const comments = context.getSourceCode().getAllComments();
5187
+ const comments = context.sourceCode.getAllComments();
5188
5188
  const siblings = requireGraphQLOperations(RULE_ID16, context);
5189
5189
  const filePath = context.filename;
5190
5190
  return {
@@ -5349,7 +5349,7 @@ var rule27 = {
5349
5349
  const rootTypeNames = new Set(
5350
5350
  [schema16.getQueryType(), schema16.getMutationType()].filter((v) => !!v).map((type) => type.name)
5351
5351
  );
5352
- const sourceCode = context.getSourceCode();
5352
+ const { sourceCode } = context;
5353
5353
  return {
5354
5354
  "ObjectTypeDefinition,ObjectTypeExtension"(node) {
5355
5355
  if (!rootTypeNames.has(node.name.value)) return;
@@ -5804,7 +5804,7 @@ var rule30 = {
5804
5804
  {
5805
5805
  desc: "Remove selections",
5806
5806
  fix(fixer) {
5807
- const sourceCode = context.getSourceCode();
5807
+ const { sourceCode } = context;
5808
5808
  const foundNode = sourceCode.getNodeByRangeIndex(token.range[0]);
5809
5809
  const parentNode = foundNode.parent.parent;
5810
5810
  return fixer.remove(
@@ -6058,7 +6058,7 @@ var rule32 = {
6058
6058
  };
6059
6059
 
6060
6060
  // src/rules/unique-fragment-name/index.ts
6061
- import { relative as relative2 } from "node:path";
6061
+ import { relative as relative2 } from "path";
6062
6062
  import { Kind as Kind24 } from "graphql";
6063
6063
  var RULE_ID23 = "unique-fragment-name";
6064
6064
  var checkNode = (context, node, ruleId) => {
@@ -4,5 +4,4 @@ export { convertLocation, convertToken, extractComments, extractTokens, getBaseT
4
4
  import 'graphql';
5
5
  import 'eslint';
6
6
  import 'estree';
7
- import 'graphql/jsutils/Maybe.js';
8
- import 'graphql/jsutils/ObjMap.js';
7
+ import 'graphql/utilities/valueFromASTUntyped.js';
@@ -1,11 +1,9 @@
1
- import * as graphql_jsutils_Maybe_js from 'graphql/jsutils/Maybe.js';
2
- import * as graphql_jsutils_ObjMap_js from 'graphql/jsutils/ObjMap.js';
3
- import * as graphql from 'graphql';
4
- import { GraphQLOutputType, GraphQLNamedType, TokenKind, Token, Location } from 'graphql';
5
1
  import { AST } from 'eslint';
6
2
  import { Comment, SourceLocation } from 'estree';
3
+ import { GraphQLOutputType, GraphQLNamedType, TokenKind, Token, Location } from 'graphql';
4
+ import { valueFromASTUntyped } from 'graphql/utilities/valueFromASTUntyped.js';
7
5
 
8
- declare const valueFromNode: (valueNode: graphql.ValueNode, variables?: graphql_jsutils_Maybe_js.Maybe<graphql_jsutils_ObjMap_js.ObjMap<unknown>>) => any;
6
+ declare const valueFromNode: (...args: Parameters<typeof valueFromASTUntyped>) => any;
9
7
  declare function getBaseType(type: GraphQLOutputType): GraphQLNamedType;
10
8
  declare function convertToken<T extends TokenKind | 'Block' | 'Line'>(token: Token, type: T): Omit<AST.Token, 'type'> & {
11
9
  type: T;
package/cjs/index.d.cts CHANGED
@@ -622,4 +622,6 @@ declare const _default: {
622
622
  };
623
623
  };
624
624
 
625
- export { GraphQLESLintRule, _default as default, parseForESLint, processors };
625
+ // @ts-ignore
626
+ export = _default;
627
+ export { GraphQLESLintRule, parseForESLint, processors };
package/cjs/meta.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});const version = "4.4.0";
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});const version = "4.4.1";
2
2
 
3
3
 
4
4
  exports.version = version;
package/cjs/processor.js CHANGED
@@ -19,7 +19,7 @@ const processor = {
19
19
  preprocess(code, filePath) {
20
20
  if (process.env.ESLINT_USE_FLAT_CONFIG !== "false" && filePath.endsWith(".vue")) {
21
21
  throw new Error(
22
- "Processing of `.vue` files is no longer supported, follow the new official vue example for ESLint's flat config https://github.com/dimaMachina/graphql-eslint/tree/master/examples/vue-code-file"
22
+ "Processing of `.vue` files is no longer supported, follow the new official vue example for ESLint's flat config https://github.com/graphql-hive/graphql-eslint/tree/master/examples/vue-code-file"
23
23
  );
24
24
  }
25
25
  if (!onDiskConfigLoaded) {
@@ -204,7 +204,7 @@ const rule = {
204
204
  schema
205
205
  },
206
206
  create(context) {
207
- const sourceCode = context.getSourceCode();
207
+ const { sourceCode } = context;
208
208
  function isNodeAndCommentOnSameLine(node, comment) {
209
209
  return node.loc.end.line === comment.loc.start.line;
210
210
  }
@@ -68,7 +68,7 @@ const rule = {
68
68
  {
69
69
  desc: `Change to ${isBlock ? "block" : "inline"} style description`,
70
70
  fix(fixer) {
71
- const sourceCode = context.getSourceCode();
71
+ const { sourceCode } = context;
72
72
  const originalText = sourceCode.getText(node);
73
73
  const newText = isBlock ? originalText.replace(/(^")|("$)/g, '"""') : originalText.replace(/(^""")|("""$)/g, '"').replace(/\s+/g, " ");
74
74
  return fixer.replaceText(node, newText);
@@ -56,7 +56,7 @@ function validateDocument({
56
56
  const validationErrors = schema ? _graphql.validate.call(void 0, schema, documentNode, [rule]) : _validatejs.validateSDL.call(void 0, documentNode, null, [rule]);
57
57
  for (const error of validationErrors) {
58
58
  const { line, column } = error.locations[0];
59
- const sourceCode = context.getSourceCode();
59
+ const { sourceCode } = context;
60
60
  const { tokens } = sourceCode.ast;
61
61
  const token = tokens.find(
62
62
  (token2) => token2.loc.start.line === line && token2.loc.start.column === column - 1
@@ -55,7 +55,7 @@ const rule = {
55
55
  {
56
56
  desc: `Rename to \`${suggestedName}\``,
57
57
  fix(fixer) {
58
- const sourceCode = context.getSourceCode();
58
+ const { sourceCode } = context;
59
59
  const hasQueryKeyword = sourceCode.getText({ range: [node.range[0], node.range[0] + 1] }) !== "{";
60
60
  return fixer.insertTextAfterRange(
61
61
  [node.range[0], node.range[0] + (hasQueryKeyword ? node.operation.length : 0)],
@@ -72,7 +72,7 @@ const rule = {
72
72
  const isEslintComment = value.trimStart().startsWith("eslint");
73
73
  const linesAfter = next.line - line;
74
74
  if (!isEslintComment && line !== prev.line && next.kind === _graphql.TokenKind.NAME && linesAfter < 2) {
75
- const sourceCode = context.getSourceCode();
75
+ const { sourceCode } = context;
76
76
  const { tokens } = sourceCode.ast;
77
77
  const t = tokens.find(
78
78
  (token2) => token2.loc.start.line === next.line && token2.loc.start.column === next.column - 1
@@ -229,7 +229,7 @@ const rule = {
229
229
  {
230
230
  desc: `Remove \`${fieldName}\` field`,
231
231
  fix(fixer) {
232
- const sourceCode = context.getSourceCode();
232
+ const sourceCode = context.sourceCode;
233
233
  const tokenBefore = sourceCode.getTokenBefore(node);
234
234
  const tokenAfter = sourceCode.getTokenAfter(node);
235
235
  const isEmptyType = tokenBefore.type === "{" && tokenAfter.type === "}";
@@ -76,7 +76,7 @@ const rule = {
76
76
  schema: []
77
77
  },
78
78
  create(context) {
79
- const comments = context.getSourceCode().getAllComments();
79
+ const comments = context.sourceCode.getAllComments();
80
80
  const siblings = _utilsjs.requireGraphQLOperations.call(void 0, RULE_ID, context);
81
81
  const filePath = context.filename;
82
82
  return {
@@ -47,7 +47,7 @@ const rule = {
47
47
  const rootTypeNames = new Set(
48
48
  [schema.getQueryType(), schema.getMutationType()].filter((v) => !!v).map((type) => type.name)
49
49
  );
50
- const sourceCode = context.getSourceCode();
50
+ const { sourceCode } = context;
51
51
  return {
52
52
  "ObjectTypeDefinition,ObjectTypeExtension"(node) {
53
53
  if (!rootTypeNames.has(node.name.value)) return;
@@ -113,7 +113,7 @@ const rule = {
113
113
  {
114
114
  desc: "Remove selections",
115
115
  fix(fixer) {
116
- const sourceCode = context.getSourceCode();
116
+ const { sourceCode } = context;
117
117
  const foundNode = sourceCode.getNodeByRangeIndex(token.range[0]);
118
118
  const parentNode = foundNode.parent.parent;
119
119
  return fixer.remove(
@@ -4,5 +4,4 @@ export { convertLocation, convertToken, extractComments, extractTokens, getBaseT
4
4
  import 'graphql';
5
5
  import 'eslint';
6
6
  import 'estree';
7
- import 'graphql/jsutils/Maybe.js';
8
- import 'graphql/jsutils/ObjMap.js';
7
+ import 'graphql/utilities/valueFromASTUntyped.js';
@@ -1,11 +1,9 @@
1
- import * as graphql_jsutils_Maybe_js from 'graphql/jsutils/Maybe.js';
2
- import * as graphql_jsutils_ObjMap_js from 'graphql/jsutils/ObjMap.js';
3
- import * as graphql from 'graphql';
4
- import { GraphQLOutputType, GraphQLNamedType, TokenKind, Token, Location } from 'graphql';
5
1
  import { AST } from 'eslint';
6
2
  import { Comment, SourceLocation } from 'estree';
3
+ import { GraphQLOutputType, GraphQLNamedType, TokenKind, Token, Location } from 'graphql';
4
+ import { valueFromASTUntyped } from 'graphql/utilities/valueFromASTUntyped.js';
7
5
 
8
- declare const valueFromNode: (valueNode: graphql.ValueNode, variables?: graphql_jsutils_Maybe_js.Maybe<graphql_jsutils_ObjMap_js.ObjMap<unknown>>) => any;
6
+ declare const valueFromNode: (...args: Parameters<typeof valueFromASTUntyped>) => any;
9
7
  declare function getBaseType(type: GraphQLOutputType): GraphQLNamedType;
10
8
  declare function convertToken<T extends TokenKind | 'Block' | 'Line'>(token: Token, type: T): Omit<AST.Token, 'type'> & {
11
9
  type: T;
package/esm/meta.js CHANGED
@@ -1,4 +1,4 @@
1
- const version = "4.4.0";
1
+ const version = "4.4.1";
2
2
  export {
3
3
  version
4
4
  };
package/esm/processor.js CHANGED
@@ -19,7 +19,7 @@ const processor = {
19
19
  preprocess(code, filePath) {
20
20
  if (process.env.ESLINT_USE_FLAT_CONFIG !== "false" && filePath.endsWith(".vue")) {
21
21
  throw new Error(
22
- "Processing of `.vue` files is no longer supported, follow the new official vue example for ESLint's flat config https://github.com/dimaMachina/graphql-eslint/tree/master/examples/vue-code-file"
22
+ "Processing of `.vue` files is no longer supported, follow the new official vue example for ESLint's flat config https://github.com/graphql-hive/graphql-eslint/tree/master/examples/vue-code-file"
23
23
  );
24
24
  }
25
25
  if (!onDiskConfigLoaded) {
@@ -204,7 +204,7 @@ const rule = {
204
204
  schema
205
205
  },
206
206
  create(context) {
207
- const sourceCode = context.getSourceCode();
207
+ const { sourceCode } = context;
208
208
  function isNodeAndCommentOnSameLine(node, comment) {
209
209
  return node.loc.end.line === comment.loc.start.line;
210
210
  }
@@ -68,7 +68,7 @@ const rule = {
68
68
  {
69
69
  desc: `Change to ${isBlock ? "block" : "inline"} style description`,
70
70
  fix(fixer) {
71
- const sourceCode = context.getSourceCode();
71
+ const { sourceCode } = context;
72
72
  const originalText = sourceCode.getText(node);
73
73
  const newText = isBlock ? originalText.replace(/(^")|("$)/g, '"""') : originalText.replace(/(^""")|("""$)/g, '"').replace(/\s+/g, " ");
74
74
  return fixer.replaceText(node, newText);
@@ -56,7 +56,7 @@ function validateDocument({
56
56
  const validationErrors = schema ? validate(schema, documentNode, [rule]) : validateSDL(documentNode, null, [rule]);
57
57
  for (const error of validationErrors) {
58
58
  const { line, column } = error.locations[0];
59
- const sourceCode = context.getSourceCode();
59
+ const { sourceCode } = context;
60
60
  const { tokens } = sourceCode.ast;
61
61
  const token = tokens.find(
62
62
  (token2) => token2.loc.start.line === line && token2.loc.start.column === column - 1
@@ -55,7 +55,7 @@ const rule = {
55
55
  {
56
56
  desc: `Rename to \`${suggestedName}\``,
57
57
  fix(fixer) {
58
- const sourceCode = context.getSourceCode();
58
+ const { sourceCode } = context;
59
59
  const hasQueryKeyword = sourceCode.getText({ range: [node.range[0], node.range[0] + 1] }) !== "{";
60
60
  return fixer.insertTextAfterRange(
61
61
  [node.range[0], node.range[0] + (hasQueryKeyword ? node.operation.length : 0)],
@@ -72,7 +72,7 @@ const rule = {
72
72
  const isEslintComment = value.trimStart().startsWith("eslint");
73
73
  const linesAfter = next.line - line;
74
74
  if (!isEslintComment && line !== prev.line && next.kind === TokenKind.NAME && linesAfter < 2) {
75
- const sourceCode = context.getSourceCode();
75
+ const { sourceCode } = context;
76
76
  const { tokens } = sourceCode.ast;
77
77
  const t = tokens.find(
78
78
  (token2) => token2.loc.start.line === next.line && token2.loc.start.column === next.column - 1
@@ -229,7 +229,7 @@ const rule = {
229
229
  {
230
230
  desc: `Remove \`${fieldName}\` field`,
231
231
  fix(fixer) {
232
- const sourceCode = context.getSourceCode();
232
+ const sourceCode = context.sourceCode;
233
233
  const tokenBefore = sourceCode.getTokenBefore(node);
234
234
  const tokenAfter = sourceCode.getTokenAfter(node);
235
235
  const isEmptyType = tokenBefore.type === "{" && tokenAfter.type === "}";
@@ -76,7 +76,7 @@ const rule = {
76
76
  schema: []
77
77
  },
78
78
  create(context) {
79
- const comments = context.getSourceCode().getAllComments();
79
+ const comments = context.sourceCode.getAllComments();
80
80
  const siblings = requireGraphQLOperations(RULE_ID, context);
81
81
  const filePath = context.filename;
82
82
  return {
@@ -47,7 +47,7 @@ const rule = {
47
47
  const rootTypeNames = new Set(
48
48
  [schema.getQueryType(), schema.getMutationType()].filter((v) => !!v).map((type) => type.name)
49
49
  );
50
- const sourceCode = context.getSourceCode();
50
+ const { sourceCode } = context;
51
51
  return {
52
52
  "ObjectTypeDefinition,ObjectTypeExtension"(node) {
53
53
  if (!rootTypeNames.has(node.name.value)) return;
@@ -113,7 +113,7 @@ const rule = {
113
113
  {
114
114
  desc: "Remove selections",
115
115
  fix(fixer) {
116
- const sourceCode = context.getSourceCode();
116
+ const { sourceCode } = context;
117
117
  const foundNode = sourceCode.getNodeByRangeIndex(token.range[0]);
118
118
  const parentNode = foundNode.parent.parent;
119
119
  return fixer.remove(
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "4.4.0",
3
+ "version": "4.4.1",
4
4
  "type": "module",
5
5
  "description": "GraphQL plugin for ESLint",
6
- "repository": "https://github.com/dimaMachina/graphql-eslint",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/graphql-hive/graphql-eslint"
9
+ },
7
10
  "author": "Dotan Simha <dotansimha@gmail.com>",
8
11
  "license": "MIT",
9
12
  "engines": {