Skip to content

Commit 3cf0802

Browse files
committed
fixes
1 parent 44d89cd commit 3cf0802

16 files changed

Lines changed: 215 additions & 45 deletions

File tree

File renamed without changes.
File renamed without changes.
File renamed without changes.

packages/lint-examples/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"private": true,
55
"type": "module",
66
"bin": {
7-
"eslint-examples-jsx": "./bin/eslint-examples-jsx.js",
8-
"eslint-examples-tsx": "./bin/eslint-examples-tsx.js",
9-
"tsc-examples": "./bin/tsc-examples.js"
7+
"eslint-examples-jsx": "./bin/eslint-examples-jsx.ts",
8+
"eslint-examples-tsx": "./bin/eslint-examples-tsx.ts",
9+
"tsc-examples": "./bin/tsc-examples.ts"
1010
},
1111
"scripts": {
1212
"lint": "eslint"

packages/lint-examples/src/lintExamples.js renamed to packages/lint-examples/src/lintExamples.ts

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,17 @@ const validExtensions = ['js', 'tsx'];
4343
* @param opts.extension extension to treat the example as if it does not specify one
4444
* @param opts.writeBack whether to update examples with mutations made by the linter
4545
*/
46-
async function lintExamples({command, args, extension, writeBack}) {
46+
async function lintExamples({
47+
command,
48+
args,
49+
extension,
50+
writeBack,
51+
}: {
52+
command: string;
53+
args?: string[];
54+
extension: string;
55+
writeBack: boolean;
56+
}) {
4757
if (!validExtensions.includes(extension)) {
4858
console.error(
4959
`Invalid extension "${extension}" (should be one of ${JSON.stringify(
@@ -73,12 +83,17 @@ async function lintExamples({command, args, extension, writeBack}) {
7383
*
7484
* @param extension extension to treat the example as if it does not specify
7585
*/
76-
async function extractExamples(extension) {
86+
async function extractExamples(extension: string) {
7787
const documents = await glob.glob('**/*.md', {
7888
cwd: documentsRoot,
7989
absolute: true,
8090
});
81-
const mappings = [];
91+
const mappings: {
92+
documentPath: string;
93+
examplePath: string;
94+
offset: number;
95+
length: number;
96+
}[] = [];
8297

8398
await fs.mkdir(outputRoot, {recursive: true});
8499
await fs.rm(outputRoot, {recursive: true});
@@ -99,7 +114,10 @@ async function extractExamples(extension) {
99114
* @param filename absolute filename of the documents root
100115
* @param extension extension to treat the example as if it does not specify
101116
*/
102-
async function extractExamplesFromDocument(filename, extension) {
117+
async function extractExamplesFromDocument(
118+
filename: string,
119+
extension: string,
120+
) {
103121
const fileContents = await fs.readFile(filename, {
104122
encoding: 'utf-8',
105123
});
@@ -167,7 +185,7 @@ async function extractExamplesFromDocument(filename, extension) {
167185
* @param command an npx command to run as the linter tool
168186
* @param args extra arguments to be passed to the linter
169187
*/
170-
async function runLinter(command, args) {
188+
async function runLinter(command: string, args: string[]) {
171189
const combinedArgs = [...processArgs, ...args];
172190

173191
try {
@@ -178,6 +196,7 @@ async function runLinter(command, args) {
178196

179197
return 0;
180198
} catch (ex) {
199+
// @ts-expect-error
181200
return ex.status;
182201
}
183202
}
@@ -187,8 +206,23 @@ async function runLinter(command, args) {
187206
*
188207
* @param mappings file mappings generated by extractExamples()
189208
*/
190-
async function updateDocuments(mappings) {
191-
const mappingsByDocument = {};
209+
async function updateDocuments(
210+
mappings: {
211+
documentPath: string;
212+
examplePath: string;
213+
offset: number;
214+
length: number;
215+
}[],
216+
) {
217+
const mappingsByDocument: Record<
218+
string,
219+
{
220+
documentPath: string;
221+
examplePath: string;
222+
offset: number;
223+
length: number;
224+
}[]
225+
> = {};
192226
for (const mapping of mappings) {
193227
if (mappingsByDocument[mapping.documentPath] === undefined) {
194228
mappingsByDocument[mapping.documentPath] = [];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "@react-native/typescript-config/tsconfig.json",
3-
"include": ["./out"]
3+
"include": ["./src", "./bin"],
44
}

plugins/remark-codeblock-language-as-title/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
},
2222
"devDependencies": {
2323
"@types/mdast": "^4.0.4",
24-
"remark": "^15.0.1"
24+
"remark": "^15.0.1",
25+
"typescript": "^5.9.2"
2526
}
2627
}

plugins/remark-codeblock-language-as-title/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import { Root } from 'mdast';
8+
import {Root} from 'mdast';
99

1010
export default function codeblockLanguageAsTitleRemarkPlugin() {
1111
return async (root: Root) => {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "@react-native/typescript-config/tsconfig.json",
3+
"include": ["./src"],
4+
}

plugins/remark-lint-no-dead-urls/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
"test": "yarn node --experimental-vm-modules $(yarn bin jest)"
1919
},
2020
"dependencies": {
21-
"got": "^13.0.0",
21+
"got": "^14.6.3",
2222
"unified-lint-rule": "^3.0.0",
2323
"unist-util-visit": "^5.0.0"
2424
},
2525
"devDependencies": {
2626
"dedent": "^1.5.3",
2727
"jest": "^29.4.3",
28-
"remark": "^15.0.1"
28+
"remark": "^15.0.1",
29+
"typescript": "^5.9.2"
2930
}
3031
}

0 commit comments

Comments
 (0)