ESLint rules for React Native Unistyles to help you write cleaner, more maintainable stylesheets.
- ESLint
- React Native Unistyles
^3.0.0
Install the plugin as a dev dependency:
yarn add eslint-plugin-react-native-unistyles -DFor ESLint 9+ with flat config:
import { defineConfig } from 'eslint/config';
import unistyles from 'eslint-plugin-react-native-unistyles';
export default defineConfig([
// Your other configs...
unistyles.configs.recommended,
]);import unistyles from 'eslint-plugin-react-native-unistyles';
export default defineConfig([
{
plugins: {
'react-native-unistyles': unistyles,
},
rules: {
'react-native-unistyles/no-unused-styles': 'error',
'react-native-unistyles/sort-styles': [
'warn',
'asc',
{
ignoreStyleNames: false,
ignoreStyleProperties: false
}
],
},
},
]);For older ESLint versions:
{
"extends": ["plugin:react-native-unistyles/legacy-recommended"]
}{
"plugins": ["react-native-unistyles"],
"rules": {
"react-native-unistyles/no-unused-styles": "warn",
"react-native-unistyles/sort-styles": [
"warn",
"asc",
{
"ignoreStyleNames": false,
"ignoreStyleProperties": false
}
]
}
}If it is not already the case you must also configure ESLint to support JSX.
{
"languageOptions": {
"parserOptions": {
"ecmaFeatures": {"jsx": true}
}
}
}| Rule | Description |
|---|---|
no-unused-styles |
Detect unused stylesheet definitions |
sort-styles |
Enforce sorted style properties |
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by eslint-plugin-react-native
- Built for React Native Unistyles by @jpudysz
- React Native Unistyles - The styling library this plugin supports
- ESLint - The pluggable linting utility for JavaScript
