diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-11-13 08:16:12 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-11-13 08:16:52 +0100 |
commit | b2128609ac8159a14224deba399144b3400c8c20 (patch) | |
tree | 4759dfda67c54f6838c3aef0951545ae18bb83bd /thirdparty/preact/config/codemod-const.js | |
parent | 3f0ee289c4a61991d0e75906a9bd949cebb39d20 (diff) | |
download | wallet-core-b2128609ac8159a14224deba399144b3400c8c20.tar.xz |
Finally give in and use React, minor tweeks.
Preact (a minimalistic React alternative) had too many bugs ...
Diffstat (limited to 'thirdparty/preact/config/codemod-const.js')
-rw-r--r-- | thirdparty/preact/config/codemod-const.js | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/thirdparty/preact/config/codemod-const.js b/thirdparty/preact/config/codemod-const.js deleted file mode 100644 index 4bffd9add..000000000 --- a/thirdparty/preact/config/codemod-const.js +++ /dev/null @@ -1,39 +0,0 @@ -/* eslint no-console:0 */ - -/** Find constants (identified by ALL_CAPS_DECLARATIONS), and inline them globally. - * This is safe because Preact *only* uses global constants. - */ -export default (file, api) => { - let j = api.jscodeshift, - code = j(file.source), - constants = {}, - found = 0; - - code.find(j.VariableDeclaration) - .filter( decl => { - for (let i=decl.value.declarations.length; i--; ) { - let node = decl.value.declarations[i], - name = node.id && node.id.name, - init = node.init; - if (name && init && name.match(/^[A-Z0-9_$]+$/g)) { - if (init.type==='Literal') { - console.log(`Inlining constant: ${name}=${init.raw}`); - found++; - constants[name] = init; - // remove declaration - decl.value.declarations.splice(i, 1); - // if it's the last, we'll remove the whole statement - return !decl.value.declarations.length; - } - } - } - return false; - }) - .remove(); - - code.find(j.Identifier) - .filter( path => path.value.name && constants.hasOwnProperty(path.value.name) ) - .replaceWith( path => (found++, constants[path.value.name]) ); - - return found ? code.toSource({ quote: 'single' }) : null; -}; |