eslint-plugin-sort-component
v1.0.9
Published
Eslint plugin to sort expressions inside of the React component
Downloads
7
Maintainers
Readme
eslint-plugin-sort-component
eslint-plugin-sort-component
is an ESLint plugin designed to sort expressions inside React components. This plugin helps maintain a consistent order of statements within your components, improving readability and maintainability.
The expected order of statements is as follows:
- Selectors
- Dispatchers
- Built-in hooks (useState, useEffect, etc.)
- Custom hooks (useCounter, etc.)
- Declarations (Constants and variables)
- Functions
Installation
To install the plugin, run:
npm install -D eslint-plugin-sort-component
Ensure that you have ESLint installed as a peer dependency:
npm install -D eslint
Usage
Add sort-component to the plugins section of your ESLint configuration file (e.g., eslint.config.js):
// eslint.config.js
import sortComponent from 'eslint-plugin-sort-component'
//...settings
plugins: {
//...plugins
'sort-component': sortComponent
}
Then, add the rule to the rules section:
//...settings
rules: {
//...rules
'sort-component/sort-component': 'warn'
}
License
This project is licensed under the MIT License.
Made with ❤️ by German Tellez in Colombia 🇨🇴