Skip to content
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

🛠️ ESLint: clean all ESLint warnings, add --max-warnings=0 and --cache flags #2962

Merged
merged 3 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/orange-carrots-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'cm6-graphql': patch
'codemirror-graphql': patch
'graphiql': patch
'@graphiql/toolkit': patch
'graphql-language-service': patch
'graphql-language-service-server': patch
---

clean all ESLint warnings, add `--max-warnings=0` and `--cache` flags
20 changes: 5 additions & 15 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ module.exports = {
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
Comment on lines -17 to -19
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be set while extending react recommended config

},
settings: {
react: {
Expand All @@ -29,10 +26,7 @@ module.exports = {
es6: true,
node: true,
browser: true,
jest: true,
'jest/globals': true,
Comment on lines -32 to -33
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to set this for all files

},

extends: [
'eslint:recommended',
'plugin:import/recommended',
Expand Down Expand Up @@ -107,7 +101,7 @@ module.exports = {
'no-script-url': 1,
'no-self-compare': 1,
'no-sequences': 1,
'no-throw-literal': 1,
'no-throw-literal': 'error',
'no-unmodified-loop-condition': 0,
'no-useless-call': 1,
'no-useless-concat': 1,
Expand Down Expand Up @@ -215,7 +209,7 @@ module.exports = {
'no-useless-computed-key': 1,
'no-useless-constructor': 0,
'no-useless-rename': 1,
'no-var': 1,
'no-var': 'error',
'object-shorthand': 1,
'prefer-arrow-callback': [0, { allowNamedFunctions: true }], // prettier --list-different
'prefer-const': 1,
Expand All @@ -230,7 +224,7 @@ module.exports = {
'import/no-duplicates': 'error',
'import/no-named-as-default': 'error',
'prefer-object-spread': 'error',
// react rules
// React rules
'react/no-unused-state': 'error',
'react/jsx-curly-brace-presence': 'error',
'react/jsx-boolean-value': 'error',
Expand Down Expand Up @@ -258,8 +252,6 @@ module.exports = {
'error',
{ extensions: ['.tsx', '.jsx'], allow: 'as-needed' },
],
// Jest rules
'jest/no-conditional-expect': 0,

'unicorn/consistent-destructuring': 'error',
'prefer-destructuring': ['error', { VariableDeclarator: { object: true } }],
Expand Down Expand Up @@ -300,11 +292,9 @@ module.exports = {
'**/*.spec.{ts,js.jsx.tsx}',
],
extends: ['plugin:jest/recommended'],
env: {
'jest/globals': true,
},
Comment on lines -303 to -305
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be set while extending jest recommend config

rules: {
'jest/no-conditional-expect': 0,
'jest/no-conditional-expect': 'off',
'jest/expect-expect': ['error', { assertFunctionNames: ['expect*'] }],
},
},
{
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ yarn-1.18.0.js
.netlify

examples/*/yarn.lock
.eslintcache
5 changes: 2 additions & 3 deletions examples/monaco-graphql-react-vite/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,13 @@ export default function App() {
localStorage.setItem('variables', variablesModel.getValue());
}),
);

// only run once on mount
// eslint-disable-next-line react-hooks/exhaustive-deps -- only run once on mount
}, []);

useEffect(() => {
queryEditor?.addAction(queryAction);
variablesEditor?.addAction(queryAction);
}, [variablesEditor]);
}, [queryEditor, variablesEditor]);
/**
* Handle the initial schema load
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"dev-graphiql": "yarn workspace graphiql dev",
"e2e": "yarn run e2e:build && yarn workspace graphiql e2e",
"e2e:build": "yarn build && yarn workspace graphiql run build-bundles-min",
"eslint": "eslint --ext=ts,js,jsx,tsx .",
"eslint": "eslint --max-warnings=0 --cache --ext=ts,js,jsx,tsx .",
"format": "yarn eslint --fix && yarn pretty",
"jest": "jest",
"license-check": "jsgl --local ./",
Expand Down
1 change: 1 addition & 0 deletions packages/cm6-graphql/__tests__/test.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable jest/expect-expect */
import { graphqlLanguage } from '../dist/index.js';
import { fileTests } from '@lezer/generator/dist/test';

Expand Down
2 changes: 1 addition & 1 deletion packages/codemirror-graphql/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'codemirror/addon/hint/show-hint';

declare module 'codemirror' {
var Init: any;
let Init: any;

interface Editor {
doc: CodeMirror.Doc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import jsonParse, { ParseTokenOutput } from '../jsonParse';

describe('jsonParse', () => {
function checkEscapedString(
function expectEscapedString(
str: string,
key: ParseTokenOutput,
value: ParseTokenOutput,
Expand All @@ -21,17 +21,17 @@ describe('jsonParse', () => {
}

it('correctly parses escaped strings', () => {
checkEscapedString(
expectEscapedString(
'{ "test": "\\"" }',
{ kind: 'String', start: 2, end: 8, value: 'test' },
{ kind: 'String', start: 10, end: 14, value: '"' },
);
checkEscapedString(
expectEscapedString(
'{ "test": "\\\\" }',
{ kind: 'String', start: 2, end: 8, value: 'test' },
{ kind: 'String', start: 10, end: 14, value: '\\' },
);
checkEscapedString(
expectEscapedString(
'{ "slash": "\\/" }',
{ kind: 'String', start: 2, end: 9, value: 'slash' },
{ kind: 'String', start: 11, end: 15, value: '/' },
Expand Down
20 changes: 10 additions & 10 deletions packages/codemirror-graphql/src/variables/__tests__/hint-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function getHintSuggestions(
});
}

function checkSuggestions(source: string[], suggestions?: IHint[]) {
function expectSuggestions(source: string[], suggestions?: IHint[]) {
const titles = suggestions?.map(suggestion => suggestion.text);
expect(titles).toEqual(source);
}
Expand All @@ -62,7 +62,7 @@ describe('graphql-variables-hint', () => {
it('provides correct initial token', async () => {
const suggestions = await getHintSuggestions('', '', { line: 0, ch: 0 });
const initialKeywords = ['{'];
checkSuggestions(initialKeywords, suggestions?.list);
expectSuggestions(initialKeywords, suggestions?.list);
});

it('provides correct field name suggestions', async () => {
Expand All @@ -71,7 +71,7 @@ describe('graphql-variables-hint', () => {
'{ ',
{ line: 0, ch: 2 },
);
checkSuggestions(['"foo": ', '"bar": '], suggestions?.list);
expectSuggestions(['"foo": ', '"bar": '], suggestions?.list);
});

it('provides correct variable suggestion indentation', async () => {
Expand All @@ -90,7 +90,7 @@ describe('graphql-variables-hint', () => {
'{\n ba',
{ line: 1, ch: 4 },
);
checkSuggestions(['"bar": '], suggestions?.list);
expectSuggestions(['"bar": '], suggestions?.list);
expect(suggestions?.from).toEqual({ line: 1, ch: 2, sticky: null });
expect(suggestions?.to).toEqual({ line: 1, ch: 4, sticky: null });
});
Expand All @@ -101,7 +101,7 @@ describe('graphql-variables-hint', () => {
'{\n "',
{ line: 1, ch: 4 },
);
checkSuggestions(['"foo": ', '"bar": '], suggestions?.list);
expectSuggestions(['"foo": ', '"bar": '], suggestions?.list);
expect(suggestions?.from).toEqual({ line: 1, ch: 2, sticky: null });
expect(suggestions?.to).toEqual({ line: 1, ch: 3, sticky: null });
});
Expand All @@ -113,7 +113,7 @@ describe('graphql-variables-hint', () => {
{ line: 1, ch: 12 },
);
const TestEnum = TestSchema.getType('TestEnum');
checkSuggestions(
expectSuggestions(
(TestEnum as GraphQLEnumType)
?.getValues()
.map(value => `"${value.name}"`),
Expand All @@ -127,7 +127,7 @@ describe('graphql-variables-hint', () => {
'{\n "myInput": ',
{ line: 1, ch: 13 },
);
checkSuggestions(['{'], suggestions?.list);
expectSuggestions(['{'], suggestions?.list);
});

it('provides Input Object fields', async () => {
Expand All @@ -137,7 +137,7 @@ describe('graphql-variables-hint', () => {
{ line: 2, ch: 4 },
);
const TestInput = TestSchema.getType('TestInput');
checkSuggestions(
expectSuggestions(
Object.keys((TestInput as GraphQLInputObjectType).getFields()).map(
name => `"${name}": `,
),
Expand All @@ -153,7 +153,7 @@ describe('graphql-variables-hint', () => {
'{\n "myInput": {\n bool',
{ line: 2, ch: 8 },
);
checkSuggestions(['"boolean": ', '"listBoolean": '], suggestions?.list);
expectSuggestions(['"boolean": ', '"listBoolean": '], suggestions?.list);
expect(suggestions?.from).toEqual({ line: 2, ch: 4, sticky: null });
expect(suggestions?.to).toEqual({ line: 2, ch: 8, sticky: null });
});
Expand All @@ -164,6 +164,6 @@ describe('graphql-variables-hint', () => {
'{\n "myInput": {\n "boolean": ',
{ line: 2, ch: 15 },
);
checkSuggestions(['true', 'false'], suggestions?.list);
expectSuggestions(['true', 'false'], suggestions?.list);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ describe('missing graphql-ws dependency', () => {
it('should throw a nice error', () => {
jest.resetModules();
jest.doMock('graphql-ws', () => {
// eslint-disable-next-line no-throw-literal
throw { code: 'MODULE_NOT_FOUND' };
});

Expand Down
Loading