An ESLint plugin for rotki projects that provides custom rules and configurations to maintain consistent code quality.
This ESLint plugin is designed specifically for rotki projects, drawing inspiration from established plugins like:
# 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-pluginUse 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.*'],
}],
},
},
];See the full list of available rules,
including which are enabled by the recommended preset and which are auto-fixable.
For detailed rule options and configuration, please visit our documentation.
To test rules against the real rotki codebase and benchmark performance:
- 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"- In the rotki frontend, point the
@rotki/eslint-pluginentry in thecatalog:section offrontend/pnpm-workspace.yamlat the tarball, then install.@rotki/eslint-configtakes the plugin as a peer dependency, so it uses this copy too. The path is relative tofrontend/; the commands assume rotki is cloned next to this repository:
catalog:
# ...other entries
'@rotki/eslint-plugin': file:../../rotki-eslint-plugin-1.10.1-1795790266.tgzcd ../rotki/frontend
pnpm install
pnpm run lint- Pack again under a new name after each change. When you are done, restore
pnpm-workspace.yamland runpnpm installto restore the lockfile. Do not commit the tarball path.
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'| 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.
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
AGPL-3.0 License © 2023- Rotki Solutions GmbH