Skip to content

Commit

Permalink
enable sonarjs/no-identical-functions, `sonarjs/no-unused-collectio…
Browse files Browse the repository at this point in the history
…n`, `sonarjs/no-extra-arguments` rules (#3038)
  • Loading branch information
dimaMachina authored Feb 24, 2023
1 parent 04c876b commit 708c428
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
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

0 comments on commit 708c428

Please sign in to comment.