Skip to content

Commit 8b53954

Browse files
authored
refactor: remove method alias (#71)
1 parent 0a84314 commit 8b53954

File tree

10 files changed

+16
-34
lines changed

10 files changed

+16
-34
lines changed

src/rules/newline-after-import.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
66
import debug from 'debug'
77

8-
import { isStaticRequire, createRule, getScope } from '../utils'
8+
import { isStaticRequire, createRule } from '../utils'
99

1010
const log = debug('eslint-plugin-import-x:rules:newline-after-import')
1111

@@ -276,7 +276,7 @@ export = createRule<[Options?], MessageId>({
276276
'Program:exit'(node) {
277277
log('exit processing for', context.physicalFilename)
278278

279-
const scopeBody = getScopeBody(getScope(context, node))
279+
const scopeBody = getScopeBody(context.sourceCode.getScope(node))
280280

281281
log('got scope:', scopeBody)
282282

src/rules/no-amd.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Rule to prefer imports to AMD
33
*/
44

5-
import { createRule, getScope } from '../utils'
5+
import { createRule } from '../utils'
66

77
type MessageId = 'amd'
88

@@ -23,7 +23,7 @@ export = createRule<[], MessageId>({
2323
create(context) {
2424
return {
2525
CallExpression(node) {
26-
if (getScope(context, node).type !== 'module') {
26+
if (context.sourceCode.getScope(node).type !== 'module') {
2727
return
2828
}
2929

src/rules/no-commonjs.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
66

7-
import { createRule, getScope } from '../utils'
7+
import { createRule } from '../utils'
88

99
type NormalizedOptions = {
1010
allowPrimitiveModules?: boolean
@@ -127,16 +127,16 @@ export = createRule<[Options?], MessageId>({
127127

128128
// exports.
129129
if ('name' in node.object && node.object.name === 'exports') {
130-
const isInScope = getScope(context, node).variables.some(
131-
variable => variable.name === 'exports',
132-
)
130+
const isInScope = context.sourceCode
131+
.getScope(node)
132+
.variables.some(variable => variable.name === 'exports')
133133
if (!isInScope) {
134134
context.report({ node, messageId: 'export' })
135135
}
136136
}
137137
},
138138
CallExpression(call) {
139-
if (!validateScope(getScope(context, call))) {
139+
if (!validateScope(context.sourceCode.getScope(call))) {
140140
return
141141
}
142142

src/rules/no-mutable-exports.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
22

3-
import { createRule, getScope } from '../utils'
3+
import { createRule } from '../utils'
44

55
type MessageId = 'noMutable'
66

@@ -48,14 +48,14 @@ export = createRule<[], MessageId>({
4848

4949
return {
5050
ExportDefaultDeclaration(node) {
51-
const scope = getScope(context, node)
51+
const scope = context.sourceCode.getScope(node)
5252

5353
if ('name' in node.declaration) {
5454
checkDeclarationsInScope(scope, node.declaration.name)
5555
}
5656
},
5757
ExportNamedDeclaration(node) {
58-
const scope = getScope(context, node)
58+
const scope = context.sourceCode.getScope(node)
5959

6060
if (node.declaration) {
6161
checkDeclaration(node.declaration)

src/rules/no-namespace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
66
import { minimatch } from 'minimatch'
77

8-
import { createRule, getScope } from '../utils'
8+
import { createRule } from '../utils'
99

1010
type MessageId = 'noNamespace'
1111

@@ -59,7 +59,7 @@ export = createRule<[Options?], MessageId>({
5959
return
6060
}
6161

62-
const scopeVariables = getScope(context, node).variables
62+
const scopeVariables = context.sourceCode.getScope(node).variables
6363
const namespaceVariable = scopeVariables.find(
6464
variable => variable.defs[0].node === node,
6565
)!

src/utils/declared-scope.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import type { TSESTree } from '@typescript-eslint/utils'
22

33
import type { RuleContext } from '../types'
44

5-
import { getScope } from './get-scope'
6-
75
export function declaredScope(
86
context: RuleContext,
97
node: TSESTree.Node,
108
name: string,
119
) {
12-
const references = getScope(context, node).references
10+
const references = context.sourceCode.getScope(node).references
1311
const reference = references.find(x => x.identifier.name === name)
1412
if (!reference || !reference.resolved) {
1513
return

src/utils/get-ancestors.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/utils/get-scope.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/utils/import-declaration.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ import type { TSESTree } from '@typescript-eslint/utils'
22

33
import type { RuleContext } from '../types'
44

5-
import { getAncestors } from './get-ancestors'
6-
75
export const importDeclaration = (
86
context: RuleContext,
97
node: TSESTree.Node,
108
) => {
11-
const ancestors = getAncestors(context, node)
9+
const ancestors = context.sourceCode.getAncestors(node)
1210
return ancestors[ancestors.length - 1] as TSESTree.ImportDeclaration
1311
}

src/utils/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ export * from './create-rule'
33
export * from './declared-scope'
44
export * from './docs-url'
55
export * from './export-map'
6-
export * from './get-ancestors'
7-
export * from './get-scope'
86
export * from './get-value'
97
export * from './hash'
108
export * from './ignore'

0 commit comments

Comments
 (0)