graphql-schema-linter
Advanced tools
Comparing version 0.0.8 to 0.0.9
# Changelog | ||
## 0.0.9 (August 10th, 2017) | ||
- Fix a bug where the wrong location (column/line) was being reported for `DeprecationsHaveAReason` rule. [#13](https://github.com/cjoudrey/graphql-schema-linter/issues/13) | ||
- Fix a bug where the wrong location (column/line) was being reported for `TypesAreCapitalized` rule. [#14](https://github.com/cjoudrey/graphql-schema-linter/issues/14) | ||
## 0.0.8 (August 10th, 2017) | ||
@@ -4,0 +9,0 @@ |
@@ -15,20 +15,32 @@ 'use strict'; | ||
FieldDefinition: function FieldDefinition(node, key, parent, path, ancestors) { | ||
if (!isDeprecatedWithoutReason(node)) { | ||
var deprecatedDirective = getDeprecatedDirective(node); | ||
if (!deprecatedDirective) { | ||
return; | ||
} | ||
var reasonArgument = getReasonArgument(deprecatedDirective); | ||
if (reasonArgument) { | ||
return; | ||
} | ||
var fieldName = node.name.value; | ||
var parentName = ancestors[ancestors.length - 1].name.value; | ||
context.reportError(new _error.GraphQLError('The field `' + parentName + '.' + fieldName + '` is deprecated but has no deprecation reason.', [node])); | ||
context.reportError(new _error.GraphQLError('The field `' + parentName + '.' + fieldName + '` is deprecated but has no deprecation reason.', [deprecatedDirective])); | ||
}, | ||
EnumValueDefinition: function EnumValueDefinition(node, key, parent, path, ancestors) { | ||
if (!isDeprecatedWithoutReason(node)) { | ||
var deprecatedDirective = getDeprecatedDirective(node); | ||
if (!deprecatedDirective) { | ||
return; | ||
} | ||
var reasonArgument = getReasonArgument(deprecatedDirective); | ||
if (reasonArgument) { | ||
return; | ||
} | ||
var fieldName = node.name.value; | ||
var parentName = ancestors[ancestors.length - 1].name.value; | ||
context.reportError(new _error.GraphQLError('The enum value `' + parentName + '.' + fieldName + '` is deprecated but has no deprecation reason.', [node])); | ||
context.reportError(new _error.GraphQLError('The enum value `' + parentName + '.' + fieldName + '` is deprecated but has no deprecation reason.', [deprecatedDirective])); | ||
} | ||
@@ -38,3 +50,3 @@ }; | ||
function isDeprecatedWithoutReason(node) { | ||
function getDeprecatedDirective(node) { | ||
var deprecatedDirective = node.directives.find(function (directive) { | ||
@@ -48,6 +60,6 @@ if (directive.name.value != 'deprecated') { | ||
if (!deprecatedDirective) { | ||
return false; | ||
} | ||
return deprecatedDirective; | ||
} | ||
function getReasonArgument(deprecatedDirective) { | ||
var reasonArgument = deprecatedDirective.arguments.find(function (arg) { | ||
@@ -61,3 +73,3 @@ if (arg.name.value == 'reason') { | ||
return !reasonArgument; | ||
return reasonArgument; | ||
} |
@@ -15,3 +15,3 @@ 'use strict'; | ||
if (typeName[0] == typeName[0].toLowerCase()) { | ||
context.reportError(new _error.GraphQLError('The object type `' + typeName + '` should start with a capital letter.', [node])); | ||
context.reportError(new _error.GraphQLError('The object type `' + typeName + '` should start with a capital letter.', [node.name])); | ||
} | ||
@@ -22,3 +22,3 @@ }, | ||
if (typeName[0] == typeName[0].toLowerCase()) { | ||
context.reportError(new _error.GraphQLError('The interface type `' + typeName + '` should start with a capital letter.', [node])); | ||
context.reportError(new _error.GraphQLError('The interface type `' + typeName + '` should start with a capital letter.', [node.name])); | ||
} | ||
@@ -25,0 +25,0 @@ } |
{ | ||
"name": "graphql-schema-linter", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Command line tool and package to validate GraphQL schemas against a set of rules.", | ||
@@ -5,0 +5,0 @@ "author": "Christian Joudrey", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
212980
398