{"id":19528876,"url":"https://github.com/adonisjs/eslint-plugin-adonisjs","last_synced_at":"2025-04-26T11:33:33.867Z","repository":{"id":255436962,"uuid":"842380934","full_name":"adonisjs/eslint-plugin-adonisjs","owner":"adonisjs","description":"ESLint plugin for AdonisJS to enforce framework specific rules","archived":false,"fork":false,"pushed_at":"2024-08-31T11:28:16.000Z","size":38,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"2.x","last_synced_at":"2025-04-04T12:04:23.349Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adonisjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"thetutlage"}},"created_at":"2024-08-14T08:30:20.000Z","updated_at":"2025-04-04T03:46:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"377ccbb0-83e0-4307-b578-3ac7925f9521","html_url":"https://github.com/adonisjs/eslint-plugin-adonisjs","commit_stats":null,"previous_names":["adonisjs/eslint-plugin-adonisjs"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adonisjs%2Feslint-plugin-adonisjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adonisjs%2Feslint-plugin-adonisjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adonisjs%2Feslint-plugin-adonisjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adonisjs%2Feslint-plugin-adonisjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adonisjs","download_url":"https://codeload.github.com/adonisjs/eslint-plugin-adonisjs/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250980949,"owners_count":21517754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T01:20:29.890Z","updated_at":"2025-04-26T11:33:33.861Z","avatar_url":"https://github.com/adonisjs.png","language":"TypeScript","funding_links":["https://github.com/sponsors/thetutlage"],"categories":[],"sub_categories":[],"readme":"# @adonisjs/eslint-plugin\n\n\u003e Compatible with ESLint\u003e=9.0 and TypeScript \u003e=5.4\n\n\u003chr\u003e\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch3\u003eESLint plugin for AdonisJS applications\u003c/h3\u003e\n  \u003cp\u003e\n    The plugin forces your application to use lazy imports for controllers and event listeners. \u003cstrong\u003eLazy imports are a must when you are using HMR mode in AdonisJS\u003c/strong\u003e.\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![gh-workflow-image]][gh-workflow-url] [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]\n\n\u003c/div\u003e\n\n## Installation\n\nThe package comes pre-configured with the [@adonisjs/eslint-config](https://github.com/adonisjs/eslint-config) preset and hence manual installation is not required.\n\nHowever, you can install and configure it as follows.\n\n```sh\nnpm i -D @adonisjs/eslint-plugin@beta\n\n# Install peer dependencies\nnpm i -D eslint@9 typescript typescript-eslint\n```\n\n## Usage\n\nAfter installation, you can register the following as follows. Make sure to also setup the `typescript-eslint` parser in order for the rules to work.\n\n```ts\n// eslint.config.js\nimport adonisJSPlugin from '@adonisjs/eslint-plugin'\n\nexport default [\n  {\n    plugins: {\n      '@adonisjs': adonisJSPlugin,\n    },\n    rules: {\n      '@adonisjs/prefer-lazy-controller-import': 'error',\n      '@adonisjs/prefer-lazy-listener-import': 'error',\n    },\n  },\n]\n```\n\n## `prefer-lazy-controller-import`\n\n\u003e [!IMPORTANT]\n\u003e The HMR mode of AdonisJS only works with Lazy loaded controllers\n\nThe `@adonisjs/prefer-lazy-controller-import` rule complains when you import a controller using the import expression and assign it to a route. For example:\n\n```ts\nimport router from '@adonisjs/core/services/router'\n// ❌ Error: Replace standard import with lazy controller import\nimport UsersController from '#controllers/user_controller'\n\nrouter.get('users', [UsersController, 'index'])\n```\n\nThe rule is auto fixable, therefore you can apply the fix depending upon the shortcuts provided by your\ncode editor.\n\n```ts\nimport router from '@adonisjs/core/services/router'\n// ✅ Fixed\nconst UsersController = () =\u003e import('#controllers/user_controller')\n\nrouter.get('users', [UsersController, 'index'])\n```\n\n## `prefer-lazy-listener-import`\n\n\u003e [!IMPORTANT]\n\u003e The HMR mode of AdonisJS only works with Lazy loaded event listeners\n\nThe `@adonisjs/prefer-lazy-listener-import` rule complains when you import an event listener using the import expression and assign it to an event. For example:\n\n```ts\nimport emitter from '@adonisjs/core/services/emitter'\n// ❌ Error: Replace standard import with lazy controller import\nimport SendVerificationEmail from '#listeners/send_verification_email'\n\nemitter.on('user:created', [SendVerificationEmail, 'handle'])\n```\n\nThe rule is auto fixable, therefore you can apply the fix depending upon the shortcuts provided by your\ncode editor.\n\n```ts\nimport emitter from '@adonisjs/core/services/emitter'\n// ✅ Fixed\nconst SendVerificationEmail = () =\u003e import('#listeners/send_verification_email')\n\nemitter.on('user:created', [SendVerificationEmail, 'handle'])\n```\n\n\u003cdiv align=\"center\"\u003e\n  \u003csub\u003eBuilt with ❤︎ by \u003ca href=\"https://github.com/Julien-R44\"\u003eJulien Ripouteau\u003c/a\u003e and \u003ca href=\"https://github.com/thetutlage\"\u003eHarminder Virk\u003c/a\u003e\n\u003c/div\u003e\n\n[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/eslint-plugin-adonisjs/checks.yml?style=for-the-badge\n[gh-workflow-url]: https://github.com/adonisjs/eslint-plugin-adonisjs/actions/workflows/checks.yml 'Github action'\n[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge\u0026logo=typescript\n[typescript-url]: \"typescript\"\n[npm-image]: https://img.shields.io/npm/v/@adonisjs/eslint-plugin/latest.svg?style=for-the-badge\u0026logo=npm\n[npm-url]: https://www.npmjs.com/package/@adonisjs/eslint-plugin/v/latest 'npm'\n[license-url]: LICENSE.md\n[license-image]: https://img.shields.io/github/license/adonisjs/eslint-plugin-adonisjs?style=for-the-badge\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadonisjs%2Feslint-plugin-adonisjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadonisjs%2Feslint-plugin-adonisjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadonisjs%2Feslint-plugin-adonisjs/lists"}