(node)
| 195 | }, |
| 196 | |
| 197 | VariableDeclaration(node) { |
| 198 | const {declarations} = node; |
| 199 | if (declarations.length !== 1) { |
| 200 | return; |
| 201 | } |
| 202 | const decl = declarations[0]; |
| 203 | const {id, init} = decl; |
| 204 | if (id.type !== 'Identifier') { |
| 205 | return; |
| 206 | } |
| 207 | |
| 208 | rename(id, null, id); |
| 209 | |
| 210 | if (!/_E(NUM|num)$/.test(id.name)) { |
| 211 | return; |
| 212 | } |
| 213 | |
| 214 | let annotationNode = node; |
| 215 | const {parent} = node; |
| 216 | if (parent.type === 'ExportNamedDeclaration') { |
| 217 | annotationNode = parent; |
| 218 | } |
| 219 | if (!hasEnumAnnotation(annotationNode)) { |
| 220 | context.report({ |
| 221 | node: annotationNode, |
| 222 | message: 'Static enums require an @enum annotation', |
| 223 | }); |
| 224 | } |
| 225 | |
| 226 | checkEnumId(id); |
| 227 | if (init?.type === 'ObjectExpression') { |
| 228 | checkEnumKeys(init); |
| 229 | } else { |
| 230 | context.report({ |
| 231 | node: decl.init || decl, |
| 232 | message: [ |
| 233 | 'Static enums must be initialized with at literal object expression', |
| 234 | `eg, \`${node.kind} ${id.name} = { … }\``, |
| 235 | ].join('\n\t'), |
| 236 | }); |
| 237 | } |
| 238 | }, |
| 239 | |
| 240 | ImportDeclaration(node) { |
| 241 | for (const imp of node.specifiers) { |
nothing calls this directly
no test coverage detected