1.0.15 • Published 12 months ago

@thestartupfactory/eslint-plugin-open-eslint-rules v1.0.15

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

TSF Open ESLint Rules

Custom ESLint rules to enforce specific coding standards and best practices for your project.

Installation

You can install the package via npm:

npm install your-eslint-rules-package --save-dev

or via Yarn:

yarn add your-eslint-rules-package --dev

Usage

To use these rules in your project, add the library as a plugin in your ESLint configuration.

Example .eslintrc.js:

module.exports = {
  plugins: [
    'your-eslint-rules-package'
  ],
  rules: {
    'your-eslint-rules-package/switch-exhaustive': 'error',
    'your-eslint-rules-package/prisma-explicit-select': 'warn',
    'your-eslint-rules-package/prisma-find-many-requires-limit': 'error',
  }
};

Or add to your eslint configuration using default rules via:

  "plugins": [
    "@thestartupfactory/open-eslint-rules"
  ],
  "extends": ["plugin:@thestartupfactory/eslint-plugin-open-eslint-rules/recommended"],

Configuration

Each rule in this library can be enabled or disabled independently, and configured to either warn or error as per your project’s requirements.

If additional configuration is needed for individual rules, refer to the rule-specific settings in the Rules section below.

Rules

Here’s a brief overview of the rules available in this library:

switch-exhaustive:

Ensures that switch statements include exhaustive cases, with a default case that calls an exhaustivenessCheck function to verify all cases are handled.

switch (value) {
  case 'case1':
    // handle case
    break;
  default:
    exhaustivenessCheck(value);
}

prisma-explicit-select:

Enforces explicit select statements when using Prisma ORM to ensure only the required fields are fetched from the database.

const user = await prisma.user.findUnique({
  where: { id: 1 },
  select: { name: true, email: true } // Ensures specific fields are selected
});

prisma-find-many-requires-limit:

Ensures that findMany queries with Prisma ORM include a limit clause to prevent fetching large datasets unintentionally.

const users = await prisma.user.findMany({
  where: { active: true },
  take: 10 // Limit the results to 10
});
1.0.9

12 months ago

1.0.8

12 months ago

1.0.7

12 months ago

1.0.11

12 months ago

1.0.10

12 months ago

1.0.15

12 months ago

1.0.14

12 months ago

1.0.13

12 months ago

1.0.12

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago