From 7b86c03b75eaa8e3aa1b365befe1d26f1dad2690 Mon Sep 17 00:00:00 2001 From: Daniel Lazar Date: Sun, 16 Jun 2024 14:15:38 +0200 Subject: [PATCH] refact(prettier): run formatter --- README.md | 23 ++++++++++--------- lib/index.ts | 2 +- .../decorator-array-items/order-check.util.ts | 4 ++-- .../decorator-array-items/order-fixer.util.ts | 13 ++++------- tsconfig.json | 2 +- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index c9d7d67..9d61b65 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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'; @@ -77,6 +76,7 @@ import {Component} from '@angular/core'; ``` - Fix with default options + ```ts import {Component} from '@angular/core'; @@ -94,6 +94,7 @@ import {Component} from '@angular/core'; ``` - With option `"reverseSort": true` + ```ts import {Component} from '@angular/core'; diff --git a/lib/index.ts b/lib/index.ts index 3937675..233905a 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -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, diff --git a/lib/rules/decorator-array-items/order-check.util.ts b/lib/rules/decorator-array-items/order-check.util.ts index 3aeb970..eb0f04e 100644 --- a/lib/rules/decorator-array-items/order-check.util.ts +++ b/lib/rules/decorator-array-items/order-check.util.ts @@ -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, diff --git a/lib/rules/decorator-array-items/order-fixer.util.ts b/lib/rules/decorator-array-items/order-fixer.util.ts index 40fd86e..5c8b7aa 100644 --- a/lib/rules/decorator-array-items/order-fixer.util.ts +++ b/lib/rules/decorator-array-items/order-fixer.util.ts @@ -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, @@ -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}`; } diff --git a/tsconfig.json b/tsconfig.json index 3286c9d..a28f503 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,6 +14,6 @@ "strict": true, "target": "es2017", "lib": ["es2017", "dom"] - }, + }, "include": ["./lib/**/*.ts", "./tests/**/*.ts"] }