@profi.co/eslint-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

ESLint plugin by Profico

This plugin is used to enforce some ESLint rules Profico developers use on a day-to-day basis.

Installation

Install @profi.co/eslint-plugin with npm:

npm install --save-dev @profi.co/eslint-plugin

or with yarn:

yarn add --dev @profi.co/eslint-plugin

Usage

To use the recommended rules, add our plugin to your .eslintrc file:

{
  "extends": ["plugin:@profi.co/recommended"]
}

// or configure manually:
{
  "plugins": ["@profi.co"],
  "rules": {
    "@profi.co/lodash-imports": ["error"],
    "@profi.co/grouped-imports": ["error"],
    "@profi.co/dto-decorators": ["error"],
    "@profi.co/ordered-controllers-params": ["error"]
  }
}

The following checklist shows what we have implemented and what we plan on implementing in the near future:

  • [x] Default import lodash modules instead of importing the whole library or parts of it:
// Bad
import _ from "lodash"; // Not fixable
import { get, pick } from "lodash"; // Fixable

// Good
import get from "lodash/get";
import pick from "lodash/pick";
// Bad
@IsString()
@ApiProperty()
public classProperty: string;

// Good
@ApiProperty()
@IsString()
public classProperty: string;
// Bad
public findAll(
  @Req() req: ProficoRequest,
  @Query() queryParams: QueryParams,
  @Custom2() customParam2: CustomParam,
  @Custom1() customParam1: CustomParam,
) {
  return this.service.find();
}

// Good
public findAll(
  @Query() queryParams: QueryParams,
  @Req() req: ProficoRequest,
  @Custom1() customParam1: CustomParam,
  @Custom2() customParam2: CustomParam,
) {
  return this.service.find();
}

Also take a look at our own ESLint config: https://github.com/profico/eslint-config-profico

Package Sidebar

Install

npm i @profi.co/eslint-plugin

Weekly Downloads

269

Version

1.3.0

License

MIT

Unpacked Size

67.1 kB

Total Files

61

Last publish

Collaborators

  • proficopkgs