azat-io / eslint-plugin-perfectionist

🦄 ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.
https://eslint-plugin-perfectionist.azat.io
MIT License
1.62k stars 28 forks source link

fix(sort-exports): work with star exports #124

Closed chirokas closed 1 month ago

chirokas commented 1 month ago

Description

Fixes #119 .

Additional context


What is the purpose of this pull request?

Before submitting the PR, please make sure you do the following

azat-io commented 1 month ago

I think we should add a check that these are TS or TSX files. For javascript files, this behavior looks unsafe.

chirokas commented 1 month ago

That has nothing to do with sort-exports.

If there are two wildcard exports statements that implicitly re-export the same name, neither one is re-exported.

// -- mod1.js --
export const a = 1

// -- mod2.js --
export const a = 3

// -- barrel.js --
export * from './mod1.js'
export * from './mod2.js'

// -- main.js --
import * as ns from './barrel.js'
console.log(ns.a) // undefined

Attempting to import the duplicate name directly will throw an error.

import { a } from './barrel.js'
// Uncaught SyntaxError: The requested module './barrel.js' contains conflicting star exports for name 'a'
azat-io commented 1 month ago

Okay. Thank you!