1.5.2 • Published 2 months ago

@sp-packages/lintrc v1.5.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

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/lintrc

This allows you to use lintrc globally in your terminal.

Local Installation (For project-specific use)

npm install @sp-packages/lintrc --save-dev

Then, 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 command

Examples:

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 (npm or composer).
  • command: The command to run the linter.
  • args: An array of arguments to pass to the command.
  • behavior: The behavior of the tool (error or warn).
  • 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 with PHPCS.
  • JavaScript files (.js) and TypeScript files (.ts) will be checked with ESLINT and PRETTIER.
  • All files (*) will be checked with CSPELL.

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 husky to 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.

1.5.2

2 months ago

1.5.1

2 months ago

1.5.0

4 months ago

1.4.0

4 months ago

1.3.0

4 months ago

1.2.2

4 months ago

1.2.1

4 months ago

1.2.0

4 months ago

1.1.0

4 months ago

1.0.0

4 months ago