babel / babel

@@ -95,6 +95,7 @@
Loading
95 95
    const props = path.node.properties;
96 96
    const keys = [];
97 97
    let allLiteral = true;
98 +
    let hasTemplateLiteral = false;
98 99
99 100
    for (const prop of props) {
100 101
      if (t.isIdentifier(prop.key) && !prop.computed) {
@@ -102,6 +103,7 @@
Loading
102 103
        keys.push(t.stringLiteral(prop.key.name));
103 104
      } else if (t.isTemplateLiteral(prop.key)) {
104 105
        keys.push(t.cloneNode(prop.key));
106 +
        hasTemplateLiteral = true;
105 107
      } else if (t.isLiteral(prop.key)) {
106 108
        keys.push(t.stringLiteral(String(prop.key.value)));
107 109
      } else {
@@ -110,7 +112,7 @@
Loading
110 112
      }
111 113
    }
112 114
113 -
    return { keys, allLiteral };
115 +
    return { keys, allLiteral, hasTemplateLiteral };
114 116
  }
115 117
116 118
  // replaces impure computed keys with new identifiers
@@ -156,7 +158,8 @@
Loading
156 158
      path.get("properties"),
157 159
      path.scope,
158 160
    );
159 -
    const { keys, allLiteral } = extractNormalizedKeys(path);
161 +
    const { keys, allLiteral, hasTemplateLiteral } =
162 +
      extractNormalizedKeys(path);
160 163
161 164
    if (keys.length === 0) {
162 165
      return [
@@ -179,7 +182,7 @@
Loading
179 182
    } else {
180 183
      keyExpression = t.arrayExpression(keys);
181 184
182 -
      if (!t.isProgram(path.scope.block)) {
185 +
      if (!hasTemplateLiteral && !t.isProgram(path.scope.block)) {
183 186
        // Hoist definition of excluded keys, so that it's not created each time.
184 187
        const program = path.findParent(path => path.isProgram());
185 188
        const id = path.scope.generateUidIdentifier("excluded");
Files Coverage
codemods 100.00%
eslint 93.14%
packages 92.01%
Project Totals (455 files) 92.05%
1
coverage:
2
  parsers:
3
    javascript:
4
      enable_partials: yes
5
  status:
6
    project:
7
      default:
8
        target: "90%"
9
    patch:
10
      enabled: false
11
ignore:
12
  - packages/babel-types/src/*/generated/*
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading