Skip to content

Commit efc1b8e

Browse files
authored
chore: allow ../assets/example.glb in issue reproducers (#4437)
Add a small cube model to the example assets and allow it in the issue code example lint, so 3D-model bugs can be reproduced with require(). Also make the import allowlist actually re-include the sanctioned assets, allow require() in TypeScript examples, and let LINT_FILE runs skip the GitHub label lookup.
1 parent 341b13c commit efc1b8e

5 files changed

Lines changed: 56 additions & 46 deletions

File tree

‎.github/ISSUE_TEMPLATE/bug_report.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ body:
6363
description: |-
6464
- Use [our BugReportTemplate](https://github.com/rnmapbox/maps/blob/main/example/src/examples/BugReportExample.js) screens as a starting point.
6565
- Component should be self contained - no extra libraries, external data, no parameters
66+
- The only local files allowed are `require('../assets/example.png')` for an image and `require('../assets/example.glb')` for a 3D model
6667
- Do not include setAccessToken or access token istelf.
6768
value: |-
6869
```javascript

‎.github/REPRODUCING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A working reproducer is worth 100x more than a speculative fix. Without one, mai
1616

1717
Keep all provocation and instrumentation **out of the final PR** — capture its output as evidence instead.
1818

19-
3. **Package the reproducer so others can run it.** Base it on [`example/src/examples/BugReportExample.js`](../example/src/examples/BugReportExample.js), self-contained (no extra libraries, external data, or parameters). For intermittent bugs, make it toggleable — a Start/Stop button and live counters — so it can run unattended until the bug fires. Include it in the issue or PR description in a collapsed `<details>` block; it does not need to be committed to the repo.
19+
3. **Package the reproducer so others can run it.** Base it on [`example/src/examples/BugReportExample.js`](../example/src/examples/BugReportExample.js), self-contained (no extra libraries, external data, or parameters; the only local files it may use are `../assets/example.png` for an image and `../assets/example.glb` for a 3D model). For intermittent bugs, make it toggleable — a Start/Stop button and live counters — so it can run unattended until the bug fires. Include it in the issue or PR description in a collapsed `<details>` block; it does not need to be committed to the repo.
2020

2121
4. **Verify the fix against the reproducer.** The reproducer should fail on the unfixed build and pass on the fixed one. Include before/after evidence in the PR: crash stacks, iteration counts, timings.
2222

‎example/src/assets/example.glb‎

2.7 KB
Binary file not shown.

‎scripts/actions/lint-code-example-in-issues/README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
## Debugging
22

3+
The lint rejects local files in the code example, except `../assets/example.png` and `../assets/example.glb` (both in `example/src/assets`).
4+
35

46

57
```sh
68
npm install
7-
node ./fetch-issue.js
9+
node ./fetch-issue-for-testing.js 2871
810
GITHUB_EVENT_PATH=./test-issue.json node lint-code-example-in-issues.js
911
```
1012

‎scripts/actions/lint-code-example-in-issues/lint-code-example-in-issues.js‎

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,49 @@ const core = require('@actions/core');
66
const github = require('@actions/github');
77
const { ESLint } = require('eslint');
88

9+
const localFilesMessage =
10+
'Repo example should complete - it should not use files from your project, use ../assets/example.png if you need an example image or ../assets/example.glb if you need an example 3D model';
11+
12+
const localFilesRules = {
13+
'no-restricted-imports': [
14+
'error',
15+
{
16+
patterns: [
17+
{
18+
group: [
19+
'./*',
20+
'../*',
21+
// gitignore semantics: a file can't be re-included while its parent dir is excluded
22+
'!../assets',
23+
'../assets/*',
24+
'!../assets/example.png',
25+
'!../assets/example.glb',
26+
],
27+
message: localFilesMessage,
28+
},
29+
{
30+
group: ['!react', '!react-native', '!@rnmapbox/maps'],
31+
message: 'Should not use third-party libraries',
32+
},
33+
],
34+
},
35+
],
36+
'node/no-restricted-require': [
37+
'error',
38+
[
39+
{
40+
name: [
41+
'./**',
42+
'../**',
43+
'!../assets/example.png',
44+
'!../assets/example.glb',
45+
],
46+
message: localFilesMessage,
47+
},
48+
],
49+
],
50+
};
51+
952
const Config = {
1053
/// the login of the but used to make the comment
1154
botLogin: 'github-actions[bot]',
@@ -53,32 +96,7 @@ const Config = {
5396
rules: {
5497
'import/prefer-default-export': ['error'],
5598
'no-undef': 'error',
56-
'no-restricted-imports': [
57-
'error',
58-
{
59-
patterns: [
60-
{
61-
group: ['./*', '../*', '!../assets/example.png'],
62-
message:
63-
'Repo example should complete - it should not use files from your project',
64-
},
65-
{
66-
group: ['!react', '!react-native', '!@rnmapbox/maps'],
67-
message: 'Should not use third-party libraries',
68-
},
69-
],
70-
},
71-
],
72-
'node/no-restricted-require': [
73-
'error',
74-
[
75-
{
76-
name: ['./**', '../**', '!../assets/example.png'],
77-
message:
78-
'Repo example should complete - it should not use files from your project, use ../assets/example.png if you need an example image',
79-
},
80-
],
81-
],
99+
...localFilesRules,
82100
},
83101
},
84102
/// the eslint config used for typescript
@@ -88,6 +106,7 @@ const Config = {
88106
env: {
89107
browser: true,
90108
es2021: true,
109+
node: true,
91110
},
92111
extends: 'plugin:react/recommended',
93112
overrides: [],
@@ -100,26 +119,11 @@ const Config = {
100119
version: '17.0.2',
101120
},
102121
},
103-
plugins: ['react', 'eslint-plugin-import'],
122+
plugins: ['react', 'eslint-plugin-import', 'eslint-plugin-node'],
104123
rules: {
105124
'import/prefer-default-export': ['error'],
106125
'no-undef': 'error',
107-
'no-restricted-imports': [
108-
'error',
109-
{
110-
patterns: [
111-
{
112-
group: ['./*', '../*', '!../assets/example.png'],
113-
message:
114-
'Repo example should complete - it should not use files from your project',
115-
},
116-
{
117-
group: ['!react', '!react-native', '!@rnmapbox/maps'],
118-
message: 'Should not use third-party libraries',
119-
},
120-
],
121-
},
122-
],
126+
...localFilesRules,
123127
},
124128
},
125129
};
@@ -148,7 +152,10 @@ async function ignoreIssue(issueNumber, ignoreLabels) {
148152
async function run() {
149153
try {
150154
const issueNumber = getIssueNumber();
151-
if (await ignoreIssue(issueNumber, Config.ignoreLabels)) {
155+
if (
156+
!process.env.LINT_FILE &&
157+
(await ignoreIssue(issueNumber, Config.ignoreLabels))
158+
) {
152159
return;
153160
}
154161
const [code, { isTypescript = false }] = getCode();

0 commit comments

Comments
 (0)