let i = 0; if (i) console.log(i); elseconsole.log(1); for (let j = 0; j < 2; j++) console.log(j); while (i < 2) i++, console.log(i); const set = newSet([1, 2, 3]); for (let element of set) console.log(element); const str = "Hello"; for (let char of str) console.log(char); //----------------------------------------- let i = 0; if (i) { console.log(i); } else { console.log(1); } for (let j = 0; j < 2; j++) { console.log(j); } while (i < 2) { i++, console.log(i); } const set = newSet([1, 2, 3]); for (let element of set) { console.log(element); } const str = "Hello"; for (let char of str) { console.log(char); }
插件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
constBlockSyntax = { "ForStatement|WhileStatement|ForInStatement|ForOfStatement"({ node }) { if (!types.isBlockStatement(node.body)) { node.body = types.BlockStatement([node.body]); } }, IfStatement(path) { let nodes = ["consequent", "alternate"]; for (let i = 0; i < nodes.length; i++) { let _path = path.get(nodes[i]); if (_path.node && !_path.isBlockStatement()) { _path.replaceInline(types.BlockStatement([_path.node])); } } }, };