microsoft/rnx-kit

eslint-plugin: incorrect expansion of namespace exports in fixer

ecraig12345 opened this issue · 0 comments

What happened?

Currently the no-export-all fixer has incorrect expansion of namespace exports: it will export all the individual identifiers instead of the namespace.

Consider this scenario:

// utils/foo.ts
export const bar = 'bar';
export type Baz = {};

// utils/index.ts
export * as foo from './foo'; // ❌ lint error!

// bar.ts
import { foo } from './utils';
const bar: foo.Bar = {};
console.log(foo.bar);

The no-export-all fixer will fix the lint error in my-pkg/index.ts as follows, which breaks the consuming code:

// utils/index.ts
export { bar } from './foo';
export type { Baz } from './foo';

// bar.ts
import { foo } from 'my-pkg'; // ❌ error, foo does not exist!
const bar: foo.Bar = {};
console.log(foo.bar);

Correct output (I think):

// utils/index.ts
import * as foo from './foo';
export { foo };

Affected Package

@rnx-kit/eslint-plugin

Version

0.4.1

Which platforms are you seeing this issue on?

n/a

System Information

n/a

Steps to Reproduce

see above

Code of Conduct

  • I agree to follow this project's Code of Conduct