ESLint Plugin Clean Styled Components

raw JSON →
0.0.2 verified Fri May 01 auth: no javascript

An ESLint plugin that enforces clean code practices in styled-components usage. Version 0.0.2 is the latest, with no known release cadence. It provides rules such as 'single-component-per-file' to enforce one styled component per file. Unlike other styled-components lint plugins, this focuses on structural cleanliness rather than syntax or style. No major changes or updates have been made since initial release.

error ESLint couldn't find the plugin "eslint-plugin-clean-styled-components".
cause Plugin not installed or ESLint cannot find it due to global/local mismatch.
fix
Install plugin locally: npm install eslint-plugin-clean-styled-components --save-dev
error Configuration for rule "clean-styled-components/single-component-per-file" is invalid.
cause Invalid rule severity or rule name typo.
fix
Use numeric severity (0,1,2) or string ('off','warn','error'). Ensure rule name is kebab-case.
gotcha The plugin is very early (v0.0.2) and may have limited rules or bugs. Only one rule is documented.
fix Consider other mature styled-components lint plugins like eslint-plugin-styled-components-a11y or custom rules.
gotcha The plugin does not appear to support TypeScript or styled-components macro syntax out of the box.
fix Use a more comprehensive plugin or extend with custom rule parsers.
npm install eslint-plugin-clean-styled-components
yarn add eslint-plugin-clean-styled-components
pnpm add eslint-plugin-clean-styled-components

Shows how to enable the 'single-component-per-file' rule in ESLint config and an example that violates it.

// .eslintrc.json
{
  "plugins": ["clean-styled-components"],
  "rules": {
    "clean-styled-components/single-component-per-file": 2
  }
}

// styled-components file (styled.js)
// This will fail lint because multiple styled components are in one file
import styled from 'styled-components';

export const Button = styled.button`
  color: red;
`;

export const Input = styled.input`
  border: 1px solid;
`;