Update to Prettier 2.3 (#13288)
This commit is contained in:
parent
5ae3a6c2a4
commit
b2d9156cc6
@ -1,10 +1,10 @@
|
|||||||
import { tokTypes } from "@babel/core";
|
import { tokTypes } from "@babel/core";
|
||||||
|
|
||||||
const tl = (process.env.BABEL_8_BREAKING
|
const tl = (
|
||||||
|
process.env.BABEL_8_BREAKING
|
||||||
? Object.fromEntries
|
? Object.fromEntries
|
||||||
: p => p.reduce((o, [k, v]) => ({ ...o, [k]: v }), {}))(
|
: p => p.reduce((o, [k, v]) => ({ ...o, [k]: v }), {})
|
||||||
Object.keys(tokTypes).map(key => [key, tokTypes[key].label]),
|
)(Object.keys(tokTypes).map(key => [key, tokTypes[key].label]));
|
||||||
);
|
|
||||||
|
|
||||||
function convertTemplateType(tokens) {
|
function convertTemplateType(tokens) {
|
||||||
let curlyBrace = null;
|
let curlyBrace = null;
|
||||||
|
|||||||
@ -67,182 +67,152 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import { Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import { Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import { Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { NotErrors, Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import { NotErrors, Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { NotErrors, Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import { NotErrors, Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { NotErrors, Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import { NotErrors, Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import { Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import { Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import { Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { NotErrors, Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import { NotErrors, Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { NotErrors, Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import { NotErrors, Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { NotErrors, Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import { NotErrors, Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import Errors from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors from './errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import Errors from './errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import Errors from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import Errors, { NotErrors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import Errors, { NotErrors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import NotErrors, { Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import NotErrors, { Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import NotErrors, { Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import NotErrors, { Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import NotErrors, { Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import NotErrors, { Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import Errors from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import Errors from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import Errors from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import Errors, { NotErrors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import Errors, { NotErrors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import Errors, { NotErrors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import NotErrors, { Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import NotErrors, { Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import NotErrors, { Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import NotErrors, { Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import NotErrors, { Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import NotErrors, { Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -268,8 +238,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
// Support ternary as second argument
|
// Support ternary as second argument
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? Errors.someErrorMessage : Errors.someOtherErrorMessage);",
|
||||||
"import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? Errors.someErrorMessage : Errors.someOtherErrorMessage);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -309,8 +278,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "const Errors = { someErrorMessage: 'Uh oh!' }; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"const Errors = { someErrorMessage: 'Uh oh!' }; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -332,8 +300,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { Errors } from 'errorsModule'; const msg = 'Uh oh!'; this.raise(loc, msg);",
|
||||||
"import { Errors } from 'errorsModule'; const msg = 'Uh oh!'; this.raise(loc, msg);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -344,8 +311,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import { Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -356,8 +322,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import { Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -368,8 +333,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import { Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -380,8 +344,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { NotErrors, Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import { NotErrors, Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -392,8 +355,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { NotErrors, Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import { NotErrors, Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -404,8 +366,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { NotErrors, Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import { NotErrors, Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -416,8 +377,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import { Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -428,8 +388,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import { Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -440,8 +399,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import { Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -452,8 +410,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { NotErrors, Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import { NotErrors, Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -464,8 +421,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { NotErrors, Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import { NotErrors, Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -476,8 +432,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import { NotErrors, Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import { NotErrors, Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -488,8 +443,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import Errors from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -500,8 +454,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import Errors from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -512,8 +465,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import Errors from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -524,8 +476,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import Errors, { NotErrors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -536,8 +487,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import Errors, { NotErrors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -548,8 +498,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import Errors, { NotErrors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -560,8 +509,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import NotErrors, { Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import NotErrors, { Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -572,8 +520,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import NotErrors, { Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import NotErrors, { Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -584,8 +531,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import NotErrors, { Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
||||||
"import NotErrors, { Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -596,8 +542,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import Errors from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -608,8 +553,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import Errors from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -620,8 +564,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import Errors from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -632,8 +575,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import Errors, { NotErrors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -644,8 +586,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import Errors, { NotErrors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -656,8 +597,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import Errors, { NotErrors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -668,8 +608,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import NotErrors, { Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import NotErrors, { Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -680,8 +619,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import NotErrors, { Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import NotErrors, { Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_SAME_DIR }],
|
options: [{ errorModule: MODULE_SAME_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -692,8 +630,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import NotErrors, { Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
||||||
"import NotErrors, { Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }",
|
|
||||||
options: [{ errorModule: MODULE_PARENT_DIR }],
|
options: [{ errorModule: MODULE_PARENT_DIR }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -706,8 +643,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
// Should error if either part of a ternary isn't from error module
|
// Should error if either part of a ternary isn't from error module
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? Errors.someErrorMessage : 'hello');",
|
||||||
"import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? Errors.someErrorMessage : 'hello');",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -718,8 +654,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? 'hello' : Errors.someErrorMessage);",
|
||||||
"import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? 'hello' : Errors.someErrorMessage);",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@ -730,8 +665,7 @@ ruleTester.run("dry-error-messages", rule, {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: FILENAME,
|
filename: FILENAME,
|
||||||
code:
|
code: "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? 'hello' : 'world');",
|
||||||
"import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? 'hello' : 'world');",
|
|
||||||
options: [{ errorModule: ERRORS_MODULE }],
|
options: [{ errorModule: ERRORS_MODULE }],
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -63,7 +63,7 @@
|
|||||||
"lint-staged": "^9.2.0",
|
"lint-staged": "^9.2.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mergeiterator": "^1.2.5",
|
"mergeiterator": "^1.2.5",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "2.3.0",
|
||||||
"rollup": "^2.47.0",
|
"rollup": "^2.47.0",
|
||||||
"rollup-plugin-dts": "^2.0.0",
|
"rollup-plugin-dts": "^2.0.0",
|
||||||
"rollup-plugin-node-polyfills": "^0.2.1",
|
"rollup-plugin-node-polyfills": "^0.2.1",
|
||||||
|
|||||||
@ -208,7 +208,7 @@ function updateFunctionCache<
|
|||||||
ArgT,
|
ArgT,
|
||||||
ResultT,
|
ResultT,
|
||||||
SideChannel,
|
SideChannel,
|
||||||
Cache extends CacheMap<ArgT, ResultT, SideChannel>
|
Cache extends CacheMap<ArgT, ResultT, SideChannel>,
|
||||||
>(
|
>(
|
||||||
cache: Cache,
|
cache: Cache,
|
||||||
config: CacheConfigurator<SideChannel>,
|
config: CacheConfigurator<SideChannel>,
|
||||||
|
|||||||
@ -497,7 +497,7 @@ function buildOverrideEnvDescriptors(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeChainWalker<
|
function makeChainWalker<
|
||||||
ArgT extends { options: ValidatedOptions; dirname: string }
|
ArgT extends { options: ValidatedOptions; dirname: string },
|
||||||
>({
|
>({
|
||||||
root,
|
root,
|
||||||
env,
|
env,
|
||||||
@ -582,8 +582,12 @@ function makeChainWalker<
|
|||||||
// that we don't do extra work loading extended configs if a file is
|
// that we don't do extra work loading extended configs if a file is
|
||||||
// ignored.
|
// ignored.
|
||||||
if (
|
if (
|
||||||
flattenedConfigs.some(({ config: { options: { ignore, only } } }) =>
|
flattenedConfigs.some(
|
||||||
shouldIgnore(context, ignore, only, dirname),
|
({
|
||||||
|
config: {
|
||||||
|
options: { ignore, only },
|
||||||
|
},
|
||||||
|
}) => shouldIgnore(context, ignore, only, dirname),
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
@ -713,10 +717,8 @@ function normalizeOptions(opts: ValidatedOptions): ValidatedOptions {
|
|||||||
function dedupDescriptors(
|
function dedupDescriptors(
|
||||||
items: Array<UnloadedDescriptor>,
|
items: Array<UnloadedDescriptor>,
|
||||||
): Array<UnloadedDescriptor> {
|
): Array<UnloadedDescriptor> {
|
||||||
const map: Map<
|
const map: Map<Function, Map<string | void, { value: UnloadedDescriptor }>> =
|
||||||
Function,
|
new Map();
|
||||||
Map<string | void, { value: UnloadedDescriptor }>
|
|
||||||
> = new Map();
|
|
||||||
|
|
||||||
const descriptors = [];
|
const descriptors = [];
|
||||||
|
|
||||||
|
|||||||
@ -205,9 +205,7 @@ const readConfigJS = makeStrongCache(function* readConfigJS(
|
|||||||
// @ts-expect-error - if we want to make it possible to use async configs
|
// @ts-expect-error - if we want to make it possible to use async configs
|
||||||
yield* [];
|
yield* [];
|
||||||
|
|
||||||
options = ((options as any) as (api: ConfigAPI) => {})(
|
options = (options as any as (api: ConfigAPI) => {})(makeConfigAPI(cache));
|
||||||
makeConfigAPI(cache),
|
|
||||||
);
|
|
||||||
|
|
||||||
assertCache = true;
|
assertCache = true;
|
||||||
}
|
}
|
||||||
@ -256,8 +254,7 @@ const packageToBabelConfig = makeWeakCacheSync(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const readConfigJSON5 = makeStaticFileCache(
|
const readConfigJSON5 = makeStaticFileCache((filepath, content): ConfigFile => {
|
||||||
(filepath, content): ConfigFile => {
|
|
||||||
let options;
|
let options;
|
||||||
try {
|
try {
|
||||||
options = json5.parse(content);
|
options = json5.parse(content);
|
||||||
@ -280,8 +277,7 @@ const readConfigJSON5 = makeStaticFileCache(
|
|||||||
dirname: path.dirname(filepath),
|
dirname: path.dirname(filepath),
|
||||||
options,
|
options,
|
||||||
};
|
};
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
const readIgnoreConfig = makeStaticFileCache((filepath, content) => {
|
const readIgnoreConfig = makeStaticFileCache((filepath, content) => {
|
||||||
const ignoreDir = path.dirname(filepath);
|
const ignoreDir = path.dirname(filepath);
|
||||||
|
|||||||
@ -3,7 +3,7 @@ type indexType = typeof import("./index");
|
|||||||
|
|
||||||
// Kind of gross, but essentially asserting that the exports of this module are the same as the
|
// Kind of gross, but essentially asserting that the exports of this module are the same as the
|
||||||
// exports of index-browser, since this file may be replaced at bundle time with index-browser.
|
// exports of index-browser, since this file may be replaced at bundle time with index-browser.
|
||||||
((({} as any) as indexBrowserType) as indexType);
|
({} as any as indexBrowserType as indexType);
|
||||||
|
|
||||||
export { findPackageData } from "./package";
|
export { findPackageData } from "./package";
|
||||||
|
|
||||||
|
|||||||
@ -17,8 +17,10 @@ const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/;
|
|||||||
const BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-preset-)/;
|
const BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-preset-)/;
|
||||||
const BABEL_PLUGIN_ORG_RE = /^(@babel\/)(?!plugin-|[^/]+\/)/;
|
const BABEL_PLUGIN_ORG_RE = /^(@babel\/)(?!plugin-|[^/]+\/)/;
|
||||||
const BABEL_PRESET_ORG_RE = /^(@babel\/)(?!preset-|[^/]+\/)/;
|
const BABEL_PRESET_ORG_RE = /^(@babel\/)(?!preset-|[^/]+\/)/;
|
||||||
const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-plugin(?:-|\/|$)|[^/]+\/)/;
|
const OTHER_PLUGIN_ORG_RE =
|
||||||
const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-preset(?:-|\/|$)|[^/]+\/)/;
|
/^(@(?!babel\/)[^/]+\/)(?![^/]*babel-plugin(?:-|\/|$)|[^/]+\/)/;
|
||||||
|
const OTHER_PRESET_ORG_RE =
|
||||||
|
/^(@(?!babel\/)[^/]+\/)(?![^/]*babel-preset(?:-|\/|$)|[^/]+\/)/;
|
||||||
const OTHER_ORG_DEFAULT_RE = /^(@(?!babel$)[^/]+)$/;
|
const OTHER_ORG_DEFAULT_RE = /^(@(?!babel$)[^/]+)$/;
|
||||||
|
|
||||||
export function resolvePlugin(name: string, dirname: string): string | null {
|
export function resolvePlugin(name: string, dirname: string): string | null {
|
||||||
|
|||||||
@ -279,14 +279,10 @@ const makeDescriptorLoader = <Context, API>(
|
|||||||
return { value: item, options, dirname, alias };
|
return { value: item, options, dirname, alias };
|
||||||
});
|
});
|
||||||
|
|
||||||
const pluginDescriptorLoader = makeDescriptorLoader<
|
const pluginDescriptorLoader =
|
||||||
Context.SimplePlugin,
|
makeDescriptorLoader<Context.SimplePlugin, PluginAPI>(makePluginAPI);
|
||||||
PluginAPI
|
const presetDescriptorLoader =
|
||||||
>(makePluginAPI);
|
makeDescriptorLoader<Context.SimplePreset, PresetAPI>(makePresetAPI);
|
||||||
const presetDescriptorLoader = makeDescriptorLoader<
|
|
||||||
Context.SimplePreset,
|
|
||||||
PresetAPI
|
|
||||||
>(makePresetAPI);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate a plugin for the given descriptor, returning the plugin/options pair.
|
* Instantiate a plugin for the given descriptor, returning the plugin/options pair.
|
||||||
|
|||||||
@ -24,9 +24,10 @@ const loadOptionsRunner = gensync<(opts: unknown) => any>(function* (opts) {
|
|||||||
return config?.options ?? null;
|
return config?.options ?? null;
|
||||||
});
|
});
|
||||||
|
|
||||||
const createConfigItemRunner = gensync<
|
const createConfigItemRunner =
|
||||||
(...args: Parameters<typeof createConfigItemImpl>) => ConfigItem
|
gensync<(...args: Parameters<typeof createConfigItemImpl>) => ConfigItem>(
|
||||||
>(createConfigItemImpl);
|
createConfigItemImpl,
|
||||||
|
);
|
||||||
|
|
||||||
const maybeErrback = runner => (opts: unknown, callback?: Function) => {
|
const maybeErrback = runner => (opts: unknown, callback?: Function) => {
|
||||||
if (callback === undefined && typeof opts === "function") {
|
if (callback === undefined && typeof opts === "function") {
|
||||||
|
|||||||
@ -169,10 +169,8 @@ export const loadPartialConfig = gensync<
|
|||||||
({ showIgnoredFiles, ...opts } = opts);
|
({ showIgnoredFiles, ...opts } = opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result:
|
const result: PrivPartialConfig | undefined | null =
|
||||||
| PrivPartialConfig
|
yield* loadPrivatePartialConfig(opts);
|
||||||
| undefined
|
|
||||||
| null = yield* loadPrivatePartialConfig(opts);
|
|
||||||
if (!result) return null;
|
if (!result) return null;
|
||||||
|
|
||||||
const { options, babelrc, ignore, config, fileHandling, files } = result;
|
const { options, babelrc, ignore, config, fileHandling, files } = result;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ type nodeType = typeof import("./resolve-targets");
|
|||||||
|
|
||||||
// Kind of gross, but essentially asserting that the exports of this module are the same as the
|
// Kind of gross, but essentially asserting that the exports of this module are the same as the
|
||||||
// exports of index-browser, since this file may be replaced at bundle time with index-browser.
|
// exports of index-browser, since this file may be replaced at bundle time with index-browser.
|
||||||
((({} as any) as browserType) as nodeType);
|
({} as any as browserType as nodeType);
|
||||||
|
|
||||||
import type { ValidatedOptions } from "./validation/options";
|
import type { ValidatedOptions } from "./validation/options";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|||||||
@ -67,7 +67,7 @@ const withKind = gensync<(cb: (kind: "sync" | "async") => any) => any>({
|
|||||||
// )
|
// )
|
||||||
export function forwardAsync<
|
export function forwardAsync<
|
||||||
Action extends (...args: unknown[]) => any,
|
Action extends (...args: unknown[]) => any,
|
||||||
Return
|
Return,
|
||||||
>(
|
>(
|
||||||
action: (...args: Parameters<Action>) => Handler<ReturnType<Action>>,
|
action: (...args: Parameters<Action>) => Handler<ReturnType<Action>>,
|
||||||
cb: (
|
cb: (
|
||||||
|
|||||||
@ -12,7 +12,7 @@ type transformFileType = typeof import("./transform-file");
|
|||||||
// Kind of gross, but essentially asserting that the exports of this module are the same as the
|
// Kind of gross, but essentially asserting that the exports of this module are the same as the
|
||||||
// exports of transform-file-browser, since this file may be replaced at bundle time with
|
// exports of transform-file-browser, since this file may be replaced at bundle time with
|
||||||
// transform-file-browser.
|
// transform-file-browser.
|
||||||
((({} as any) as transformFileBrowserType) as transformFileType);
|
({} as any as transformFileBrowserType as transformFileType);
|
||||||
|
|
||||||
type TransformFile = {
|
type TransformFile = {
|
||||||
(filename: string, callback: FileResultCallback): void;
|
(filename: string, callback: FileResultCallback): void;
|
||||||
|
|||||||
@ -187,9 +187,8 @@ export default class File {
|
|||||||
// make sure that the helper exists
|
// make sure that the helper exists
|
||||||
helpers.ensure(name, File);
|
helpers.ensure(name, File);
|
||||||
|
|
||||||
const uid = (this.declarations[name] = this.scope.generateUidIdentifier(
|
const uid = (this.declarations[name] =
|
||||||
name,
|
this.scope.generateUidIdentifier(name));
|
||||||
));
|
|
||||||
|
|
||||||
const dependencies = {};
|
const dependencies = {};
|
||||||
for (const dep of helpers.getDependencies(name)) {
|
for (const dep of helpers.getDependencies(name)) {
|
||||||
|
|||||||
@ -76,7 +76,7 @@ export default function* normalizeFile(
|
|||||||
} else {
|
} else {
|
||||||
inputMap = convertSourceMap.fromJSON(
|
inputMap = convertSourceMap.fromJSON(
|
||||||
// todo:
|
// todo:
|
||||||
(inputMapContent as unknown) as string,
|
inputMapContent as unknown as string,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -99,8 +99,10 @@ export default function* normalizeFile(
|
|||||||
// but without // or /* at the beginning of the comment.
|
// but without // or /* at the beginning of the comment.
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
|
const INLINE_SOURCEMAP_REGEX =
|
||||||
const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=([^\s'"`]+)[ \t]*$/;
|
/^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
|
||||||
|
const EXTERNAL_SOURCEMAP_REGEX =
|
||||||
|
/^[@#][ \t]+sourceMappingURL=([^\s'"`]+)[ \t]*$/;
|
||||||
|
|
||||||
function extractCommentsFromList(regex, comments, lastComment) {
|
function extractCommentsFromList(regex, comments, lastComment) {
|
||||||
if (comments) {
|
if (comments) {
|
||||||
|
|||||||
@ -66,7 +66,8 @@ async function spawn(runner, filename, cwd = process.cwd()) {
|
|||||||
{ cwd, env: process.env },
|
{ cwd, env: process.env },
|
||||||
);
|
);
|
||||||
|
|
||||||
const EXPERIMENTAL_WARNING = /\(node:\d+\) ExperimentalWarning: The ESM module loader is experimental\./;
|
const EXPERIMENTAL_WARNING =
|
||||||
|
/\(node:\d+\) ExperimentalWarning: The ESM module loader is experimental\./;
|
||||||
|
|
||||||
if (stderr.replace(EXPERIMENTAL_WARNING, "").trim()) {
|
if (stderr.replace(EXPERIMENTAL_WARNING, "").trim()) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
@ -81,13 +81,8 @@ export default class Buffer {
|
|||||||
|
|
||||||
append(str: string): void {
|
append(str: string): void {
|
||||||
this._flush();
|
this._flush();
|
||||||
const {
|
const { line, column, filename, identifierName, force } =
|
||||||
line,
|
this._sourcePosition;
|
||||||
column,
|
|
||||||
filename,
|
|
||||||
identifierName,
|
|
||||||
force,
|
|
||||||
} = this._sourcePosition;
|
|
||||||
this._append(str, line, column, identifierName, filename, force);
|
this._append(str, line, column, identifierName, filename, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,13 +98,8 @@ export default class Buffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const { line, column, filename, identifierName, force } =
|
||||||
line,
|
this._sourcePosition;
|
||||||
column,
|
|
||||||
filename,
|
|
||||||
identifierName,
|
|
||||||
force,
|
|
||||||
} = this._sourcePosition;
|
|
||||||
this._queue.unshift([str, line, column, identifierName, filename, force]);
|
this._queue.unshift([str, line, column, identifierName, filename, force]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -200,16 +200,19 @@ export const nodes: {
|
|||||||
* Test if Property needs whitespace.
|
* Test if Property needs whitespace.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function (
|
nodes.ObjectProperty =
|
||||||
|
nodes.ObjectTypeProperty =
|
||||||
|
nodes.ObjectMethod =
|
||||||
|
function (
|
||||||
node: t.ObjectProperty | t.ObjectTypeProperty | t.ObjectMethod,
|
node: t.ObjectProperty | t.ObjectTypeProperty | t.ObjectMethod,
|
||||||
parent: any,
|
parent: any,
|
||||||
): WhitespaceObject | undefined | null {
|
): WhitespaceObject | undefined | null {
|
||||||
if (parent.properties[0] === node) {
|
if (parent.properties[0] === node) {
|
||||||
return {
|
return {
|
||||||
before: true,
|
before: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes.ObjectTypeCallProperty = function (
|
nodes.ObjectTypeCallProperty = function (
|
||||||
node: t.ObjectTypeCallProperty,
|
node: t.ObjectTypeCallProperty,
|
||||||
@ -287,14 +290,16 @@ export const list = {
|
|||||||
* Add whitespace tests for nodes and their aliases.
|
* Add whitespace tests for nodes and their aliases.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
([
|
(
|
||||||
|
[
|
||||||
["Function", true],
|
["Function", true],
|
||||||
["Class", true],
|
["Class", true],
|
||||||
["Loop", true],
|
["Loop", true],
|
||||||
["LabeledStatement", true],
|
["LabeledStatement", true],
|
||||||
["SwitchStatement", true],
|
["SwitchStatement", true],
|
||||||
["TryStatement", true],
|
["TryStatement", true],
|
||||||
] as Array<[string, any]>).forEach(function ([type, amounts]) {
|
] as Array<[string, any]>
|
||||||
|
).forEach(function ([type, amounts]) {
|
||||||
if (typeof amounts === "boolean") {
|
if (typeof amounts === "boolean") {
|
||||||
amounts = { after: amounts, before: amounts };
|
amounts = { after: amounts, before: amounts };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -210,12 +210,8 @@ export function createClassFeaturePlugin({
|
|||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
keysNodes = extractComputedKeys(ref, path, computedPaths, this.file);
|
keysNodes = extractComputedKeys(ref, path, computedPaths, this.file);
|
||||||
({
|
({ staticNodes, pureStaticNodes, instanceNodes, wrapClass } =
|
||||||
staticNodes,
|
buildFieldsInitNodes(
|
||||||
pureStaticNodes,
|
|
||||||
instanceNodes,
|
|
||||||
wrapClass,
|
|
||||||
} = buildFieldsInitNodes(
|
|
||||||
ref,
|
ref,
|
||||||
path.node.superClass,
|
path.node.superClass,
|
||||||
props,
|
props,
|
||||||
|
|||||||
@ -80,16 +80,20 @@ function wrap(state, method, id, scope) {
|
|||||||
build = buildGeneratorPropertyMethodAssignmentWrapper;
|
build = buildGeneratorPropertyMethodAssignmentWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
const template = (build({
|
const template = (
|
||||||
|
build({
|
||||||
FUNCTION: method,
|
FUNCTION: method,
|
||||||
FUNCTION_ID: id,
|
FUNCTION_ID: id,
|
||||||
FUNCTION_KEY: scope.generateUidIdentifier(id.name),
|
FUNCTION_KEY: scope.generateUidIdentifier(id.name),
|
||||||
}) as t.ExpressionStatement).expression as t.CallExpression;
|
}) as t.ExpressionStatement
|
||||||
|
).expression as t.CallExpression;
|
||||||
|
|
||||||
// shim in dummy params to retain function arity, if you try to read the
|
// shim in dummy params to retain function arity, if you try to read the
|
||||||
// source then you'll get the original since it's proxied so it's all good
|
// source then you'll get the original since it's proxied so it's all good
|
||||||
const params = (((template.callee as t.FunctionExpression).body
|
const params = (
|
||||||
.body[0] as any) as t.FunctionExpression).params;
|
(template.callee as t.FunctionExpression).body
|
||||||
|
.body[0] as any as t.FunctionExpression
|
||||||
|
).params;
|
||||||
|
|
||||||
for (let i = 0, len = getFunctionArity(method); i < len; i++) {
|
for (let i = 0, len = getFunctionArity(method); i < len; i++) {
|
||||||
params.push(scope.generateUidIdentifier("x"));
|
params.push(scope.generateUidIdentifier("x"));
|
||||||
|
|||||||
@ -279,7 +279,8 @@ function buildESModuleHeader(
|
|||||||
metadata: ModuleMetadata,
|
metadata: ModuleMetadata,
|
||||||
enumerableModuleMeta: boolean = false,
|
enumerableModuleMeta: boolean = false,
|
||||||
) {
|
) {
|
||||||
return (enumerableModuleMeta
|
return (
|
||||||
|
enumerableModuleMeta
|
||||||
? template.statement`
|
? template.statement`
|
||||||
EXPORTS.__esModule = true;
|
EXPORTS.__esModule = true;
|
||||||
`
|
`
|
||||||
@ -287,14 +288,16 @@ function buildESModuleHeader(
|
|||||||
Object.defineProperty(EXPORTS, "__esModule", {
|
Object.defineProperty(EXPORTS, "__esModule", {
|
||||||
value: true,
|
value: true,
|
||||||
});
|
});
|
||||||
`)({ EXPORTS: metadata.exportName });
|
`
|
||||||
|
)({ EXPORTS: metadata.exportName });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a re-export initialization loop for a specific imported namespace.
|
* Create a re-export initialization loop for a specific imported namespace.
|
||||||
*/
|
*/
|
||||||
function buildNamespaceReexport(metadata, namespace, constantReexports) {
|
function buildNamespaceReexport(metadata, namespace, constantReexports) {
|
||||||
return (constantReexports
|
return (
|
||||||
|
constantReexports
|
||||||
? template.statement`
|
? template.statement`
|
||||||
Object.keys(NAMESPACE).forEach(function(key) {
|
Object.keys(NAMESPACE).forEach(function(key) {
|
||||||
if (key === "default" || key === "__esModule") return;
|
if (key === "default" || key === "__esModule") return;
|
||||||
@ -323,7 +326,8 @@ function buildNamespaceReexport(metadata, namespace, constantReexports) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
`)({
|
`
|
||||||
|
)({
|
||||||
NAMESPACE: namespace,
|
NAMESPACE: namespace,
|
||||||
EXPORTS: metadata.exportName,
|
EXPORTS: metadata.exportName,
|
||||||
VERIFY_NAME_LIST: metadata.exportNameListName
|
VERIFY_NAME_LIST: metadata.exportNameListName
|
||||||
|
|||||||
@ -197,13 +197,8 @@ const buildImportThrow = localName => {
|
|||||||
|
|
||||||
const rewriteReferencesVisitor: Visitor<RewriteReferencesVisitorState> = {
|
const rewriteReferencesVisitor: Visitor<RewriteReferencesVisitorState> = {
|
||||||
ReferencedIdentifier(path) {
|
ReferencedIdentifier(path) {
|
||||||
const {
|
const { seen, buildImportReference, scope, imported, requeueInParent } =
|
||||||
seen,
|
this;
|
||||||
buildImportReference,
|
|
||||||
scope,
|
|
||||||
imported,
|
|
||||||
requeueInParent,
|
|
||||||
} = this;
|
|
||||||
if (seen.has(path.node)) return;
|
if (seen.has(path.node)) return;
|
||||||
seen.add(path.node);
|
seen.add(path.node);
|
||||||
|
|
||||||
|
|||||||
@ -373,9 +373,8 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
takeDecorators(node: N.HasDecorators): void {
|
takeDecorators(node: N.HasDecorators): void {
|
||||||
const decorators = this.state.decoratorStack[
|
const decorators =
|
||||||
this.state.decoratorStack.length - 1
|
this.state.decoratorStack[this.state.decoratorStack.length - 1];
|
||||||
];
|
|
||||||
if (decorators.length) {
|
if (decorators.length) {
|
||||||
node.decorators = decorators;
|
node.decorators = decorators;
|
||||||
this.resetStartLocationFromNode(node, decorators[0]);
|
this.resetStartLocationFromNode(node, decorators[0]);
|
||||||
@ -388,9 +387,8 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parseDecorators(allowExport?: boolean): void {
|
parseDecorators(allowExport?: boolean): void {
|
||||||
const currentContextDecorators = this.state.decoratorStack[
|
const currentContextDecorators =
|
||||||
this.state.decoratorStack.length - 1
|
this.state.decoratorStack[this.state.decoratorStack.length - 1];
|
||||||
];
|
|
||||||
while (this.match(tt.at)) {
|
while (this.match(tt.at)) {
|
||||||
const decorator = this.parseDecorator();
|
const decorator = this.parseDecorator();
|
||||||
currentContextDecorators.push(decorator);
|
currentContextDecorators.push(decorator);
|
||||||
@ -2067,9 +2065,8 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentContextDecorators = this.state.decoratorStack[
|
const currentContextDecorators =
|
||||||
this.state.decoratorStack.length - 1
|
this.state.decoratorStack[this.state.decoratorStack.length - 1];
|
||||||
];
|
|
||||||
// If node.declaration is a class, it will take all decorators in the current context.
|
// If node.declaration is a class, it will take all decorators in the current context.
|
||||||
// Thus we should throw if we see non-empty decorators here.
|
// Thus we should throw if we see non-empty decorators here.
|
||||||
if (currentContextDecorators.length) {
|
if (currentContextDecorators.length) {
|
||||||
|
|||||||
@ -150,6 +150,5 @@ export const mixinPlugins: { [name: string]: MixinPlugin } = {
|
|||||||
placeholders,
|
placeholders,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mixinPluginNames: $ReadOnlyArray<string> = Object.keys(
|
export const mixinPluginNames: $ReadOnlyArray<string> =
|
||||||
mixinPlugins,
|
Object.keys(mixinPlugins);
|
||||||
);
|
|
||||||
|
|||||||
@ -1350,9 +1350,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
return this.finishNode(node, "FunctionTypeParam");
|
return this.finishNode(node, "FunctionTypeParam");
|
||||||
}
|
}
|
||||||
|
|
||||||
flowParseFunctionTypeParams(
|
flowParseFunctionTypeParams(params: N.FlowFunctionTypeParam[] = []): {
|
||||||
params: N.FlowFunctionTypeParam[] = [],
|
|
||||||
): {
|
|
||||||
params: N.FlowFunctionTypeParam[],
|
params: N.FlowFunctionTypeParam[],
|
||||||
rest: ?N.FlowFunctionTypeParam,
|
rest: ?N.FlowFunctionTypeParam,
|
||||||
_this: ?N.FlowFunctionTypeParam,
|
_this: ?N.FlowFunctionTypeParam,
|
||||||
@ -3131,7 +3129,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
node.callee = base;
|
node.callee = base;
|
||||||
|
|
||||||
const result = this.tryParse(() => {
|
const result = this.tryParse(() => {
|
||||||
node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();
|
node.typeArguments =
|
||||||
|
this.flowParseTypeParameterInstantiationCallOrNew();
|
||||||
this.expect(tt.parenL);
|
this.expect(tt.parenL);
|
||||||
node.arguments = this.parseCallExpressionArguments(tt.parenR, false);
|
node.arguments = this.parseCallExpressionArguments(tt.parenR, false);
|
||||||
if (subscriptState.optionalChainMember) node.optional = false;
|
if (subscriptState.optionalChainMember) node.optional = false;
|
||||||
|
|||||||
@ -537,13 +537,11 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
this.expect(tt.parenL);
|
this.expect(tt.parenL);
|
||||||
signature.parameters = this.tsParseBindingListForSignature();
|
signature.parameters = this.tsParseBindingListForSignature();
|
||||||
if (returnTokenRequired) {
|
if (returnTokenRequired) {
|
||||||
signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(
|
signature.typeAnnotation =
|
||||||
returnToken,
|
this.tsParseTypeOrTypePredicateAnnotation(returnToken);
|
||||||
);
|
|
||||||
} else if (this.match(returnToken)) {
|
} else if (this.match(returnToken)) {
|
||||||
signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(
|
signature.typeAnnotation =
|
||||||
returnToken,
|
this.tsParseTypeOrTypePredicateAnnotation(returnToken);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1176,9 +1176,10 @@ export type TsSignatureDeclarationOrIndexSignatureBase = NodeBase & {
|
|||||||
typeAnnotation: ?TsTypeAnnotation,
|
typeAnnotation: ?TsTypeAnnotation,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TsSignatureDeclarationBase = TsSignatureDeclarationOrIndexSignatureBase & {
|
export type TsSignatureDeclarationBase =
|
||||||
|
TsSignatureDeclarationOrIndexSignatureBase & {
|
||||||
typeParameters: ?TsTypeParameterDeclaration,
|
typeParameters: ?TsTypeParameterDeclaration,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ================
|
// ================
|
||||||
// TypeScript type members (for type literal / interface / class)
|
// TypeScript type members (for type literal / interface / class)
|
||||||
|
|||||||
@ -33,7 +33,8 @@ const WARNING_CALLS = new WeakSet();
|
|||||||
*/
|
*/
|
||||||
function applyEnsureOrdering(path) {
|
function applyEnsureOrdering(path) {
|
||||||
// TODO: This should probably also hoist computed properties.
|
// TODO: This should probably also hoist computed properties.
|
||||||
const decorators = (path.isClass()
|
const decorators = (
|
||||||
|
path.isClass()
|
||||||
? [path].concat(path.get("body.body"))
|
? [path].concat(path.get("body.body"))
|
||||||
: path.get("properties")
|
: path.get("properties")
|
||||||
).reduce((acc, prop) => acc.concat(prop.node.decorators || []), []);
|
).reduce((acc, prop) => acc.concat(prop.node.decorators || []), []);
|
||||||
@ -47,9 +48,8 @@ function applyEnsureOrdering(path) {
|
|||||||
identDecorators
|
identDecorators
|
||||||
.map(decorator => {
|
.map(decorator => {
|
||||||
const expression = decorator.expression;
|
const expression = decorator.expression;
|
||||||
const id = (decorator.expression = path.scope.generateDeclaredUidIdentifier(
|
const id = (decorator.expression =
|
||||||
"dec",
|
path.scope.generateDeclaredUidIdentifier("dec"));
|
||||||
));
|
|
||||||
return t.assignmentExpression("=", id, expression);
|
return t.assignmentExpression("=", id, expression);
|
||||||
})
|
})
|
||||||
.concat([path.node]),
|
.concat([path.node]),
|
||||||
|
|||||||
@ -371,11 +371,8 @@ export default declare((api, opts) => {
|
|||||||
path.isObjectPattern(),
|
path.isObjectPattern(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const [
|
const [impureComputedPropertyDeclarators, argument, callExpression] =
|
||||||
impureComputedPropertyDeclarators,
|
createObjectRest(objectPatternPath, file, ref);
|
||||||
argument,
|
|
||||||
callExpression,
|
|
||||||
] = createObjectRest(objectPatternPath, file, ref);
|
|
||||||
|
|
||||||
if (pureGetters) {
|
if (pureGetters) {
|
||||||
removeUnusedExcludedKeys(objectPatternPath);
|
removeUnusedExcludedKeys(objectPatternPath);
|
||||||
@ -454,11 +451,8 @@ export default declare((api, opts) => {
|
|||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const [
|
const [impureComputedPropertyDeclarators, argument, callExpression] =
|
||||||
impureComputedPropertyDeclarators,
|
createObjectRest(leftPath, file, t.identifier(refName));
|
||||||
argument,
|
|
||||||
callExpression,
|
|
||||||
] = createObjectRest(leftPath, file, t.identifier(refName));
|
|
||||||
|
|
||||||
if (impureComputedPropertyDeclarators.length > 0) {
|
if (impureComputedPropertyDeclarators.length > 0) {
|
||||||
nodes.push(
|
nodes.push(
|
||||||
|
|||||||
@ -169,8 +169,9 @@ export function transform(
|
|||||||
// i.e. `?.b` in `(a?.b.c)()`
|
// i.e. `?.b` in `(a?.b.c)()`
|
||||||
if (i === 0 && parentIsCall) {
|
if (i === 0 && parentIsCall) {
|
||||||
// `(a?.b)()` to `(a == null ? undefined : a.b.bind(a))()`
|
// `(a?.b)()` to `(a == null ? undefined : a.b.bind(a))()`
|
||||||
const object = skipTransparentExprWrappers(replacementPath.get("object"))
|
const object = skipTransparentExprWrappers(
|
||||||
.node;
|
replacementPath.get("object"),
|
||||||
|
).node;
|
||||||
let baseRef;
|
let baseRef;
|
||||||
if (!pureGetters || !isSimpleMemberExpression(object)) {
|
if (!pureGetters || !isSimpleMemberExpression(object)) {
|
||||||
// memoize the context object when getters are not always pure
|
// memoize the context object when getters are not always pure
|
||||||
|
|||||||
@ -610,9 +610,8 @@ export default function transformClass(
|
|||||||
annotateAsPure(arg);
|
annotateAsPure(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
const param = classState.scope.generateUidIdentifierBasedOnNode(
|
const param =
|
||||||
superName,
|
classState.scope.generateUidIdentifierBasedOnNode(superName);
|
||||||
);
|
|
||||||
|
|
||||||
closureParams.push(param);
|
closureParams.push(param);
|
||||||
closureArgs.push(arg);
|
closureArgs.push(arg);
|
||||||
|
|||||||
@ -38,13 +38,8 @@ function injectWrapper(path, wrapper) {
|
|||||||
export default declare((api, options) => {
|
export default declare((api, options) => {
|
||||||
api.assertVersion(7);
|
api.assertVersion(7);
|
||||||
|
|
||||||
const {
|
const { allowTopLevelThis, strict, strictMode, importInterop, noInterop } =
|
||||||
allowTopLevelThis,
|
options;
|
||||||
strict,
|
|
||||||
strictMode,
|
|
||||||
importInterop,
|
|
||||||
noInterop,
|
|
||||||
} = options;
|
|
||||||
|
|
||||||
const constantReexports =
|
const constantReexports =
|
||||||
api.assumption("constantReexports") ?? options.loose;
|
api.assumption("constantReexports") ?? options.loose;
|
||||||
|
|||||||
@ -37,8 +37,8 @@ const iifeVisitor = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// type annotations don't use or introduce "real" bindings
|
// type annotations don't use or introduce "real" bindings
|
||||||
"TypeAnnotation|TSTypeAnnotation|TypeParameterDeclaration|TSTypeParameterDeclaration": path =>
|
"TypeAnnotation|TSTypeAnnotation|TypeParameterDeclaration|TSTypeParameterDeclaration":
|
||||||
path.skip(),
|
path => path.skip(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// last 2 parameters are optional -- they are used by proposal-object-rest-spread/src/index.js
|
// last 2 parameters are optional -- they are used by proposal-object-rest-spread/src/index.js
|
||||||
|
|||||||
@ -25,9 +25,8 @@ export default declare(api => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isCreateClassCallExpression = t.buildMatchMemberExpression(
|
const isCreateClassCallExpression =
|
||||||
"React.createClass",
|
t.buildMatchMemberExpression("React.createClass");
|
||||||
);
|
|
||||||
const isCreateClassAddon = callee => callee.name === "createReactClass";
|
const isCreateClassAddon = callee => callee.name === "createReactClass";
|
||||||
|
|
||||||
function isCreateClass(node) {
|
function isCreateClass(node) {
|
||||||
|
|||||||
@ -68,9 +68,8 @@ export default declare(api => {
|
|||||||
if (!state.fileNameIdentifier) {
|
if (!state.fileNameIdentifier) {
|
||||||
const fileName = state.filename || "";
|
const fileName = state.filename || "";
|
||||||
|
|
||||||
const fileNameIdentifier = path.scope.generateUidIdentifier(
|
const fileNameIdentifier =
|
||||||
FILE_NAME_VAR,
|
path.scope.generateUidIdentifier(FILE_NAME_VAR);
|
||||||
);
|
|
||||||
const scope = path.hub.getScope();
|
const scope = path.hub.getScope();
|
||||||
if (scope) {
|
if (scope) {
|
||||||
scope.push({
|
scope.push({
|
||||||
|
|||||||
@ -262,7 +262,8 @@ export const all = {
|
|||||||
"transform-new-target": transformNewTarget,
|
"transform-new-target": transformNewTarget,
|
||||||
"transform-object-assign": transformObjectAssign,
|
"transform-object-assign": transformObjectAssign,
|
||||||
"transform-object-super": transformObjectSuper,
|
"transform-object-super": transformObjectSuper,
|
||||||
"transform-object-set-prototype-of-to-assign": transformObjectSetPrototypeOfToAssign,
|
"transform-object-set-prototype-of-to-assign":
|
||||||
|
transformObjectSetPrototypeOfToAssign,
|
||||||
"transform-parameters": transformParameters,
|
"transform-parameters": transformParameters,
|
||||||
"transform-property-literals": transformPropertyLiterals,
|
"transform-property-literals": transformPropertyLiterals,
|
||||||
"transform-property-mutators": transformPropertyMutators,
|
"transform-property-mutators": transformPropertyMutators,
|
||||||
|
|||||||
@ -58,8 +58,9 @@ const require = createRequire(import.meta.url);
|
|||||||
],
|
],
|
||||||
sourceType: "script",
|
sourceType: "script",
|
||||||
};
|
};
|
||||||
const output = Babel.transformFromAst(ast, "42", { presets: ["es2015"] })
|
const output = Babel.transformFromAst(ast, "42", {
|
||||||
.code;
|
presets: ["es2015"],
|
||||||
|
}).code;
|
||||||
expect(output).toBe("42;");
|
expect(output).toBe("42;");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -191,13 +191,8 @@ function hoistFunctionEnvironment(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const { thisPaths, argumentsPaths, newTargetPaths, superProps, superCalls } =
|
||||||
thisPaths,
|
getScopeInformation(fnPath);
|
||||||
argumentsPaths,
|
|
||||||
newTargetPaths,
|
|
||||||
superProps,
|
|
||||||
superCalls,
|
|
||||||
} = getScopeInformation(fnPath);
|
|
||||||
|
|
||||||
// Convert all super() calls in the constructor, if super is used in an arrow.
|
// Convert all super() calls in the constructor, if super is used in an arrow.
|
||||||
if (inConstructor && superCalls.length > 0) {
|
if (inConstructor && superCalls.length > 0) {
|
||||||
|
|||||||
@ -432,9 +432,7 @@ function evaluateQuasis(path, quasis: Array<any>, state, raw = false) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function evaluate(
|
export function evaluate(this: NodePath): {
|
||||||
this: NodePath,
|
|
||||||
): {
|
|
||||||
confident: boolean;
|
confident: boolean;
|
||||||
value: any;
|
value: any;
|
||||||
deopt?: NodePath;
|
deopt?: NodePath;
|
||||||
|
|||||||
@ -175,9 +175,9 @@ export function referencesImport(
|
|||||||
? t.isStringLiteral(this.node.property, { value: importName })
|
? t.isStringLiteral(this.node.property, { value: importName })
|
||||||
: (this.node.property as t.Identifier).name === importName)
|
: (this.node.property as t.Identifier).name === importName)
|
||||||
) {
|
) {
|
||||||
const object = (this as NodePath<
|
const object = (
|
||||||
t.MemberExpression | t.OptionalMemberExpression
|
this as NodePath<t.MemberExpression | t.OptionalMemberExpression>
|
||||||
>).get("object");
|
).get("object");
|
||||||
return (
|
return (
|
||||||
object.isReferencedIdentifier() &&
|
object.isReferencedIdentifier() &&
|
||||||
object.referencesImport(moduleSource, "*")
|
object.referencesImport(moduleSource, "*")
|
||||||
|
|||||||
@ -202,8 +202,7 @@ const aliasDescriptions = {
|
|||||||
FlowDeclaration: "A cover of Flow declarations.",
|
FlowDeclaration: "A cover of Flow declarations.",
|
||||||
FlowPredicate: "A cover of Flow predicates.",
|
FlowPredicate: "A cover of Flow predicates.",
|
||||||
FlowType: "A cover of Flow type annotations.",
|
FlowType: "A cover of Flow type annotations.",
|
||||||
For:
|
For: "A cover of [ForStatement](https://tc39.es/ecma262/#sec-for-statement)s and [ForXStatement](#forxstatement)s.",
|
||||||
"A cover of [ForStatement](https://tc39.es/ecma262/#sec-for-statement)s and [ForXStatement](#forxstatement)s.",
|
|
||||||
ForXStatement:
|
ForXStatement:
|
||||||
"A cover of [ForInStatements and ForOfStatements](https://tc39.es/ecma262/#sec-for-in-and-for-of-statements).",
|
"A cover of [ForInStatements and ForOfStatements](https://tc39.es/ecma262/#sec-for-in-and-for-of-statements).",
|
||||||
Function:
|
Function:
|
||||||
@ -212,10 +211,8 @@ const aliasDescriptions = {
|
|||||||
"A cover of AST nodes that start an execution context with new [VariableEnvironment](https://tc39.es/ecma262/#table-additional-state-components-for-ecmascript-code-execution-contexts). In other words, they define the scope of `var` declarations. FunctionParent did not include `Program` since Babel 7.",
|
"A cover of AST nodes that start an execution context with new [VariableEnvironment](https://tc39.es/ecma262/#table-additional-state-components-for-ecmascript-code-execution-contexts). In other words, they define the scope of `var` declarations. FunctionParent did not include `Program` since Babel 7.",
|
||||||
Immutable:
|
Immutable:
|
||||||
"A cover of immutable objects and JSX elements. An object is [immutable](https://tc39.es/ecma262/#immutable-prototype-exotic-object) if no other properties can be defined once created.",
|
"A cover of immutable objects and JSX elements. An object is [immutable](https://tc39.es/ecma262/#immutable-prototype-exotic-object) if no other properties can be defined once created.",
|
||||||
JSX:
|
JSX: "A cover of AST nodes defined for [JSX](https://facebook.github.io/jsx/).",
|
||||||
"A cover of AST nodes defined for [JSX](https://facebook.github.io/jsx/).",
|
LVal: "A cover of left hand side expressions used in the `left` of assignment expressions and [ForXStatement](#forxstatement)s. ",
|
||||||
LVal:
|
|
||||||
"A cover of left hand side expressions used in the `left` of assignment expressions and [ForXStatement](#forxstatement)s. ",
|
|
||||||
Literal:
|
Literal:
|
||||||
"A cover of [Literal](https://tc39.es/ecma262/#sec-primary-expression-literals)s, [Regular Expression Literal](https://tc39.es/ecma262/#sec-primary-expression-regular-expression-literals)s and [Template Literal](https://tc39.es/ecma262/#sec-template-literals)s.",
|
"A cover of [Literal](https://tc39.es/ecma262/#sec-primary-expression-literals)s, [Regular Expression Literal](https://tc39.es/ecma262/#sec-primary-expression-regular-expression-literals)s and [Template Literal](https://tc39.es/ecma262/#sec-template-literals)s.",
|
||||||
Loop: "A cover of loop statements.",
|
Loop: "A cover of loop statements.",
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import type * as t from "..";
|
|||||||
* Prepend a node to a member expression.
|
* Prepend a node to a member expression.
|
||||||
*/
|
*/
|
||||||
export default function prependToMemberExpression<
|
export default function prependToMemberExpression<
|
||||||
T extends Pick<t.MemberExpression, "object" | "property">
|
T extends Pick<t.MemberExpression, "object" | "property">,
|
||||||
>(member: T, prepend: t.MemberExpression["object"]): T {
|
>(member: T, prepend: t.MemberExpression["object"]): T {
|
||||||
member.object = memberExpression(prepend, member.object);
|
member.object = memberExpression(prepend, member.object);
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export default function is<T extends t.Node["type"]>(
|
|||||||
|
|
||||||
export default function is<
|
export default function is<
|
||||||
T extends t.Node["type"],
|
T extends t.Node["type"],
|
||||||
P extends Extract<t.Node, { type: T }>
|
P extends Extract<t.Node, { type: T }>,
|
||||||
>(type: T, n: t.Node | null | undefined, required: Partial<P>): n is P;
|
>(type: T, n: t.Node | null | undefined, required: Partial<P>): n is P;
|
||||||
|
|
||||||
export default function is<P extends t.Node>(
|
export default function is<P extends t.Node>(
|
||||||
|
|||||||
10
yarn.lock
10
yarn.lock
@ -5646,7 +5646,7 @@ __metadata:
|
|||||||
lint-staged: ^9.2.0
|
lint-staged: ^9.2.0
|
||||||
lodash: ^4.17.21
|
lodash: ^4.17.21
|
||||||
mergeiterator: ^1.2.5
|
mergeiterator: ^1.2.5
|
||||||
prettier: ^2.2.1
|
prettier: 2.3.0
|
||||||
rollup: ^2.47.0
|
rollup: ^2.47.0
|
||||||
rollup-plugin-dts: ^2.0.0
|
rollup-plugin-dts: ^2.0.0
|
||||||
rollup-plugin-node-polyfills: ^0.2.1
|
rollup-plugin-node-polyfills: ^0.2.1
|
||||||
@ -12403,12 +12403,12 @@ fsevents@^1.2.7:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"prettier@npm:^2.2.1":
|
"prettier@npm:2.3.0":
|
||||||
version: 2.2.1
|
version: 2.3.0
|
||||||
resolution: "prettier@npm:2.2.1"
|
resolution: "prettier@npm:2.3.0"
|
||||||
bin:
|
bin:
|
||||||
prettier: bin-prettier.js
|
prettier: bin-prettier.js
|
||||||
checksum: 92c6c9f4b87eba1f28466edee57dd18c80d00b858edda77d46d1950d20e6e302b68ee255fc91133ba931e63c4577b5ae30da194d9626a8f3c0177778b91bf056
|
checksum: 652640cc8b71bc5277cfb8bf6f161783ca588efcf683c3d630837b39da8d57fef35c9e00ae5855a8e3c75136c42274046c913cc2b2d2968558315f31c6a26981
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user