Skip to content

About

rotki's ESLint plugin.

Topics

Resources

Contributing

Stars

3 stars

Watchers

3 watching

Forks

Repository files navigation

@rotki/eslint-plugin

npm version

An ESLint plugin for rotki projects that provides custom rules and configurations to maintain consistent code quality.

Overview

This ESLint plugin is designed specifically for rotki projects, drawing inspiration from established plugins like:

Installation

# Using pnpm (recommended)
pnpm add -D @rotki/eslint-plugin

# Using npm
npm install --save-dev @rotki/eslint-plugin

# Using yarn
yarn add -D @rotki/eslint-plugin

Usage

Use the recommended configuration in your ESLint flat config:

import rotkiPlugin from '@rotki/eslint-plugin';

export default [
  rotkiPlugin.configs['recommended-flat'],
];

Or configure individual rules:

import rotkiPlugin from '@rotki/eslint-plugin';
import * as jsoncParser from 'jsonc-eslint-parser';

export default [
  {
    plugins: { '@rotki': rotkiPlugin },
  },
  {
    files: ['**/src/locales/*.json'],
    languageOptions: { parser: jsoncParser },
    rules: {
      '@rotki/no-unused-i18n-keys': ['error', {
        src: 'src',
        extensions: ['.ts', '.vue'],
        ignoreKeys: ['backend_mappings.*'],
      }],
    },
  },
];

Rules

See the full list of available rules, including which are enabled by the recommended preset and which are auto-fixable.

Documentation

For detailed rule options and configuration, please visit our documentation.

Testing Rules with Rotki

To test rules against the real rotki codebase and benchmark performance:

Setup

  1. Build the plugin and pack it into a tarball with a name you have not used before (pnpm reuses a tarball it has already seen under the same name):
pnpm run build
pnpm pack --out "$PWD/../rotki-eslint-plugin-%v-$(date +%s).tgz"
  1. In the rotki frontend, point the @rotki/eslint-plugin entry in the catalog: section of frontend/pnpm-workspace.yaml at the tarball, then install. @rotki/eslint-config takes the plugin as a peer dependency, so it uses this copy too. The path is relative to frontend/; the commands assume rotki is cloned next to this repository:
catalog:
  # ...other entries
  '@rotki/eslint-plugin': file:../../rotki-eslint-plugin-1.10.1-1795790266.tgz
cd ../rotki/frontend
pnpm install
pnpm run lint
  1. Pack again under a new name after each change. When you are done, restore pnpm-workspace.yaml and run pnpm install to restore the lockfile. Do not commit the tarball path.

Benchmarking

Create minimal ESLint configs that isolate individual rules, then time them against all locale files:

# Intlify rule
time pnpm exec eslint -c bench-intlify.config.js 'app/src/locales/*.json'

# Rotki rule
time pnpm exec eslint -c bench-rotki.config.js 'app/src/locales/*.json'

Benchmark Results (rotki frontend, 7 locale files, ~1.1MB total)

Rule Average Time
@intlify/vue-i18n/no-unused-keys ~71s
@rotki/no-unused-i18n-keys ~5s

The rotki rule is ~14x faster due to file-level caching, early bail-out on files without i18n calls, and avoiding the vue-i18n settings/localeDir resolution overhead.

Contributing

Contributions are welcome! Please read our Contributing Guide before submitting a Pull Request. The guide includes detailed information about:

  • Project prerequisites
  • Development setup
  • Commit message conventions
  • Code style and linting
  • Pull request process

License

AGPL-3.0 License © 2023- Rotki Solutions GmbH

About

rotki's ESLint plugin.

Topics

Resources

Contributing

Stars

3 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages