Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/compiler_discord_notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
actor: ${{ github.event.pull_request.user.login }}

notify:
if: ${{ needs.check_maintainer.outputs.is_core_team == 'true' }}
if: ${{ needs.check_maintainer.outputs.is_core_team == 'true' && github.event.label.name == 'React Core Team' }}
needs: check_maintainer
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/runtime_discord_notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
actor: ${{ github.event.pull_request.user.login }}

notify:
if: ${{ needs.check_maintainer.outputs.is_core_team == 'true' }}
if: ${{ needs.check_maintainer.outputs.is_core_team == 'true' && github.event.label.name == 'React Core Team' }}
needs: check_maintainer
runs-on: ubuntu-latest
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2528,6 +2528,7 @@ function lowerExpression(
loc: expr.node.loc ?? GeneratedSource,
};
}
case 'TSInstantiationExpression':
case 'TSNonNullExpression': {
let expr = exprPath as NodePath<t.TSNonNullExpression>;
return lowerExpression(builder, expr.get('expression'));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

## Input

```javascript
import {identity, invoke} from 'shared-runtime';

function Test() {
const str = invoke(identity<string>, 'test');
return str;
}

export const FIXTURE_ENTRYPOINT = {
fn: Test,
params: [],
};

```

## Code

```javascript
import { c as _c } from "react/compiler-runtime";
import { identity, invoke } from "shared-runtime";

function Test() {
const $ = _c(1);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = invoke(identity, "test");
$[0] = t0;
} else {
t0 = $[0];
}
const str = t0;
return str;
}

export const FIXTURE_ENTRYPOINT = {
fn: Test,
params: [],
};

```

### Eval output
(kind: ok) "test"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {identity, invoke} from 'shared-runtime';

function Test() {
const str = invoke(identity<string>, 'test');
return str;
}

export const FIXTURE_ENTRYPOINT = {
fn: Test,
params: [],
};
70 changes: 70 additions & 0 deletions packages/eslint-plugin-react-hooks/src/types/estree.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* This file augments the `estree` types to include types that are not built-in to `estree` or `estree-jsx`.
* This is necessary because the `estree` types are used by ESLint, and ESLint does not natively support
* TypeScript or Flow types. Since we're not using a ton of them, we can just add them here, rather than
* installing typescript estree or flow estree types.
*
* This also adds support for the AST mutation that the Exhaustive deps rule does to add parent nodes.
*/
declare module 'estree' {
// The Exhaustive deps rule mutates the AST to add parent nodes for efficient traversal.
// We need to augment the `estree` types to support that.
interface BaseNode {
parent?: Node;
}

// Adding types that aren't built-in to estree or estree-jsx.
// Namely, the specific TS and Flow types that we're using.
interface AsExpression extends BaseExpression {
type: 'AsExpression';
expression: Expression | Identifier;
}

interface OptionalCallExpression extends BaseCallExpression {
type: 'OptionalCallExpression';
}

interface OptionalMemberExpression extends MemberExpression {
type: 'OptionalMemberExpression';
}

interface TSAsExpression extends BaseExpression {
type: 'TSAsExpression';
expression: Expression | Identifier;
}

interface TSTypeQuery extends BaseNode {
type: 'TSTypeQuery';
exprName: Identifier;
}

interface TSTypeReference extends BaseNode {
type: 'TSTypeReference';
typeName: Identifier;
}

interface TypeCastExpression extends BaseExpression {
type: 'TypeCastExpression';
expression: Expression | Identifier;
}

// Extend the set of known Expression types
interface ExpressionMap {
AsExpression: AsExpression;
OptionalCallExpression: OptionalCallExpression;
OptionalMemberExpression: OptionalMemberExpression;
TSAsExpression: TSAsExpression;
TypeCastExpression: TypeCastExpression;
}

// Extend the set of known Node types
interface NodeMap {
AsExpression: AsExpression;
OptionalCallExpression: OptionalCallExpression;
OptionalMemberExpression: OptionalMemberExpression;
TSAsExpression: TSAsExpression;
TSTypeQuery: TSTypeQuery;
TSTypeReference: TSTypeReference;
TypeCastExpression: TypeCastExpression;
}
}
4 changes: 4 additions & 0 deletions packages/eslint-plugin-react-hooks/src/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// In order to support the __EXPERIMENTAL__ global in TypeScript,
// we need to declare it here. The value of this is set in both
// the jest setup and CI build
declare const __EXPERIMENTAL__: boolean;
15 changes: 15 additions & 0 deletions packages/eslint-plugin-react-hooks/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "@tsconfig/strictest/tsconfig.json",
"compilerOptions": {
"module": "ES2015",
"target": "ES2015",
"moduleResolution": "Bundler",
"lib": ["ES2020"],
"rootDir": ".",
"noEmit": true,
"sourceMap": false,
"types": ["estree-jsx", "node"]
},
"exclude": ["node_modules"],
"include": ["src/**/*.ts"]
}
9 changes: 9 additions & 0 deletions packages/eslint-plugin-react-hooks/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {defineConfig} from 'tsup';

export default defineConfig({
clean: true,
dts: true,
entry: ['src/index.ts'],
format: ['cjs'],
outDir: 'build',
});
Loading