Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
1a6b2bb
Fixes animation jank on hover (#7904)
wesbos Aug 6, 2025
b092216
fix: box-shadow animation on community (#7905)
ChezFre Aug 7, 2025
e9a7cb1
Updates to Activity docs (#7884)
samselikoff Aug 8, 2025
0a74f01
Add more information about event and property binding on custom eleme…
crutchcorn Aug 22, 2025
27d86ff
Touch-ups to Activity (#7940)
samselikoff Aug 22, 2025
694aeac
Add React Paris 2025 conference talks + Add React Paris 2026 (#7935)
AymenBenAmor Aug 26, 2025
90686d8
Add CityJS New Delhi 2026 conference details (#7949)
arismarko Aug 26, 2025
9a370f2
[compiler] Tweak intro section on manual memo guidance (#7953)
poteto Aug 28, 2025
94a1164
[compiler][ez] Reference rc tag for install instructions (#7955)
poteto Aug 28, 2025
19c8201
[compiler] Update docs on eslint-plugin-react-hooks installation (#7956)
poteto Aug 28, 2025
2774ddf
Add reload button, rename reset to clear (#7954)
rickhanlonii Aug 29, 2025
ddfcf6e
fix: typo in component style documentation (#7925)
sky21kr Sep 1, 2025
bb998fd
fix broken link server-functions (#7923)
PouriaDamavandi Sep 1, 2025
4db5ecd
docs: Add Rendercon 2025 Conference (#7962)
orama254 Sep 2, 2025
9ced885
feat(i18n): make DocsPageFooter navigation labels translatable (#7943)
mrbadri Sep 2, 2025
04feec4
fix(rtl): resolve RTL issues in Challenges component (#7942)
mrbadri Sep 2, 2025
4d53629
Introduce Liverpool and Edinburgh meetup groups. (#7950)
asimno Sep 2, 2025
73a5fdd
docs: fix typo in update useTransition.md (#7936)
brookslybrand Sep 2, 2025
fc27b0a
docs: fix ordered list numbering in TypeScript with React Components …
mrbadri Sep 2, 2025
03a5465
Docs: update ref callback behaviour (#7927)
ninamma Sep 2, 2025
a4a37d8
Add setup to home sidebar (#7963)
rickhanlonii Sep 2, 2025
ca3e271
fix: definition typo on view transitions blog post (#7918)
vitormrmonteiro Sep 2, 2025
67584b3
Fix: grammar and add comma (#7917)
deepu7ds Sep 2, 2025
0cc37ee
fix: typo (#7914)
Raghuboi Sep 2, 2025
afd84d1
Recommend installing `@types/*` as dev dependencies
Dejumo Sep 2, 2025
337d5ea
docs: minor grammar correction (#7906)
ergusto Sep 2, 2025
e9efd19
fix : typo in form component documentation (#7894)
developerjhp Sep 2, 2025
2217f45
Update "Deep Dive" in reusing-logic-with-custom-hooks.md with link an…
aurorascharff Sep 2, 2025
ff11cd2
Add note that form actions are actions (#7964)
rickhanlonii Sep 2, 2025
85ee6b2
Remove deprecated loremflickr placeholder images (#7968)
poteto Sep 3, 2025
b8e9faf
Fix handleClick compiler intro example (#7967)
rickhanlonii Sep 3, 2025
d34c6a2
Fix/tictactoe docs invalid file names (#7969)
mtayyabrawan Sep 4, 2025
4d3d495
Add React Conf 2024 to /videos (#7977)
rickhanlonii Sep 9, 2025
0bfd418
docs: add flushSync Troubleshooting section (#7978)
Akshay090 Sep 11, 2025
a5181c2
Bump Activity docs to canary (#7974)
rickhanlonii Sep 12, 2025
5b9a2ce
Upgrade babel-plugin-react-compiler (#7985)
poteto Sep 16, 2025
a566d87
Add copyright script (#7991)
poteto Sep 18, 2025
bd03b86
Update copyright on all files (#7992)
poteto Sep 18, 2025
b6a32d1
Add local eslint rule to validate markdown codeblocks with React Comp…
poteto Sep 18, 2025
5cc9b7b
fix compiler errors (#7989)
poteto Sep 18, 2025
2a9ef2d
Revert "fix compiler errors (#7989)" (#7995)
poteto Sep 18, 2025
f369f3e
Ignore braces when building Sandpack file map (#7996)
poteto Sep 18, 2025
730d045
Restore lint corrections from #7989 (#7997)
poteto Sep 18, 2025
c15e20f
Install eslint-local-rules as postinstall (#7993)
poteto Sep 19, 2025
366b5fb
Add new eslint rule reference docs (#7986)
poteto Sep 19, 2025
8c8067c
merging all conflicts
react-translations-bot Sep 22, 2025
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
24 changes: 21 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,36 @@
"root": true,
"extends": "next/core-web-vitals",
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "eslint-plugin-react-compiler"],
"plugins": ["@typescript-eslint", "eslint-plugin-react-compiler", "local-rules"],
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", {"varsIgnorePattern": "^_"}],
"react-hooks/exhaustive-deps": "error",
"react/no-unknown-property": ["error", {"ignore": ["meta"]}],
"react-compiler/react-compiler": "error"
"react-compiler/react-compiler": "error",
"local-rules/lint-markdown-code-blocks": "error"
},
"env": {
"node": true,
"commonjs": true,
"browser": true,
"es6": true
}
},
"overrides": [
{
"files": ["src/content/**/*.md"],
"parser": "./eslint-local-rules/parser",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"react-hooks/exhaustive-deps": "off",
"react/no-unknown-property": "off",
"react-compiler/react-compiler": "off",
"local-rules/lint-markdown-code-blocks": "error"
}
}
]
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
node_modules
/.pnp
.pnp.js

Expand Down
7 changes: 7 additions & 0 deletions colors.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```jsx
import {useState} from 'react';
function Counter() {
const [count, setCount] = useState(0);
setCount(count + 1);
return <div>{count}</div>;
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```jsx title="Counter" {expectedErrors: {'react-compiler': [99]}} {expectedErrors: {'react-compiler': [2]}}
import {useState} from 'react';
function Counter() {
const [count, setCount] = useState(0);
setCount(count + 1);
return <div>{count}</div>;
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```jsx {expectedErrors: {'react-compiler': 'invalid'}}
import {useState} from 'react';
function Counter() {
const [count, setCount] = useState(0);
setCount(count + 1);
return <div>{count}</div>;
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```bash
setCount()
```

```txt
import {useState} from 'react';
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```jsx {expectedErrors: {'react-compiler': [3]}}
function Hello() {
return <h1>Hello</h1>;
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```jsx {expectedErrors: {'react-compiler': [4]}}
import {useState} from 'react';
function Counter() {
const [count, setCount] = useState(0);
setCount(count + 1);
return <div>{count}</div>;
}
```
131 changes: 131 additions & 0 deletions eslint-local-rules/__tests__/lint-markdown-code-blocks.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const {ESLint} = require('eslint');
const plugin = require('..');

const FIXTURES_DIR = path.join(
__dirname,
'fixtures',
'src',
'content'
);
const PARSER_PATH = path.join(__dirname, '..', 'parser.js');

function createESLint({fix = false} = {}) {
return new ESLint({
useEslintrc: false,
fix,
plugins: {
'local-rules': plugin,
},
overrideConfig: {
parser: PARSER_PATH,
plugins: ['local-rules'],
rules: {
'local-rules/lint-markdown-code-blocks': 'error',
},
parserOptions: {
sourceType: 'module',
},
},
});
}

function readFixture(name) {
return fs.readFileSync(path.join(FIXTURES_DIR, name), 'utf8');
}

async function lintFixture(name, {fix = false} = {}) {
const eslint = createESLint({fix});
const filePath = path.join(FIXTURES_DIR, name);
const markdown = readFixture(name);
const [result] = await eslint.lintText(markdown, {filePath});
return result;
}

async function run() {
const basicResult = await lintFixture('basic-error.md');
assert.strictEqual(
basicResult.messages.length,
1,
'expected one diagnostic'
);
assert(
basicResult.messages[0].message.includes('Calling setState during render'),
'expected message to mention setState during render'
);

const suppressedResult = await lintFixture('suppressed-error.md');
assert.strictEqual(
suppressedResult.messages.length,
0,
'expected suppression metadata to silence diagnostic'
);

const staleResult = await lintFixture('stale-expected-error.md');
assert.strictEqual(
staleResult.messages.length,
1,
'expected stale metadata error'
);
assert.strictEqual(
staleResult.messages[0].message,
'React Compiler expected error on line 3 was not triggered'
);

const duplicateResult = await lintFixture('duplicate-metadata.md');
assert.strictEqual(
duplicateResult.messages.length,
2,
'expected duplicate metadata to surface compiler diagnostic and stale metadata notice'
);
const duplicateFixed = await lintFixture('duplicate-metadata.md', {
fix: true,
});
assert(
duplicateFixed.output.includes(
"{expectedErrors: {'react-compiler': [4]}}"
),
'expected duplicates to be rewritten to a single canonical block'
);
assert(
!duplicateFixed.output.includes('[99]'),
'expected stale line numbers to be removed from metadata'
);

const mixedLanguageResult = await lintFixture('mixed-language.md');
assert.strictEqual(
mixedLanguageResult.messages.length,
0,
'expected non-js code fences to be ignored'
);

const malformedResult = await lintFixture('malformed-metadata.md');
assert.strictEqual(
malformedResult.messages.length,
1,
'expected malformed metadata to fall back to compiler diagnostics'
);
const malformedFixed = await lintFixture('malformed-metadata.md', {
fix: true,
});
assert(
malformedFixed.output.includes(
"{expectedErrors: {'react-compiler': [4]}}"
),
'expected malformed metadata to be replaced with canonical form'
);
}

run().catch(error => {
console.error(error);
process.exitCode = 1;
});
14 changes: 14 additions & 0 deletions eslint-local-rules/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const lintMarkdownCodeBlocks = require('./rules/lint-markdown-code-blocks');

module.exports = {
rules: {
'lint-markdown-code-blocks': lintMarkdownCodeBlocks,
},
};
12 changes: 12 additions & 0 deletions eslint-local-rules/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "eslint-plugin-local-rules",
"version": "0.0.0",
"main": "index.js",
"private": "true",
"scripts": {
"test": "node __tests__/lint-markdown-code-blocks.test.js"
},
"devDependencies": {
"eslint-mdx": "^2"
}
}
8 changes: 8 additions & 0 deletions eslint-local-rules/parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = require('eslint-mdx');
77 changes: 77 additions & 0 deletions eslint-local-rules/rules/diagnostics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

function getRelativeLine(loc) {
return loc?.start?.line ?? loc?.line ?? 1;
}

function getRelativeColumn(loc) {
return loc?.start?.column ?? loc?.column ?? 0;
}

function getRelativeEndLine(loc, fallbackLine) {
if (loc?.end?.line != null) {
return loc.end.line;
}
if (loc?.line != null) {
return loc.line;
}
return fallbackLine;
}

function getRelativeEndColumn(loc, fallbackColumn) {
if (loc?.end?.column != null) {
return loc.end.column;
}
if (loc?.column != null) {
return loc.column;
}
return fallbackColumn;
}

/**
* @param {import('./markdown').MarkdownCodeBlock} block
* @param {Array<{detail: any, loc: any, message: string}>} diagnostics
* @returns {Array<{detail: any, message: string, relativeStartLine: number, markdownLoc: {start: {line: number, column: number}, end: {line: number, column: number}}}>}
*/
function normalizeDiagnostics(block, diagnostics) {
return diagnostics.map(({detail, loc, message}) => {
const relativeStartLine = Math.max(getRelativeLine(loc), 1);
const relativeStartColumn = Math.max(getRelativeColumn(loc), 0);
const relativeEndLine = Math.max(
getRelativeEndLine(loc, relativeStartLine),
relativeStartLine
);
const relativeEndColumn = Math.max(
getRelativeEndColumn(loc, relativeStartColumn),
relativeStartColumn
);

const markdownStartLine = block.codeStartLine + relativeStartLine - 1;
const markdownEndLine = block.codeStartLine + relativeEndLine - 1;

return {
detail,
message,
relativeStartLine,
markdownLoc: {
start: {
line: markdownStartLine,
column: relativeStartColumn,
},
end: {
line: markdownEndLine,
column: relativeEndColumn,
},
},
};
});
}

module.exports = {
normalizeDiagnostics,
};
Loading
Loading