Development workflow for eslint-plugin-primer-react: rules, testing, validation, and contribution guidelines for Primer React component linting
Expert development workflow for eslint-plugin-primer-react, an ESLint plugin providing rules for validating and auto-fixing Primer React component usage.
This skill provides comprehensive instructions for developing, testing, and maintaining ESLint rules within the primer/eslint-plugin-primer-react repository. This is a JavaScript-based ESLint plugin with no build step required.
Before starting any development work:
```bash
node --version && npm --version
npm ci
```
**Important**: No build step is required. Main entry point is `src/index.js`.
Familiarize yourself with key directories:
All validation commands are very fast:
```bash
npm test
npm run lint
npm run lint:md
npm run format:check
npm run format
```
Follow this sequence:
1. **Create rule implementation**: `src/rules/new-rule-name.js`
2. **Create test file**: `src/rules/__tests__/new-rule-name.test.js`
3. **Export rule**: Add to `src/index.js` rules object
4. **Document rule**: Create `docs/rules/new-rule-name.md`
5. **Optional**: Add to `src/configs/recommended.js` for recommended preset
6. **Validate**:
```bash
npm test
npm run lint
```
When updating a rule:
1. **Edit rule**: Modify `src/rules/rule-name.js`
2. **Update tests**: Modify `src/rules/__tests__/rule-name.test.js`
3. **Update docs**: Modify `docs/rules/rule-name.md` if behavior changed
4. **Validate changes**:
```bash
npm test
npm run lint
```
Test individual rules interactively:
```bash
node -e "
const rule = require('./src/rules/RULE_NAME');
const {RuleTester} = require('eslint');
const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: { jsx: true }
}
});
ruleTester.run('test', rule, {
valid: [{ code: 'VALID_CODE_HERE' }],
invalid: [{ code: 'INVALID_CODE_HERE', errors: [{ messageId: 'MESSAGE_ID' }] }]
});
"
```
**After making rule changes**:
```bash
npm test -- --testNamePattern="rule-name"
npm test
```
**Before committing**:
```bash
npm run lint # 1.5 seconds
npm run lint:md # <1 second
npm run format:check # 0.5 seconds
npm test # 5 seconds
```
When making changes that should be published:
```bash
npx changeset
npx changeset status
```
**Common issues and solutions**:
1. **Always reference these instructions first** before searching or running exploratory commands
2. **Always run tests** after making changes - tests are fast (5 seconds)
3. **No build step required** - this is a direct JavaScript project
4. **All validation commands are fast** - no need for extended timeouts
5. **Follow the rule development pattern** - implementation, tests, docs, export
Every rule follows this consistent structure:
1. Implementation: `src/rules/rule-name.js`
2. Tests: `src/rules/__tests__/rule-name.test.js` (using ESLint RuleTester)
3. Documentation: `docs/rules/rule-name.md`
4. Export: Add to `src/index.js`
5. Config: Optionally add to `src/configs/recommended.js`
Quick reference with execution times:
| Command | Purpose | Time |
|---------|---------|------|
| `npm ci` | Install dependencies | 60s |
| `npm test` | Run all tests | 5s |
| `npm run lint` | Lint JavaScript | 1.5s |
| `npm run lint:md` | Lint Markdown | <1s |
| `npm run format:check` | Check formatting | 0.5s |
| `npm run format` | Fix formatting | ~0.5s |
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/eslint-plugin-primer-react-development/raw