@graphql-eslint/eslint-plugin 3.12.0 → 3.13.0-alpha-20221023200034-8eb7722
Sign up to get free protection for your applications and to get access to all the features.
- package/cache.d.ts +10 -0
- package/{sibling-operations.d.ts → documents.d.ts} +1 -1
- package/index.js +53 -53
- package/index.mjs +53 -53
- package/package.json +1 -1
- package/schema.d.ts +5 -2
- package/types.d.ts +7 -7
- package/utils.d.ts +7 -13
package/cache.d.ts
ADDED
@@ -18,4 +18,4 @@ export declare type SiblingOperations = {
|
|
18
18
|
getOperations(): OperationSource[];
|
19
19
|
getOperationByType(operationType: OperationTypeNode): OperationSource[];
|
20
20
|
};
|
21
|
-
export declare function
|
21
|
+
export declare function getDocuments(project: GraphQLProjectConfig): SiblingOperations;
|
package/index.js
CHANGED
@@ -12,12 +12,12 @@ const graphqlConfig = require('graphql-config');
|
|
12
12
|
const codeFileLoader = require('@graphql-tools/code-file-loader');
|
13
13
|
const graphql = require('graphql');
|
14
14
|
const validate = require('graphql/validation/validate');
|
15
|
-
const fs = require('fs');
|
16
15
|
const lowerCase = _interopDefault(require('lodash.lowercase'));
|
17
16
|
const chalk = _interopDefault(require('chalk'));
|
17
|
+
const fs = require('fs');
|
18
18
|
const valueFromASTUntyped = require('graphql/utilities/valueFromASTUntyped');
|
19
19
|
const depthLimit = _interopDefault(require('graphql-depth-limit'));
|
20
|
-
const
|
20
|
+
const fg = _interopDefault(require('fast-glob'));
|
21
21
|
const eslint = require('eslint');
|
22
22
|
const codeFrame = require('@babel/code-frame');
|
23
23
|
|
@@ -164,26 +164,8 @@ const logger = {
|
|
164
164
|
warn: (...args) => console.warn(chalk.yellow('warning'), '[graphql-eslint]', chalk(...args)),
|
165
165
|
};
|
166
166
|
const normalizePath = (path) => (path || '').replace(/\\/g, '/');
|
167
|
-
|
168
|
-
|
169
|
-
* Given a filepath, get the nearest path that is a regular file.
|
170
|
-
* The filepath provided by eslint may be a virtual filepath rather than a file
|
171
|
-
* on disk. This attempts to transform a virtual path into an on-disk path
|
172
|
-
*/
|
173
|
-
const getOnDiskFilepath = (filepath) => {
|
174
|
-
try {
|
175
|
-
if (fs.statSync(filepath).isFile()) {
|
176
|
-
return filepath;
|
177
|
-
}
|
178
|
-
}
|
179
|
-
catch (err) {
|
180
|
-
// https://github.com/eslint/eslint/issues/11989
|
181
|
-
if (err.code === 'ENOTDIR') {
|
182
|
-
return getOnDiskFilepath(path.dirname(filepath));
|
183
|
-
}
|
184
|
-
}
|
185
|
-
return filepath;
|
186
|
-
};
|
167
|
+
const VIRTUAL_DOCUMENT_REGEX = /\/\d+_document.graphql$/;
|
168
|
+
const CWD = process.cwd();
|
187
169
|
const getTypeName = (node) => 'type' in node ? getTypeName(node.type) : node.name.value;
|
188
170
|
const TYPES_KINDS = [
|
189
171
|
graphql.Kind.OBJECT_TYPE_DEFINITION,
|
@@ -4114,7 +4096,7 @@ const checkNode = (context, node, ruleId) => {
|
|
4114
4096
|
data: {
|
4115
4097
|
documentName,
|
4116
4098
|
summary: conflictingDocuments
|
4117
|
-
.map(f => `\t${path.relative(
|
4099
|
+
.map(f => `\t${path.relative(CWD, f.filePath.replace(VIRTUAL_DOCUMENT_REGEX, ''))}`)
|
4118
4100
|
.join('\n'),
|
4119
4101
|
},
|
4120
4102
|
node: node.name,
|
@@ -4275,36 +4257,59 @@ const rules = {
|
|
4275
4257
|
'unique-operation-name': rule$r,
|
4276
4258
|
};
|
4277
4259
|
|
4278
|
-
|
4260
|
+
// Based on the `eslint-plugin-import`'s cache
|
4261
|
+
const log = debugFactory('graphql-eslint:ModuleCache');
|
4262
|
+
class ModuleCache {
|
4263
|
+
constructor() {
|
4264
|
+
this.map = new Map();
|
4265
|
+
}
|
4266
|
+
set(cacheKey, result) {
|
4267
|
+
this.map.set(cacheKey, { lastSeen: process.hrtime(), result });
|
4268
|
+
log('setting entry for', cacheKey);
|
4269
|
+
}
|
4270
|
+
get(cacheKey, settings = { lifetime: 10 /* seconds */ }) {
|
4271
|
+
if (!this.map.has(cacheKey)) {
|
4272
|
+
log('cache miss for', cacheKey);
|
4273
|
+
return;
|
4274
|
+
}
|
4275
|
+
const { lastSeen, result } = this.map.get(cacheKey);
|
4276
|
+
// check freshness
|
4277
|
+
if (process.hrtime(lastSeen)[0] < settings.lifetime) {
|
4278
|
+
return result;
|
4279
|
+
}
|
4280
|
+
}
|
4281
|
+
}
|
4282
|
+
|
4283
|
+
const schemaCache = new ModuleCache();
|
4279
4284
|
const debug$1 = debugFactory('graphql-eslint:schema');
|
4280
|
-
function getSchema(project,
|
4281
|
-
const schemaKey =
|
4285
|
+
function getSchema(project, schemaOptions) {
|
4286
|
+
const schemaKey = project.schema;
|
4282
4287
|
if (!schemaKey) {
|
4283
4288
|
return null;
|
4284
4289
|
}
|
4285
|
-
|
4286
|
-
|
4290
|
+
const cache = schemaCache.get(schemaKey);
|
4291
|
+
if (cache) {
|
4292
|
+
return cache;
|
4287
4293
|
}
|
4288
4294
|
let schema;
|
4289
4295
|
try {
|
4290
4296
|
debug$1('Loading schema from %o', project.schema);
|
4291
4297
|
schema = project.loadSchemaSync(project.schema, 'GraphQLSchema', {
|
4292
|
-
...
|
4298
|
+
...schemaOptions,
|
4293
4299
|
pluckConfig: project.extensions.pluckConfig,
|
4294
4300
|
});
|
4295
4301
|
if (debug$1.enabled) {
|
4296
4302
|
debug$1('Schema loaded: %o', schema instanceof graphql.GraphQLSchema);
|
4297
|
-
const schemaPaths =
|
4298
|
-
absolute: true,
|
4299
|
-
});
|
4303
|
+
const schemaPaths = fg.sync(project.schema, { absolute: true });
|
4300
4304
|
debug$1('Schema pointers %O', schemaPaths);
|
4301
4305
|
}
|
4306
|
+
// Do not set error to cache, since cache reload will be done after some `lifetime` seconds
|
4307
|
+
schemaCache.set(schemaKey, schema);
|
4302
4308
|
}
|
4303
4309
|
catch (error) {
|
4304
4310
|
error.message = chalk.red(`Error while loading schema: ${error.message}`);
|
4305
4311
|
schema = error;
|
4306
4312
|
}
|
4307
|
-
schemaCache.set(schemaKey, schema);
|
4308
4313
|
return schema;
|
4309
4314
|
}
|
4310
4315
|
|
@@ -4325,14 +4330,14 @@ const handleVirtualPath = (documents) => {
|
|
4325
4330
|
};
|
4326
4331
|
});
|
4327
4332
|
};
|
4328
|
-
const operationsCache = new
|
4333
|
+
const operationsCache = new ModuleCache();
|
4329
4334
|
const siblingOperationsCache = new Map();
|
4330
4335
|
const getSiblings = (project) => {
|
4331
|
-
const documentsKey =
|
4336
|
+
const documentsKey = project.documents;
|
4332
4337
|
if (!documentsKey) {
|
4333
4338
|
return [];
|
4334
4339
|
}
|
4335
|
-
let siblings = operationsCache.get(
|
4340
|
+
let siblings = operationsCache.get(project.name);
|
4336
4341
|
if (!siblings) {
|
4337
4342
|
debug$2('Loading operations from %o', project.documents);
|
4338
4343
|
const documents = project.loadDocumentsSync(project.documents, {
|
@@ -4341,9 +4346,7 @@ const getSiblings = (project) => {
|
|
4341
4346
|
});
|
4342
4347
|
if (debug$2.enabled) {
|
4343
4348
|
debug$2('Loaded %d operations', documents.length);
|
4344
|
-
const operationsPaths =
|
4345
|
-
absolute: true,
|
4346
|
-
});
|
4349
|
+
const operationsPaths = fg.sync(project.documents, { absolute: true });
|
4347
4350
|
debug$2('Operations pointers %O', operationsPaths);
|
4348
4351
|
}
|
4349
4352
|
siblings = handleVirtualPath(documents);
|
@@ -4351,7 +4354,7 @@ const getSiblings = (project) => {
|
|
4351
4354
|
}
|
4352
4355
|
return siblings;
|
4353
4356
|
};
|
4354
|
-
function
|
4357
|
+
function getDocuments(project) {
|
4355
4358
|
const siblings = getSiblings(project);
|
4356
4359
|
if (siblings.length === 0) {
|
4357
4360
|
let printed = false;
|
@@ -4450,32 +4453,29 @@ function getSiblingOperations(project) {
|
|
4450
4453
|
}
|
4451
4454
|
|
4452
4455
|
const debug$3 = debugFactory('graphql-eslint:parser');
|
4453
|
-
debug$3('cwd %o',
|
4456
|
+
debug$3('cwd %o', CWD);
|
4454
4457
|
function parseForESLint(code, options) {
|
4455
4458
|
try {
|
4456
4459
|
const { filePath } = options;
|
4457
|
-
|
4458
|
-
|
4459
|
-
const projectForFile = realFilepath
|
4460
|
-
? gqlConfig.getProjectForFile(realFilepath)
|
4461
|
-
: gqlConfig.getDefault();
|
4462
|
-
const schema = getSchema(projectForFile, options);
|
4463
|
-
const siblingOperations = getSiblingOperations(projectForFile);
|
4460
|
+
// First parse code from file, in case of syntax error do not try load schema,
|
4461
|
+
// documents or even graphql-config instance
|
4464
4462
|
const { document } = utils.parseGraphQLSDL(filePath, code, {
|
4465
4463
|
...options.graphQLParserOptions,
|
4466
4464
|
noLocation: false,
|
4467
4465
|
});
|
4468
|
-
const
|
4469
|
-
const
|
4466
|
+
const gqlConfig = loadGraphQLConfig(options);
|
4467
|
+
const realFilepath = filePath.replace(VIRTUAL_DOCUMENT_REGEX, '');
|
4468
|
+
const project = gqlConfig.getProjectForFile(realFilepath);
|
4469
|
+
const schema = getSchema(project, options.schemaOptions);
|
4470
4470
|
const rootTree = convertToESTree(document, schema instanceof graphql.GraphQLSchema ? schema : null);
|
4471
4471
|
return {
|
4472
4472
|
services: {
|
4473
4473
|
schema,
|
4474
|
-
siblingOperations,
|
4474
|
+
siblingOperations: getDocuments(project),
|
4475
4475
|
},
|
4476
4476
|
ast: {
|
4477
|
-
comments,
|
4478
|
-
tokens,
|
4477
|
+
comments: extractComments(document.loc),
|
4478
|
+
tokens: extractTokens(filePath, code),
|
4479
4479
|
loc: rootTree.loc,
|
4480
4480
|
range: rootTree.range,
|
4481
4481
|
type: 'Program',
|
package/index.mjs
CHANGED
@@ -6,12 +6,12 @@ import { loadConfigSync, GraphQLConfig } from 'graphql-config';
|
|
6
6
|
import { CodeFileLoader } from '@graphql-tools/code-file-loader';
|
7
7
|
import { Kind, visit, validate, TokenKind, isScalarType, DirectiveLocation, isInterfaceType, TypeInfo, visitWithTypeInfo, isObjectType as isObjectType$1, Source, isNonNullType, isListType, GraphQLObjectType, GraphQLInterfaceType, GraphQLSchema, GraphQLError } from 'graphql';
|
8
8
|
import { validateSDL } from 'graphql/validation/validate';
|
9
|
-
import { statSync, existsSync, readFileSync } from 'fs';
|
10
9
|
import lowerCase from 'lodash.lowercase';
|
11
10
|
import chalk from 'chalk';
|
11
|
+
import { existsSync, readFileSync } from 'fs';
|
12
12
|
import { valueFromASTUntyped } from 'graphql/utilities/valueFromASTUntyped';
|
13
13
|
import depthLimit from 'graphql-depth-limit';
|
14
|
-
import
|
14
|
+
import fg from 'fast-glob';
|
15
15
|
import { RuleTester, Linter } from 'eslint';
|
16
16
|
import { codeFrameColumns } from '@babel/code-frame';
|
17
17
|
|
@@ -158,26 +158,8 @@ const logger = {
|
|
158
158
|
warn: (...args) => console.warn(chalk.yellow('warning'), '[graphql-eslint]', chalk(...args)),
|
159
159
|
};
|
160
160
|
const normalizePath = (path) => (path || '').replace(/\\/g, '/');
|
161
|
-
|
162
|
-
|
163
|
-
* Given a filepath, get the nearest path that is a regular file.
|
164
|
-
* The filepath provided by eslint may be a virtual filepath rather than a file
|
165
|
-
* on disk. This attempts to transform a virtual path into an on-disk path
|
166
|
-
*/
|
167
|
-
const getOnDiskFilepath = (filepath) => {
|
168
|
-
try {
|
169
|
-
if (statSync(filepath).isFile()) {
|
170
|
-
return filepath;
|
171
|
-
}
|
172
|
-
}
|
173
|
-
catch (err) {
|
174
|
-
// https://github.com/eslint/eslint/issues/11989
|
175
|
-
if (err.code === 'ENOTDIR') {
|
176
|
-
return getOnDiskFilepath(dirname(filepath));
|
177
|
-
}
|
178
|
-
}
|
179
|
-
return filepath;
|
180
|
-
};
|
161
|
+
const VIRTUAL_DOCUMENT_REGEX = /\/\d+_document.graphql$/;
|
162
|
+
const CWD = process.cwd();
|
181
163
|
const getTypeName = (node) => 'type' in node ? getTypeName(node.type) : node.name.value;
|
182
164
|
const TYPES_KINDS = [
|
183
165
|
Kind.OBJECT_TYPE_DEFINITION,
|
@@ -4108,7 +4090,7 @@ const checkNode = (context, node, ruleId) => {
|
|
4108
4090
|
data: {
|
4109
4091
|
documentName,
|
4110
4092
|
summary: conflictingDocuments
|
4111
|
-
.map(f => `\t${relative(
|
4093
|
+
.map(f => `\t${relative(CWD, f.filePath.replace(VIRTUAL_DOCUMENT_REGEX, ''))}`)
|
4112
4094
|
.join('\n'),
|
4113
4095
|
},
|
4114
4096
|
node: node.name,
|
@@ -4269,36 +4251,59 @@ const rules = {
|
|
4269
4251
|
'unique-operation-name': rule$r,
|
4270
4252
|
};
|
4271
4253
|
|
4272
|
-
|
4254
|
+
// Based on the `eslint-plugin-import`'s cache
|
4255
|
+
const log = debugFactory('graphql-eslint:ModuleCache');
|
4256
|
+
class ModuleCache {
|
4257
|
+
constructor() {
|
4258
|
+
this.map = new Map();
|
4259
|
+
}
|
4260
|
+
set(cacheKey, result) {
|
4261
|
+
this.map.set(cacheKey, { lastSeen: process.hrtime(), result });
|
4262
|
+
log('setting entry for', cacheKey);
|
4263
|
+
}
|
4264
|
+
get(cacheKey, settings = { lifetime: 10 /* seconds */ }) {
|
4265
|
+
if (!this.map.has(cacheKey)) {
|
4266
|
+
log('cache miss for', cacheKey);
|
4267
|
+
return;
|
4268
|
+
}
|
4269
|
+
const { lastSeen, result } = this.map.get(cacheKey);
|
4270
|
+
// check freshness
|
4271
|
+
if (process.hrtime(lastSeen)[0] < settings.lifetime) {
|
4272
|
+
return result;
|
4273
|
+
}
|
4274
|
+
}
|
4275
|
+
}
|
4276
|
+
|
4277
|
+
const schemaCache = new ModuleCache();
|
4273
4278
|
const debug$1 = debugFactory('graphql-eslint:schema');
|
4274
|
-
function getSchema(project,
|
4275
|
-
const schemaKey =
|
4279
|
+
function getSchema(project, schemaOptions) {
|
4280
|
+
const schemaKey = project.schema;
|
4276
4281
|
if (!schemaKey) {
|
4277
4282
|
return null;
|
4278
4283
|
}
|
4279
|
-
|
4280
|
-
|
4284
|
+
const cache = schemaCache.get(schemaKey);
|
4285
|
+
if (cache) {
|
4286
|
+
return cache;
|
4281
4287
|
}
|
4282
4288
|
let schema;
|
4283
4289
|
try {
|
4284
4290
|
debug$1('Loading schema from %o', project.schema);
|
4285
4291
|
schema = project.loadSchemaSync(project.schema, 'GraphQLSchema', {
|
4286
|
-
...
|
4292
|
+
...schemaOptions,
|
4287
4293
|
pluckConfig: project.extensions.pluckConfig,
|
4288
4294
|
});
|
4289
4295
|
if (debug$1.enabled) {
|
4290
4296
|
debug$1('Schema loaded: %o', schema instanceof GraphQLSchema);
|
4291
|
-
const schemaPaths =
|
4292
|
-
absolute: true,
|
4293
|
-
});
|
4297
|
+
const schemaPaths = fg.sync(project.schema, { absolute: true });
|
4294
4298
|
debug$1('Schema pointers %O', schemaPaths);
|
4295
4299
|
}
|
4300
|
+
// Do not set error to cache, since cache reload will be done after some `lifetime` seconds
|
4301
|
+
schemaCache.set(schemaKey, schema);
|
4296
4302
|
}
|
4297
4303
|
catch (error) {
|
4298
4304
|
error.message = chalk.red(`Error while loading schema: ${error.message}`);
|
4299
4305
|
schema = error;
|
4300
4306
|
}
|
4301
|
-
schemaCache.set(schemaKey, schema);
|
4302
4307
|
return schema;
|
4303
4308
|
}
|
4304
4309
|
|
@@ -4319,14 +4324,14 @@ const handleVirtualPath = (documents) => {
|
|
4319
4324
|
};
|
4320
4325
|
});
|
4321
4326
|
};
|
4322
|
-
const operationsCache = new
|
4327
|
+
const operationsCache = new ModuleCache();
|
4323
4328
|
const siblingOperationsCache = new Map();
|
4324
4329
|
const getSiblings = (project) => {
|
4325
|
-
const documentsKey =
|
4330
|
+
const documentsKey = project.documents;
|
4326
4331
|
if (!documentsKey) {
|
4327
4332
|
return [];
|
4328
4333
|
}
|
4329
|
-
let siblings = operationsCache.get(
|
4334
|
+
let siblings = operationsCache.get(project.name);
|
4330
4335
|
if (!siblings) {
|
4331
4336
|
debug$2('Loading operations from %o', project.documents);
|
4332
4337
|
const documents = project.loadDocumentsSync(project.documents, {
|
@@ -4335,9 +4340,7 @@ const getSiblings = (project) => {
|
|
4335
4340
|
});
|
4336
4341
|
if (debug$2.enabled) {
|
4337
4342
|
debug$2('Loaded %d operations', documents.length);
|
4338
|
-
const operationsPaths =
|
4339
|
-
absolute: true,
|
4340
|
-
});
|
4343
|
+
const operationsPaths = fg.sync(project.documents, { absolute: true });
|
4341
4344
|
debug$2('Operations pointers %O', operationsPaths);
|
4342
4345
|
}
|
4343
4346
|
siblings = handleVirtualPath(documents);
|
@@ -4345,7 +4348,7 @@ const getSiblings = (project) => {
|
|
4345
4348
|
}
|
4346
4349
|
return siblings;
|
4347
4350
|
};
|
4348
|
-
function
|
4351
|
+
function getDocuments(project) {
|
4349
4352
|
const siblings = getSiblings(project);
|
4350
4353
|
if (siblings.length === 0) {
|
4351
4354
|
let printed = false;
|
@@ -4444,32 +4447,29 @@ function getSiblingOperations(project) {
|
|
4444
4447
|
}
|
4445
4448
|
|
4446
4449
|
const debug$3 = debugFactory('graphql-eslint:parser');
|
4447
|
-
debug$3('cwd %o',
|
4450
|
+
debug$3('cwd %o', CWD);
|
4448
4451
|
function parseForESLint(code, options) {
|
4449
4452
|
try {
|
4450
4453
|
const { filePath } = options;
|
4451
|
-
|
4452
|
-
|
4453
|
-
const projectForFile = realFilepath
|
4454
|
-
? gqlConfig.getProjectForFile(realFilepath)
|
4455
|
-
: gqlConfig.getDefault();
|
4456
|
-
const schema = getSchema(projectForFile, options);
|
4457
|
-
const siblingOperations = getSiblingOperations(projectForFile);
|
4454
|
+
// First parse code from file, in case of syntax error do not try load schema,
|
4455
|
+
// documents or even graphql-config instance
|
4458
4456
|
const { document } = parseGraphQLSDL(filePath, code, {
|
4459
4457
|
...options.graphQLParserOptions,
|
4460
4458
|
noLocation: false,
|
4461
4459
|
});
|
4462
|
-
const
|
4463
|
-
const
|
4460
|
+
const gqlConfig = loadGraphQLConfig(options);
|
4461
|
+
const realFilepath = filePath.replace(VIRTUAL_DOCUMENT_REGEX, '');
|
4462
|
+
const project = gqlConfig.getProjectForFile(realFilepath);
|
4463
|
+
const schema = getSchema(project, options.schemaOptions);
|
4464
4464
|
const rootTree = convertToESTree(document, schema instanceof GraphQLSchema ? schema : null);
|
4465
4465
|
return {
|
4466
4466
|
services: {
|
4467
4467
|
schema,
|
4468
|
-
siblingOperations,
|
4468
|
+
siblingOperations: getDocuments(project),
|
4469
4469
|
},
|
4470
4470
|
ast: {
|
4471
|
-
comments,
|
4472
|
-
tokens,
|
4471
|
+
comments: extractComments(document.loc),
|
4472
|
+
tokens: extractTokens(filePath, code),
|
4473
4473
|
loc: rootTree.loc,
|
4474
4474
|
range: rootTree.range,
|
4475
4475
|
type: 'Program',
|
package/package.json
CHANGED
package/schema.d.ts
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
1
2
|
import { GraphQLProjectConfig } from 'graphql-config';
|
2
|
-
import
|
3
|
-
|
3
|
+
import { ParserOptions, Schema } from './types';
|
4
|
+
import { ModuleCache } from './cache';
|
5
|
+
export declare const schemaCache: ModuleCache<Error | GraphQLSchema, any>;
|
6
|
+
export declare function getSchema(project: GraphQLProjectConfig, schemaOptions?: ParserOptions['schemaOptions']): Schema;
|
package/types.d.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import
|
7
|
-
import
|
1
|
+
import { Rule, AST, Linter } from 'eslint';
|
2
|
+
import * as ESTree from 'estree';
|
3
|
+
import { GraphQLSchema } from 'graphql';
|
4
|
+
import { IExtensions, IGraphQLProject } from 'graphql-config';
|
5
|
+
import { GraphQLParseOptions } from '@graphql-tools/utils';
|
6
|
+
import { GraphQLESLintRuleListener } from './testkit';
|
7
|
+
import { SiblingOperations } from './documents';
|
8
8
|
export declare type Schema = GraphQLSchema | Error | null;
|
9
9
|
export declare type Pointer = string | string[];
|
10
10
|
export interface ParserOptions {
|
package/utils.d.ts
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
import
|
2
|
-
import {
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import type { SiblingOperations } from './sibling-operations';
|
1
|
+
import { GraphQLSchema, Kind } from 'graphql';
|
2
|
+
import { AST } from 'eslint';
|
3
|
+
import { Position } from 'estree';
|
4
|
+
import { GraphQLESLintRuleContext } from './types';
|
5
|
+
import { SiblingOperations } from './documents';
|
7
6
|
export declare function requireSiblingsOperations(ruleId: string, context: GraphQLESLintRuleContext): SiblingOperations | never;
|
8
7
|
export declare function requireGraphQLSchemaFromContext(ruleId: string, context: GraphQLESLintRuleContext): GraphQLSchema | never;
|
9
8
|
export declare const logger: {
|
@@ -11,13 +10,8 @@ export declare const logger: {
|
|
11
10
|
warn: (...args: any[]) => void;
|
12
11
|
};
|
13
12
|
export declare const normalizePath: (path: string) => string;
|
14
|
-
|
15
|
-
|
16
|
-
* Given a filepath, get the nearest path that is a regular file.
|
17
|
-
* The filepath provided by eslint may be a virtual filepath rather than a file
|
18
|
-
* on disk. This attempts to transform a virtual path into an on-disk path
|
19
|
-
*/
|
20
|
-
export declare const getOnDiskFilepath: (filepath: string) => string;
|
13
|
+
export declare const VIRTUAL_DOCUMENT_REGEX: RegExp;
|
14
|
+
export declare const CWD: string;
|
21
15
|
export declare const getTypeName: (node: any) => string;
|
22
16
|
export declare const TYPES_KINDS: readonly [Kind.OBJECT_TYPE_DEFINITION, Kind.INTERFACE_TYPE_DEFINITION, Kind.ENUM_TYPE_DEFINITION, Kind.SCALAR_TYPE_DEFINITION, Kind.INPUT_OBJECT_TYPE_DEFINITION, Kind.UNION_TYPE_DEFINITION];
|
23
17
|
export declare type CaseStyle = 'camelCase' | 'PascalCase' | 'snake_case' | 'UPPER_CASE' | 'kebab-case';
|