Porting babel-plugin-transform-for-of-as-array into transform-for-of as an option (#6914)
This commit is contained in:
4
packages/babel-plugin-transform-for-of/test/fixtures/error/invalid-option/actual.js
vendored
Normal file
4
packages/babel-plugin-transform-for-of/test/fixtures/error/invalid-option/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
let elm;
|
||||
for (elm of array) {
|
||||
console.log(elm);
|
||||
}
|
||||
4
packages/babel-plugin-transform-for-of/test/fixtures/error/invalid-option/options.json
vendored
Normal file
4
packages/babel-plugin-transform-for-of/test/fixtures/error/invalid-option/options.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"plugins": [["transform-for-of", { "assumeArray": true, "loose": true}]],
|
||||
"throws": "The loose and assumeArray options cannot be used together in @babel/plugin-transform-for-of"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
let elm;
|
||||
for ([elm] of array) {
|
||||
console.log(elm);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
let elm;
|
||||
|
||||
for (let _i = 0, _array = array; _i < _array.length; _i++) {
|
||||
[elm] = _array[_i];
|
||||
console.log(elm);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
for (const [elm] of array) {
|
||||
console.log(elm);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
for (let _i = 0, _array = array; _i < _array.length; _i++) {
|
||||
const [elm] = _array[_i];
|
||||
console.log(elm);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
for (const elm of array) {
|
||||
console.log(elm);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
for (let _i = 0, _array = array; _i < _array.length; _i++) {
|
||||
const elm = _array[_i];
|
||||
console.log(elm);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
for (const i of items) i;
|
||||
@@ -0,0 +1,4 @@
|
||||
for (let _i = 0, _items = items; _i < _items.length; _i++) {
|
||||
const i = _items[_i];
|
||||
i;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
let i;
|
||||
for (i of items) i;
|
||||
@@ -0,0 +1,6 @@
|
||||
let i;
|
||||
|
||||
for (let _i = 0, _items = items; _i < _items.length; _i++) {
|
||||
i = _items[_i];
|
||||
i;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { array } from "foo";
|
||||
|
||||
for (const elm of array) {
|
||||
console.log(elm);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
define(["foo"], function (_foo) {
|
||||
"use strict";
|
||||
|
||||
for (let _i = 0; _i < _foo.array.length; _i++) {
|
||||
const elm = _foo.array[_i];
|
||||
console.log(elm);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"plugins": [["transform-for-of", {
|
||||
"assumeArray": true
|
||||
}],
|
||||
["transform-modules-amd"]
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { array } from "foo";
|
||||
|
||||
for (const elm of array) {
|
||||
console.log(elm);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var _foo = require("foo");
|
||||
|
||||
for (let _i = 0; _i < _foo.array.length; _i++) {
|
||||
const elm = _foo.array[_i];
|
||||
console.log(elm);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"plugins": [["transform-for-of", {
|
||||
"assumeArray": true
|
||||
}],
|
||||
["transform-modules-commonjs"]
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { array } from "foo";
|
||||
|
||||
for (const elm of array) {
|
||||
console.log(elm);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { array } from "foo";
|
||||
|
||||
for (let _i = 0; _i < array.length; _i++) {
|
||||
const elm = array[_i];
|
||||
console.log(elm);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
const array = [];
|
||||
|
||||
for (const elm of array) {
|
||||
console.log(elm);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
const array = [];
|
||||
|
||||
for (let _i = 0; _i < array.length; _i++) {
|
||||
const elm = array[_i];
|
||||
console.log(elm);
|
||||
}
|
||||
6
packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-of-static/actual.js
vendored
Normal file
6
packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-of-static/actual.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
const array = [];
|
||||
let elm;
|
||||
|
||||
for (elm of array) {
|
||||
console.log(elm);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
const array = [];
|
||||
let elm;
|
||||
|
||||
for (let _i = 0; _i < array.length; _i++) {
|
||||
elm = array[_i];
|
||||
console.log(elm);
|
||||
}
|
||||
5
packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-of/actual.js
vendored
Normal file
5
packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-of/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
let elm;
|
||||
|
||||
for (elm of array) {
|
||||
console.log(elm);
|
||||
}
|
||||
6
packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-of/expected.js
vendored
Normal file
6
packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-of/expected.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
let elm;
|
||||
|
||||
for (let _i = 0, _array = array; _i < _array.length; _i++) {
|
||||
elm = _array[_i];
|
||||
console.log(elm);
|
||||
}
|
||||
6
packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/options.json
vendored
Normal file
6
packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/options.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [["transform-for-of", {
|
||||
"assumeArray": true
|
||||
}]
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user