@samitouri / QOS-React / commits / 9c8547cc9f

Add script to print out a list of warnings

We'll use this in the GH sync script to track which warnings have changed since the last sync

Andrew Clark committed Mar 2, 2017 at 11:18 UTC 9c8547cc9f3d3d18c2916639de2ce3467336c2b2
5 files changed +210 -10
gulpfile.js
+2
@@ -103,6 +103,8 @@ var paths = {
103 },
104 };
105
106 +exports.paths = paths;
107 +
108 var moduleMapBase = {'object-assign': 'object-assign'};
109
110 var fbjsModules = require('fbjs/module-map');
package.json
+1
@@ -51,6 +51,7 @@
51 "fbjs-scripts": "^0.6.0",
52 "flow-bin": "^0.37.0",
53 "glob": "^6.0.1",
54 + "glob-stream": "^6.1.0",
55 "grunt": "^0.4.5",
56 "grunt-cli": "^0.1.13",
57 "grunt-compare-size": "^0.4.0",
scripts/circleci/test_extract_errors.sh
+4
@@ -4,3 +4,7 @@ set -e
4
5 ./node_modules/.bin/gulp react:extract-errors
6 git checkout -- scripts/error-codes/codes.json
7 +
8 +WARNINGS=$(node scripts/error-codes/print-warnings.js)
9 +echo "$WARNINGS"
10 +test ! -z "$WARNINGS"
scripts/error-codes/print-warnings.js new
+77
@@ -0,0 +1,77 @@
1 +/**
2 + * Copyright (c) 2013-present, Facebook, Inc.
3 + * All rights reserved.
4 + *
5 + * This source code is licensed under the BSD-style license found in the
6 + * LICENSE file in the root directory of this source tree. An additional grant
7 + * of patent rights can be found in the PATENTS file in the same directory.
8 + */
9 +'use strict';
10 +
11 +const babylon = require('babylon');
12 +const fs = require('fs');
13 +const through = require('through2');
14 +const traverse = require('babel-traverse').default;
15 +const gs = require('glob-stream');
16 +
17 +const evalToString = require('./evalToString');
18 +
19 +const { paths } = require('../../gulpfile');
20 +
21 +
22 +const babylonOptions = {
23 + sourceType: 'module',
24 + // As a parser, babylon has its own options and we can't directly
25 + // import/require a babel preset. It should be kept **the same** as
26 + // the `babel-plugin-syntax-*` ones specified in
27 + // https://github.com/facebook/fbjs/blob/master/babel-preset/configure.js
28 + plugins: [
29 + 'classProperties',
30 + 'flow',
31 + 'jsx',
32 + 'trailingFunctionCommas',
33 + 'objectRestSpread',
34 + ],
35 +};
36 +
37 +const warnings = new Set();
38 +
39 +function transform(file, enc, cb) {
40 + fs.readFile(file.path, 'utf8', function(err, source) {
41 + if (err) {
42 + cb(err);
43 + return;
44 + }
45 +
46 + const ast = babylon.parse(source, babylonOptions);
47 + traverse(ast, {
48 + CallExpression: {
49 + exit: function(astPath) {
50 + if (astPath.get('callee').isIdentifier({name: 'warning'})) {
51 + const node = astPath.node;
52 +
53 + // warning messages can be concatenated (`+`) at runtime, so here's
54 + // a trivial partial evaluator that interprets the literal value
55 + const warningMsgLiteral = evalToString(node.arguments[1]);
56 + warnings.add(JSON.stringify(warningMsgLiteral));
57 + }
58 + },
59 + },
60 + });
61 +
62 + cb(null);
63 + });
64 +}
65 +
66 +const sourcePaths = [].concat(
67 + paths.react.src,
68 + paths.reactDOM.src,
69 + paths.reactNative.src,
70 + paths.reactTestRenderer.src
71 +);
72 +
73 +gs(sourcePaths)
74 + .pipe(through.obj(transform, cb => {
75 + process.stdout.write(Array.from(warnings).sort().join('\n') + '\n');
76 + cb();
77 + }));
yarn.lock
+126 -10
@@ -1700,6 +1700,15 @@ duplexer2@^0.1.2, duplexer2@~0.1.0, duplexer2@~0.1.2:
1700 dependencies:
1701 readable-stream "^2.0.2"
1702
1703 +duplexify@^3.1.2:
1704 + version "3.5.0"
1705 + resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.5.0.tgz#1aa773002e1578457e9d9d4a50b0ccaaebcbd604"
1706 + dependencies:
1707 + end-of-stream "1.0.0"
1708 + inherits "^2.0.1"
1709 + readable-stream "^2.0.0"
1710 + stream-shift "^1.0.0"
1711 +
1712 ecc-jsbn@~0.1.1:
1713 version "0.1.1"
1714 resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
@@ -1721,6 +1730,18 @@ encoding@^0.1.11:
1730 dependencies:
1731 iconv-lite "~0.4.13"
1732
1733 +end-of-stream@1.0.0:
1734 + version "1.0.0"
1735 + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.0.0.tgz#d4596e702734a93e40e9af864319eabd99ff2f0e"
1736 + dependencies:
1737 + once "~1.3.0"
1738 +
1739 +end-of-stream@^1.1.0:
1740 + version "1.1.0"
1741 + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.1.0.tgz#e9353258baa9108965efc41cb0ef8ade2f3cfb07"
1742 + dependencies:
1743 + once "~1.3.0"
1744 +
1745 end-of-stream@~0.1.5:
1746 version "0.1.5"
1747 resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-0.1.5.tgz#8e177206c3c80837d85632e8b9359dfe8b2f6eaf"
@@ -1849,9 +1870,6 @@ eslint-plugin-flowtype@^2.25.0:
1870 "eslint-plugin-react-internal@file:./eslint-rules":
1871 version "0.0.0"
1872
1852 -"eslint-plugin-react-internal@file:eslint-rules":
1853 - version "0.0.0"
1854 -
1873 eslint-plugin-react@^6.7.1:
1874 version "6.9.0"
1875 resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-6.9.0.tgz#54c2e9906b76f9d10142030bdc34e9d6840a0bb2"
@@ -1998,6 +2016,12 @@ expand-tilde@^1.2.1, expand-tilde@^1.2.2:
2016 dependencies:
2017 os-homedir "^1.0.1"
2018
2019 +extend-shallow@^2.0.1:
2020 + version "2.0.1"
2021 + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f"
2022 + dependencies:
2023 + is-extendable "^0.1.0"
2024 +
2025 extend@^1.2.1:
2026 version "1.3.0"
2027 resolved "https://registry.yarnpkg.com/extend/-/extend-1.3.0.tgz#d1516fb0ff5624d2ebf9123ea1dac5a1994004f8"
@@ -2312,6 +2336,13 @@ glob-parent@^2.0.0:
2336 dependencies:
2337 is-glob "^2.0.0"
2338
2339 +glob-parent@^3.1.0:
2340 + version "3.1.0"
2341 + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae"
2342 + dependencies:
2343 + is-glob "^3.1.0"
2344 + path-dirname "^1.0.0"
2345 +
2346 glob-stream@^3.1.5:
2347 version "3.1.18"
2348 resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-3.1.18.tgz#9170a5f12b790306fdfe598f313f8f7954fd143b"
@@ -2323,6 +2354,21 @@ glob-stream@^3.1.5:
2354 through2 "^0.6.1"
2355 unique-stream "^1.0.0"
2356
2357 +glob-stream@^6.1.0:
2358 + version "6.1.0"
2359 + resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-6.1.0.tgz#7045c99413b3eb94888d83ab46d0b404cc7bdde4"
2360 + dependencies:
2361 + extend "^3.0.0"
2362 + glob "^7.1.1"
2363 + glob-parent "^3.1.0"
2364 + is-negated-glob "^1.0.0"
2365 + ordered-read-streams "^1.0.0"
2366 + pumpify "^1.3.5"
2367 + readable-stream "^2.1.5"
2368 + remove-trailing-separator "^1.0.1"
2369 + to-absolute-glob "^2.0.0"
2370 + unique-stream "^2.0.2"
2371 +
2372 glob-watcher@^0.0.6:
2373 version "0.0.6"
2374 resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-0.0.6.tgz#b95b4a8df74b39c83298b0c05c978b4d9a3b710b"
@@ -2364,7 +2410,7 @@ glob@^6.0.1:
2410 once "^1.3.0"
2411 path-is-absolute "^1.0.0"
2412
2367 -glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.0:
2413 +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.0, glob@^7.1.1:
2414 version "7.1.1"
2415 resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
2416 dependencies:
@@ -2842,7 +2888,7 @@ invert-kv@^1.0.0:
2888 version "1.0.0"
2889 resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6"
2890
2845 -is-absolute@^0.2.3:
2891 +is-absolute@^0.2.3, is-absolute@^0.2.5:
2892 version "0.2.6"
2893 resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-0.2.6.tgz#20de69f3db942ef2d87b9c2da36f172235b1b5eb"
2894 dependencies:
@@ -2893,7 +2939,7 @@ is-equal-shallow@^0.1.3:
2939 dependencies:
2940 is-primitive "^2.0.0"
2941
2896 -is-extendable@^0.1.1:
2942 +is-extendable@^0.1.0, is-extendable@^0.1.1:
2943 version "0.1.1"
2944 resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89"
2945
@@ -2901,6 +2947,10 @@ is-extglob@^1.0.0:
2947 version "1.0.0"
2948 resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0"
2949
2950 +is-extglob@^2.1.0:
2951 + version "2.1.1"
2952 + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
2953 +
2954 is-finite@^1.0.0:
2955 version "1.0.2"
2956 resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa"
@@ -2923,6 +2973,12 @@ is-glob@^2.0.0, is-glob@^2.0.1:
2973 dependencies:
2974 is-extglob "^1.0.0"
2975
2976 +is-glob@^3.1.0:
2977 + version "3.1.0"
2978 + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a"
2979 + dependencies:
2980 + is-extglob "^2.1.0"
2981 +
2982 is-integer@^1.0.4:
2983 version "1.0.6"
2984 resolved "https://registry.yarnpkg.com/is-integer/-/is-integer-1.0.6.tgz#5273819fada880d123e1ac00a938e7172dd8d95e"
@@ -2938,6 +2994,10 @@ is-my-json-valid@^2.10.0, is-my-json-valid@^2.12.4:
2994 jsonpointer "^4.0.0"
2995 xtend "^4.0.0"
2996
2997 +is-negated-glob@^1.0.0:
2998 + version "1.0.0"
2999 + resolved "https://registry.yarnpkg.com/is-negated-glob/-/is-negated-glob-1.0.0.tgz#6910bca5da8c95e784b5751b976cf5a10fee36d2"
3000 +
3001 is-number@^2.0.2, is-number@^2.1.0:
3002 version "2.1.0"
3003 resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f"
@@ -3922,7 +3982,7 @@ object.omit@^2.0.0:
3982 for-own "^0.1.4"
3983 is-extendable "^0.1.1"
3984
3925 -once@^1.3.0, once@^1.4.0:
3985 +once@^1.3.0, once@^1.3.1, once@^1.4.0:
3986 version "1.4.0"
3987 resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
3988 dependencies:
@@ -3968,6 +4028,13 @@ ordered-read-streams@^0.1.0:
4028 version "0.1.0"
4029 resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz#fd565a9af8eb4473ba69b6ed8a34352cb552f126"
4030
4031 +ordered-read-streams@^1.0.0:
4032 + version "1.0.0"
4033 + resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-1.0.0.tgz#d674a86ffcedf83d0ae06afa2918855e96d4033a"
4034 + dependencies:
4035 + is-stream "^1.0.1"
4036 + readable-stream "^2.0.1"
4037 +
4038 os-browserify@~0.1.1:
4039 version "0.1.2"
4040 resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.1.2.tgz#49ca0293e0b19590a5f5de10c7f265a617d8fe54"
@@ -4063,6 +4130,10 @@ path-browserify@~0.0.0:
4130 version "0.0.0"
4131 resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.0.tgz#a0b870729aae214005b7d5032ec2cbbb0fb4451a"
4132
4133 +path-dirname@^1.0.0:
4134 + version "1.0.2"
4135 + resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0"
4136 +
4137 path-exists@^1.0.0:
4138 version "1.0.0"
4139 resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-1.0.0.tgz#d5a8998eb71ef37a74c34eb0d9eba6e878eea081"
@@ -4197,6 +4268,21 @@ public-encrypt@^4.0.0:
4268 parse-asn1 "^5.0.0"
4269 randombytes "^2.0.1"
4270
4271 +pump@^1.0.0:
4272 + version "1.0.2"
4273 + resolved "https://registry.yarnpkg.com/pump/-/pump-1.0.2.tgz#3b3ee6512f94f0e575538c17995f9f16990a5d51"
4274 + dependencies:
4275 + end-of-stream "^1.1.0"
4276 + once "^1.3.1"
4277 +
4278 +pumpify@^1.3.5:
4279 + version "1.3.5"
4280 + resolved "https://registry.yarnpkg.com/pumpify/-/pumpify-1.3.5.tgz#1b671c619940abcaeac0ad0e3a3c164be760993b"
4281 + dependencies:
4282 + duplexify "^3.1.2"
4283 + inherits "^2.0.1"
4284 + pump "^1.0.0"
4285 +
4286 punycode@1.3.2:
4287 version "1.3.2"
4288 resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d"
@@ -4280,7 +4366,7 @@ read-pkg@^1.0.0:
4366 isarray "0.0.1"
4367 string_decoder "~0.10.x"
4368
4283 -"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.1.0, readable-stream@^2.1.5:
4369 +readable-stream@^2.0.0, "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.1.0, readable-stream@^2.1.5:
4370 version "2.2.2"
4371 resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.2.tgz#a9e6fec3c7dda85f8bb1b3ba7028604556fc825e"
4372 dependencies:
@@ -4402,6 +4488,10 @@ regjsparser@^0.1.4:
4488 dependencies:
4489 jsesc "~0.5.0"
4490
4491 +remove-trailing-separator@^1.0.1:
4492 + version "1.0.1"
4493 + resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.0.1.tgz#615ebb96af559552d4bf4057c8436d486ab63cc4"
4494 +
4495 repeat-element@^1.1.2:
4496 version "1.1.2"
4497 resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a"
@@ -4751,6 +4841,10 @@ stream-http@^2.0.0:
4841 to-arraybuffer "^1.0.0"
4842 xtend "^4.0.0"
4843
4844 +stream-shift@^1.0.0:
4845 + version "1.0.0"
4846 + resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952"
4847 +
4848 stream-splicer@^2.0.0:
4849 version "2.0.0"
4850 resolved "https://registry.yarnpkg.com/stream-splicer/-/stream-splicer-2.0.0.tgz#1b63be438a133e4b671cc1935197600175910d83"
@@ -4902,6 +4996,13 @@ throat@^3.0.0:
4996 version "3.0.0"
4997 resolved "https://registry.yarnpkg.com/throat/-/throat-3.0.0.tgz#e7c64c867cbb3845f10877642f7b60055b8ec0d6"
4998
4999 +through2-filter@^2.0.0:
5000 + version "2.0.0"
5001 + resolved "https://registry.yarnpkg.com/through2-filter/-/through2-filter-2.0.0.tgz#60bc55a0dacb76085db1f9dae99ab43f83d622ec"
5002 + dependencies:
5003 + through2 "~2.0.0"
5004 + xtend "~4.0.0"
5005 +
5006 through2@^0.6.1:
5007 version "0.6.5"
5008 resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48"
@@ -4916,7 +5017,7 @@ through2@^1.0.0:
5017 readable-stream ">=1.1.13-1 <1.2.0-0"
5018 xtend ">=4.0.0 <4.1.0-0"
5019
4919 -through2@^2.0.0:
5020 +through2@^2.0.0, through2@~2.0.0:
5021 version "2.0.3"
5022 resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be"
5023 dependencies:
@@ -4953,6 +5054,14 @@ tmpl@1.0.x:
5054 version "1.0.4"
5055 resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1"
5056
5057 +to-absolute-glob@^2.0.0:
5058 + version "2.0.1"
5059 + resolved "https://registry.yarnpkg.com/to-absolute-glob/-/to-absolute-glob-2.0.1.tgz#70c375805b9e3105e899ee8dbdd6a9aa108f407b"
5060 + dependencies:
5061 + extend-shallow "^2.0.1"
5062 + is-absolute "^0.2.5"
5063 + is-negated-glob "^1.0.0"
5064 +
5065 to-arraybuffer@^1.0.0:
5066 version "1.0.1"
5067 resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43"
@@ -5072,6 +5181,13 @@ unique-stream@^1.0.0:
5181 version "1.0.0"
5182 resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-1.0.0.tgz#d59a4a75427447d9aa6c91e70263f8d26a4b104b"
5183
5184 +unique-stream@^2.0.2:
5185 + version "2.2.1"
5186 + resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-2.2.1.tgz#5aa003cfbe94c5ff866c4e7d668bb1c4dbadb369"
5187 + dependencies:
5188 + json-stable-stringify "^1.0.0"
5189 + through2-filter "^2.0.0"
5190 +
5191 url@~0.11.0:
5192 version "0.11.0"
5193 resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1"
@@ -5261,7 +5377,7 @@ xml-name-validator@^2.0.1:
5377 version "2.0.1"
5378 resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-2.0.1.tgz#4d8b8f1eccd3419aa362061becef515e1e559635"
5379
5264 -"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.1:
5380 +"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.0, xtend@~4.0.1:
5381 version "4.0.1"
5382 resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"
5383