absolute/no-multi-style-objects
Disallow grouping CSS style objects in a single export; export each style separately.
#Rule Details
Disallows grouping multiple CSS style objects under a single export default object or a single returned object. The rule counts properties whose key ends in Style; when more than one such property shares an object, it asks you to export each style on its own.
Separate exports keep styles individually importable and tree-shakeable, make diffs smaller, and pair naturally with sort-exports. Objects with at most one *Style key, and properties with other names, are left alone.
#Examples
export default {
headerStyle: { color: 'red' },
footerStyle: { color: 'blue' }
};function getStyles() {
return { headerStyle: {}, footerStyle: {} };
}Export each style separately
export const headerStyle: CSSProperties = { color: 'red' };
export const footerStyle: CSSProperties = { color: 'blue' };export default { headerStyle: {}, version: 1 }; // only one *Style key#Configuration
Enable this rule in your ESLint configuration:
{
rules: {
'absolute/no-multi-style-objects': 'error'
}
}#Related Rules
#When Not To Use It
If you deliberately bundle related styles into a single theme object that is consumed as a unit, this rule works against that pattern — disable it for those modules.