eslint-plugin-eggache
raw JSON → 2.0.0 verified Sat Apr 25 auth: no javascript
Custom ESLint plugin for enforcing best practices in Egg.js applications. Version 2.0.0, stable maintenance. It provides rules to catch common mistakes like overriding module.exports/exports, unexpected keys in plugin.js, and leftover .only in tests. Differentiates from generic ESLint rules by being specifically tailored to Egg.js conventions. Released under the Egg.js organization.
Common errors
error Failed to load plugin 'eggache': Cannot find module 'eslint-plugin-eggache' ↓
cause Missing installation of eslint-plugin-eggache
fix
Run npm install eslint-plugin-eggache --save-dev
error ESLint configuration error: Unable to load config 'eggache/recommended' ↓
cause Missing 'plugin:' prefix in extends
fix
Change extends to 'plugin:eggache/recommended'
error Definition for rule 'no-override-exports' was not found ↓
cause Missing plugin name prefix in rule key
fix
Use 'eggache/no-override-exports' as rule name
Warnings
gotcha Plugin must be installed as dev dependency: npm i eslint-plugin-eggache --save-dev ↓
fix Run npm i eslint-plugin-eggache --save-dev
gotcha When using extends, must prefix with 'plugin:': extends: ['plugin:eggache/recommended'] ↓
fix Use extends: ['plugin:eggache/recommended']
gotcha Rule names must be prefixed with plugin name: 'eggache/no-override-exports' ↓
fix Use 'eggache/no-override-exports' in rules object
gotcha The no-override-exports rule by default only checks config files; set option true to check all files. ↓
fix Use 'eggache/no-override-exports': ['error', true] to enable for all files
Install
npm install eslint-plugin-eggache yarn add eslint-plugin-eggache pnpm add eslint-plugin-eggache Imports
- plugin wrong
require('eslint-plugin-eggache')correctmodule.exports.plugins = ['eggache'] - config with extends wrong
extends: ['eggache/recommended']correctextends: ['plugin:eggache/recommended'] - rule 'no-override-exports' wrong
'no-override-exports': ['error']correct'eggache/no-override-exports': ['error']
Quickstart
// .eslintrc.cjs
module.exports = {
plugins: ['eggache'],
extends: ['plugin:eggache/recommended'],
rules: {
'eggache/no-only-tests': 'error',
},
};