diff --git a/.changeset/two-ravens-care.md b/.changeset/two-ravens-care.md new file mode 100644 index 00000000000..25ca8684577 --- /dev/null +++ b/.changeset/two-ravens-care.md @@ -0,0 +1,5 @@ +--- +'monaco-graphql': patch +--- + +combining multiple Array#push() into one call diff --git a/.eslintrc.js b/.eslintrc.js index 299117cb6eb..3ea3bc76dc2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -228,6 +228,7 @@ module.exports = { 'sort-imports': 0, 'symbol-description': 1, + 'unicorn/no-array-push-push': 'error', 'import/no-extraneous-dependencies': 'error', 'import/no-duplicates': 'error', 'import/no-named-as-default': 'error', diff --git a/packages/graphiql-react/src/explorer/components/__tests__/doc-explorer.spec.tsx b/packages/graphiql-react/src/explorer/components/__tests__/doc-explorer.spec.tsx index 7d70a7707f9..2d8ee2dd1f4 100644 --- a/packages/graphiql-react/src/explorer/components/__tests__/doc-explorer.spec.tsx +++ b/packages/graphiql-react/src/explorer/components/__tests__/doc-explorer.spec.tsx @@ -118,6 +118,7 @@ describe('DocExplorer', () => { useEffect(() => { if (context.explorerNavStack.length === 1) { context.push({ name: 'Query', def: Query }); + // eslint-disable-next-line unicorn/no-array-push-push -- false positive, push here accept only 1 argument context.push({ name: 'field', def: field }); } }, [context]); @@ -184,6 +185,7 @@ describe('DocExplorer', () => { useEffect(() => { if (context.explorerNavStack.length === 1) { context.push({ name: 'Query', def: Query }); + // eslint-disable-next-line unicorn/no-array-push-push -- false positive, push here accept only 1 argument context.push({ name: 'field', def: field }); } }, [context]); diff --git a/packages/monaco-graphql/src/languageFeatures.ts b/packages/monaco-graphql/src/languageFeatures.ts index 2b1f515191a..6b39627e59e 100644 --- a/packages/monaco-graphql/src/languageFeatures.ts +++ b/packages/monaco-graphql/src/languageFeatures.ts @@ -72,32 +72,27 @@ export class DiagnosticsAdapter { } }; - this._disposables.push(editor.onDidCreateModel(onModelAdd)); - this._disposables.push({ - dispose: () => { - clearTimeout(onChangeTimeout); - }, - }); this._disposables.push( + editor.onDidCreateModel(onModelAdd), + { + dispose: () => { + clearTimeout(onChangeTimeout); + }, + }, editor.onWillDisposeModel(model => { onModelRemoved(model); }), - ); - this._disposables.push( editor.onDidChangeModelLanguage(event => { onModelRemoved(event.model); onModelAdd(event.model); }), - ); - - this._disposables.push({ - dispose: () => { - for (const key in this._listener) { - this._listener[key].dispose(); - } + { + dispose: () => { + for (const key in this._listener) { + this._listener[key].dispose(); + } + }, }, - }); - this._disposables.push( defaults.onDidChange(() => { editor.getModels().forEach(model => { if (getModelLanguageId(model) === this.defaults.languageId) {