Skip to content

Commit

Permalink
refactor: migrate imports-first rule
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Mar 18, 2024
1 parent 6ea05f4 commit e19f960
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/docs-url.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - We're using commonjs
// @ts-ignore - The structures of `lib` and `src` are same
import pkg from '../package.json'

const repoUrl = 'https://github.com/un-es/eslint-plugin-import-x'
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import noImportModuleExports from './rules/no-import-module-exports'
import noEmptyNamedBlocks from './rules/no-empty-named-blocks'
import exportsLast from './rules/exports-last'
import noDeprecated from './rules/no-deprecated'
import importsFirst from './rules/imports-first'

// configs
import recommended from './config/recommended'
Expand Down Expand Up @@ -111,7 +112,7 @@ export const rules = {
'no-deprecated': noDeprecated,

// deprecated aliases to rules
'imports-first': require('./rules/imports-first'),
'imports-first': importsFirst,
} satisfies Record<string, TSESLint.RuleModule<string, readonly unknown[]>>

export const configs = {
Expand Down
15 changes: 0 additions & 15 deletions src/rules/imports-first.js

This file was deleted.

22 changes: 22 additions & 0 deletions src/rules/imports-first.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ESLintUtils } from '@typescript-eslint/utils'

import { docsUrl } from '../docs-url'

import first from './first'

const createRule = ESLintUtils.RuleCreator(ruleName =>
docsUrl(ruleName, '7b25c1cb95ee18acc1531002fd343e1e6031f9ed'),
)

export = createRule({
...first,
name: 'imports-first',
meta: {
...first.meta,
deprecated: true,
docs: {
category: 'Style guide',
description: 'Replaced by `import-x/first`.',
},
},
})

0 comments on commit e19f960

Please sign in to comment.