Skip to content

teambit/oxlint-node

Repository files navigation

Oxlint Node.js API

License NPM Version

A Node.js API wrapper for the Oxlint project, a fast and reliable Rust-based linter. This repository also includes various examples and Bit components that demonstrate how to integrate and use Oxlint in real-world applications.

⚠️ Beta Status

Note: This project is currently in beta. Users should expect potential breaking changes in future releases due to ongoing redesigns of the Node.js API or changes in the Oxlint project and CLI itself.

Table of Contents

Features

  • 🚀 Fast and efficient: Leverages the performance of the Rust-based Oxlint linter.
  • 🛠 Easy integration: Simple API for Node.js applications.
  • 📦 Bit Integration: Examples of integrating Oxlint with Bit for component-driven development.
  • Cross-platform: Compatible with major operating systems.
  • 💻 Fully typed: Provides TypeScript support out-of-the-box, ensuring type safety and better development experience.

Project Structure

The repository is organized as follows:

oxc/
  ├── linter/
  │   ├── oxlint-node/        # Main folder of the project - the Node.js wrapper
  │   └── oxlint-linter/      # A Bit linter that utilizes oxlint-node to build a Bit linter (also serves as a consumer example)
  └── examples/
      └── envs/
          └── oxlint-env/     # A Bit environment that uses oxlint-linter, enabling linting on Bit components
testing-components/           # Simple (local only) Bit components that use the oxlint-env, 
                              # demonstrating linting through the `bit lint` or `bit build` command

Detailed Structure:

  • oxc/linter/oxlint-node/:

    • This is the core of the project, containing the Node.js wrapper for Oxlint, allowing Node.js applications to leverage Oxlint's linting capabilities.
  • oxc/linter/oxlint-linter/:

    • This folder includes a Bit linter built on top of oxlint-node. It serves as both a utility and an example for how to integrate Oxlint with Bit for component-based development.
  • oxc/examples/envs/oxlint-env/:

    • An environment setup that uses oxlint-linter, allowing developers to run linting on Bit components within their projects.
  • testing-components/:

    • A collection of simple Bit components intended for local testing. These components use the oxlint-env, providing practical examples of running the linter via bit lint or bit build.

Installation

To install the Oxlint Node.js API, you can use pnpm, npm, or yarn.

Using pnpm

pnpm add @teambit/oxc.linter.oxlint-node

Using npm

npm install @teambit/oxc.linter.oxlint-node

Using yarn

yarn add @teambit/oxc.linter.oxlint-node

Usage

Simple Usage

import { OxlintNode } from '@teambit/oxc.linter.oxlint-node';

const oxlintNode = OxlintNode.create({});
const result = await oxlintNode.run(['paths']);
console.log(result);

Advanced Usage

const oxlintNode = OxlintNode.create({
  binPath: 'path to oxlint binary',
  formats: ['json', 'default'],
  configPath: 'path to oxlint config file',
  tsconfigPath: 'path to tsconfig',
  pluginsFlags: {
    'plugin-name': true,
  },
  rulesFlags: [{
    name: 'rule-name',
    severity: 'warn',
  }],
  fixesFlags: {
    all: true,
  }
});

Documentation

For more comprehensive documentation, including the full API reference, please visit the component page on Bit Cloud:

Other Related Components:

Changelog and Version History

Changelog and version history for this project are managed through the oxlint-node component's version history on Bit Cloud. You can view the full changelog at the following URL:

Contributing

We welcome contributions! Please read our Contributing Guide to get started.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.