@sp-packages/lintrc v1.5.2
LintRC
⨠Features
- š Detects file types and applies appropriate linters automatically
 - š Supports multiple linters (ESLint, Prettier, PHPStan, PHPCS, Markdownlint, etc.)
 - š Parallel execution for improved performance
 - š Customizable config file (
lintrc.json) - ā Runs only on Git-tracked files by default
 - š Ideal for CI/CD pipelines and local development
 
š¦ Installation
Global Installation (For system-wide CLI use)
npm install -g @sp-packages/lintrcThis allows you to use lintrc globally in your terminal.
Local Installation (For project-specific use)
npm install @sp-packages/lintrc --save-devThen, run it via:
npx lintrcš CLI Usage
Basic Usage
lintrc [options]Options:
lintrc -h
Usage: LintRC [options] [files...]
LintRC - A CLI tool for running linters based on file extensions.
Arguments:
files List of files to lint. If omitted, uses Git-tracked files.
Options:
-V, --version output the version number
-c, --config <config> Path to the configuration file (default: lintrc.json)
-e, --ext <ext...> Optionally limit the linter to specific extensions
-q, --quiet Disable output
-v, --verbose Enable verbose logging
-h, --help display help for commandExamples:
lintrc --ext js,ts,php
lintrc --config custom-lintrc.json --verboseš Programmatic Usage (Inside Node.js)
You can also use lintrc inside your JavaScript/TypeScript projects.
Import and Use in Your Project
import { lintrc } from '@sp-packages/lintrc';
lintrc({ verbose: true });āļø Configuration (lintrc.json)
By default, lintrc will look for a lintrc.json or .lintrc.json file in your project's root directory. You can customize it as follows:
The lintrc.json configuration file allows you to define the tools and file type mappings for lintrc. Below is an example configuration and explanation of its keys:
TOOLS
The TOOLS section defines the linters and their configurations. Each tool has the following properties:
title: The display name of the tool.type: The type of package manager used (npmorcomposer).command: The command to run the linter.args: An array of arguments to pass to the command.behavior: The behavior of the tool (errororwarn).priority: The priority of the tool execution (lower number means higher priority).
Example:
{
  "TOOLS": {
    "CSPELL": {
      "title": "cSpell",
      "type": "npm",
      "command": "cspell",
      "args": ["--no-progress", "--no-summary"],
      "behavior": "warn",
      "priority": 4
    },
    "ESLINT": {
      "title": "ESLint",
      "type": "npm",
      "command": "eslint",
      "args": ["--fix"],
      "behavior": "error",
      "priority": 2
    },
    "PHPCS": {
      "title": "PHP Code Sniffer",
      "type": "composer",
      "command": "phpcs",
      "behavior": "error",
      "priority": 3
    },
    "PRETTIER": {
      "title": "Prettier",
      "type": "npm",
      "command": "prettier",
      "args": ["--write"],
      "behavior": "error",
      "priority": 1
    }
  }
}MAPPING
The MAPPING section defines which tools to run based on file extensions. Each key is a file extension, and the value is an array of tool identifiers from the TOOLS section.
Example:
{
  "MAPPING": {
    "php": ["PHPCS"],
    "js": ["ESLINT", "PRETTIER"],
    "jsx": ["ESLINT", "PRETTIER"],
    "ts": ["ESLINT", "PRETTIER"],
    "*": ["CSPELL"]
  }
}In this example:
- PHP files (
.php) will be checked withPHPCS. - JavaScript files (
.js) and TypeScript files (.ts) will be checked withESLINTandPRETTIER. - All files (
*) will be checked withCSPELL. 
This configuration allows lintrc to automatically apply the appropriate linters based on the file types in your project.
šÆ Example Outputs
lintrc
------------------------------
 cSpell
------------------------------
ā  [ERROR] package.json:112:32 - Unknown word (lintrc)
------------------------------
 LintRC Results
------------------------------
ā
 [SUCCESS] Prettier: Passed
ā
 [SUCCESS] ESLint: Passed
ā
 [SUCCESS] Markdown Lint: Passed
ā
 [SUCCESS] Commit Lint: Passed
ā
 [SUCCESS] DepCheck: Passed
ā  [ERROR] cSpell: Failedš” Use Cases
- CI/CD Pipelines ā Automate code quality checks in your workflows.
 - Pre-Commit Hooks ā Integrate with 
huskyto enforce coding standards. - Local Development ā Run linters before pushing code changes.
 
š¤ Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
š License
This project is licensed under the MIT License. See the LICENSE file for details.