eslint-plugin-material-ui
raw JSON → 1.0.1 verified Sat Apr 25 auth: no javascript
Custom ESLint rules for Material-UI projects. Version 1.0.1 is the latest release. This plugin provides a small set of linting rules, such as ignore-before-comment, to enforce code conventions in Material-UI codebases. It is maintained by the Material-UI team, but offers limited rules compared to more comprehensive style linting tools. The plugin follows standard ESLint plugin conventions and requires peer dependency eslint (any version). It is compatible with both CommonJS and ESM ESLint configs.
Common errors
error ESLint couldn't find the plugin "eslint-plugin-material-ui". ↓
cause Missing or not installed in the local node_modules.
fix
Run 'npm install eslint-plugin-material-ui --save-dev' from the project root.
error Error: Failed to load plugin 'material-ui': Cannot find module 'eslint-plugin-material-ui' ↓
cause Global ESLint installation with local plugin or vice versa.
fix
Match the installation scope: if ESLint is global, install the plugin globally; if local, install locally.
Warnings
gotcha The plugin only includes one rule ('ignore-before-comment') as of v1.0.1. Do not expect comprehensive Material-UI linting. ↓
fix Use additional plugins like eslint-plugin-react or eslint-plugin-material-ui (community) for broader coverage.
deprecated No known deprecated rules.
Install
npm install eslint-plugin-material-ui yarn add eslint-plugin-material-ui pnpm add eslint-plugin-material-ui Imports
- ESLint plugin wrong
const plugin = require('eslint-plugin-material-ui'); // Not needed for plugin registrationcorrect// In .eslintrc { "plugins": ["material-ui"] } - Rule configuration wrong
rules: { 'material-ui/ignore-before-comment': 2 } // Valid but less semanticcorrect// In .eslintrc { "rules": { "material-ui/ignore-before-comment": "warn" } }
Quickstart
// 1. Install dependencies
npm install eslint eslint-plugin-material-ui --save-dev
// 2. Create .eslintrc.json
{
"plugins": ["material-ui"],
"rules": {
"material-ui/ignore-before-comment": "error"
}
}
// 3. Example code that triggers the rule
// Code with a comment before ignored block
// eslint-disable-next-line material-ui/ignore-before-comment
const x = 1;