#Build a Lint Rule

This documentation provides step-by-step instructions on developing a lint rule for the inlang ecosystem. Lint rules are used to check for specific patterns or issues in translated messages to ensure high-quality translations. Follow the guide below to create your own custom lint rule.

#Pre-requisites

Before you begin developing a lint rule, make sure you have the following pre-requisites installed on your system:

#Step-by-step

#1. Initialize a new lint rule module

You need to initialize a new lint rule module using the inlang CLI to get started. Open your terminal and run the following command:

npx @inlang/cli@latest module init --type lintRule

This command will create a new lint rule project with the necessary files and directory structure.

#2. Implement your lint rule

Now that you have a basic lint rule project, it's time to implement your custom lint rule logic. You can use the following code as a starting point and customize it to fit your lint rule requirements:

import type { MessageLintRule } from "@inlang/message-lint-rule";
import { id, displayName, description } from "../marketplace-manifest.json";

export const yourLintRule: MessageLintRule = {
  meta: {
    id: id as MessageLintRule["id"],
    displayName,
    description,
  },
  message: ({ message: { id, variants }, languageTags, sourceLanguageTag, report }) => {
    // Your custom lint rule logic goes here
    // You can analyze message variants and report issues if necessary
  },
};

Replace yourLintRule with a meaningful name for your lint rule.

Helpful example implementations of lint rules can be found here.

#3. Configure your lint rule

In your lint rule's marketplace-manifest.json make sure to define the following information:

ParameterDescription
idUnique identifier for your lint rule.
iconLink to the icon of your lint rule (optional).
galleryOptional gallery, the first image acts as coverImage for your lint rule.
displayNameA user-friendly display name for your lint rule.
descriptionBriefly describe what your lint rule checks for.
readmeLink to the README documentation for your lint rule.
keywordsKeywords that describe your lint rule.
publisherNameYour publisher name.
publisherIconLink to your publisher's icon or avatar (optional).
licenseThe license under which your lint rule is distributed.
moduleThe path to your lint rule's JavaScript module (Please use jsDelivr).

#4. Test your lint rule

Before publishing your lint rule to the marketplace, thoroughly test it to ensure it functions correctly and detects issues as intended.

#5. Publish your lint rule

To make your lint rule available in the inlang.com marketplace, see Publish on marketplace.

Feel free to join our Discord if you have any questions or need assistance developing and publishing your lint rule.




Was this helpful?

Thank you for your feedback ♥️