Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-schema-linter

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-schema-linter - npm Package Compare versions

Comparing version 0.0.18 to 0.0.19

CONTRIBUTING.md

14

CHANGELOG.md

@@ -11,2 +11,16 @@ # Changelog

## 0.0.19 (November 25th, 2017)
### New features
- The `types-have-descriptions` rule now validates that `union` types have a description. [#56](https://github.com/cjoudrey/graphql-schema-linter/pull/56)
- The `types-have-descriptions` rule now validates that `input` types have a description. [#57](https://github.com/cjoudrey/graphql-schema-linter/pull/57)
- The `types-have-descriptions` rule now validates that `scalar` types have a description. [#60](https://github.com/cjoudrey/graphql-schema-linter/pull/60)
- The `types-have-descriptions` rule now validates that `enum` types have a description. [#61](https://github.com/cjoudrey/graphql-schema-linter/pull/61)
- GraphQL syntax errors will now be reported like other errors instead of crashing. [#59](https://github.com/cjoudrey/graphql-schema-linter/pull/59)
### Bug fixes
- Fix a crash that occured when a `.graphql` file had no line breaks. [#58](https://github.com/cjoudrey/graphql-schema-linter/pull/58)
## 0.0.18 (October 11th, 2017)

@@ -13,0 +27,0 @@

40

lib/rules/types_have_descriptions.js

@@ -12,2 +12,12 @@ 'use strict';

function validateTypeHasDescription(context, node, typeKind) {
if ((0, _buildASTSchema.getDescription)(node)) {
return;
}
var interfaceTypeName = node.name.value;
context.reportError(new _error.GraphQLError('The ' + typeKind + ' type `' + interfaceTypeName + '` is missing a description.', [node]));
}
function TypesHaveDescriptions(context) {

@@ -18,21 +28,21 @@ return {

},
ScalarTypeDefinition: function ScalarTypeDefinition(node) {
validateTypeHasDescription(context, node, 'scalar');
},
ObjectTypeDefinition: function ObjectTypeDefinition(node) {
validateTypeHasDescription(context, node, 'object');
},
InterfaceTypeDefinition: function InterfaceTypeDefinition(node) {
if ((0, _buildASTSchema.getDescription)(node)) {
return;
}
var interfaceTypeName = node.name.value;
context.reportError(new _error.GraphQLError('The interface type `' + interfaceTypeName + '` is missing a description.', [node]));
validateTypeHasDescription(context, node, 'interface');
},
ObjectTypeDefinition: function ObjectTypeDefinition(node) {
if ((0, _buildASTSchema.getDescription)(node)) {
return;
}
var objectTypeName = node.name.value;
context.reportError(new _error.GraphQLError('The object type `' + objectTypeName + '` is missing a description.', [node]));
UnionTypeDefinition: function UnionTypeDefinition(node) {
validateTypeHasDescription(context, node, 'union');
},
EnumTypeDefinition: function EnumTypeDefinition(node) {
validateTypeHasDescription(context, node, 'enum');
},
InputObjectTypeDefinition: function InputObjectTypeDefinition(node) {
validateTypeHasDescription(context, node, 'input object');
}
};
}

@@ -48,16 +48,4 @@ 'use strict';

var errors;
var errors = (0, _validator.validateSchemaDefinition)(schema, rules);
try {
errors = (0, _validator.validateSchemaDefinition)(schema, rules);
} catch (e) {
if (e instanceof _error.GraphQLError) {
stderr.write(_chalk2.default.red(_figures2.default.cross + ' An error occurred while parsing the GraphQL schema:\n\n'));
stderr.write(String(e));
return 2;
}
throw e;
}
var groupedErrors = groupErrorsBySchemaFilePath(errors, schemaSourceMap);

@@ -64,0 +52,0 @@

@@ -30,3 +30,4 @@ 'use strict';

var currentSegment = _this.sourceFiles[path];
var amountLines = currentSegment.match(/\r?\n/g).length;
var currentSegmentLines = currentSegment.match(/\r?\n/g);
var amountLines = currentSegmentLines ? currentSegmentLines.length : 0;

@@ -33,0 +34,0 @@ var startLine = currentOffset;

@@ -16,4 +16,15 @@ 'use strict';

var _error = require('graphql/error');
function validateSchemaDefinition(schemaDefinition, rules) {
var ast = (0, _graphql.parse)(schemaDefinition);
var ast;
try {
ast = (0, _graphql.parse)(schemaDefinition);
} catch (e) {
if (e instanceof _error.GraphQLError) {
return [e];
} else {
throw e;
}
}
var schema = (0, _buildASTSchema.buildASTSchema)(ast);

@@ -20,0 +31,0 @@ var errors = (0, _validation.validate)(schema, ast, rules);

{
"name": "graphql-schema-linter",
"version": "0.0.18",
"version": "0.0.19",
"description":

@@ -5,0 +5,0 @@ "Command line tool and package to validate GraphQL schemas against a set of rules.",

@@ -73,3 +73,3 @@ # graphql-schema-linter [![Travis CI](https://travis-ci.org/cjoudrey/graphql-schema-linter.svg?branch=master)](https://travis-ci.org/cjoudrey/graphql-schema-linter) [![npm version](https://badge.fury.io/js/graphql-schema-linter.svg)](https://yarnpkg.com/en/package/graphql-schema-linter)

"lint-staged": {
"*.graphql": ["graphql-schema-linter **/*.graphql"]
"*.graphql": ["graphql-schema-linter"]
}

@@ -89,4 +89,4 @@ }

"lint-staged": {
"client/*.graphql": ["graphql-schema-linter client/**/*.graphql"],
"server/*.graphql": ["graphql-schema-linter server/**/*.graphql"],
"client/*.graphql": ["graphql-schema-linter"],
"server/*.graphql": ["graphql-schema-linter"],
}

@@ -157,3 +157,3 @@ }

This will will validate that interface types and object types have descriptions.
This will will validate that interface types, object types, union types, scalar types, enum types and input types have descriptions.

@@ -160,0 +160,0 @@ ## Output formatters

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc