ESLint Plugin Adonis

raw JSON →
2.1.1 verified Sat Apr 25 auth: no javascript

ESLint plugin providing rules for AdonisJS applications and addons, maintained by the AdonisJS community. Current stable version is 3.0.3 (released 2023-06-13), release cadence is irregular. Features TypeScript support and is designed for AdonisJS 5+ with ESM modules. v3 major release targets ESM and updated coding style; v2.x supports ESLint 8. Differentiates from generic ESLint configs by providing AdonisJS-specific conventions like Edge template rules, Lucid ORM usage, and Ace commands.

error Error: Failed to load plugin 'adonis' declared in '.eslintrc': Cannot find module 'eslint-plugin-adonis'
cause Plugin not installed in project or global node_modules not visible.
fix
Run 'npm install --save-dev eslint-plugin-adonis' from project root.
error Error: ESLint configuration in .eslintrc is invalid: - Configuration for rule 'adonis/no-unused-vars' is invalid: Value ["error"] is the wrong type.
cause Rule configuration expects an array but received a string or wrong format.
fix
Use object format: 'adonis/no-unused-vars': ['warn'] or set to 'off'.
error Parsing error: The keyword 'import' is reserved
cause ESM syntax used with old parser; missing ecmaVersion or sourceType.
fix
Set parserOptions.ecmaVersion: 2020 (or higher) and sourceType: 'module'.
error TypeError: Cannot set properties of undefined (setting 'adonis')
cause Plugin not registered in plugins array before extending.
fix
Add 'plugins: ['adonis']' to ESLint config.
error Error: Rule 'unicorn/no-array-for-each' was not found.
cause Using v3.0.3+ where rule removed, or eslint-plugin-unicorn not installed.
fix
Update to v3.0.3+ or install eslint-plugin-unicorn if you need that specific rule.
breaking v3 drops CommonJS support and requires ESM. Migrate to ES modules or stay on v2.
fix Switch to ESM by adding 'type': 'module' in package.json and using import syntax in .eslintrc.cjs or .eslintrc.js.
gotcha Rule 'unicorn/no-array-for-each' removed in v3.0.3; if you depend on it, upgrade or stay on v3.0.2.
fix Use the base 'unicorn/no-array-for-each' rule directly (requires eslint-plugin-unicorn).
deprecated Rule 'prefer-number-properties' was incorrectly referenced in v3.0.0-3.0.1; fixed in v3.0.2.
fix Update to v3.0.2+ which uses 'unicorn/prefer-number-properties' prefix.
gotcha Plugin expects ESLint 8.x; using with ESLint <8 will fail.
fix Update ESLint to version 8 or higher.
breaking v2.0.0 dropped support for ESLint 7; upgrade from v1 to v2 requires ESLint 8.
fix Run 'npm install eslint@8' and update config files.
npm install eslint-plugin-adonis
yarn add eslint-plugin-adonis
pnpm add eslint-plugin-adonis

Example ESLint configuration using adonis plugin with common and TypeScript presets, showing rule customization.

// .eslintrc.cjs
module.exports = {
  extends: [
    'plugin:adonis/common',
    'plugin:adonis/typescript' // if using TS
  ],
  plugins: ['adonis'],
  parserOptions: {
    ecmaVersion: 2020,
    sourceType: 'module'
  },
  rules: {
    'adonis/no-unused-vars': 'warn',
    'adonis/sort-imports': 'off'
  }
};