Documentation
    Preparing search index...

    Documentation

    GitHub Actions Codecov Renovate
    Maven Central Java
    PyPI TestPyPI Python
    NPM Node

    Rulebook

    The Rulebook logo.

    Third-party linter rules for multiple programming languages. It aims to standardize existing rules from various linters, providing a consistent style across different languages and tools. It also serves as a reference for best practices in coding style.

    Language Linter Styles
    Java Checkstyle Sun Java Style or
    Google Java Style Guide
    Groovy CodeNarc Groovy Style Guide
    Kotlin Ktlint Ktlint Official Style
    C/C++ Cppcheck C++ Core Guidelines or
    Google C++ Style Guide
    Python Pylint Pylint Style or
    Google Python Style Guide
    JavaScript ESLint Crockford Code Conventions or
    Google JavaScript Style Guide
    TypeScript typescript-eslint Crockford Code Conventions or
    Google TypeScript Style Guide

    View all rules

    repositories.mavenCentral()
    
    dependencies {
        ktlint "com.hanggrian.rulebook:rulebook-ktlint:$version"
        checkstyle "com.hanggrian.rulebook:rulebook-checkstyle:$version"
        codenarc "com.hanggrian.rulebook:rulebook-codenarc:$version"
    }
    
    pip install rulebook-cppcheck
    pip install rulebook-pylint
    npm i rulebook-eslint eslint globals \
    eslint-plugin-import \
    eslint-plugin-jsdoc \
    eslint-plugin-sort-class-members \
    eslint-vitest-rule-tester --save-dev
    npm i rulebook-typescript-eslint typescript-eslint globals \
    eslint-plugin-import \
    eslint-plugin-jsdoc \
    eslint-plugin-sort-class-members \
    eslint-vitest-rule-tester --save-dev
    • Apply Checkstyle Gradle Plugin.

    • Using configuration checkstyle, add this project as dependency.

    • Point to local config file or put in /config/checkstyle/codenarc.xml.

      plugins {
          checkstyle
      }
      
      checkstyle {
          toolVersion "$checkstyleVersion"
          configFile "path/to/rulebook_checkstyle.xml"
      }
      
      dependencies {
          checkstyle "com.hanggrian.rulebook:rulebook-checkstyle:$libraryVersion"
      }
      
    • Apply CodeNarc Gradle Plugin.

    • Using configuration codenarc, add this project as dependency.

    • Point to local config file or put in /config/codenarc/codenarc.xml.

      plugins {
          codenarc
      }
      
      codenarc {
          toolVersion "$codenarcVersion"
          configFile "path/to/rulebook_codenarc.xml"
      }
      
      dependencies {
          codenarc "com.hanggrian.rulebook:rulebook-codenarc:$libraryVersion"
      }
      
    • Apply Ktlint Integration to Gradle project.

    • Using configuration ktlint, add this project as dependency.

      configurations {
          ktlint
      }
      
      dependencies {
          ktlint "com.hanggrian.rulebook:rulebook-ktlint:$libraryVersion"
      }
      
      // the rest of ktlint tasks' configuration
      

    Create addon.json file.

    Create .pylintrc file in the root directory.

    Create .eslint.config.js file in the root directory.

    Presuming the IDE is IntelliJ IDEA or PyCharm, consider applying the linter style to it.

    1. Ktlint Style

      Explained in Ktlint IntelliJ IDEA Configuration, using standard Kotlin coding conventions is enough:

      • In File > Settings > Editor > Code Style > Kotlin, set from Kotlin style guide.
        • Append kotlin.code.style=official to root gradle.properties.
    2. Google Java Style

      Explained in Google Java Format: