graphql-schema-linter
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -11,2 +11,8 @@ # Changelog | ||
## 0.2.3 (December 1st, 2019) | ||
### New features | ||
- Add support for `schemaPaths` to be configured via `package.json`. See [README.md](https://github.com/cjoudrey/graphql-schema-linter/blob/5dfe1f0550ac80319b2550ddcaff7535b2ef7ee5/README.md#configuration-file) for examples. [#](https://github.com/cjoudrey/graphql-schema-linter/pull/196) (Thanks @gagoar) | ||
## 0.2.2 (October 31st, 2019) | ||
@@ -13,0 +19,0 @@ |
@@ -10,2 +10,6 @@ 'use strict'; | ||
var _cosmiconfig = require('cosmiconfig'); | ||
var _cosmiconfig2 = _interopRequireDefault(_cosmiconfig); | ||
var _fs = require('fs'); | ||
@@ -33,4 +37,2 @@ | ||
var cosmiconfig = require('cosmiconfig'); | ||
var Configuration = exports.Configuration = function () { | ||
@@ -98,4 +100,7 @@ /* | ||
} else if (this.options.schemaPaths) { | ||
var expandedPaths = expandPaths(this.options.schemaPaths); | ||
var schemaPaths = this.options.schemaPaths; | ||
var expandedPaths = expandPaths(schemaPaths); | ||
var segments = getSchemaSegmentsFromFiles(expandedPaths); | ||
if (Object.keys(segments).length === 0) { | ||
@@ -247,3 +252,3 @@ return null; | ||
var cosmic = cosmiconfig('graphql-schema-linter', { | ||
var cosmic = (0, _cosmiconfig2.default)('graphql-schema-linter', { | ||
cache: false | ||
@@ -253,5 +258,24 @@ }).searchSync(searchPath); | ||
if (cosmic) { | ||
var schemaPaths = []; | ||
var customRulePaths = []; | ||
// If schemaPaths come from cosmic, we resolve the given paths relative to the searchPath. | ||
if (cosmic.config.schemaPaths) { | ||
schemaPaths = cosmic.config.schemaPaths.map(function (schemaPath) { | ||
return _path2.default.resolve(searchPath, schemaPath); | ||
}); | ||
} | ||
// If customRulePaths come from cosmic, we resolve the given paths relative to the searchPath. | ||
if (cosmic.config.customRulePaths) { | ||
customRulePaths = cosmic.config.customRulePaths.map(function (schemaPath) { | ||
return _path2.default.resolve(searchPath, schemaPath); | ||
}); | ||
} | ||
return { | ||
rules: cosmic.config.rules, | ||
customRulePaths: cosmic.config.customRulePaths || [] | ||
customRulePaths: customRulePaths || [], | ||
schemaPaths: schemaPaths | ||
}; | ||
@@ -258,0 +282,0 @@ } else { |
{ | ||
"name": "graphql-schema-linter", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Command line tool and package to validate GraphQL schemas against a set of rules.", | ||
@@ -12,2 +12,5 @@ "author": "Christian Joudrey", | ||
}, | ||
"pkg": { | ||
"scripts": "lib/**/*.js" | ||
}, | ||
"homepage": "https://github.com/cjoudrey/graphql-schema-linter", | ||
@@ -27,3 +30,3 @@ "repository": { | ||
"lint-staged": "8.2.1", | ||
"mocha": "6.1.4", | ||
"mocha": "6.2.2", | ||
"prettier": "1.18.2" | ||
@@ -41,3 +44,3 @@ }, | ||
"columnify": "^1.5.4", | ||
"commander": "^2.11.0", | ||
"commander": "^3.0.0", | ||
"cosmiconfig": "^5.2.1", | ||
@@ -44,0 +47,0 @@ "glob": "^7.1.2", |
@@ -75,3 +75,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) | ||
Using [lint-staged](https://github.com/okonet/lint-staged) and [husky](https://github.com/typicode/husky), you can lint | ||
your staged GraphQL schema file before you commit. First, install these packages: | ||
your staged GraphQL schema file before you commit. First, install these packages: | ||
@@ -148,3 +148,3 @@ ```bash | ||
For now, only `rules` can be configured in a configuration file, but more options may be added in the future. | ||
For now, only `rules`, `customRulePaths` and `schemaPaths` can be configured in a configuration file, but more options may be added in the future. | ||
@@ -156,3 +156,5 @@ ### In `package.json` | ||
"graphql-schema-linter": { | ||
"rules": ["enum-values-sorted-alphabetically"] | ||
"rules": ["enum-values-sorted-alphabetically"], | ||
"schemaPaths": ["path/to/my/schema/files/**.graphql"], | ||
"customRulePaths": ["path/to/my/custom/rules/*.js"] | ||
} | ||
@@ -166,3 +168,5 @@ } | ||
{ | ||
"rules": ["enum-values-sorted-alphabetically"] | ||
"rules": ["enum-values-sorted-alphabetically"], | ||
"schemaPaths": ["path/to/my/schema/files/**.graphql"], | ||
"customRulePaths": ["path/to/my/custom/rules/*.js"] | ||
} | ||
@@ -176,2 +180,4 @@ ``` | ||
rules: ['enum-values-sorted-alphabetically'], | ||
schemaPaths: ['path/to/my/schema/files/**.graphql'], | ||
customRulePaths: ['path/to/my/custom/rules/*.js'], | ||
}; | ||
@@ -178,0 +184,0 @@ ``` |
Sorry, the diff of this file is not supported yet
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
1068
335
344193
+ Addedcommander@3.0.2(transitive)
- Removedcommander@2.20.3(transitive)
Updatedcommander@^3.0.0