Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions .felixrc.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"fixers": ["eslint", "prettier"],
"fixers": [
{
"name": "eslint",
"command": ["npm", "run", "lint:fix"],
"appendPaths": false
},
{
"name": "prettier",
"command": ["npm", "run", "format:fix"],
"appendPaths": false
}
],
"paths": ["src/**", "examples/**", "tests/**", "*.md", "jest.config.js", "test-felix.js"],
"ignore": ["node_modules/**", "dist/**", "build/**", ".git/**", "coverage/**", "test-files/**", "package.json", "package-lock.json", ".github/**"],
"_comment": "Using custom commands to demonstrate the feature. In production, ensure 'npm ci' runs before Felix.",
"eslint": {
"command": ["npm", "run", "lint:fix"],
"appendPaths": false
},
"prettier": {
"command": ["npm", "run", "format:fix"],
"appendPaths": false
}
"_comment": "Using custom commands to demonstrate the new inline configuration format. In production, ensure 'npm ci' runs before Felix."
}
53 changes: 35 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,33 @@ Control Felix through action inputs:

### Repository Configuration

For advanced settings, create a `.felixrc.json` file:
For simple configurations, create a `.felixrc.json` file:

```json
{
"fixers": ["eslint", "prettier"],
"fixers": ["eslint", "prettier", "markdownlint"],
"paths": ["src", "docs"],
"ignore": ["node_modules/**", "dist/**"],
"eslint": {
"configFile": ".eslintrc.js",
"extensions": [".js", ".jsx", ".ts", ".tsx"]
},
"prettier": {
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json", ".md"]
}
"ignore": ["node_modules/**", "dist/**"]
}
```

For advanced settings with custom configurations:

```json
{
"fixers": [
{
"name": "eslint",
"configFile": ".eslintrc.js",
"extensions": [".js", ".jsx", ".ts", ".tsx"]
},
{
"name": "prettier",
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json", ".md"]
}
],
"paths": ["src", "docs"],
"ignore": ["node_modules/**", "dist/**"]
}
```

Expand All @@ -145,14 +158,18 @@ Use your own npm scripts instead of built-in commands:

```json
{
"eslint": {
"command": ["npm", "run", "lint:fix"],
"appendPaths": true // Append file paths for performance
},
"prettier": {
"command": ["npm", "run", "format"],
"appendPaths": false // Run script as-is
}
"fixers": [
{
"name": "eslint",
"command": ["npm", "run", "lint:fix"],
"appendPaths": true
},
{
"name": "prettier",
"command": ["npm", "run", "format"],
"appendPaths": false
}
]
}
```

