Skip to content

Commit

Permalink
refact(prettier): run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
ducktordanny committed Jun 16, 2024
1 parent c7ec831 commit 7b86c03
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ Add `ng-module-sort` to the plugins section of your `.eslintrc` configuration fi

```json
{
"plugins": [
"ng-module-sort"
]
"plugins": ["ng-module-sort"]
}
```


Then configure the rules you want to use under the rules section.

## Rules
Expand All @@ -47,19 +44,21 @@ With this rule you can detect unsorted arrays of imports, declarations, provider

```json
{
"rules": {
"ng-module-sort/decorator-array-items": [
"error", {
"reverseSort": false
}
]
}
"rules": {
"ng-module-sort/decorator-array-items": [
"error",
{
"reverseSort": false
}
]
}
}
```

A few example of it:

- Error

```ts
import {Component} from '@angular/core';

Expand All @@ -77,6 +76,7 @@ import {Component} from '@angular/core';
```

- Fix with default options

```ts
import {Component} from '@angular/core';

Expand All @@ -94,6 +94,7 @@ import {Component} from '@angular/core';
```

- With option `"reverseSort": true`

```ts
import {Component} from '@angular/core';

Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { decoratorArrayItemsRule } from './rules/decorator-array-items';
import {decoratorArrayItemsRule} from './rules/decorator-array-items';

export const rules = {
'decorator-array-items': decoratorArrayItemsRule,
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/decorator-array-items/order-check.util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Identifier } from "@typescript-eslint/types/dist/generated/ast-spec";
import {Identifier} from '@typescript-eslint/types/dist/generated/ast-spec';

import { DecoratorArrayItemsRuleContext } from "../../types";
import {DecoratorArrayItemsRuleContext} from '../../types';

export const orderCheck = (
context: DecoratorArrayItemsRuleContext,
Expand Down
13 changes: 5 additions & 8 deletions lib/rules/decorator-array-items/order-fixer.util.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import {
ArrayExpression,
Identifier,
} from "@typescript-eslint/types/dist/generated/ast-spec";
import { RuleFix, RuleFixer } from "@typescript-eslint/utils/dist/ts-eslint";
import {ArrayExpression, Identifier} from '@typescript-eslint/types/dist/generated/ast-spec';
import {RuleFix, RuleFixer} from '@typescript-eslint/utils/dist/ts-eslint';

import { DecoratorArrayItemsRuleContext } from "../../types";
import {DecoratorArrayItemsRuleContext} from '../../types';

export const orderFixer = (
fixer: RuleFixer,
Expand All @@ -17,11 +14,11 @@ export const orderFixer = (
const sortedElements = elements.map((el) => sourceCode.getText(el)).sort();
if (reverseSort) sortedElements.reverse();

let joinSeparator = ", ";
let joinSeparator = ', ';
const start = elements?.at(0)?.loc?.start;
const end = elements?.at(-1)?.loc?.start;
if (start && end && start.line !== end.line) {
const indentation = " ".repeat(start.column);
const indentation = ' '.repeat(start.column);
joinSeparator = `,\n${indentation}`;
}

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"strict": true,
"target": "es2017",
"lib": ["es2017", "dom"]
},
},
"include": ["./lib/**/*.ts", "./tests/**/*.ts"]
}

0 comments on commit 7b86c03

Please sign in to comment.