Skip to content

Commit

Permalink
fix(utilities/ast): Added missing ts as and satisfies expressions han…
Browse files Browse the repository at this point in the history
…dling to getFunctionIdentifier, closes #843
  • Loading branch information
Rel1cx committed Oct 22, 2024
1 parent 9859c8a commit 9e9bfa8
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 18 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.15.1-next.9
1.15.1-next.10
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/monorepo",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"private": true,
"description": "A series of composable ESLint plugins for libraries and frameworks that use React as a UI runtime.",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/core",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and Patterns.",
"homepage": "https://github.com/rel1cx/eslint-react",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/eslint-plugin-react-debug/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-debug",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "ESLint React's ESLint plugin for debugging related rules.",
"keywords": [
"eslint",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1373,5 +1373,23 @@ ruleTester.run(RULE_NAME, rule, {
"const results = allSettled.map((x) => (x.status === 'fulfilled' ? <div /> : null))",
"const results = allSettled.map((x) => (x.status === 'fulfilled' ? format(x.value) : null))",
"const results = allSettled.mapLike((x) => (x.status === 'fulfilled' ? format(x.value) : null))",
/* tsx */ `
export const action = (() => {
// ^?
return null;
});
`,
/* tsx */ `
export const action = (() => {
// ^?
return null;
}) as ActionFUnction;
`,
/* tsx */ `
export const action = (() => {
// ^?
return null;
}) satisfies ActionFUnction;
`,
],
});
2 changes: 1 addition & 1 deletion packages/plugins/eslint-plugin-react-dom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-dom",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "ESLint React's ESLint plugin for React DOM related rules.",
"keywords": [
"eslint",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-hooks-extra",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "ESLint React's ESLint plugin for React Hooks related rules.",
"keywords": [
"eslint",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-naming-convention",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "ESLint React's ESLint plugin for naming convention related rules.",
"keywords": [
"eslint",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/eslint-plugin-react-web-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-web-api",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
"keywords": [
"eslint",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/eslint-plugin-react-x/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-x",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "A set of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
"keywords": [
"eslint",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/eslint-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/eslint-plugin",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "The main ESLint plugin of ESLint React. Contains all the rules and presets of ESLint React.",
"keywords": [
"eslint",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/shared",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "ESLint React's Shared constants and functions.",
"homepage": "https://github.com/rel1cx/eslint-react",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/tools",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "ESLint React's std library and primitives.",
"homepage": "https://github.com/rel1cx/eslint-react",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/types",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "ESLint React's type definitions.",
"homepage": "https://github.com/rel1cx/eslint-react",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/ast/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/ast",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "ESLint React's TSESTree AST utility module.",
"homepage": "https://github.com/rel1cx/eslint-react",
"bugs": {
Expand Down
10 changes: 8 additions & 2 deletions packages/utilities/ast/src/get-function-identifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { AST_NODE_TYPES } from "@typescript-eslint/types";
import { isOneOf } from "./is";
import type { TSESTreeFunction } from "./types";

export function getFunctionIdentifier(node: TSESTreeFunction): O.Option<TSESTree.Identifier> {
export function getFunctionIdentifier(node: TSESTree.Expression | TSESTreeFunction): O.Option<TSESTree.Identifier> {
// function MaybeComponent() {}
// const whatever = function MaybeComponent() {};
if (node.id) return O.some(node.id);
if ("id" in node && node.id) return O.some(node.id);
// const MaybeComponent = () => {};
if (
node.parent.type === AST_NODE_TYPES.VariableDeclarator
Expand Down Expand Up @@ -67,5 +67,11 @@ export function getFunctionIdentifier(node: TSESTreeFunction): O.Option<TSESTree
return O.some(node.parent.left);
}

if (
isOneOf([AST_NODE_TYPES.TSAsExpression, AST_NODE_TYPES.TSSatisfiesExpression])(node.parent)
&& node.parent.expression === node
) {
return getFunctionIdentifier(node.parent);
}
return O.none();
}
2 changes: 1 addition & 1 deletion packages/utilities/jsx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/jsx",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "ESLint React's TSESTree AST utility module for static analysis of JSX.",
"homepage": "https://github.com/rel1cx/eslint-react",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/var/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/var",
"version": "1.15.1-next.9",
"version": "1.15.1-next.10",
"description": "TSESTree AST utility module for static analysis of variables",
"homepage": "https://github.com/rel1cx/eslint-react",
"bugs": {
Expand Down

0 comments on commit 9e9bfa8

Please sign in to comment.