Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zignis/eslint-plugin-alignment
🗃️ Format and align objects, enums, interfaces, and type literals for better readability
https://github.com/zignis/eslint-plugin-alignment
aligment-comment enums eslint eslint-plugin eslintplugin formatting interface objects typescript
Last synced: 27 days ago
JSON representation
🗃️ Format and align objects, enums, interfaces, and type literals for better readability
- Host: GitHub
- URL: https://github.com/zignis/eslint-plugin-alignment
- Owner: zignis
- License: mit
- Created: 2023-09-27T14:37:44.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-20T08:45:17.000Z (about 1 year ago)
- Last Synced: 2024-10-06T01:38:04.082Z (about 1 month ago)
- Topics: aligment-comment, enums, eslint, eslint-plugin, eslintplugin, formatting, interface, objects, typescript
- Language: TypeScript
- Homepage:
- Size: 59.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-alignment
![GitHub Workflow Status](https://github.com/zignis/eslint-plugin-alignment/actions/workflows/main.yaml/badge.svg)
![npm](https://img.shields.io/npm/v/eslint-plugin-alignment?style=plastic)> [!WARNING]
> This plugin is still in beta, and some rules might not work as expected.Format and align your objects, enums, interfaces, and type literals for better readability.
Turn this
Into this
```js
const person = {
name: "Connor",
age: 26,
jobTitle: "Musician",
city: "New York",
country: "USA",
favoriteColor: "Blue",
hobbies: ["Reading", "Cooking", "Hiking"],
getSomething: () => "something",
};
``````js
const person = {
name /* */: "Connor",
age /* */: 26,
jobTitle /* */: "Musician",
city /* */: "New York",
country /* */: "USA",
favoriteColor /**/: "Blue",
hobbies /* */: ["Reading", "Cooking", "Hiking"],
getSomething /* */: () => "something",
};
``````ts
enum DaysOfWeek {
MONDAY = "Monday",
TUESDAY = "Tuesday",
WEDNESDAY = "Wednesday",
THURSDAY = "Thursday",
FRIDAY = "Friday",
SATURDAY = "Saturday",
SUNDAY = "Sunday",
}
``````ts
enum DaysOfWeek {
MONDAY /* */ = "Monday",
TUESDAY /* */ = "Tuesday",
WEDNESDAY /**/ = "Wednesday",
THURSDAY /* */ = "Thursday",
FRIDAY /* */ = "Friday",
SATURDAY /* */ = "Saturday",
SUNDAY /* */ = "Sunday",
}
``````ts
type ContactInfo = {
name: string;
email: string;
phone?: string;
address?: string;
};interface User {
id: number;
username: string;
email: string;
age: number;
}
``````ts
// prettier-ignore
type ContactInfo = {
name /* */: string;
email /* */: string;
phone /* */?: string;
address /**/?: string;
};// prettier-ignore
interface User {
id /* */: number;
username /**/: string;
email /* */: string;
age /* */: number;
}
```## Installation
### Yarn
```bash
yarn add -D eslint-plugin-alignment
```## Usage
Add `alignment` to your list of plugins and extend the
recommended configuration.```json
{
"extends": "plugin:alignment/recommended",
"plugins": ["alignment"]
}
```## Rules
| Name | Description | Fixable (using `--fix`) |
| -------------------------------------------------------- | ---------------------------------------------------- | ----------------------- |
| [`alignment/align-objects`](docs/rules/align-objects.md) | Aligns values inside plain JS object expressions | Yes |
| [`alignment/align-enums`](docs/rules/align-enums.md) | Aligns members of TS enums | Yes |
| [`alignment/align-types`](docs/rules/align-types.md) | Aligns properties of TS interfaces and type literals | Yes |