Code Style Rulesfor React Projects
81 custom ESLint rules for enforcing consistent code formatting in React and JSX projects. 71 auto-fixable, 20 configurable, zero dependencies.
81 rules · 71 auto-fix · zero deps
hover the editor to pause →
author's note
Most linters hand you a thousand options and ask you to decide. This one picks for you — opinionated defaults, auto-fixed where possible. It enforces the decisions Prettier deliberately leaves to you: prop order, absolute imports, extracted strings, component structure. If you disagree, configure it. If you don't, you're already done.
It enforces the decisions Prettier deliberately leaves to you.
— why this plugin exists
where Prettier stops.
The things Prettier won't do.
Prettier reformats what's formattable. This plugin enforces what's opinionated. The two are complementary — run them both.
Prettier only
<Button onClick={onSave} disabled={isLoading} type="submit"> Save</Button>with this plugin
<Button disabled={isLoading} type="submit" onClick={onSave}> Save</Button>JSX props — alphabetical, callbacks last · react/jsx-sort-props
Prettier only
import { Button } from "../../components/button";import { useTheme } from "../../hooks/use-theme";with this plugin
import { Button } from "@/components";import { useTheme } from "@/hooks";Imports — absolute via @/ alias · code-style/absolute-imports-only
Prettier only
<p className="text-sm">Welcome to the dashboard</p>with this plugin
<p className="text-sm">{uiStringsData.welcome}</p>Strings — extracted into data files · code-style/no-hardcoded-strings
the gestures
Six things it does.
Built to fill the gaps left by existing ESLint and Prettier plugins.
01
Auto-Fixable Rules
71 of 81 rules come with auto-fix support. Run eslint --fix and watch your code snap into shape.
02
React & JSX First
Purpose-built for React projects. JSX formatting, component conventions, hook patterns, and prop naming.
03
ESLint v9+ Flat Config
Designed for the modern flat config system. No legacy .eslintrc files needed.
04
Zero Dependencies
No external runtime dependencies. Lightweight and fast, with no supply-chain concerns.
05
TypeScript Support
9 TypeScript-specific rules for enums, interfaces, type annotations, and prop naming.
06
Ready-to-Use Configs
4 preset configs for React, React+TypeScript, React+Tailwind, and React+TypeScript+Tailwind.
the index
The complete index.
All 81 rules, grouped into 17 categories. Every category page lists rules with examples, rationale, and options.
Quick Start
Get up and running in under a minute.
this works in seconds ✦
Install
npm install -D eslint-plugin-code-styleConfigure
import codeStyle from "eslint-plugin-code-style"; export default [ codeStyle.configs.react,];Using TypeScript? Use react-ts instead:
import codeStyle from "eslint-plugin-code-style"; export default [ codeStyle.configs["react-ts"],];Lint
npx eslint . --fix