bem / bem-react

A set of tools for developing user interfaces using the BEM methodology in React
http://bem.github.io/bem-react
Other
440 stars 64 forks source link

@bem-react/classname: lint formatter usage with null #604

Closed PavelPivkin closed 3 years ago

PavelPivkin commented 3 years ago

The declared type of classname formatter always allows to use null as a first argument. However using formatter with null and blockMods returns only block name.

const cat = cn('Cat')

cat() // Cat

cat({ size: 'm' }) // Cat Cat_size_m
// but
cat(null, { size: 'm' }) // Cat

// mixes
cat(null, ['Dog']) // Cat Dog
// but
cat(null, { size: 'm' }, ['Dog']) // Cat

Let's fix ClassNameFormatter type https://github.com/bem/bem-react/blob/master/packages/classname/classname.ts#L21

PavelPivkin commented 3 years ago

PR with fix: https://github.com/bem/bem-react/pull/605