1.0.11 • Published 11 months ago

@edarioq/eslint-plugin-prop-ordering v1.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@edarioq/eslint-plugin-prop-ordering

ESLint plugin for consistent property ordering in TypeScript interfaces and React components.

Installation

npm install --save-dev @edarioq/eslint-plugin-prop-ordering

Example usage

interface Props {
  effectiveSelectedKeys: "all" | Set<Key>;
  page: number;
  pages: number;
  setPage: Dispatch<SetStateAction<number>>;
  onNextPage: () => void;
  onPreviousPage: () => void;
}

export function Pagination({
  effectiveSelectedKeys,
  page,
  pages,
  setPage,
  onNextPage,
  onPreviousPage,
}: Props) {
  return (
    <div>
      Notice that all props in both the type definition and the function params are sorted according to the rules
    </div>
  );
}

<Pagination
  effectiveSelectedKeys={effectiveSelectedKeys}
  page={page}
  pages={pages}
  totalItems={10}
  setPage={setPage}
  onNextPage={onNextPage}
  onPreviousPage={onPreviousPage}
/>

Example config in an .eslintrc.json file

{
  // other stuff

  "rules": {
    "@edarioq/prop-ordering/sort-type-properties": [
      "warn",
      {
        "callbacksLast": true,
        "shorthandFirst": true,
        "noSortAlphabetically": false,
        "reservedFirst": true,
        "reservedPropsNames": ["id", "key", "ref", "name", "type"]
      }
    ],
    "@edarioq/prop-ordering/sort-component-props": [
      "warn",
      {
        "callbacksLast": true,
        "noSortAlphabetically": false,
        "reservedFirst": true,
        "reservedPropsNames": ["id", "key", "ref", "name", "type"]
      }
    ]
  }
}
1.0.11

11 months ago

1.0.10

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago