Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a couple of no-cycle bugs #2083

Merged
merged 2 commits into from May 18, 2021
Merged

Fix a couple of no-cycle bugs #2083

merged 2 commits into from May 18, 2021

Conversation

cherryblossom000
Copy link
Contributor

This fixes these two bugs:

// a.ts
// false positive: reports a cycle even though b.ts is only importing types
import { foo } from './b'

// b.ts
import type { Bar } from './a'
// a.js
// @flow
// false negative: doesn't report a cycle even though b.js is importing the value bar
import { foo } from './b'

// b.js
// @flow
import { bar, type Baz } from './a'

There isn't an open issue for these, but these issues were relatively quick and easy for me to fix so I don't really mind if this PR gets rejected. Also, these bugs were introduced by me in #1974 (oops), so I wanted to fix them.

If you would like me to split these two bug fixes into two PRs, I'm more than happy to do that as well.

…es of importing file

This fixes this situation:

`a.ts`:
```ts
import { foo } from './b'
```

`b.ts`:
```ts
import type { Bar } from './a'
```

Previously, `no-cycle` would have incorrectly reported a dependency cycle for the import in `a.ts`,
even though `b.ts` is only importing types from `a.ts`.
…mporting a value in Flow

This fixes this situation:

`a.js`:
```js
import { foo } from './b'
```

`b.js`:
```js
// @flow
import { bar, type Baz } from './a'
```

Previously, `no-cycle` would have not reported a dependency cycle for the import in `a.js`, even
though `b.js` is importing `bar`, which is not a type import, from `a.js`. This commit fixes that.
@coveralls
Copy link

coveralls commented May 17, 2021

Coverage Status

Coverage increased (+1.0%) to 82.434% when pulling 72b9c3d on cherryblossom000:no-cycle-fixes into 3cf913d on benmosher:master.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good, thanks!

src/rules/no-cycle.js Outdated Show resolved Hide resolved
@ljharb ljharb merged commit 72b9c3d into import-js:master May 18, 2021
@cherryblossom000 cherryblossom000 deleted the no-cycle-fixes branch May 18, 2021 21:20
@Nokel81
Copy link
Contributor

Nokel81 commented May 19, 2021

I am wondering when a new patch release will happen. I would like to use no-cycle in my codebase but we would rely heavily on this bug fix. Thanks.

@ljharb
Copy link
Member

ljharb commented May 21, 2021

v2.23.3 is released.

@Nokel81
Copy link
Contributor

Nokel81 commented May 21, 2021

Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants