Skip to content

Commit

Permalink
feat: update utils
Browse files Browse the repository at this point in the history
  • Loading branch information
lzear committed Nov 4, 2023
1 parent 1d84c7f commit f6fe552
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 16 deletions.
4 changes: 2 additions & 2 deletions utils/compare.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import naturalCompare from 'natural-compare-lite'

import type { SortingNode, SortOrder } from '../typings'
import type { SortingNode, SortOrder } from '../typings/index.js'

import { SortType } from '../typings'
import { SortType } from '../typings/index.js'

export const compare = (
a: SortingNode,
Expand Down
18 changes: 16 additions & 2 deletions utils/create-eslint-rule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { ESLintUtils } from '@typescript-eslint/utils'
/* eslint-disable */
import * as uuu from '@typescript-eslint/utils'
import { RuleWithMetaAndName } from './eslint-types/RuleCreator.js'
import { RuleListener, RuleModule } from './eslint-types/Rule.js'

export const createEslintRule = ESLintUtils.RuleCreator(
export let createEslintRule: <
TOptions extends readonly unknown[],
TMessageIds extends string,
>({
name,
meta,
...rule
}: Readonly<RuleWithMetaAndName<TOptions, TMessageIds>>) => RuleModule<
TMessageIds,
TOptions,
RuleListener
> = uuu.ESLintUtils.RuleCreator(
ruleName => `https://www.dont.ninja/rules/${ruleName}`,
)
2 changes: 1 addition & 1 deletion utils/get-group-number.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SortingNode } from '../typings'
import type { SortingNode } from '../typings/index.js'

export const getGroupNumber = (
groups: (string[] | string)[],
Expand Down
6 changes: 3 additions & 3 deletions utils/get-node-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import type { TSESLint } from '@typescript-eslint/utils'

import { ASTUtils } from '@typescript-eslint/utils'

import type { PartitionComment } from '../typings'
import type { PartitionComment } from '../typings/index.js'

import { isPartitionComment } from './is-partition-comment'
import { getCommentBefore } from './get-comment-before'
import { isPartitionComment } from './is-partition-comment.js'
import { getCommentBefore } from './get-comment-before.js'

export const getNodeRange = (
node: TSESTree.Node,
Expand Down
5 changes: 3 additions & 2 deletions utils/is-partition-comment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { minimatch } from 'minimatch'
import * as minimatchModule from '../node_modules/minimatch/dist/mjs/index.js'
const { minimatch } = minimatchModule

import type { PartitionComment } from '../typings'
import type { PartitionComment } from '../typings/index.js'

export const isPartitionComment = (
partitionComment: PartitionComment,
Expand Down
6 changes: 3 additions & 3 deletions utils/make-fixes.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { TSESTree } from '@typescript-eslint/types'
import type { TSESLint } from '@typescript-eslint/utils'

import type { PartitionComment, SortingNode } from '../typings'
import type { PartitionComment, SortingNode } from '../typings/index.js'

import { getCommentAfter } from './get-comment-after'
import { getNodeRange } from './get-node-range'
import { getCommentAfter } from './get-comment-after.js'
import { getNodeRange } from './get-node-range.js'

export const makeFixes = (
fixer: TSESLint.RuleFixer,
Expand Down
4 changes: 2 additions & 2 deletions utils/sort-nodes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SortingNode, SortOrder, SortType } from '../typings'
import type { SortingNode, SortOrder, SortType } from '../typings/index.js'

import { compare } from './compare'
import { compare } from './compare.js'

export const sortNodes = <T extends SortingNode>(
nodes: T[],
Expand Down
4 changes: 3 additions & 1 deletion utils/use-groups.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { minimatch } from 'minimatch'
import * as minimatchModule from '../node_modules/minimatch/dist/mjs/index.js'

const { minimatch } = minimatchModule

export const useGroups = (groups: (string[] | string)[]) => {
let group: undefined | string
Expand Down

0 comments on commit f6fe552

Please sign in to comment.