Expand Down
37 changes: 34 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29989,13 +29989,29 @@ class ConfigManager {
getFixers() {
// Config file takes precedence over input
if (this.config.fixers && this.config.fixers.length > 0) {
return this.config.fixers;
try {
return this.config.fixers.map(fixer => this.getFixerName(fixer));
}
catch (error) {
core.error(`Invalid fixer configuration: ${error}`);
throw error;
}
}
return this.inputs.fixers
.split(',')
.map(f => f.trim())
.filter(f => f.length > 0);
}
getFixerName(fixer) {
if (typeof fixer === 'string') {
return fixer;
}
// Since InlineFixerConfig requires name, this should always be present
if (!fixer.name) {
throw new Error('Inline fixer configuration must have a "name" property');
}
return fixer.name;
}
getPaths() {
// Priority: action input > config file > default
if (this.inputs.paths) {
Expand All @@ -30022,7 +30038,20 @@ class ConfigManager {
return this.config.ignore || ['node_modules/**', 'dist/**', 'build/**', '.git/**'];
}
getFixerConfig(fixerName) {
return this.config[fixerName] || {};
// First check the new format - inline fixer objects in the fixers array
if (this.config.fixers) {
for (const fixer of this.config.fixers) {
if (typeof fixer === 'object' && this.getFixerName(fixer) === fixerName) {
return fixer;
}
}
}
// Fall back to legacy format for backward compatibility
const legacyConfig = this.config[fixerName];
if (legacyConfig && typeof legacyConfig === 'object') {
return legacyConfig;
}
return {};
}
getAllowedBots() {
return this.inputs.allowedBots
Expand Down Expand Up @@ -30745,7 +30774,9 @@ class BaseFixer {
this.paths = paths;
}
hasCustomCommand() {
return (this.config.command && Array.isArray(this.config.command) && this.config.command.length > 0);
return !!(this.config.command &&
Array.isArray(this.config.command) &&
this.config.command.length > 0);
}
getCustomCommand() {
if (!this.hasCustomCommand()) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

136 changes: 108 additions & 28 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,38 @@ Create a `.felixrc.json` file in your repository root for advanced configuration
}
```

### Advanced Configuration with Inline Fixer Objects

For more complex setups, you can mix simple fixer names with inline configuration objects:

```json
{
"fixers": [
"eslint",
{
"name": "prettier",
"command": ["yarn", "prettier:write:path"],
"appendPaths": true
},
{
"name": "oxlint",
"command": ["yarn", "oxlint:js:path", "--fix"],
"appendPaths": true
}
],
"paths": ["src", "docs"]
}
```

This new format eliminates the need to specify fixers twice by allowing configuration to be defined inline.

### Global Configuration Options

| Option | Type | Description | Default |
| -------- | ---------- | --------------------------------------- | ------- |
| `fixers` | `string[]` | List of fixers to run | `[]` |
| `paths` | `string[]` | Global paths for all fixers | `["."]` |
| `ignore` | `string[]` | Glob patterns to ignore | See below |
| Option | Type | Description | Default |
| -------- | ------------------------ | --------------------------------------- | ------- |
| `fixers` | `(string \| InlineFixerConfig)[]` | List of fixers to run (strings or objects) | `[]` |
| `paths` | `string[]` | Global paths for all fixers | `["."]` |
| `ignore` | `string[]` | Glob patterns to ignore | See below |

**Default ignore patterns:**
```json
Expand All @@ -102,55 +127,70 @@ Create a `.felixrc.json` file in your repository root for advanced configuration

### Per-Fixer Configuration

Each fixer can be configured with these options:
Each fixer can be configured with these options (whether as an inline object in the fixers array or using the legacy format):

| Option | Type | Description | Default |
| ------------- | ---------- | -------------------------------------------- | ------- |
| `configFile` | `string` | Path to fixer's config file | (none) |
| `extensions` | `string[]` | File extensions to process | Built-in defaults |
| `paths` | `string[]` | Fixer-specific paths (overrides global) | Global paths |
| `command` | `string[]` | Custom command to run instead of built-in | (none) |
| `appendPaths` | `boolean` | Whether to append paths to custom commands | `true` |
| Option | Type | Description | Default |
| ------------- | ------------------- | -------------------------------------------- | ------- |
| `name` | `string` | Fixer name (**required** for inline objects) | (none) |
| `configFile` | `string` | Path to fixer's config file | (none) |
| `extensions` | `string[]` | File extensions to process | Built-in defaults |
| `paths` | `string[]` | Fixer-specific paths (overrides global) | Global paths |
| `command` | `string[]` | Custom command to run instead of built-in | (none) |
| `appendPaths` | `boolean` | Whether to append paths to custom commands | `true` |
| `env` | `Record<string, string>` | Environment variables for custom commands | `{}` |

### Examples

#### ESLint Configuration
#### Legacy Format (Still Supported)

```json
{
"fixers": ["eslint", "prettier", "markdownlint"],
"eslint": {
"configFile": ".eslintrc.custom.js",
"extensions": [".js", ".jsx", ".ts", ".tsx"],
"paths": ["src", "scripts"],
"command": ["npm", "run", "lint:fix"],
"appendPaths": true
}
}
```

#### Prettier Configuration

```json
{
},
"prettier": {
"configFile": ".prettierrc.json",
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json", ".md"],
"paths": ["src", "docs"],
"command": ["npm", "run", "format"],
"appendPaths": false
},
"markdownlint": {
"configFile": ".markdownlint.yml",
"paths": ["docs", "*.md"],
"command": ["npm", "run", "lint:markdown"]
}
}
```

#### Markdownlint Configuration
#### New Inline Format (Recommended)

```json
{
"markdownlint": {
"configFile": ".markdownlint.yml",
"paths": ["docs", "*.md"],
"command": ["npm", "run", "lint:markdown"]
}
"fixers": [
{
"name": "eslint",
"configFile": ".eslintrc.custom.js",
"extensions": [".js", ".jsx", ".ts", ".tsx"],
"paths": ["src", "scripts"],
"command": ["npm", "run", "lint:fix"],
"appendPaths": true
},
{
"name": "prettier",
"configFile": ".prettierrc.json",
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json", ".md"],
"paths": ["src", "docs"],
"command": ["npm", "run", "format"],
"appendPaths": false
},
"markdownlint"
]
}
```

Expand Down Expand Up @@ -323,6 +363,7 @@ Result: `npm run format:all` and `npm run lint:project`

## Complete Configuration Example

### Legacy Format
```json
{
"fixers": ["eslint", "prettier", "markdownlint"],
Expand Down Expand Up @@ -357,6 +398,45 @@ Result: `npm run format:all` and `npm run lint:project`
}
```

### New Inline Format (Recommended)
```json
{
"fixers": [
{
"name": "eslint",
"configFile": ".eslintrc.js",
"extensions": [".js", ".jsx", ".ts", ".tsx"],
"paths": ["src", "scripts"],
"command": ["npm", "run", "lint:fix"],
"appendPaths": true
},
{
"name": "prettier",
"configFile": ".prettierrc.json",
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json", ".css", ".scss", ".md"],
"paths": ["src", "docs", "examples"],
"command": ["npm", "run", "format"],
"appendPaths": false
},
{
"name": "markdownlint",
"configFile": ".markdownlint.yml",
"paths": ["docs", "README.md", "CHANGELOG.md"],
"command": ["npm", "run", "lint:markdown"],
"appendPaths": true
}
],
"paths": ["src/**/*", "docs/**/*"],
"ignore": [
"node_modules/**",
"dist/**",
"build/**",
"coverage/**",
"*.min.js"
]
}
```

## Troubleshooting

### Common Issues
Expand Down
Loading
Loading