-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop Node 8. Support GraphQL 15. Update Babel 7 & ESLint 6.8 #271
Changes from 9 commits
ff6187d
9791e3a
4b0a239
5314c57
db89399
ab4e43b
6f7bbf9
48bffb9
a689360
f87519f
3ecf7de
ea292ba
65c07d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
presets: ['@babel/preset-env'], | ||
plugins: ['@babel/plugin-transform-runtime'], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
graphql: | ||
versions: ^0.12.0 || ^0.13.0 || ^14.0.0 | ||
versions: ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 | ||
commands: mocha test/index.js |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- "8" | ||
- "10" | ||
- "12" | ||
install: | ||
- npm install | ||
|
||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
"scripts": { | ||
"test": "tav --ci && mocha test/index.js", | ||
"prepublish": "babel ./src --ignore test --out-dir ./lib", | ||
"pretest": "node test/updateSchemaJson.js", | ||
"pretest": "babel-node test/updateSchemaJson.js", | ||
"tav": "tav", | ||
"lint": "eslint 'src/**/*.js' 'test/**/*.js'" | ||
}, | ||
|
@@ -17,39 +17,36 @@ | |
"url": "git+https://github.com/apollostack/eslint-plugin-graphql.git" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "6.26.0", | ||
"babel-core": "6.26.3", | ||
"babel-eslint": "10.0.1", | ||
"babel-plugin-transform-runtime": "6.23.0", | ||
"babel-preset-es2015": "6.24.1", | ||
"babel-preset-stage-0": "6.24.1", | ||
"eslint": "5.16.0", | ||
"graphql": "14.4.2", | ||
"graphql-tools": "4.0.5", | ||
"mocha": "6.2.0", | ||
"pretty-quick": "1.11.1", | ||
"@babel/cli": "7.10.1", | ||
"@babel/core": "7.10.1", | ||
"@babel/node": "7.10.1", | ||
"@babel/plugin-transform-runtime": "7.10.1", | ||
"@babel/preset-env": "7.10.1", | ||
"@babel/register": "7.9.0", | ||
"babel-eslint": "10.1.0", | ||
"eslint": "6.8.0", | ||
"graphql": "15.0.0", | ||
"graphql-tools": "6.0.3", | ||
"mocha": "7.2.0", | ||
"pretty-quick": "2.0.1", | ||
"test-all-versions": "4.1.1" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"es2015", | ||
"stage-0" | ||
] | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "pretty-quick --staged" | ||
} | ||
}, | ||
"engines": { | ||
"node": ">=6.0" | ||
"node": ">=10.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add a note about dropping support for Node.js to the changelog after merging. |
||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"graphql-config": "^2.0.1", | ||
"lodash": "^4.11.1" | ||
"@babel/runtime": "^7.10.0", | ||
"graphql-config": "^3.0.2", | ||
"lodash.flatten": "^4.4.0", | ||
"lodash.without": "^4.4.0" | ||
}, | ||
"peerDependencies": { | ||
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0" | ||
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,10 @@ import { | |
specifiedRules as allGraphQLValidators | ||
} from "graphql"; | ||
|
||
import { flatten, keys, reduce, without, includes } from "lodash"; | ||
import flatten from "lodash.flatten"; | ||
import without from "lodash.without"; | ||
|
||
import { getGraphQLConfig, ConfigNotFoundError } from "graphql-config"; | ||
import { loadConfigSync, ConfigNotFoundError, ProjectNotFoundError } from "graphql-config"; | ||
|
||
import * as customRules from "./customGraphQLValidationRules"; | ||
import { internalTag } from "./constants"; | ||
|
@@ -21,34 +22,54 @@ const envGraphQLValidatorNames = { | |
apollo: without( | ||
allGraphQLValidatorNames, | ||
"KnownFragmentNames", | ||
"NoUnusedFragments" | ||
"NoUnusedFragments", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR didn't introduce it this, but worth noting that this technique of excluding by validator rules by the string-form of their name has broken down once before when subjected to minification since the functions in Because of its role in the ecosystem (in dev tooling) I don't suspect this package or its dependencies will be subject to minification, but just noting. Definitely not asking for a change. 😄 |
||
// `graphql`@15 | ||
"KnownFragmentNamesRule", | ||
"NoUnusedFragmentsRule" | ||
), | ||
lokka: without( | ||
allGraphQLValidatorNames, | ||
"KnownFragmentNames", | ||
"NoUnusedFragments" | ||
"NoUnusedFragments", | ||
// `graphql`@15 | ||
"KnownFragmentNamesRule", | ||
"NoUnusedFragmentsRule" | ||
), | ||
fraql: without( | ||
allGraphQLValidatorNames, | ||
"KnownFragmentNames", | ||
"NoUnusedFragments" | ||
"NoUnusedFragments", | ||
// `graphql`@15 | ||
"KnownFragmentNamesRule", | ||
"NoUnusedFragmentsRule" | ||
), | ||
relay: without( | ||
allGraphQLValidatorNames, | ||
"KnownDirectives", | ||
"KnownFragmentNames", | ||
"NoUndefinedVariables", | ||
"NoUnusedFragments", | ||
// `graphql`@15 | ||
"KnownDirectivesRule", | ||
"KnownFragmentNamesRule", | ||
"NoUndefinedVariablesRule", | ||
"NoUnusedFragmentsRule", | ||
// `graphql` < 14 | ||
"ProvidedNonNullArguments", | ||
// `graphql`@14 | ||
"ProvidedRequiredArguments", | ||
"ScalarLeafs" | ||
"ScalarLeafs", | ||
// `graphql`@15 | ||
"ProvidedRequiredArgumentsRule", | ||
"ScalarLeafsRule" | ||
), | ||
literal: without( | ||
allGraphQLValidatorNames, | ||
"KnownFragmentNames", | ||
"NoUnusedFragments" | ||
"NoUnusedFragments", | ||
// `graphql`@15 | ||
"KnownFragmentNamesRule", | ||
"NoUnusedFragmentsRule" | ||
) | ||
}; | ||
|
||
|
@@ -268,23 +289,34 @@ function parseOptions(optionGroup, context) { | |
schema = initSchemaFromString(schemaString); | ||
} else { | ||
try { | ||
const config = getGraphQLConfig(path.dirname(context.getFilename())); | ||
const config = loadConfigSync({ | ||
rootDir: path.resolve( | ||
process.cwd(), | ||
path.dirname(context.getFilename()) | ||
) | ||
}); | ||
let projectConfig; | ||
if (projectName) { | ||
projectConfig = config.getProjects()[projectName]; | ||
projectConfig = config.getProject(projectName); | ||
if (!projectConfig) { | ||
throw new Error( | ||
`Project with name "${projectName}" not found in ${config.configPath}.` | ||
`Project with name "${projectName}" not found in ${config.filepath}.` | ||
); | ||
} | ||
} else { | ||
projectConfig = config.getConfigForFile(context.getFilename()); | ||
try { | ||
projectConfig = config.getProjectForFile(context.getFilename()); | ||
} catch (e) { | ||
if (!(e instanceof ProjectNotFoundError)) { | ||
throw e; | ||
} | ||
} | ||
} | ||
if (projectConfig) { | ||
const key = `${config.configPath}[${projectConfig.projectName}]`; | ||
const key = `${config.filepath}[${projectConfig.name}]`; | ||
schema = projectCache[key]; | ||
if (!schema) { | ||
schema = projectConfig.getSchema(); | ||
schema = projectConfig.getSchemaSync(); | ||
projectCache[key] = schema; | ||
} | ||
} | ||
|
@@ -294,7 +326,7 @@ function parseOptions(optionGroup, context) { | |
} catch (e) { | ||
if (e instanceof ConfigNotFoundError) { | ||
throw new Error( | ||
"Must provide .graphqlconfig file or pass in `schemaJson` option " + | ||
"Must provide GraphQL Config file or pass in `schemaJson` option " + | ||
"with schema object or `schemaJsonFilepath` with absolute path to the json file." | ||
); | ||
} | ||
|
@@ -385,14 +417,13 @@ const gqlProcessor = { | |
}, | ||
postprocess: function(messages) { | ||
// only report graphql-errors | ||
return flatten(messages).filter(message => { | ||
return includes(keys(rules).map(key => `graphql/${key}`), message.ruleId); | ||
}); | ||
return flatten(messages).filter(message => | ||
Object.keys(rules).map(key => `graphql/${key}`).includes(message.ruleId) | ||
); | ||
} | ||
}; | ||
|
||
export const processors = reduce( | ||
gqlFiles, | ||
export const processors = gqlFiles.reduce( | ||
(result, value) => { | ||
return { ...result, [`.${value}`]: gqlProcessor }; | ||
}, | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"projects": { | ||
"gql": { | ||
"schema": "../../schema.graphql", | ||
"include": ["first.graphql"] | ||
}, | ||
"swapi": { | ||
"schema": "../../second-schema.graphql", | ||
"include": ["second.graphql"] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"projects": { | ||
"gql": { | ||
"schemaPath": "../../schema.graphql" | ||
"schema": "../../schema.graphql" | ||
}, | ||
"swapi": { | ||
"schemaPath": "../../second-schema.graphql" | ||
"schema": "../../second-schema.graphql" | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"schema": "../../schema.graphql" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't specify
targets
here orbrowserslist
in thepackage.json
, this transpiles to ES2015 (ES6) (Source). That's probably fine, but if we're specifyingengines
at>= 10
, I guess we can go ahead and bump the transpilation target. I've done that in 3ecf7de.