From bb88af80cfca39c8532849f64f3dca4363509dc7 Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Thu, 13 May 2021 12:21:35 +0200 Subject: [PATCH] Merge pull request #3947 from overleaf/msm-reenable-eslint-rules Reenable `eslint` rules GitOrigin-RevId: a0aa5f941ba1bc49ff758b5256f91d696f442c6d --- services/web/.eslintrc | 8 -------- .../app/src/Features/LinkedFiles/LinkedFilesController.js | 7 ++++++- .../components/online-users-widget.js | 2 ++ .../file-tree/components/file-tree-context-menu.js | 2 ++ .../preview/components/preview-download-file-list.js | 8 +++----- .../aceEditor/track-changes/TrackChangesManager.js | 2 +- services/web/frontend/js/ide/history/HistoryManager.js | 5 +++-- .../web/frontend/js/ide/pdfng/directives/pdfViewer.js | 1 + .../controllers/UserAffiliationsController.js | 4 +--- .../modals/create-file/create-file-modal-decorator.js | 2 +- .../frontend/features/chat/context/chat-context.test.js | 1 + .../preview/components/preview-download-file-list.test.js | 2 +- services/web/test/unit/src/Uploads/ArchiveManagerTests.js | 2 +- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/services/web/.eslintrc b/services/web/.eslintrc index 9f77b5761c..80ba6dd196 100644 --- a/services/web/.eslintrc +++ b/services/web/.eslintrc @@ -41,11 +41,7 @@ // Disable some rules after upgrading ESLint // TODO: re-enable and fix - "no-prototype-builtins": "off", "no-var": "off", - "array-callback-return": "off", - "no-unreachable-loop": "off", - "no-loss-of-precision": "off", // do not allow importing of implicit dependencies. "import/no-extraneous-dependencies": "error", @@ -55,11 +51,7 @@ "node/handle-callback-err": "off", "node/no-path-concat": "off", - "react/display-name": "off", - "react/no-unescaped-entities": "off", - "react/no-unused-prop-types": "off", "react/jsx-no-target-blank": "off", - "react/jsx-handler-names": "off" }, "overrides": [ // NOTE: changing paths may require updating them in the Makefile too. diff --git a/services/web/app/src/Features/LinkedFiles/LinkedFilesController.js b/services/web/app/src/Features/LinkedFiles/LinkedFilesController.js index 4106e86e84..860093564c 100644 --- a/services/web/app/src/Features/LinkedFiles/LinkedFilesController.js +++ b/services/web/app/src/Features/LinkedFiles/LinkedFilesController.js @@ -48,7 +48,12 @@ module.exports = LinkedFilesController = { ), _getAgent(provider) { - if (!LinkedFilesController.Agents.hasOwnProperty(provider)) { + if ( + !Object.prototype.hasOwnProperty.call( + LinkedFilesController.Agents, + provider + ) + ) { return null } if (!Array.from(Settings.enabledLinkedFileTypes).includes(provider)) { diff --git a/services/web/frontend/js/features/editor-navigation-toolbar/components/online-users-widget.js b/services/web/frontend/js/features/editor-navigation-toolbar/components/online-users-widget.js index f1e1a68093..3b01c1c93c 100644 --- a/services/web/frontend/js/features/editor-navigation-toolbar/components/online-users-widget.js +++ b/services/web/frontend/js/features/editor-navigation-toolbar/components/online-users-widget.js @@ -112,6 +112,8 @@ const DropDownToggleButton = React.forwardRef((props, ref) => { ) }) +DropDownToggleButton.displayName = 'DropDownToggleButton' + DropDownToggleButton.propTypes = { onlineUserCount: PropTypes.number.isRequired, onClick: PropTypes.func, diff --git a/services/web/frontend/js/features/file-tree/components/file-tree-context-menu.js b/services/web/frontend/js/features/file-tree/components/file-tree-context-menu.js index 3621631795..2e2ec06093 100644 --- a/services/web/frontend/js/features/file-tree/components/file-tree-context-menu.js +++ b/services/web/frontend/js/features/file-tree/components/file-tree-context-menu.js @@ -50,4 +50,6 @@ const FakeDropDownToggle = React.forwardRef((props, ref) => { return null }) +FakeDropDownToggle.displayName = 'FakeDropDownToggle' + export default FileTreeContextMenu diff --git a/services/web/frontend/js/features/preview/components/preview-download-file-list.js b/services/web/frontend/js/features/preview/components/preview-download-file-list.js index e3fd0e772a..0ef1846075 100644 --- a/services/web/frontend/js/features/preview/components/preview-download-file-list.js +++ b/services/web/frontend/js/features/preview/components/preview-download-file-list.js @@ -13,16 +13,14 @@ function PreviewDownloadFileList({ fileList = [] }) { if (fileList) { topFiles = fileList.filter(file => { - if (topFileTypes.includes(file.type)) { - return file - } + return topFileTypes.includes(file.type) }) otherFiles = fileList.filter(file => { if (!topFileTypes.includes(file.type)) { - if (file.type === 'pdf' && file.main === true) return - return file + return !(file.type === 'pdf' && file.main === true) } + return false }) } diff --git a/services/web/frontend/js/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.js b/services/web/frontend/js/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.js index 013bb147c5..f66f2433a8 100644 --- a/services/web/frontend/js/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.js +++ b/services/web/frontend/js/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.js @@ -168,7 +168,7 @@ class TrackChangesManager { } } - Array.from(this.rangesTracker.comments).map(comment => { + Array.from(this.rangesTracker.comments).forEach(comment => { if (!this.isCommentResolved(comment)) { this.adapter.onCommentAdded(comment) } diff --git a/services/web/frontend/js/ide/history/HistoryManager.js b/services/web/frontend/js/ide/history/HistoryManager.js index 0c77de7cbc..1ae712cd35 100644 --- a/services/web/frontend/js/ide/history/HistoryManager.js +++ b/services/web/frontend/js/ide/history/HistoryManager.js @@ -364,10 +364,11 @@ export default HistoryManager = (function () { if (selected_doc != null && affected_docs[selected_doc.id] != null) { // Selected doc is already open } else { - for (doc_id in affected_docs) { + const doc_ids = Object.keys(affected_docs) + if (doc_ids.length > 0) { + const doc_id = doc_ids[0] doc = affected_docs[doc_id] selected_doc = doc - break } } diff --git a/services/web/frontend/js/ide/pdfng/directives/pdfViewer.js b/services/web/frontend/js/ide/pdfng/directives/pdfViewer.js index a8193ebd90..28a6831cd9 100644 --- a/services/web/frontend/js/ide/pdfng/directives/pdfViewer.js +++ b/services/web/frontend/js/ide/pdfng/directives/pdfViewer.js @@ -224,6 +224,7 @@ App.controller( let ref return ([topPageIdx, topPage] = Array.from((ref = [i, page]))), ref } + return false }) if (visible && topPage.element != null) { // console.log 'found it', topPageIdx diff --git a/services/web/frontend/js/main/affiliations/controllers/UserAffiliationsController.js b/services/web/frontend/js/main/affiliations/controllers/UserAffiliationsController.js index 1666416b01..6caecc5ffc 100644 --- a/services/web/frontend/js/main/affiliations/controllers/UserAffiliationsController.js +++ b/services/web/frontend/js/main/affiliations/controllers/UserAffiliationsController.js @@ -309,9 +309,7 @@ export default App.controller( }) $scope.linkedInstitutionIds = emails .filter(email => { - if (email.samlProviderId) { - return email.samlProviderId - } + return !!email.samlProviderId }) .map(email => email.samlProviderId) }) diff --git a/services/web/frontend/stories/modals/create-file/create-file-modal-decorator.js b/services/web/frontend/stories/modals/create-file/create-file-modal-decorator.js index 6f25e55405..11342b41ae 100644 --- a/services/web/frontend/stories/modals/create-file/create-file-modal-decorator.js +++ b/services/web/frontend/stories/modals/create-file/create-file-modal-decorator.js @@ -40,6 +40,7 @@ const defaultContextProps = { export const createFileModalDecorator = ( contextProps = {}, createMode = 'doc' + // eslint-disable-next-line react/display-name ) => Story => { fetchMock .restore() @@ -127,7 +128,6 @@ function OpenCreateFileModal({ children, createMode }) { } OpenCreateFileModal.propTypes = { createMode: PropTypes.string, - finishCreating: PropTypes.bool, children: PropTypes.oneOfType([ PropTypes.arrayOf(PropTypes.node), PropTypes.node, diff --git a/services/web/test/frontend/features/chat/context/chat-context.test.js b/services/web/test/frontend/features/chat/context/chat-context.test.js index b44f452d59..82c8e1d896 100644 --- a/services/web/test/frontend/features/chat/context/chat-context.test.js +++ b/services/web/test/frontend/features/chat/context/chat-context.test.js @@ -443,6 +443,7 @@ describe('ChatContext', function () { function renderChatContextHook(props) { return renderHook(() => useChatContext(), { // Wrap with ChatContext.Provider (and the other editor context providers) + // eslint-disable-next-line react/display-name wrapper: ({ children }) => ( {children} ), diff --git a/services/web/test/frontend/features/preview/components/preview-download-file-list.test.js b/services/web/test/frontend/features/preview/components/preview-download-file-list.test.js index 9fd2b9a059..47fc70b87c 100644 --- a/services/web/test/frontend/features/preview/components/preview-download-file-list.test.js +++ b/services/web/test/frontend/features/preview/components/preview-download-file-list.test.js @@ -50,7 +50,7 @@ describe('', function () { expect(topFileTypes.length).to.be.above(0) const outputTopFileTypes = outputFiles .filter(file => { - if (topFileTypes.includes(file.type)) return file.type + return topFileTypes.includes(file.type) }) .map(file => file.type) const topMenuItems = menuItems.slice(0, outputTopFileTypes.length) diff --git a/services/web/test/unit/src/Uploads/ArchiveManagerTests.js b/services/web/test/unit/src/Uploads/ArchiveManagerTests.js index 39ca0441c6..396d17fb57 100644 --- a/services/web/test/unit/src/Uploads/ArchiveManagerTests.js +++ b/services/web/test/unit/src/Uploads/ArchiveManagerTests.js @@ -456,7 +456,7 @@ describe('ArchiveManager', function () { isTooLarge.should.equal(true) return done() }) - this.zipfile.emit('entry', { uncompressedSize: 1090000000000000042 }) + this.zipfile.emit('entry', { uncompressedSize: 109e16 }) return this.zipfile.emit('end') })