Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix typos #15432

Merged
merged 10 commits into from
Feb 18, 2023
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ For example, in [`@babel/plugin-transform-exponentiation-operator/test`](https:/

- In each subfolder, you can organize your directory structure by categories of tests. (Example: these folders can be named after the feature you are testing or can reference the issue number they fix)
- Generally, there are two kinds of tests for plugins
  - The first is a simple test of the input and output produced by running Babel on some code. We do this by creating an [`input.js`](https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/input.js) file and an [`output.js`](https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/output.js) file. This kind of test only works in sub-subdirectories of `/fixtures`, i.e. `/fixtures/exponentian-operator/binary/input.js` and **not** `/fixtures/exponentian-operator/input.js`.
  - The first is a simple test of the input and output produced by running Babel on some code. We do this by creating an [`input.js`](https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/input.js) file and an [`output.js`](https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/output.js) file. This kind of test only works in sub-subdirectories of `/fixtures`, i.e. `/fixtures/exponentiation-operator/binary/input.js` and **not** `/fixtures/exponentiation-operator/input.js`.
- If you need to expect an error, you can ignore creating the `output.js` file and pass a new `throws` key to the `options.json` that contains the error string that is created.
- The second and preferred type is a test that actually evaluates the produced code and asserts that certain properties are true or false. We do this by creating an [`exec.js`](https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/comprehensive/exec.js) file.

Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ function pluginImportMetaUrl({ types: t, template }) {
return {
visitor: {
Program(programPath) {
// We must be sure to run this before the instanbul plugins, because its
// We must be sure to run this before the istanbul plugins, because its
// instrumentation breaks our detection.
programPath.traverse({
// fileURLToPath(import.meta.url)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { func1 } from "./iodex.js";
import { func1 } from "./index.js";

export function five() {
return { five: `number(${5})` };
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module.exports = {
"/test/__data__/",
"<rootDir>/build/",
],
// We don't need module name mappers here as depedencies of workspace
// We don't need module name mappers here as dependencies of workspace
// package should be declared explicitly in the package.json
// Yarn will generate correct file links so that Jest can resolve correctly
moduleNameMapper: null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"args": ["--whitelist", "nenexistent", "--output-type", "var"]
"args": ["--whitelist", "nonexistent", "--output-type", "var"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ for (const feature of finishedProposals) {
const standardizedName = feature.replace("esnext.", "es.");
if (!builtInDefinitions.includes(standardizedName)) {
console.log(
`${feature} is now standarized as ${standardizedName}, please add "${standardizedName}" to "${builtInDefinitionsPath}"`
`${feature} is now standardized as ${standardizedName}, please add "${standardizedName}" to "${builtInDefinitionsPath}"`
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const importMetaResolveP: Promise<ImportMeta["resolve"]> =
// - we will move to ESM, so that we have direct access to import.meta.resolve, or
// - the V8 bug will be fixed so that we can safely use dynamic import by default.
//
// I (@nicolo-ribaudo) am really anoyed by this bug, because there is no known
// I (@nicolo-ribaudo) am really annoyed by this bug, because there is no known
// work-around other than "don't use dynamic import if you are running in a `vm` context",
// but there is no reliable way to detect it (you cannot try/catch segfaults).
//
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/src/config/validation/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function validatePluginObject(obj: {
const invalidPluginPropertyError = new Error(
`.${key} is not a valid Plugin property`,
);
// @ts-expect-error todo(flow->ts) consider additing BabelConfigError with code field
// @ts-expect-error todo(flow->ts) consider adding BabelConfigError with code field
invalidPluginPropertyError.code = "BABEL_UNKNOWN_PLUGIN_PROPERTY";
throw invalidPluginPropertyError;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-core/src/errors/config-error.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { injcectVirtualStackFrame, expectedError } from "./rewrite-stack-trace";
import { injectVirtualStackFrame, expectedError } from "./rewrite-stack-trace";

export default class ConfigError extends Error {
constructor(message: string, filename?: string) {
super(message);
expectedError(this);
if (filename) injcectVirtualStackFrame(this, filename);
if (filename) injectVirtualStackFrame(this, filename);
}
}
22 changes: 11 additions & 11 deletions packages/babel-core/src/errors/rewrite-stack-trace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file uses the iternal V8 Stack Trace API (https://v8.dev/docs/stack-trace-api)
* This file uses the internal V8 Stack Trace API (https://v8.dev/docs/stack-trace-api)
* to provide utilities to rewrite the stack trace.
* When this API is not present, all the functions in this file become noops.
*
Expand Down Expand Up @@ -33,10 +33,10 @@
* - If e() throws an error, then its shown call stack will be "e, f"
*
* Additionally, an error can inject additional "virtual" stack frames using the
* injcectVirtualStackFrame(error, filename) function: those are injected as a
* injectVirtualStackFrame(error, filename) function: those are injected as a
* replacement of the hidden frames.
* In the example above, if we called injcectVirtualStackFrame(err, "h") and
* injcectVirtualStackFrame(err, "i") on the expected error thrown by c(), its
* In the example above, if we called injectVirtualStackFrame(err, "h") and
* injectVirtualStackFrame(err, "i") on the expected error thrown by c(), its
* shown call stack would have been "h, i, e, f".
* This can be useful, for example, to report config validation errors as if they
* were directly thrown in the config file.
Expand All @@ -46,8 +46,8 @@ const ErrorToString = Function.call.bind(Error.prototype.toString);

const SUPPORTED = !!Error.captureStackTrace;

const START_HIDNG = "startHiding - secret - don't use this - v1";
const STOP_HIDNG = "stopHiding - secret - don't use this - v1";
const START_HIDING = "startHiding - secret - don't use this - v1";
const STOP_HIDING = "stopHiding - secret - don't use this - v1";

type CallSite = Parameters<typeof Error.prepareStackTrace>[1][number];

Expand All @@ -70,7 +70,7 @@ function CallSite(filename: string): CallSite {
} as CallSite);
}

export function injcectVirtualStackFrame(error: Error, filename: string) {
export function injectVirtualStackFrame(error: Error, filename: string) {
if (!SUPPORTED) return;

let frames = virtualFrames.get(error);
Expand All @@ -97,7 +97,7 @@ export function beginHiddenCallStack<A extends unknown[], R>(
return fn(...args);
},
"name",
{ value: STOP_HIDNG },
{ value: STOP_HIDING },
);
}

Expand All @@ -111,7 +111,7 @@ export function endHiddenCallStack<A extends unknown[], R>(
return fn(...args);
},
"name",
{ value: START_HIDNG },
{ value: START_HIDING },
);
}

Expand Down Expand Up @@ -144,9 +144,9 @@ function setupPrepareStackTrace() {
: "unknown";
for (let i = 0; i < trace.length; i++) {
const name = trace[i].getFunctionName();
if (name === START_HIDNG) {
if (name === START_HIDING) {
status = "hiding";
} else if (name === STOP_HIDNG) {
} else if (name === STOP_HIDING) {
if (status === "hiding") {
status = "showing";
if (virtualFrames.has(err)) {
Expand Down