Skip to content

Commit

Permalink
extends plugin:import/recommended and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina committed Nov 27, 2022
1 parent 6c3ca90 commit c3f32c8
Show file tree
Hide file tree
Showing 29 changed files with 6,138 additions and 211 deletions.
12 changes: 12 additions & 0 deletions .changeset/cold-doors-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'cm6-graphql': patch
'codemirror-graphql': patch
'graphiql': patch
'graphql-language-service': patch
'graphql-language-service-cli': patch
'graphql-language-service-server': patch
'monaco-graphql': patch
'vscode-graphql-execution': patch
---

extends `plugin:import/recommended` and fix warnings
37 changes: 23 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module.exports = {
react: {
version: 'detect',
},
'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
},
// https://github.com/sindresorhus/globals/blob/master/globals.json
env: {
Expand All @@ -36,6 +35,7 @@ module.exports = {

extends: [
'eslint:recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
Expand Down Expand Up @@ -227,10 +227,9 @@ module.exports = {
'sort-imports': 0,
'symbol-description': 1,

// import (https://github.com/benmosher/eslint-plugin-import)
// 'import/no-unresolved': [2, { modules: 'es6' }],
'import/no-cycle': 0,
'import/no-extraneous-dependencies': 1,
'import/no-extraneous-dependencies': 'error',
'import/no-duplicates': 'error',
'import/no-named-as-default': 'error',
'prefer-object-spread': 'error',
// react rules
'react/no-unused-state': 'error',
Expand Down Expand Up @@ -264,10 +263,10 @@ module.exports = {
'jest/no-conditional-expect': 0,
},

plugins: ['import', '@typescript-eslint'],
plugins: ['@typescript-eslint'],

overrides: [
// Cypress plugin, global, etc only for cypress directory
// Cypress plugin, global, etc. only for cypress directory
// https://github.com/cypress-io/eslint-plugin-cypress
// cypress clashes with jest expect()
{
Expand All @@ -291,13 +290,6 @@ module.exports = {
'jest/no-conditional-expect': 0,
},
},
{
// Converted from 'dependencies' options in ancient config
files: ['**/spec/**', '**/sample-*/**'],
rules: {
'import/no-cycle': 0,
},
},
{
// Resources are typically our helper scripts; make life easier there
files: ['resources/**', '**/resources/**', 'scripts/**'],
Expand All @@ -322,5 +314,22 @@ module.exports = {
'no-alert': 'off',
},
},
// Ignore imported dependencies from tests files
{
files: ['**/__tests__/**', 'webpack.config.js'],
rules: {
'import/no-extraneous-dependencies': 'off',
},
},
// Allow import `vscode` package
{
files: [
'packages/vscode-graphql/**',
'packages/vscode-graphql-execution/**',
],
rules: {
'import/no-unresolved': ['error', { ignore: ['vscode'] }],
},
},
],
};
2 changes: 1 addition & 1 deletion examples/cm6-graphql-legacy-parcel/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "example-cm6-graphql-parcel",
"name": "example-cm6-graphql-legacy-parcel",
"version": "1.1.10-alpha.8",
"license": "MIT",
"description": "GraphiQL Parcel Example",
Expand Down
1 change: 1 addition & 0 deletions examples/cm6-graphql-parcel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { history } from '@codemirror/commands';
import { autocompletion, closeBrackets } from '@codemirror/autocomplete';
import { bracketMatching, syntaxHighlighting } from '@codemirror/language';
import { oneDarkHighlightStyle, oneDark } from '@codemirror/theme-one-dark';
// eslint-disable-next-line import/no-unresolved
import { graphql } from 'cm6-graphql';
import query from './sample-query';
import { TestSchema } from './testSchema';
Expand Down
2 changes: 1 addition & 1 deletion examples/graphiql-parcel/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
import GraphiQL from 'graphiql';
import { GraphiQL } from 'graphiql';

const App = () => (
<GraphiQL
Expand Down
3 changes: 2 additions & 1 deletion examples/graphiql-webpack/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import 'regenerator-runtime/runtime.js';

import * as React from 'react';
import { render } from 'react-dom';
import GraphiQL from 'graphiql';
import { GraphiQL } from 'graphiql';
import { useExplorerPlugin } from '@graphiql/plugin-explorer';
import { useExporterPlugin } from '@graphiql/plugin-code-exporter';

// eslint-disable-next-line import/no-unresolved
import 'graphiql/graphiql.css';
import '@graphiql/plugin-explorer/dist/style.css';
import '@graphiql/plugin-code-exporter/dist/style.css';
Expand Down
2 changes: 1 addition & 1 deletion examples/monaco-graphql-webpack/src/editors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as monaco from 'monaco-editor';
// NOTE: using loader syntax because Yaml worker imports editor.worker directly and that
// import shouldn't go through loader syntax.
// @ts-ignore
import GraphQLWorker from 'monaco-graphql/esm/graphql.worker';
import GraphQLWorker from 'monaco-graphql/esm/graphql.worker'; // eslint-disable-line import/default

const GRAPHQL_LANGUAGE_ID = 'graphql';

Expand Down
1 change: 1 addition & 0 deletions functions/schema-demo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* example using https://github.com/awslabs/aws-serverless-express */
const express = require('express');
// eslint-disable-next-line import/no-extraneous-dependencies
const { graphqlHTTP } = require('express-graphql');
const awsServerlessExpress = require('aws-serverless-express');
const schema = require('../packages/graphiql/test/schema');
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"workspaces": {
"packages": [
"packages/*",
"examples/graphiql-webpack",
"examples/monaco-graphql-webpack",
"examples/monaco-graphql-react-vite",
"examples/cm6-graphql-parcel"
"examples/*"
]
},
"lint-staged": {
Expand Down Expand Up @@ -120,6 +117,7 @@
"cypress": "^4.7.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.4.5",
Expand Down
1 change: 1 addition & 0 deletions packages/cm6-graphql/__tests__/test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-unresolved
import { graphqlLanguage } from '../dist/index.js';
import { fileTests } from '@lezer/generator/dist/test';

Expand Down
1 change: 1 addition & 0 deletions packages/cm6-graphql/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import esbuild from 'rollup-plugin-esbuild';
// eslint-disable-next-line import/no-unresolved
import { lezer } from '@lezer/generator/rollup';

export default {
Expand Down
1 change: 0 additions & 1 deletion packages/codemirror-graphql/src/__tests__/hint-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
__Schema,
__Type,
} from 'graphql';
import '../hint';
import { GraphQLHintOptions, IHint, IHints } from '../hint';
import '../mode';
import {
Expand Down
1 change: 1 addition & 0 deletions packages/graphiql/cypress/plugins/cy-ts-preprocessor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const wp = require('@cypress/webpack-preprocessor');

const webpackOptions = {
Expand Down
1 change: 1 addition & 0 deletions packages/graphiql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@graphiql/toolkit": "^0.8.0",
"entities": "^2.0.0",
"graphql-language-service": "^5.1.0",
"regenerator-runtime": "0.13.11",
"markdown-it": "^12.2.0"
},
"peerDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/graphiql/test/afterDevServer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable react-hooks/rules-of-hooks */
// eslint-disable-next-line import/no-extraneous-dependencies
const { useServer } = require('graphql-ws/lib/use/ws');
const { Server: WebSocketServer } = require('ws');
const schema = require('./schema');
Expand All @@ -8,5 +8,6 @@ module.exports = function afterDevServer(_app, _server, _compiler) {
path: '/subscriptions',
port: 8081,
});
// eslint-disable-next-line react-hooks/rules-of-hooks
useServer({ schema }, wsServer);
};
3 changes: 1 addition & 2 deletions packages/graphql-language-service-cli/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
*
*/

import { GraphQLSchema } from 'graphql';
import { GraphQLSchema, buildSchema, buildClientSchema } from 'graphql';

import invariant from 'assert';
import fs from 'fs';
import { buildSchema, buildClientSchema } from 'graphql';
import {
getAutocompleteSuggestions,
getDiagnostics,
Expand Down
1 change: 1 addition & 0 deletions packages/graphql-language-service-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"nullthrows": "^1.0.0",
"vscode-jsonrpc": "^8.0.1",
"vscode-languageserver": "^8.0.1",
"vscode-languageserver-types": "^3.17.2",
"vscode-uri": "^3.0.2"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import {
ValidationRule,
FieldNode,
GraphQLError,
Kind,
parse,
print,
} from 'graphql';

import {
Expand Down Expand Up @@ -51,7 +54,6 @@ import {
SymbolKind,
} from 'vscode-languageserver-types';

import { Kind, parse, print } from 'graphql';
import { Logger } from './Logger';

const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ import type {
DidSaveTextDocumentParams,
DidOpenTextDocumentParams,
DidChangeConfigurationParams,
} from 'vscode-languageserver/node';

import type {
Diagnostic,
CompletionItem,
CompletionList,
Expand Down
1 change: 0 additions & 1 deletion packages/graphql-language-service-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ export { Logger } from './Logger';
export * from './GraphQLCache';
export * from './parseDocument';
export * from './findGraphQLTags';
export * from './stringToHash';
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
*
*/

import { GraphQLField, GraphQLSchema, GraphQLType } from 'graphql';
import { isCompositeType } from 'graphql';
import {
GraphQLField,
GraphQLSchema,
GraphQLType,
isCompositeType,
} from 'graphql';
import {
SchemaMetaFieldDef,
TypeMetaFieldDef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@ import {
isEnumType,
isInputObjectType,
isOutputType,
} from 'graphql';

import {
CompletionItem,
AllTypeInfo,
IPosition,
CompletionItemKind,
InsertTextFormat,
} from '../types';

import {
GraphQLBoolean,
GraphQLEnumType,
GraphQLInputObjectType,
Expand All @@ -61,6 +50,14 @@ import {
parse,
} from 'graphql';

import {
CompletionItem,
AllTypeInfo,
IPosition,
CompletionItemKind,
InsertTextFormat,
} from '../types';

import {
CharacterStream,
onlineParser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import {
print,
validate,
NoDeprecatedCustomRule,
parse,
} from 'graphql';

import { parse } from 'graphql';

import { CharacterStream, onlineParser } from '../parser';

import { Range, validateWithCustomRules, Position } from '../utils';
Expand Down
12 changes: 4 additions & 8 deletions packages/graphql-language-service/src/parser/onlineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
*
*/

import {
LexRules as LexRulesType,
ParseRules as ParseRulesType,
} from './Rules';
import CharacterStream from './CharacterStream';
import { State, Token, Rule, RuleKind } from './types';

Expand All @@ -39,8 +35,8 @@ import { Kind } from 'graphql';

export type ParserOptions = {
eatWhitespace: (stream: CharacterStream) => boolean;
lexRules: Partial<typeof LexRulesType>;
parseRules: typeof ParseRulesType;
lexRules: Partial<typeof LexRules>;
parseRules: typeof ParseRules;
editorConfig: { [name: string]: any };
};

Expand Down Expand Up @@ -234,7 +230,7 @@ const SpecialParseRules = {

// Push a new rule onto the state.
function pushRule(
rules: typeof ParseRulesType,
rules: typeof ParseRules,
state: State,
ruleKind: RuleKind,
): void {
Expand Down Expand Up @@ -346,7 +342,7 @@ function unsuccessful(state: State): void {

// Given a stream, returns a { kind, value } pair, or null.
function lex(
lexRules: Partial<typeof LexRulesType>,
lexRules: Partial<typeof LexRules>,
stream: CharacterStream,
): Token | null | undefined {
const kinds = Object.keys(lexRules);
Expand Down
3 changes: 2 additions & 1 deletion packages/monaco-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
"peerDependencies": {
"graphql": "^15.5.0 || ^16.0.0",
"monaco-editor": "^0.20.0"
"monaco-editor": "^0.20.0",
"prettier": "^2.8.0 || ^3.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/monaco-graphql/src/GraphQLWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class GraphQLWorker {
),
};
} catch (err) {
// eslint-disable-next-line
// eslint-disable-next-line no-console
console.error(err);
return null;
}
Expand Down
1 change: 1 addition & 0 deletions packages/vscode-graphql-execution/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"graphql-tag": "2.12.6",
"graphql-ws": "5.10.0",
"@whatwg-node/fetch": "0.2.8",
"wonka": "4.0.15",
"ws": "8.8.1",
"graphql": "16.6.0",
"nullthrows": "1.1.1"
Expand Down
Loading

0 comments on commit c3f32c8

Please sign in to comment.