From 01003a94751ba501beac6c9089ae9f0d8460a8a9 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 24 Feb 2023 18:41:32 +0100 Subject: [PATCH] lint renderExample.js, cleanup .eslintignore file --- .eslintignore | 32 -------------------- packages/graphiql/resources/renderExample.js | 14 +++++---- packages/graphiql/test/beforeDevServer.js | 8 +---- packages/graphiql/test/schema.js | 12 ++------ 4 files changed, 12 insertions(+), 54 deletions(-) diff --git a/.eslintignore b/.eslintignore index 81613514d8e..01df4f9bcaf 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,30 +1,6 @@ -################################################################################ -# -# First things first; we need to ignore our built files. To achive this, we -# have to do a bit of an ignore dance where we ignore everything, and then -# specifically un-ignore the source code, configuration files, etc. -# -# First: ignore FILES (not folders!) -/{packages,examples}/**/*.{js,jsx,ts,tsx} - -# -# Now un-ignore source code, tests, configuration, etc -!/{packages,examples}/*/{src,cypress,resources}/** - # CRA example has its own eslint config examples/graphiql-create-react-app -!.eslintrc.js -!babel.config.js -# -# End of the ignore dance. -# -################################################################################ - -# Regular eslintignore configuration follows. - -# ESLint automatically ignores node_modules _in the root_, so we only need to specify nested node_modules -**/node_modules /packages/graphiql/graphiql.* # Build artifacts @@ -36,12 +12,7 @@ examples/graphiql-create-react-app **/typedoc **/monaco **/webpack -packages/graphiql/webpack -packages/graphiql/storybook -packages/graphiql/lsp -packages/graphiql/monaco packages/graphiql/*.html -**/renderExample.js **/*.min.js **/coverage/ .nyc_output/ @@ -61,9 +32,6 @@ working-group/ **/codemirror-graphql/cm6-legacy **/codemirror-graphql/__tests__ -# Vendored files -/packages/graphiql/test/vendor - .changeset/*.md storybook-static/ diff --git a/packages/graphiql/resources/renderExample.js b/packages/graphiql/resources/renderExample.js index b859abd6e49..75db4573706 100644 --- a/packages/graphiql/resources/renderExample.js +++ b/packages/graphiql/resources/renderExample.js @@ -1,3 +1,5 @@ +/* global React, ReactDOM, GraphiQL, GraphQLVersion */ + /** * UMD GraphiQL Example * @@ -11,9 +13,8 @@ */ // Parse the search string to get url parameters. -var search = window.location.search; var parameters = {}; -search +window.location.search .substr(1) .split('&') .forEach(function (entry) { @@ -73,13 +74,14 @@ function getSchemaUrl() { // This supports an e2e test which ensures that invalid schemas do not load. if (parameters.bad === 'true') { return '/bad/graphql'; - } else if (parameters['http-error'] === 'true') { + } + if (parameters['http-error'] === 'true') { return '/http-error/graphql'; - } else if (parameters['graphql-error'] === 'true') { + } + if (parameters['graphql-error'] === 'true') { return '/graphql-error/graphql'; - } else { - return '/graphql'; } + return '/graphql'; } return '/.netlify/functions/schema-demo'; } diff --git a/packages/graphiql/test/beforeDevServer.js b/packages/graphiql/test/beforeDevServer.js index 0cc336c8348..fe3415f0c03 100644 --- a/packages/graphiql/test/beforeDevServer.js +++ b/packages/graphiql/test/beforeDevServer.js @@ -14,19 +14,13 @@ const { schema: badSchema } = require('./bad-schema'); module.exports = function beforeDevServer(app, _server, _compiler) { // GraphQL Server app.post('/graphql', graphqlHTTP({ schema })); + app.get('/graphql', graphqlHTTP({ schema })); app.post('/bad/graphql', (_req, res, next) => { res.json({ data: badSchema }); next(); }); - app.get( - '/graphql', - graphqlHTTP({ - schema, - }), - ); - app.use('/images', express.static(path.join(__dirname, 'images'))); app.use( diff --git a/packages/graphiql/test/schema.js b/packages/graphiql/test/schema.js index f554d1cd18c..545affc5941 100644 --- a/packages/graphiql/test/schema.js +++ b/packages/graphiql/test/schema.js @@ -96,9 +96,7 @@ const UnionFirst = new GraphQLObjectType({ }, first: { type: new GraphQLList(TestInterface), - resolve: () => { - return true; - }, + resolve: () => true, }, }), interfaces: [TestInterface], @@ -113,9 +111,7 @@ const UnionSecond = new GraphQLObjectType({ }, second: { type: TestInterface, - resolve: () => { - return false; - }, + resolve: () => false, }, }), interfaces: [TestInterface], @@ -295,9 +291,7 @@ const TestType = new GraphQLObjectType({ isTest: { type: GraphQLBoolean, description: 'Is this a test schema? Sure it is.', - resolve: () => { - return true; - }, + resolve: () => true, }, image: { type: GraphQLString,