react-compiler-healthcheck
Advanced tools
Comparing version 0.0.0-experimental-7054a14-20240601 to 0.0.0-experimental-714736e-20250203
{ | ||
"name": "react-compiler-healthcheck", | ||
"version": "0.0.0-experimental-7054a14-20240601", | ||
"version": "0.0.0-experimental-714736e-20250203", | ||
"description": "Health check script to test violations of the rules of react.", | ||
@@ -9,4 +9,5 @@ "bin": { | ||
"scripts": { | ||
"build": "rimraf dist && rollup --config --bundleConfigAsCjs", | ||
"test": "echo 'no tests'" | ||
"build": "rimraf dist && scripts/build.js", | ||
"test": "echo 'no tests'", | ||
"watch": "scripts/build.js --watch" | ||
}, | ||
@@ -27,3 +28,8 @@ "dependencies": { | ||
}, | ||
"license": "MIT" | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/facebook/react.git", | ||
"directory": "compiler/packages/react-compiler-healthcheck" | ||
} | ||
} |
@@ -8,4 +8,4 @@ /** | ||
import chalk from "chalk"; | ||
import { config } from "../config"; | ||
import chalk from 'chalk'; | ||
import {config} from '../config'; | ||
@@ -12,0 +12,0 @@ const packageJsonRE = /package\.json$/; |
@@ -8,5 +8,5 @@ /** | ||
import type * as BabelCore from "@babel/core"; | ||
import { transformFromAstSync } from "@babel/core"; | ||
import * as BabelParser from "@babel/parser"; | ||
import type * as BabelCore from '@babel/core'; | ||
import {transformFromAstSync} from '@babel/core'; | ||
import * as BabelParser from '@babel/parser'; | ||
import BabelPluginReactCompiler, { | ||
@@ -16,7 +16,7 @@ ErrorSeverity, | ||
type PluginOptions, | ||
} from "babel-plugin-react-compiler/src"; | ||
import { LoggerEvent as RawLoggerEvent } from "babel-plugin-react-compiler/src/Entrypoint"; | ||
import chalk from "chalk"; | ||
} from 'babel-plugin-react-compiler/src'; | ||
import {LoggerEvent as RawLoggerEvent} from 'babel-plugin-react-compiler/src/Entrypoint'; | ||
import chalk from 'chalk'; | ||
type LoggerEvent = RawLoggerEvent & { filename: string | null }; | ||
type LoggerEvent = RawLoggerEvent & {filename: string | null}; | ||
@@ -29,9 +29,9 @@ const SucessfulCompilation: Array<LoggerEvent> = []; | ||
logEvent(filename: string | null, rawEvent: RawLoggerEvent) { | ||
const event = { ...rawEvent, filename }; | ||
const event = {...rawEvent, filename}; | ||
switch (event.kind) { | ||
case "CompileSuccess": { | ||
case 'CompileSuccess': { | ||
SucessfulCompilation.push(event); | ||
return; | ||
} | ||
case "CompileError": { | ||
case 'CompileError': { | ||
if (isActionableDiagnostic(event.detail)) { | ||
@@ -44,4 +44,4 @@ ActionableFailures.push(event); | ||
} | ||
case "CompileDiagnostic": | ||
case "PipelineError": | ||
case 'CompileDiagnostic': | ||
case 'PipelineError': | ||
OtherFailures.push(event); | ||
@@ -55,4 +55,4 @@ return; | ||
noEmit: true, | ||
compilationMode: "infer", | ||
panicThreshold: "critical_errors", | ||
compilationMode: 'infer', | ||
panicThreshold: 'critical_errors', | ||
logger, | ||
@@ -79,9 +79,9 @@ }; | ||
file: string, | ||
language: "flow" | "typescript", | ||
options: Partial<PluginOptions> | null | ||
language: 'flow' | 'typescript', | ||
options: Partial<PluginOptions> | null, | ||
): BabelCore.BabelFileResult { | ||
const ast = BabelParser.parse(text, { | ||
sourceFilename: file, | ||
plugins: [language, "jsx"], | ||
sourceType: "module", | ||
plugins: [language, 'jsx'], | ||
sourceType: 'module', | ||
}); | ||
@@ -93,3 +93,3 @@ const result = transformFromAstSync(ast, text, { | ||
plugins: [[BabelPluginReactCompiler, options]], | ||
sourceType: "module", | ||
sourceType: 'module', | ||
configFile: false, | ||
@@ -100,3 +100,3 @@ babelrc: false, | ||
throw new Error( | ||
`Expected BabelPluginReactForget to codegen successfully, got: ${result}` | ||
`Expected BabelPluginReactForget to codegen successfully, got: ${result}`, | ||
); | ||
@@ -112,4 +112,4 @@ } | ||
filename, | ||
"typescript", | ||
COMPILER_OPTIONS | ||
'typescript', | ||
COMPILER_OPTIONS, | ||
); | ||
@@ -158,6 +158,6 @@ } catch {} | ||
chalk.green( | ||
`Successfully compiled ${SucessfulCompilation.length} out of ${totalComponents} components.` | ||
) | ||
`Successfully compiled ${SucessfulCompilation.length} out of ${totalComponents} components.`, | ||
), | ||
); | ||
}, | ||
}; |
@@ -8,3 +8,3 @@ /** | ||
import chalk from "chalk"; | ||
import chalk from 'chalk'; | ||
@@ -32,7 +32,7 @@ const JsFileExtensionRE = /(js|ts|jsx|tsx)$/; | ||
if (StrictModeUsage) { | ||
console.log(chalk.green("StrictMode usage found.")); | ||
console.log(chalk.green('StrictMode usage found.')); | ||
} else { | ||
console.log(chalk.red("StrictMode usage not found.")); | ||
console.log(chalk.red('StrictMode usage not found.')); | ||
} | ||
}, | ||
}; |
export const config = { | ||
knownIncompatibleLibraries: ["mobx", "@risingstack/react-easy-state"], | ||
knownIncompatibleLibraries: ['mobx', '@risingstack/react-easy-state'], | ||
}; |
@@ -8,22 +8,22 @@ /** | ||
import { glob } from "fast-glob"; | ||
import * as fs from "fs/promises"; | ||
import ora from "ora"; | ||
import yargs from "yargs/yargs"; | ||
import libraryCompatCheck from "./checks/libraryCompat"; | ||
import reactCompilerCheck from "./checks/reactCompiler"; | ||
import strictModeCheck from "./checks/strictMode"; | ||
import {glob} from 'fast-glob'; | ||
import * as fs from 'fs/promises'; | ||
import ora from 'ora'; | ||
import yargs from 'yargs/yargs'; | ||
import libraryCompatCheck from './checks/libraryCompat'; | ||
import reactCompilerCheck from './checks/reactCompiler'; | ||
import strictModeCheck from './checks/strictMode'; | ||
async function main() { | ||
const argv = yargs(process.argv.slice(2)) | ||
.scriptName("healthcheck") | ||
.usage("$ npx healthcheck <src>") | ||
.option("src", { | ||
description: "glob expression matching src files to compile", | ||
type: "string", | ||
default: "**/+(*.{js,mjs,jsx,ts,tsx}|package.json)", | ||
.scriptName('healthcheck') | ||
.usage('$ npx healthcheck <src>') | ||
.option('src', { | ||
description: 'glob expression matching src files to compile', | ||
type: 'string', | ||
default: '**/+(*.{js,mjs,jsx,ts,tsx}|package.json)', | ||
}) | ||
.parseSync(); | ||
const spinner = ora("Checking").start(); | ||
const spinner = ora('Checking').start(); | ||
let src = argv.src; | ||
@@ -34,8 +34,8 @@ | ||
ignore: [ | ||
"**/node_modules/**", | ||
"**/dist/**", | ||
"**/tests/**", | ||
"**/__tests__/**", | ||
"**/__mocks__/**", | ||
"**/__e2e__/**", | ||
'**/node_modules/**', | ||
'**/dist/**', | ||
'**/tests/**', | ||
'**/__tests__/**', | ||
'**/__mocks__/**', | ||
'**/__e2e__/**', | ||
], | ||
@@ -45,3 +45,3 @@ }; | ||
for (const path of await glob(src, globOptions)) { | ||
const source = await fs.readFile(path, "utf-8"); | ||
const source = await fs.readFile(path, 'utf-8'); | ||
spinner.text = `Checking ${path}`; | ||
@@ -48,0 +48,0 @@ reactCompilerCheck.run(source, path); |
Sorry, the diff of this file is too big to display
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
5071604
10
0
53324