Skip to content

ESLint plugin to enforce pattern rules in Clean Architecture. Currently enforces that find* operations are only defined within repository layer files.

License

Notifications You must be signed in to change notification settings

goblockchain/eslint-plugin-custom-rules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-goblock-custom-rules

ESLint plugin to enforce pattern rules in Clean Architecture. Currently enforces that find* operations are only defined within repository layer files.

Installation

npm install --save-dev eslint-plugin-goblock-custom-rules
# or
yarn add -D eslint-plugin-goblock-custom-rules

Usage

ESLint Flat Config (>= 8.21.0)

// eslint.config.js
import repositoryPlugin from "eslint-plugin-goblock-custom-rules";

export default [
  {
    files: ["src/**/*.ts"],
    plugins: {
      repository: repositoryPlugin,
    },
    rules: {
      "repository/no-find-outside-repository": "error",
    },
  },
];

Traditional Config

// .eslintrc.js
module.exports = {
  plugins: ["eslint-plugin-goblock-custom-rules"],
  rules: {
    "eslint-plugin-goblock-custom-rules/no-find-outside-repository": "error",
  },
};

Rules

no-find-outside-repository

Ensures that functions starting with find are only defined within repository files.

✅ Correct

// user.repository.ts
export class UserRepository {
  async findAll() {
    // Allowed in repository files
    return this.users.find();
  }
}

❌ Incorrect

// user.service.ts
export class UserService {
  async findAll() {
    // Error: find operations should be in repository layer
    return this.users.find();
  }
}
// user.controller.ts
export class UserController {
  async findById() {
    // Error: find operations should be in repository layer
    return this.service.findById();
  }
}

License

MIT © goBlockchain

About

ESLint plugin to enforce pattern rules in Clean Architecture. Currently enforces that find* operations are only defined within repository layer files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published