Skip to content

Commit

Permalink
refactor: rename 'isTypeOnlyExpression' to 'isTypeExpression'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rel1cx committed Dec 29, 2024
1 parent 0edd720 commit 1e1093a
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const RULE_FEATURES = [
export type MessageID = CamelCase<typeof RULE_NAME>;

function getName(node: TSESTree.Expression | TSESTree.PrivateIdentifier): O.Option<string> {
if (AST.isTypeOnlyExpression(node)) {
if (AST.isTypeExpression(node)) {
return getName(node.expression);
}
if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const RULE_FEATURES = [
export type MessageID = CamelCase<typeof RULE_NAME>;

function getName(node: TSESTree.Expression | TSESTree.PrivateIdentifier): O.Option<string> {
if (AST.isTypeOnlyExpression(node)) {
if (AST.isTypeExpression(node)) {
return getName(node.expression);
}
if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const LIFECYCLE_METHODS = new Set([
// anywhere that a literal may be used as a key (e.g., member expressions,
// method definitions, ObjectExpression property keys).
function getName(node: TSESTree.Expression | TSESTree.PrivateIdentifier): O.Option<string> {
if (AST.isTypeOnlyExpression(node)) {
if (AST.isTypeExpression(node)) {
return getName(node.expression);
}
if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const RULE_FEATURES = [
export type MessageID = CamelCase<typeof RULE_NAME>;

function getName(node: TSESTree.Expression | TSESTree.PrivateIdentifier): O.Option<string> {
if (AST.isTypeOnlyExpression(node)) {
if (AST.isTypeExpression(node)) {
return getName(node.expression);
}
if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) {
Expand Down
4 changes: 2 additions & 2 deletions packages/utilities/ast/src/get-function-identifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { O } from "@eslint-react/eff";
import type { TSESTree } from "@typescript-eslint/types";
import { AST_NODE_TYPES } from "@typescript-eslint/types";

import { isOneOf, isTypeOnlyExpression } from "./is";
import { isOneOf, isTypeExpression } from "./is";
import type { TSESTreeFunction } from "./types";

export function getFunctionIdentifier(node: TSESTree.Expression | TSESTreeFunction): O.Option<TSESTree.Identifier> {
Expand Down Expand Up @@ -55,7 +55,7 @@ export function getFunctionIdentifier(node: TSESTree.Expression | TSESTreeFuncti
// const MaybeComponent = (() => {})!;
// const MaybeComponent = (() => {}) as FunctionComponent;
// const MaybeComponent = (() => {}) satisfies FunctionComponent;
case isTypeOnlyExpression(node.parent):
case isTypeExpression(node.parent):
return getFunctionIdentifier(node.parent);
}
return O.none();
Expand Down
4 changes: 2 additions & 2 deletions packages/utilities/ast/src/is-this-expression.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { TSESTree } from "@typescript-eslint/types";
import { AST_NODE_TYPES } from "@typescript-eslint/types";

import { isTypeOnlyExpression } from "./is";
import { isTypeExpression } from "./is";

export function isThisExpression(node: TSESTree.Expression) {
if (isTypeOnlyExpression(node)) {
if (isTypeExpression(node)) {
return isThisExpression(node.expression);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/ast/src/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const isLeftHandSideExpressionType = isOneOf([
AST_NODE_TYPES.TSTypeAssertion,
]);

export const isTypeOnlyExpression = isOneOf([
export const isTypeExpression = isOneOf([
AST_NODE_TYPES.TSAsExpression,
AST_NODE_TYPES.TSTypeAssertion,
AST_NODE_TYPES.TSNonNullExpression,
Expand Down
4 changes: 2 additions & 2 deletions packages/utilities/ast/src/unwrap-type-expression.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { TSESTree } from "@typescript-eslint/types";

import { isTypeOnlyExpression } from "./is";
import { isTypeExpression } from "./is";

export function unwrapTypeExpression(node: TSESTree.Node): TSESTree.Node {
if (isTypeOnlyExpression(node)) return unwrapTypeExpression(node.expression);
if (isTypeExpression(node)) return unwrapTypeExpression(node.expression);
return node;
}
2 changes: 1 addition & 1 deletion packages/utilities/var/src/construction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export function inspectConstruction(
}
return Construction.None();
})
.when(AST.isTypeOnlyExpression, () => {
.when(AST.isTypeExpression, () => {
if (!("expression" in node) || !isObject(node.expression)) {
return Construction.None();
}
Expand Down

0 comments on commit 1e1093a

Please sign in to comment.