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] enable sonarjs/no-identical-functions, sonarjs/no-unused-collection, sonarjs/no-extra-arguments rules #3038

Merged
merged 1 commit into from
Feb 24, 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
5 changes: 5 additions & 0 deletions .changeset/strong-tips-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vscode-graphql-execution': patch
---

remove unused collection `operationNames` in `executeOperation()`
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ module.exports = {
'require-await': 0,
'vars-on-top': 0,
yoda: 1,
'sonarjs/no-identical-functions': 'error',
'sonarjs/no-unused-collection': 'error',
'sonarjs/no-extra-arguments': 'error',

// Strict Mode (http://eslint.org/docs/rules/#strict-mode)
strict: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ describe('DocExplorer', () => {
const { field } = (Query as GraphQLObjectType).getFields();

// A hacky component to set the initial explorer nav stack
// eslint-disable-next-line sonarjs/no-identical-functions -- todo: could be refactored
const SetInitialStack: React.FC = () => {
const context = useContext(ExplorerContext)!;
useEffect(() => {
Expand Down
11 changes: 5 additions & 6 deletions packages/graphiql/__mocks__/@graphiql/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,11 @@ export const QueryEditor: typeof _QueryEditor = function QueryEditor(props) {
return <div data-testid="query-editor" ref={ref} />;
};

export const ResponseEditor: typeof _ResponseEditor = function ResponseEditor(
props,
) {
const ref = useResponseEditor(props);
return <div ref={ref} />;
};
export const ResponseEditor: typeof _ResponseEditor =
function ResponseEditor() {
const ref = useResponseEditor();
return <div ref={ref} />;
};

export const VariableEditor: typeof _VariableEditor = function VariableEditor(
props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ function getDefinitionForNodeDefinition(
};
}

// eslint-disable-next-line sonarjs/no-identical-functions
function getDefinitionForFieldDefinition(
path: Uri,
text: string,
Expand Down
3 changes: 1 addition & 2 deletions packages/vscode-graphql-execution/src/helpers/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class NetworkHelper {
this.outputChannel = outputChannel;
this.sourceHelper = sourceHelper;
}

private buildClient({
operation,
endpoint,
Expand Down Expand Up @@ -112,12 +113,10 @@ export class NetworkHelper {
projectConfig,
}: ExecuteOperationOptions) {
const operationTypes: OperationTypeNode[] = [];
const operationNames: string[] = [];

visit(literal.ast, {
OperationDefinition(node) {
operationTypes.push(node.operation);
operationNames.push(node.name?.value || '');
},
});
const fragmentDefinitions = await this.sourceHelper.getFragmentDefinitions(
Expand Down