Skip to content

Commit

Permalink
enable unicorn/no-array-push-push rule (#3047)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina authored Mar 19, 2023
1 parent b82df99 commit 190fae8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-ravens-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'monaco-graphql': patch
---

combining multiple Array#push() into one call
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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]);
Expand Down
29 changes: 12 additions & 17 deletions packages/monaco-graphql/src/languageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 190fae8

Please sign in to comment.