Skip to content

Latest commit

 

History

History
50 lines (40 loc) · 916 Bytes

no-unused-styles.md

File metadata and controls

50 lines (40 loc) · 916 Bytes

Disallow unused styles

Rule Details

The following patterns are considered warnings:

function MyComponent({ styles }) {
  return (
    <div {...css(styles.foo)}>
      Foo
    </div>
  );
}

export default withStyles(() => ({
  foo: {
    backgroundColor: 'red',
  },

  bar: { // <--- this style is not used
    backgroundColor: 'green',
  },
}))(MyComponent);

The following patterns are not warnings:

function MyComponent({ styles }) {
  return (
    <div {...css(styles.foo)}>
      Foo
    </div>
  );
}

export default withStyles(() => ({
  foo: {
    backgroundColor: 'red',
  },
}))(MyComponent);

Known limitations

  • Will not detect styles defined by computed properties.
  • Will not detect styles defined by object spread.
  • Will not handle files that contain multiple styled components very well.
  • Will not handle styles prop that has been renamed to something else.