toeverything / AFFiNE

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
https://affine.pro
Other
41.98k stars 2.74k forks source link

The no-cycle rule of oxlint missed some errors #7580

Open Brooooooklyn opened 3 months ago

Brooooooklyn commented 3 months ago

yarn lint:ox is fine on our canary branch. But if run yarn oxlint --import-plugin -D no-cycle -D no-self-import packages/backend/server/dist on compiled files, there are several errors:

× eslint-plugin-import(no-cycle): Dependency cycle detected
    ╭─[packages/backend/server/dist/core/features/index.js:10:43]
  9 │ import { EarlyAccessType, FeatureManagementService } from './management';
 10 │ import { FeatureManagementResolver } from './resolver';
    ·                                           ────────────
 11 │ import { FeatureService } from './service';
    ╰────
  help: These paths form a cycle:
        -> ./resolver - packages/backend/server/dist/core/features/resolver.js
        -> ../common - packages/backend/server/dist/core/common/index.js
        -> ./admin-guard - packages/backend/server/dist/core/common/admin-guard.js
        -> ../features - packages/backend/server/dist/core/features/index.js

  × eslint-plugin-import(no-cycle): Dependency cycle detected
    ╭─[packages/backend/server/dist/core/user/index.js:10:54]
  9 │ import { UserAvatarController } from './controller';
 10 │ import { UserManagementResolver, UserResolver } from './resolver';
    ·                                                      ────────────
 11 │ import { UserService } from './service';
    ╰────
  help: These paths form a cycle:
        -> ./resolver - packages/backend/server/dist/core/user/resolver.js
        -> ../common - packages/backend/server/dist/core/common/index.js
        -> ./admin-guard - packages/backend/server/dist/core/common/admin-guard.js
        -> ../features - packages/backend/server/dist/core/features/index.js
        -> ../user - packages/backend/server/dist/core/user/index.js

Finished in 73ms on 787 files with 2 rules using 16 threads.
Found 0 warnings and 2 errors.
affine-issue-bot[bot] commented 3 months ago

Issue Status: 🆕 *Untriaged

*🆕 Untriaged**

The team has not yet reviewed the issue. We usually do it within one business day. Docs: https://github.com/toeverything/AFFiNE/blob/canary/docs/issue-triaging.md

This is an automatic reply by the bot.

Brooooooklyn commented 3 months ago

/cc @Boshen

Boshen commented 3 months ago

https://github.com/toeverything/AFFiNE/blob/b0ad36425d6299d31a20ecdad795916af583dd02/.eslintignore#L2

My guess is the ignore match here.

Specifying packages/backend/server/dist forces linting this path.

Brooooooklyn commented 3 months ago

@Boshen What I mean is that circular dependencies can be found in the compiled code, but not in the TypeScript code.

Boshen commented 3 months ago

Probably a bug, can you assign this to me so I don't forget?

Boshen commented 1 month ago

The referenced fix will display the following output, feel free to fix these before our next release.

oxlint -c oxlint.json --tsconfig tsconfig.json --import-plugin

  × eslint-plugin-import(no-cycle): Dependency cycle detected
   ╭─[packages/backend/server/src/core/features/index.ts:3:28]
 2 │
 3 │ import { UserModule } from '../user';
   ·                            ─────────
 4 │ import { EarlyAccessType, FeatureManagementService } from './management';
   ╰────
  help: These paths form a cycle:
        -> ../user - packages/backend/server/src/core/user/index.ts
        -> ./resolver - packages/backend/server/src/core/user/resolver.ts
        -> ../common - packages/backend/server/src/core/common/index.ts
        -> ./admin-guard - packages/backend/server/src/core/common/admin-guard.ts
        -> ../features - packages/backend/server/src/core/features/index.ts

  × eslint-plugin-import(no-cycle): Dependency cycle detected
    ╭─[packages/backend/server/src/core/user/resolver.ts:24:23]
 23 │ import { CurrentUser } from '../auth/session';
 24 │ import { Admin } from '../common';
    ·                       ───────────
 25 │ import { AvatarStorage } from '../storage';
    ╰────
  help: These paths form a cycle:
        -> ../common - packages/backend/server/src/core/common/index.ts
        -> ./admin-guard - packages/backend/server/src/core/common/admin-guard.ts
        -> ../features - packages/backend/server/src/core/features/index.ts
        -> ../user - packages/backend/server/src/core/user/index.ts
        -> ./resolver - packages/backend/server/src/core/user/resolver.ts

  × eslint-plugin-import(no-cycle): Dependency cycle detected
   ╭─[packages/frontend/core/src/components/page-list/index.tsx:6:15]
 5 │ export * from './components/page-display-menu';
 6 │ export * from './docs';
   ·               ────────
 7 │ export * from './docs/page-list-item';
   ╰────
  help: These paths form a cycle:
        -> ./docs - packages/frontend/core/src/components/page-list/docs/index.ts
        -> ./virtualized-page-list - packages/frontend/core/src/components/page-list/docs/virtualized-page-list.tsx
        -> ./page-list-header - packages/frontend/core/src/components/page-list/docs/page-list-header.tsx
        -> ../view/use-edit-collection - packages/frontend/core/src/components/page-list/view/use-edit-collection.tsx
        -> ./edit-collection/edit-collection - packages/frontend/core/src/components/page-list/view/edit-collection/edit-collection.tsx
        -> @affine/core/components/hooks/affine/use-all-page-list-config - packages/frontend/core/src/components/hooks/affine/use-all-page-list-config.tsx
        -> @affine/core/components/page-list - packages/frontend/core/src/components/page-list/index.tsx

  × eslint-plugin-import(no-cycle): Dependency cycle detected
    ╭─[packages/frontend/core/src/modules/peek-view/index.ts:15:57]
 14 │ export { PeekViewEntity, PeekViewService };
 15 │ export { PeekViewManagerModal, useInsidePeekView } from './view';
    ·                                                         ────────
    ╰────
  help: These paths form a cycle:
        -> ./view - packages/frontend/core/src/modules/peek-view/view/index.ts
        -> ./peek-view-manager - packages/frontend/core/src/modules/peek-view/view/peek-view-manager.tsx
        -> ./doc-preview - packages/frontend/core/src/modules/peek-view/view/doc-preview/index.ts
        -> ./doc-peek-view - packages/frontend/core/src/modules/peek-view/view/doc-preview/doc-peek-view.tsx
        -> @affine/core/components/blocksuite/block-suite-editor - packages/frontend/core/src/components/blocksuite/block-suite-editor/index.ts
        -> ./blocksuite-editor - packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx
        -> ./blocksuite-editor-container - packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor-container.tsx
        -> ./lit-adaper - packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx
        -> ./bi-directional-link-panel - packages/frontend/core/src/components/blocksuite/block-suite-editor/bi-directional-link-panel.tsx
        -> ../../affine/reference-link - packages/frontend/core/src/components/affine/reference-link/index.tsx
        -> @affine/core/modules/peek-view - packages/frontend/core/src/modules/peek-view/index.ts
Boshen commented 1 month ago

Released in oxlint v0.9.8