From 30af98b43f2a803abcc094b9e22ab0332c18df02 Mon Sep 17 00:00:00 2001 From: "William C. Johnson" Date: Wed, 25 Oct 2017 12:51:18 -0400 Subject: [PATCH] 3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 3dfd2ff5a301fd7227f981c1d249b339349c379b Author: William C. Johnson Date: Wed Oct 25 00:32:52 2017 -0400 @oigroup/lightscript-eslint@3.0.0-beta.9 commit 2d842e6d623ba39917f2286af882f4b7aabcec6f Author: William C. Johnson Date: Wed Oct 25 00:10:30 2017 -0400 @oigroup/lightscript-eslint@3.0.0-beta.8 commit ae1363ae5f4a725756bd6dd48e2cb5ae9b32ab14 Author: William C. Johnson Date: Tue Oct 24 23:54:50 2017 -0400 @oigroup/lightscript-eslint@3.0.0-beta.7 commit f74e487322dcc987053b82b98220c18d5dd02c03 Author: William C. Johnson Date: Sun Oct 22 15:18:19 2017 -0400 @oigroup/lightscript-eslint@3.0.0-beta.6 commit 8117e94b141f32e3275b845ba3124235b4924b8e Author: William C. Johnson Date: Fri Oct 20 21:02:16 2017 -0400 @oigroup/lightscript-eslint@3.0.0-beta.5 commit 046d90b49b4ac194b0e790302d4b2becc0daacef Author: William C. Johnson Date: Thu Oct 19 16:51:39 2017 -0400 @oigroup/lightscript-eslint@3.0.0-beta.4 commit 6cfb623cd6f2825f127fe0efd829372de992f736 Author: William C. Johnson Date: Thu Oct 19 16:48:27 2017 -0400 Disable no-else-return rule Doc updates also commit 8fb9ef8fe57e067268e6bf181ed55a594f727d74 Author: William C. Johnson Date: Thu Oct 12 22:31:36 2017 -0400 Disable `no-unexpected-multiline` in eslint 4 commit 3dabeae14d4449847006e10757f1c4292bfbeba4 Author: William C. Johnson Date: Thu Oct 12 21:08:36 2017 -0400 @oigroup/lightscript-eslint@3.0.0-beta.3 commit ce3ba578873a0ac6b9c901425ec83b8f8f783138 Author: William C. Johnson Date: Thu Oct 12 20:18:51 2017 -0400 @oigroup/lightscript-eslint@3.0.0-beta.2 commit d7945d67586996cdfeb2077b72e15ac65130710f Author: William C. Johnson Date: Thu Oct 12 20:06:28 2017 -0400 Packaging updates commit fb7c37897c2f1c5fa6fd74c307b78144e695ce94 Author: William C. Johnson Date: Thu Oct 12 20:03:24 2017 -0400 Update deps commit 97cae1ff1d4a548b732a744122044284e798c50a Author: William C. Johnson Date: Thu Oct 12 18:11:10 2017 -0400 Post-merge fixups commit 1c30620535e44f05b92aceae129ba271b71df8a9 Merge: 5721d25 54ed517 Author: William C. Johnson Date: Thu Oct 12 18:05:41 2017 -0400 Merge remote-tracking branch 'babel-eslint/7.x' into prerelease/3.0.0 # Conflicts: # README.md # babylon-to-espree/toAST.js # index.js # package.json # test/non-regression.js # yarn.lock commit 5721d25854d71ecaf44d62015b7fdd0ded6a5b18 Author: William C. Johnson Date: Thu Oct 12 17:20:09 2017 -0400 Remove separate `pickBy` dep commit 6bd6f198971fdecf2508d5b2378068f17fd0751b Author: William C. Johnson Date: Wed Oct 11 21:38:51 2017 -0400 @oigroup/lightscript-eslint@3.0.0-beta.1 commit fe34c6cb2ddc2052338e92b5669ef8177346ac26 Author: William C. Johnson Date: Wed Oct 11 01:24:05 2017 -0400 @oigroup/lightscript-eslint@3.0.0-beta.0 commit 52dadaa45d06d12b9d729edc6c1cf3b25d565882 Author: William C. Johnson Date: Wed Oct 11 01:15:42 2017 -0400 Monkey-patch getFirstTokens commit 419716397b95bd6da2939b98b9beb68e98a16161 Author: William C. Johnson Date: Sun Oct 8 21:31:37 2017 -0400 Linter uses tooling API https://github.com/wcjohnson/lightscript/issues/30 https://github.com/wcjohnson/lightscript/issues/31 commit ab9623318cec4d822bcd33aa8b55ce85cf494bfa Author: William C. Johnson Date: Sun Oct 8 16:35:32 2017 -0400 @oigroup/lightscript-eslint@3.0.0-alpha.6 commit ea1ddf6b4192e2a928cb3482cfa6a04dcd95c524 Author: William C. Johnson Date: Sun Oct 8 16:34:20 2017 -0400 Catch up to plugin commit 8c36f6ca3fbb50f26b536e3a201fc2c553f43770 Author: William C. Johnson Date: Fri Oct 6 17:49:53 2017 -0400 @oigroup/lightscript-eslint@3.0.0-alpha.5 commit 3f9444e5be7e103479591f637a96a6afe16df2e4 Author: William C. Johnson Date: Tue Oct 3 15:26:06 2017 -0400 @oigroup/lightscript-eslint@3.0.0-alpha.4 commit f1ea2138ac36a7b8267f26d545fb8b0aa808d236 Author: William C. Johnson Date: Mon Oct 2 21:36:21 2017 -0400 @oigroup/lightscript-eslint@3.0.0-alpha.3 commit 8dcd15bb0786995a83d18c74f8478f4a4313ed9e Author: William C. Johnson Date: Mon Oct 2 21:35:09 2017 -0400 Patch linter for 3.0 alpha changes commit f35f5bbab5aa00e680ce28a28554d97e76d135fc Author: William C. Johnson Date: Sat Sep 30 22:09:47 2017 -0400 @oigroup/lightscript-eslint@3.0.0-alpha.2 commit 9b3c535115cf1c9ecf7df1a4efbb48c8cf4ee0a5 Author: William C. Johnson Date: Thu Sep 28 21:27:31 2017 -0400 @oigroup/lightscript-eslint@3.0.0-alpha.1 commit 7e0882e7322c6b54e5706303daa60d9f9e6fca80 Author: William C. Johnson Date: Thu Sep 28 21:15:46 2017 -0400 Update comprehension syntax commit deb1718ad55920e840e66aa1a3c2a2e1b22b2c62 Author: William C. Johnson Date: Wed Sep 27 22:17:27 2017 -0400 @oigroup/lightscript-eslint@3.0.0-alpha.0 commit 57160c524b87d7281ab19f3efac0a5670592d0ec Author: William C. Johnson Date: Wed Sep 27 22:06:26 2017 -0400 3.0 defaults update commit 1b5e46691f6fbfa382b85b2fd06e4d9edfe51b47 Author: William C. Johnson Date: Wed Sep 27 22:06:20 2017 -0400 Quieted unmapped node message commit 54ed517d2ecb3afb93ac338c019f8dff224918c2 Author: Reyad Attiyat Date: Mon May 29 20:41:14 2017 -0500 Fix: Convert RegExpLieteral value to RegExp object (fixes #477) (#478) commit 94bb5a1d36c5624fb612de2dd704ffa586d38845 Author: Sebastian McKenzie Date: Fri Apr 21 22:14:19 2017 +0100 7.2.3 commit dfaff04bad37823842aec19fe131f75a069b7799 Author: Andres Suarez Date: Fri Apr 21 11:48:52 2017 -0400 Fix flow type spread handling (#465) commit f59d2009652e14acf1231a1268a8324cf046514e Author: Henry Zhu Date: Wed Apr 12 12:07:05 2017 -0400 7.2.2 commit 862200945ee2860cbd00e770280dda3d56b055eb Author: Vitor Balocco Date: Wed Apr 12 17:59:23 2017 +0200 Fix: use eslint-scope instead of escope if present (#461) commit 0f611b83311d1b44912fc1dd0fc2cd88a0ae9d0c Author: Andres Suarez Date: Thu Mar 30 13:49:51 2017 -0400 Separate finding peer deps from monkeypatching (#460) commit 1201e12800bbb4badb55620100bc871193572784 Author: Andres Suarez Date: Sat Mar 25 19:36:10 2017 -0400 Remove unused .gitmodules (#457) commit a750684e477ab72d4a62822a965c7c8f909aa37d Author: Andres Suarez Date: Sat Mar 25 19:32:05 2017 -0400 Use dedent for unpadding (#456) commit cdb92fe60d25980a8e9c66acc8c32d81de01aca1 Merge: 21dac73 ec14787 Author: Henry Zhu Date: Sat Mar 25 19:15:23 2017 -0400 Merge pull request #455 from babel/babylon-to-espree-tidy Tidy up babylon-to-espree commit ec14787172795c81fa2c544d100727d897521ebe Author: Andres Suarez Date: Sat Mar 25 18:03:17 2017 -0400 Enable strict mode in all of babylon-to-espree commit 6c5beec589cbf343c528f1a78efe42874d7c83d4 Author: Andres Suarez Date: Sat Mar 25 18:01:13 2017 -0400 Move ast convert steps to babylon-to-espree commit d2ce7894bc864ed46c0c91eeef60af0a91886d8a Author: Andres Suarez Date: Sat Mar 25 17:42:51 2017 -0400 Use for-loop for template literal conversion commit 539af05bae280d15059d783b59d77b8814a48084 Author: Andres Suarez Date: Sat Mar 25 17:36:20 2017 -0400 Only iterate over tokens once commit 06c3a31b96cb890fe3544931f60f021e5186f62a Author: Andres Suarez Date: Sat Mar 25 17:28:01 2017 -0400 Inline fixDirectives and use for-loop commit 5d32ad0d56c8769aeea680cc7a4aafa1df4c2a04 Author: Andres Suarez Date: Sat Mar 25 17:07:41 2017 -0400 Consolidate versions of "convertComments" commit 2541fc93b9bacf179661d8e27e040afe011e2926 Author: Andres Suarez Date: Sat Mar 25 00:18:57 2017 -0400 toAst pass "source" in state instead of keeping in scope commit 21dac7391470b8eb24a07cd11c527293df3c7a23 Author: Andres Suarez Date: Thu Mar 23 15:46:48 2017 -0400 Add type parameter scope tests (#454) commit 3cda62ee066c741b766526155dcdb98db1a2a2d5 Author: Henry Zhu Date: Thu Mar 23 14:03:23 2017 -0400 7.2.1 commit 5626de120d866f7c99df78566af2514a1674199c Author: Andres Suarez Date: Thu Mar 23 14:02:24 2017 -0400 Remove left over eslint 2 estraverse code (#452) This was missed in #361 commit b5fb53b718d15e95252197b5f30787ca807d069a Author: Andres Suarez Date: Thu Mar 23 12:49:19 2017 -0400 Fix type param and interface declaration scoping (#449) commit f1cee0f23193fb222270d69986313a3bd2453ba6 Author: Andres Suarez Date: Wed Mar 22 22:35:31 2017 -0400 Remove lodash dependency (#450) commit eb05812e8d3d7e203fa555f42288ff3e0ed8bd5f Author: Andres Suarez Date: Wed Mar 22 22:34:13 2017 -0400 Format non-regression errors for legibility (#451) commit 7972a052e72f44802d0860c5491abe80158a7e43 Author: Luís Couto Date: Tue Mar 21 00:11:30 2017 +0000 Update README.md with codeFrame option (#448) commit 4db4db54d18d5d2833ed9a02c5e4cde20474e995 Author: Henry Zhu Date: Mon Mar 20 17:53:26 2017 -0400 7.2.0 commit 44994124941b1e50772ee2661cf5d8c910105308 Author: wtgtybhertgeghgtwtg Date: Mon Mar 20 14:50:09 2017 -0700 Use `lodash` instead of `lodash.pickby`. (#435) commit a2c3b30e6a86a39e0cb44a95a1990ca54415bd1f Author: Alex Rattray Date: Mon Mar 20 14:46:07 2017 -0700 [flow] Process polymorphic type bounds on functions (#444) commit 515adefc54bb6097ad2fdc076614606ad0ae4262 Author: Luís Couto Date: Mon Mar 20 21:45:11 2017 +0000 Add option to disable code frame. (#446) * Add option to disable code hightlight. * Rename codeHighlight with codeFrame * Add codeFrame tests * Remove colors from test assertions commit ce66e73749dc33520013399f8585cfe00e755c09 Merge: bdeb86f b49ab20 Author: Henry Zhu Date: Mon Mar 20 11:44:33 2017 -0400 Merge pull request #447 from kaicataldo/clean-up-eslint Chore: Clean up and upgrades commit b49ab204a2091861f9645ce95e019ee88a9b08eb Author: Kai Cataldo Date: Mon Mar 20 10:33:14 2017 -0400 Updates ESLint version/remove unnecessary config commit 702d6b8279549df555451e4fe64173eb4b803327 Author: Kai Cataldo Date: Mon Mar 20 10:27:28 2017 -0400 Remove broken ESLint tests commit 6b4c4ca36a9d1930468fb105c1d88fa4d908c315 Author: Kai Cataldo Date: Sat Mar 11 22:15:47 2017 -0500 Upgrade outdated dependencies --- .eslintrc.js | 4 - .gitmodules | 3 - README.md | 37 +- babylon-to-espree/attachComments.js | 2 + babylon-to-espree/convertComments.js | 17 + babylon-to-espree/convertTemplateType.js | 2 + babylon-to-espree/index.js | 54 ++- babylon-to-espree/toAST.js | 98 +++-- babylon-to-espree/toToken.js | 2 + babylon-to-espree/toTokens.js | 13 +- eslint | 1 - eslint-tester.js | 6 - index.js | 298 ++++++++------- package.json | 30 +- test/babel-eslint.js | 27 +- test/fixtures/rules/syntax-error.js | 6 + test/integration.js | 48 +++ test/non-regression.js | 271 ++++++++++---- utils/unpad.js | 14 - yarn.lock | 440 +++++++---------------- 20 files changed, 708 insertions(+), 665 deletions(-) delete mode 100644 .gitmodules create mode 100644 babylon-to-espree/convertComments.js delete mode 160000 eslint delete mode 100644 eslint-tester.js create mode 100644 test/fixtures/rules/syntax-error.js delete mode 100644 utils/unpad.js diff --git a/.eslintrc.js b/.eslintrc.js index 1f91933f..20f31f1e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,10 +1,6 @@ module.exports = { root: true, extends: "babel", - parserOptions: { - ecmaVersion: 7, - sourceType: "module" - }, rules: { "no-var": 0, "max-len": 0 diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e922d16a..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "eslint"] - path = eslint - url = https://github.com/eslint/eslint diff --git a/README.md b/README.md index b82d8e62..3a0ecdff 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # @oigroup/lightscript-eslint -> NB: This is a fork of lightscript-eslint which implements language changes that are not necessarily endorsed by upstream. Generally speaking, our intent is to closely follow the upstream language -- however, there may be notable deviations which are documented below. +> `@oigroup/lightscript-eslint` is most frequently tested with `eslint@^4.0.0`. +> It SHOULD be backwards-compatible with `eslint@^3.0.0` as well. `@oigroup/lightscript-eslint` is a fork of `babel-eslint` that parses code with `@oigroup/babylon-lightscript` and `@oigroup/babel-plugin-lightscript`. @@ -12,7 +13,7 @@ all others will be processed exactly as in `babel-eslint`. To use, just `npm install --save-dev @oigroup/lightscript-eslint` and add `parser: "@oigroup/lightscript-eslint"` to your `.eslintrc`. -Testing so far has been limited; this is very much alpha software and it may not work well. So far, it is has seen limited use with the following configuration: +Example configuration (with React): ```json { @@ -28,10 +29,34 @@ Testing so far has been limited; this is very much alpha software and it may not "browser": true, "node": true, "es6": true - }, - "rules": { - "semi": ["error", "never"], - "react/require-render-return": 0 } } ``` + +When running `eslint` from the CLI, you must tell it to process LightScript file extensions: + +``` +$ eslint --ext .js,.lsc src +``` + +### Live Linting + +#### Visual Studio Code + +- Set up eslint for your project as above. Verify that eslint lints correctly from the CLI. +- Install the `ESLint` extension for VSCode: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint +- Tell VSCode to live-lint LightScript files by adding the following entry to your VSCode options (workspace or global): + ``` + "eslint.validate": ["javascript", "javascriptreact", "lightscript"] + ``` + +### Broken Rules + +The following lint rules are either buggy, broken, or do not make sense in the context of LightScript. They are disabled at the code level and will not run even if you enable them in your configuration. + +- `no-unexpected-multiline` +- `no-else-return` + +### Contributing + +Issues: https://github.com/wcjohnson/lightscript/issues diff --git a/babylon-to-espree/attachComments.js b/babylon-to-espree/attachComments.js index 4040ce7e..9fc9f339 100644 --- a/babylon-to-espree/attachComments.js +++ b/babylon-to-espree/attachComments.js @@ -1,3 +1,5 @@ +"use strict"; + // comment fixes module.exports = function (ast, comments, tokens) { if (comments.length) { diff --git a/babylon-to-espree/convertComments.js b/babylon-to-espree/convertComments.js new file mode 100644 index 00000000..19c6ce8c --- /dev/null +++ b/babylon-to-espree/convertComments.js @@ -0,0 +1,17 @@ +"use strict"; + +module.exports = function (comments) { + for (var i = 0; i < comments.length; i++) { + var comment = comments[i]; + if (comment.type === "CommentBlock") { + comment.type = "Block"; + } else if (comment.type === "CommentLine") { + comment.type = "Line"; + } + // sometimes comments don't get ranges computed, + // even with options.ranges === true + if (!comment.range) { + comment.range = [comment.start, comment.end]; + } + } +}; diff --git a/babylon-to-espree/convertTemplateType.js b/babylon-to-espree/convertTemplateType.js index c9537ddd..8b647c39 100644 --- a/babylon-to-espree/convertTemplateType.js +++ b/babylon-to-espree/convertTemplateType.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = function (tokens, tt) { var startingToken = 0; var currentToken = 0; diff --git a/babylon-to-espree/index.js b/babylon-to-espree/index.js index 401570b6..94e6832f 100644 --- a/babylon-to-espree/index.js +++ b/babylon-to-espree/index.js @@ -1,20 +1,36 @@ -exports.attachComments = require("./attachComments"); - -exports.toTokens = require("./toTokens"); -exports.toAST = require("./toAST"); - -exports.convertComments = function (comments) { - for (var i = 0; i < comments.length; i++) { - var comment = comments[i]; - if (comment.type === "CommentBlock") { - comment.type = "Block"; - } else if (comment.type === "CommentLine") { - comment.type = "Line"; - } - // sometimes comments don't get ranges computed, - // even with options.ranges === true - if (!comment.range) { - comment.range = [comment.start, comment.end]; - } - } +"use strict"; + +var attachComments = require("./attachComments"); +var convertComments = require("./convertComments"); +var toTokens = require("./toTokens"); +var toAST = require("./toAST"); + +module.exports = function (ast, traverse, tt, code) { + // remove EOF token, eslint doesn't use this for anything and it interferes + // with some rules see https://github.com/babel/babel-eslint/issues/2 + // todo: find a more elegant way to do this + ast.tokens.pop(); + + // convert tokens + ast.tokens = toTokens(ast.tokens, tt, code); + + // add comments + convertComments(ast.comments); + + // transform esprima and acorn divergent nodes + toAST(ast, traverse, code); + + // ast.program.tokens = ast.tokens; + // ast.program.comments = ast.comments; + // ast = ast.program; + + // remove File + ast.type = "Program"; + ast.sourceType = ast.program.sourceType; + ast.directives = ast.program.directives; + ast.body = ast.program.body; + delete ast.program; + delete ast._paths; + + attachComments(ast, ast.comments, ast.tokens); }; diff --git a/babylon-to-espree/toAST.js b/babylon-to-espree/toAST.js index fa155b73..235cf261 100644 --- a/babylon-to-espree/toAST.js +++ b/babylon-to-espree/toAST.js @@ -1,32 +1,22 @@ -var source; +"use strict"; + +var convertComments = require("./convertComments"); var cloneDeep = require("lodash/cloneDeep"); module.exports = function (ast, traverse, code) { - source = code; + var state = { source: code }; ast.range = [ast.start, ast.end]; - traverse(ast, astTransformVisitor); + traverse(ast, astTransformVisitor, null, state); }; -function changeToLiteral(node) { +function changeToLiteral(node, state) { node.type = "Literal"; if (!node.raw) { if (node.extra && node.extra.raw) { node.raw = node.extra.raw; } else { - node.raw = source.slice(node.start, node.end); - } - } -} - -function changeComments(nodeComments) { - for (var i = 0; i < nodeComments.length; i++) { - var comment = nodeComments[i]; - if (comment.type === "CommentLine") { - comment.type = "Line"; - } else if (comment.type === "CommentBlock") { - comment.type = "Block"; + node.raw = state.source.slice(node.start, node.end); } - comment.range = [comment.start, comment.end]; } } @@ -76,24 +66,40 @@ var astTransformVisitor = { } if (node.trailingComments) { - changeComments(node.trailingComments); + convertComments(node.trailingComments); } if (node.leadingComments) { - changeComments(node.leadingComments); + convertComments(node.leadingComments); } // make '_paths' non-enumerable (babel-eslint #200) Object.defineProperty(node, "_paths", { value: node._paths, writable: true }); }, - exit (path) { + exit (path, state) { var node = path.node; - [ - fixDirectives, - ].forEach((fixer) => { - fixer(path); - }); + // fixDirectives + if (path.isFunction() || path.isProgram()) { + var directivesContainer = node; + var body = node.body; + if (node.type !== "Program") { + directivesContainer = body; + body = body.body; + } + if (directivesContainer.directives) { + for (var i = directivesContainer.directives.length - 1; i >= 0; i--) { + var directive = directivesContainer.directives[i]; + directive.type = "ExpressionStatement"; + directive.expression = directive.value; + delete directive.value; + directive.expression.type = "Literal"; + changeToLiteral(directive.expression, state); + body.unshift(directive); + } + delete directivesContainer.directives; + } + } if (path.isJSXText()) { node.type = "Literal"; @@ -102,7 +108,7 @@ var astTransformVisitor = { if (path.isNumericLiteral() || path.isStringLiteral()) { - changeToLiteral(node); + changeToLiteral(node, state); } if (path.isBooleanLiteral()) { @@ -119,7 +125,11 @@ var astTransformVisitor = { if (path.isRegExpLiteral()) { node.type = "Literal"; node.raw = node.extra.raw; - node.value = {}; + try { + node.value = new RegExp(node.pattern, node.flags); + } catch (err) { + node.value = null; + } node.regex = { pattern: node.pattern, flags: node.flags @@ -135,7 +145,7 @@ var astTransformVisitor = { } if (path.isClassMethod() || path.isObjectMethod()) { - var code = source.slice(node.key.end, node.body.start); + var code = state.source.slice(node.key.end, node.body.start); var offset = code.indexOf("("); node.value = { @@ -242,7 +252,8 @@ var astTransformVisitor = { // template string range fixes if (path.isTemplateLiteral()) { - node.quasis.forEach((q) => { + for (var j = 0; j < node.quasis.length; j++) { + var q = node.quasis[j]; q.range[0] -= 1; if (q.tail) { q.range[1] += 1; @@ -255,34 +266,7 @@ var astTransformVisitor = { } else { q.loc.end.column += 2; } - }); + } } } }; - - -function fixDirectives (path) { - if (!(path.isProgram() || path.isFunction())) return; - - var node = path.node; - var directivesContainer = node; - var body = node.body; - - if (node.type !== "Program") { - directivesContainer = body; - body = body.body; - } - - if (!directivesContainer.directives) return; - - directivesContainer.directives.reverse().forEach((directive) => { - directive.type = "ExpressionStatement"; - directive.expression = directive.value; - delete directive.value; - directive.expression.type = "Literal"; - changeToLiteral(directive.expression); - body.unshift(directive); - }); - delete directivesContainer.directives; -} -// fixDirectives diff --git a/babylon-to-espree/toToken.js b/babylon-to-espree/toToken.js index 9ed93c9d..9535fb17 100644 --- a/babylon-to-espree/toToken.js +++ b/babylon-to-espree/toToken.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = function (token, tt, source) { var type = token.type; token.range = [token.start, token.end]; diff --git a/babylon-to-espree/toTokens.js b/babylon-to-espree/toTokens.js index 1f06d3e5..81ec9850 100644 --- a/babylon-to-espree/toTokens.js +++ b/babylon-to-espree/toTokens.js @@ -1,15 +1,18 @@ +"use strict"; + var convertTemplateType = require("./convertTemplateType"); var toToken = require("./toToken"); module.exports = function (tokens, tt, code) { // transform tokens to type "Template" convertTemplateType(tokens, tt); - var transformedTokens = tokens.filter((token) => { - return token.type !== "CommentLine" && token.type !== "CommentBlock"; - }); - for (var i = 0, l = transformedTokens.length; i < l; i++) { - transformedTokens[i] = toToken(transformedTokens[i], tt, code); + var transformedTokens = []; + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + if (token.type !== "CommentLine" && token.type !== "CommentBlock") { + transformedTokens.push(toToken(token, tt, code)); + } } return transformedTokens; diff --git a/eslint b/eslint deleted file mode 160000 index fdce86d2..00000000 --- a/eslint +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fdce86d24e30a31c0c819262b72ab6b454cb552a diff --git a/eslint-tester.js b/eslint-tester.js deleted file mode 100644 index 905a625d..00000000 --- a/eslint-tester.js +++ /dev/null @@ -1,6 +0,0 @@ -var ESLintTester = require("./eslint").RuleTester; - -console.log("Use babel-eslint for test suite"); -ESLintTester.setDefaultConfig({ - parser: "../../index" -}); diff --git a/index.js b/index.js index 91b999ee..df146474 100644 --- a/index.js +++ b/index.js @@ -1,35 +1,28 @@ var babylonToEspree = require("./babylon-to-espree"); -var pick = require("lodash.pickby"); -var isEmpty = require("lodash/isEmpty"); var Module = require("module"); var path = require("path"); var jsParse = require("babylon").parse; var babel = require("babel-core"); -var lscPlugin = require("@oigroup/babel-plugin-lightscript"); -var lscConfig = require("@oigroup/babel-plugin-lightscript/lib/config"); var t = require("babel-types"); -var tt = require("@oigroup/babylon-lightscript").tokTypes; +var tt = require("babylon").tokTypes; var traverse = require("babel-traverse").default; var codeFrame = require("babel-code-frame"); -var hasPatched = false; -var eslintOptions = {}; +var lscPlugin = require("@oigroup/babel-plugin-lightscript"); +var lscTooling = require("@oigroup/babel-plugin-lightscript/lib/tooling"); -function createModule(filename) { - var mod = new Module(filename); - mod.filename = filename; - mod.paths = Module._nodeModulePaths(path.dirname(filename)); - return mod; -} +var lightScriptDisabledRulesTable = { + "no-unexpected-multiline": true, + "no-else-return": true +}; -function monkeypatch() { - if (hasPatched) return; - hasPatched = true; +var hasPatched = false; +var eslintOptions = {}; - var eslintLoc; +function getModules() { try { // avoid importing a local copy of eslint, try to find a peer dependency - eslintLoc = Module._resolveFilename("eslint", module.parent); + var eslintLoc = Module._resolveFilename("eslint", module.parent); } catch (err) { try { // avoids breaking in jest where module.parent is undefined @@ -40,23 +33,44 @@ function monkeypatch() { } // get modules relative to what eslint will load - var eslintMod = createModule(eslintLoc); - // contains all the instances of estraverse so we can modify them if necessary - var estraverses = []; - // ESLint v1.9.0 uses estraverse directly to work around https://github.com/npm/npm/issues/9663 - var estraverseOfEslint = eslintMod.require("estraverse"); - estraverses.push(estraverseOfEslint); - Object.assign(estraverseOfEslint.VisitorKeys, t.VISITOR_KEYS); - - estraverses.forEach((estraverse) => { - estraverse.VisitorKeys.MethodDefinition.push("decorators"); - estraverse.VisitorKeys.Property.push("decorators"); - }); - - // monkeypatch escope - var escopeLoc = Module._resolveFilename("escope", eslintMod); - var escopeMod = createModule(escopeLoc); - var escope = require(escopeLoc); + var eslintMod = new Module(eslintLoc); + eslintMod.filename = eslintLoc; + eslintMod.paths = Module._nodeModulePaths(path.dirname(eslintLoc)); + + try { + var escope = eslintMod.require("eslint-scope"); + var Definition = eslintMod.require("eslint-scope/lib/definition").Definition; + var referencer = eslintMod.require("eslint-scope/lib/referencer"); + } catch (err) { + escope = eslintMod.require("escope"); + Definition = eslintMod.require("escope/lib/definition").Definition; + referencer = eslintMod.require("escope/lib/referencer"); + } + + var estraverse = eslintMod.require("estraverse"); + + if (referencer.__esModule) referencer = referencer.default; + + return { + eslintMod, + Definition, + escope, + estraverse, + referencer, + }; +} + +function monkeypatch(modules) { + var eslintMod = modules.eslintMod; + var Definition = modules.Definition; + var escope = modules.escope; + var estraverse = modules.estraverse; + var referencer = modules.referencer; + + Object.assign(estraverse.VisitorKeys, t.VISITOR_KEYS); + estraverse.VisitorKeys.MethodDefinition.push("decorators"); + estraverse.VisitorKeys.Property.push("decorators"); + var analyze = escope.analyze; escope.analyze = function (ast, opts) { opts.ecmaVersion = eslintOptions.ecmaVersion; @@ -69,28 +83,6 @@ function monkeypatch() { return results; }; - // monkeypatch escope/referencer - var referencerLoc; - try { - referencerLoc = Module._resolveFilename("./referencer", escopeMod); - } catch (err) { - throw new ReferenceError("couldn't resolve escope/referencer"); - } - var referencerMod = createModule(referencerLoc); - var referencer = require(referencerLoc); - if (referencer.__esModule) { - referencer = referencer.default; - } - - // reference Definition - var definitionLoc; - try { - definitionLoc = Module._resolveFilename("./definition", referencerMod); - } catch (err) { - throw new ReferenceError("couldn't resolve escope/definition"); - } - var Definition = require(definitionLoc).Definition; - // if there are decorators, then visit each function visitDecorators(node) { if (!node.decorators) { @@ -104,24 +96,29 @@ function monkeypatch() { } // iterate through part of t.VISITOR_KEYS - var visitorKeysMap = pick(t.VISITOR_KEYS, (k) => { - return t.FLIPPED_ALIAS_KEYS.Flow.concat([ - "ArrayPattern", - "ClassDeclaration", - "ClassExpression", - "FunctionDeclaration", - "FunctionExpression", - "Identifier", - "ObjectPattern", - "RestElement" - ]).indexOf(k) === -1; - }); + var flowFlippedAliasKeys = t.FLIPPED_ALIAS_KEYS.Flow.concat([ + "ArrayPattern", + "ClassDeclaration", + "ClassExpression", + "FunctionDeclaration", + "FunctionExpression", + "Identifier", + "ObjectPattern", + "RestElement" + ]); + var visitorKeysMap = Object.keys(t.VISITOR_KEYS).reduce(function(acc, key) { + var value = t.VISITOR_KEYS[key]; + if (flowFlippedAliasKeys.indexOf(value) === -1) { + acc[key] = value; + } + return acc; + }, {}); var propertyTypes = { // loops callProperties: { type: "loop", values: ["value"] }, indexers: { type: "loop", values: ["key", "value"] }, - properties: { type: "loop", values: ["value"] }, + properties: { type: "loop", values: ["argument", "value"] }, types: { type: "loop" }, params: { type: "loop" }, // single property @@ -156,7 +153,10 @@ function monkeypatch() { for (var j = 0; j < nodeProperty.length; j++) { if (Array.isArray(propertyType.values)) { for (var k = 0; k < propertyType.values.length; k++) { - checkIdentifierOrVisit.call(this, nodeProperty[j][propertyType.values[k]]); + var loopPropertyNode = nodeProperty[j][propertyType.values[k]]; + if (loopPropertyNode) { + checkIdentifierOrVisit.call(this, loopPropertyNode); + } } } else { checkIdentifierOrVisit.call(this, nodeProperty[j]); @@ -197,6 +197,9 @@ function monkeypatch() { for (var j = 0; j < node.typeParameters.params.length; j++) { var name = node.typeParameters.params[j]; scope.__define(name, new Definition("TypeParameter", name, name)); + if (name.typeAnnotation) { + checkIdentifierOrVisit.call(this, name); + } } scope.__define = function() { return parentScope.__define.apply(parentScope, arguments); @@ -210,7 +213,7 @@ function monkeypatch() { visitDecorators.call(this, node); var typeParamScope; if (node.typeParameters) { - typeParamScope = nestTypeParamScope(this.scopeManager, node); + typeParamScope = nestTypeParamScope.call(this, this.scopeManager, node); } // visit flow type: ClassImplements if (node.implements) { @@ -252,7 +255,7 @@ function monkeypatch() { referencer.prototype.visitFunction = function(node) { var typeParamScope; if (node.typeParameters) { - typeParamScope = nestTypeParamScope(this.scopeManager, node); + typeParamScope = nestTypeParamScope.call(this, this.scopeManager, node); } if (node.returnType) { checkIdentifierOrVisit.call(this, node.returnType); @@ -272,16 +275,12 @@ function monkeypatch() { } // set ArrayPattern/ObjectPattern visitor keys back to their original. otherwise // escope will traverse into them and include the identifiers within as declarations - estraverses.forEach((estraverse) => { - estraverse.VisitorKeys.ObjectPattern = ["properties"]; - estraverse.VisitorKeys.ArrayPattern = ["elements"]; - }); + estraverse.VisitorKeys.ObjectPattern = ["properties"]; + estraverse.VisitorKeys.ArrayPattern = ["elements"]; visitFunction.call(this, node); // set them back to normal... - estraverses.forEach((estraverse) => { - estraverse.VisitorKeys.ObjectPattern = t.VISITOR_KEYS.ObjectPattern; - estraverse.VisitorKeys.ArrayPattern = t.VISITOR_KEYS.ArrayPattern; - }); + estraverse.VisitorKeys.ObjectPattern = t.VISITOR_KEYS.ObjectPattern; + estraverse.VisitorKeys.ArrayPattern = t.VISITOR_KEYS.ArrayPattern; if (typeParamScope) { this.close(node); } @@ -315,11 +314,27 @@ function monkeypatch() { ); } + referencer.prototype.InterfaceDeclaration = function(node) { + createScopeVariable.call(this, node, node.id); + var typeParamScope; + if (node.typeParameters) { + typeParamScope = nestTypeParamScope.call(this, this.scopeManager, node); + } + // TODO: Handle mixins + for (var i = 0; i < node.extends.length; i++) { + visitTypeAnnotation.call(this, node.extends[i]); + } + visitTypeAnnotation.call(this, node.body); + if (typeParamScope) { + this.close(node); + } + }; + referencer.prototype.TypeAlias = function(node) { createScopeVariable.call(this, node, node.id); var typeParamScope; if (node.typeParameters) { - typeParamScope = nestTypeParamScope(this.scopeManager, node); + typeParamScope = nestTypeParamScope.call(this, this.scopeManager, node); } if (node.right) { visitTypeAnnotation.call(this, node.right); @@ -339,7 +354,7 @@ function monkeypatch() { var typeParamScope; if (node.typeParameters) { - typeParamScope = nestTypeParamScope(this.scopeManager, node); + typeParamScope = nestTypeParamScope.call(this, this.scopeManager, node); } if (typeParamScope) { this.close(node); @@ -352,18 +367,29 @@ function monkeypatch() { ts.prototype.getTokenBefore = returnNonceTokenPatch(ts.prototype.getTokenBefore); ts.prototype.getFirstToken = returnNonceTokenPatch(ts.prototype.getFirstToken); ts.prototype.getLastToken = returnNonceTokenPatch(ts.prototype.getLastToken); + var origGetFirstTokens = ts.prototype.getFirstTokens; + ts.prototype.getFirstTokens = function() { + if (!arguments[0] || arguments[0].type === "Nonce") return [createNonceToken()]; + var toks = origGetFirstTokens.apply(this, arguments); + if (toks == null || toks[0] == null) return [createNonceToken()]; else return toks; + }; // monkeypatch rules + // in eslint 4, rule getter is a class whereas it was an object in 3... + var emptyRule = function() { return {}; }; + emptyRule.create = function() { return {}; }; var rules = getModule(eslintMod, "./rules"); - var _get = rules.get; - rules.get = function get(ruleId) { - // disable no-unexpected-multiline, lsc compiler deals with this - if (ruleId === "no-unexpected-multiline") { - return function() { return {}; }; + var _get = rules.get || rules.prototype.get; + var nextGet = function get(ruleId) { + // disable invalid or broken rules + if (ruleId && lightScriptDisabledRulesTable[ruleId]) { + return emptyRule; } else { - return _get.call(rules, ruleId); + return _get.call(this || rules, ruleId); } }; + + if (rules.get) rules.get = nextGet; else rules.prototype.get = nextGet; } function createNonceToken() { @@ -409,11 +435,14 @@ exports.parse = function (code, options) { delete eslintOptions.globalReturn; } - try { - monkeypatch(); - } catch (err) { - console.error(err.stack); - process.exit(1); + if (!hasPatched) { + hasPatched = true; + try { + monkeypatch(getModules()); + } catch (err) { + console.error(err.stack); + process.exit(1); + } } return exports.parseNoPatch(code, options); @@ -421,6 +450,7 @@ exports.parse = function (code, options) { exports.parseNoPatch = function (code, options) { var opts = { + codeFrame: options.hasOwnProperty("codeFrame") ? options.codeFrame : true, sourceType: options.sourceType, allowImportExportEverywhere: options.allowImportExportEverywhere, // consistent with espree allowReturnOutsideFunction: true, @@ -449,40 +479,25 @@ exports.parseNoPatch = function (code, options) { // and come up with all this stuff. // (This setup step should also read .babelrc) var filePath = options.filePath; - var configOpts = lscConfig.parseConfigurationDirectives(code); - var useLsc = (configOpts.isLightScript || !filePath || /\.(lsc|lsx)/.test(filePath) || filePath === "unknown"); + var compilerConfig = lscTooling.getCompilerConfiguration(filePath, code, { __linter: true }); + var useLsc = compilerConfig.isLightScript; var ast; try { if (useLsc) { - if (isEmpty(configOpts)) { - configOpts = { - existential: true, - safeCall: true, - bangCall: true, - flippedImports: true, - noEnforcedSubscriptIndentation: true, - enhancedComprehension: true, - placeholderArgs: true, - pipeCall: true, - __linter: true - }; - } else { - configOpts.__linter = true; - } + tt = lscTooling.babylon.tokTypes; - const parserOpts = lscConfig.getParserOpts(configOpts); - parserOpts.sourceType = options.sourceType; - parserOpts.allowImportExportEverywhere = options.allowImportExportEverywhere; - parserOpts.allowReturnOutsideFunction = true; - parserOpts.allowSuperOutsideMethod = true; + ast = lscTooling.parse(compilerConfig, code, { + sourceType: options.sourceType, + allowImportExportEverywhere: options.allowImportExportEverywhere, + allowReturnOutsideFunction: true, + allowSuperOutsideMethod: true + }); - ast = parserOpts.parser(code, parserOpts); - // ast = lscParse(code, parserOpts); // run it through babel-plugin-lightscript to throw errors const { ast: nextAst } = babel.transformFromAst(ast, code, { code: false, - plugins: [[lscPlugin, configOpts]], + plugins: [[lscPlugin, compilerConfig]], }); nextAst.tokens = ast.tokens; ast = nextAst; @@ -492,45 +507,24 @@ exports.parseNoPatch = function (code, options) { } catch (err) { if (err.loc) { err.lineNumber = err.loc.line; - err.column = err.loc.column + 1; + err.column = err.loc.column; + + if (opts.codeFrame) { + err.lineNumber = err.loc.line; + err.column = err.loc.column + 1; - // remove trailing "(LINE:COLUMN)" acorn message and add in esprima syntax error message start - err.message = "Line " + err.lineNumber + ": " + err.message.replace(/ \((\d+):(\d+)\)$/, "") + - // add codeframe - "\n\n" + - codeFrame(code, err.lineNumber, err.column, { highlightCode: true }); + // remove trailing "(LINE:COLUMN)" acorn message and add in esprima syntax error message start + err.message = "Line " + err.lineNumber + ": " + err.message.replace(/ \((\d+):(\d+)\)$/, "") + + // add codeframe + "\n\n" + + codeFrame(code, err.lineNumber, err.column, { highlightCode: true }); + } } throw err; } - // remove EOF token, eslint doesn't use this for anything and it interferes with some rules - // see https://github.com/babel/babel-eslint/issues/2 for more info - // todo: find a more elegant way to do this - ast.tokens.pop(); - - // convert tokens - ast.tokens = babylonToEspree.toTokens(ast.tokens, tt, code); - - // add comments - babylonToEspree.convertComments(ast.comments); - - // transform esprima and acorn divergent nodes - babylonToEspree.toAST(ast, traverse, code); - - // ast.program.tokens = ast.tokens; - // ast.program.comments = ast.comments; - // ast = ast.program; - - // remove File - ast.type = "Program"; - ast.sourceType = ast.program.sourceType; - ast.directives = ast.program.directives; - ast.body = ast.program.body; - delete ast.program; - delete ast._paths; - - babylonToEspree.attachComments(ast, ast.comments, ast.tokens); + babylonToEspree(ast, traverse, tt, code); return ast; }; diff --git a/package.json b/package.json index 74da108b..59b097c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@oigroup/lightscript-eslint", - "version": "2.3.2", + "version": "3.0.0-beta.9", "description": "LightScript parser for ESLint, based on babel-eslint", "main": "index.js", "files": [ @@ -9,22 +9,18 @@ ], "repository": { "type": "git", - "url": "https://github.com/lightscript/lightscript-eslint.git" + "url": "https://github.com/wcjohnson/lightscript-eslint.git" }, "dependencies": { - "@oigroup/babel-plugin-lightscript": "2.3.2", - "@oigroup/babylon-lightscript": "2.3.2", - "babel-code-frame": "^6.22.0", - "babel-core": "^6.25.0", - "babel-traverse": "^6.25.0", - "babel-types": "^6.25.0", - "babylon": "^6.17.4", - "lodash": "^4.17.4", - "lodash.pickby": "^4.6.0" + "@oigroup/babel-plugin-lightscript": "3.0.0-beta.9", + "babel-code-frame": "^6.26.0", + "babel-core": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "lodash": "^4.17.4" }, "scripts": { - "bootstrap": "git submodule update --init && cd eslint && npm install", - "eslint": "cd eslint && mocha -c tests/lib/rules/*.js -r ../eslint-tester.js", "test": "npm run lint && npm run test-only", "test-only": "mocha", "test:debug": "node --inspect --debug-brk node_modules/.bin/_mocha", @@ -33,21 +29,21 @@ "preversion": "npm test", "changelog": "git log `git describe --tags --abbrev=0`..HEAD --pretty=format:' * %s (%an)' | grep -v 'Merge pull request'" }, - "homepage": "http://lightscript.org", + "homepage": "http://wcjohnson.github.io/lightscript", "license": "MIT", "engines": { "node": ">=4" }, "bugs": { - "url": "https://github.com/lightscript/lightscript-eslint/issues" + "url": "https://github.com/wcjohnson/lightscript/issues" }, "devDependencies": { "babel-eslint": "^7.2.1", "eslint": "^3.19.0", "eslint-config-babel": "^6.0.0", "eslint-plugin-babel": "^4.0.0", - "eslint-plugin-flowtype": "^2.20.0", - "espree": "^3.3.1", + "eslint-plugin-flowtype": "^2.30.3", + "espree": "^3.4.0", "mocha": "^3.2.0" } } diff --git a/test/babel-eslint.js b/test/babel-eslint.js index bc38183f..c09c9e08 100644 --- a/test/babel-eslint.js +++ b/test/babel-eslint.js @@ -2,7 +2,7 @@ var assert = require("assert"); var babelEslint = require(".."); var espree = require("espree"); var util = require("util"); -var unpad = require("../utils/unpad"); +var unpad = require("dedent"); // Checks if the source ast implements the target ast. Ignores extra keys on source ast function assertImplementsAST(target, source, path) { @@ -20,6 +20,8 @@ function assertImplementsAST(target, source, path) { var typeB = source === null ? "null" : typeof source; if (typeA !== typeB) { error(`have different types (${typeA} !== ${typeB}) (${target} !== ${source})`); + } else if (typeA === "object" && ["RegExp"].indexOf(target.constructor.name) !== -1 && target.constructor.name !== source.constructor.name) { + error(`object have different constructors (${target.constructor.name} !== ${source.constructor.name}`); } else if (typeA === "object") { var keysTarget = Object.keys(target); for (var i in keysTarget) { @@ -306,6 +308,18 @@ describe("babylon-to-esprima", () => { parseAndAssertSame("/affix-top|affix-bottom|affix|[a-z]/"); }); + it("regexp", () => { + parseAndAssertSame("const foo = /foo/;"); + }); + + it("regexp y flag", () => { + parseAndAssertSame("const foo = /foo/y;"); + }); + + it("regexp u flag", () => { + parseAndAssertSame("const foo = /foo/u;"); + }); + it("regexp in a template string", () => { parseAndAssertSame("`${/\\d/.exec(\"1\")[0]}`"); }); @@ -482,11 +496,12 @@ describe("babylon-to-esprima", () => { parseAndAssertSame("var a = function (...b) {}"); }); - it("SpreadOperator", () => { - parseAndAssertSame("var a = { b, ...c }"); - parseAndAssertSame("var a = [ a, ...b ]"); - parseAndAssertSame("var a = summa(...b)"); - }); + // LightScript: safe spread operator transform breaks this test. + // it("SpreadOperator", () => { + // parseAndAssertSame("var a = { b, ...c }"); + // parseAndAssertSame("var a = [ a, ...b ]"); + // parseAndAssertSame("var a = summa(...b)"); + // }); it("Async/Await", () => { parseAndAssertSame( diff --git a/test/fixtures/rules/syntax-error.js b/test/fixtures/rules/syntax-error.js new file mode 100644 index 00000000..6fa194a1 --- /dev/null +++ b/test/fixtures/rules/syntax-error.js @@ -0,0 +1,6 @@ +class ClassName { + constructor() { + + }, + aMethod() {} +} diff --git a/test/integration.js b/test/integration.js index 2814b4c3..c446ed34 100644 --- a/test/integration.js +++ b/test/integration.js @@ -200,4 +200,52 @@ function strictSuite () { // it }); // describe + describe("When \"codeFrame\"", () => { + // Strip chalk colors, these are not relevant for the test + const stripAnsi = (str) => str.replace( + /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, + "" + ); + + it("should display codeFrame when option is absent", (done) => { + lint({ + fixture: ["syntax-error"], + eslint: baseEslintOpts + }, (err, report) => { + if (err) return done(err); + assert(stripAnsi(report[0].message).indexOf("^\n 5 |") > -1); + done(); + }); + }); + + it("should display codeFrame when option is true", (done) => { + lint({ + fixture: ["syntax-error"], + eslint: Object.assign({}, baseEslintOpts, { + parserOptions: { + codeFrame: true + } + }) + }, (err, report) => { + if (err) return done(err); + assert(stripAnsi(report[0].message).indexOf("^\n 5 |") > -1); + done(); + }); + }); + + it("should not display codeFrame when option is false", (done) => { + lint({ + fixture: ["syntax-error"], + eslint: Object.assign({}, baseEslintOpts, { + parserOptions: { + codeFrame: false + } + }) + }, (err, report) => { + if (err) return done(err); + assert(stripAnsi(report[0].message).indexOf("^\n 5 |") === -1); + done(); + }); + }); + }); } diff --git a/test/non-regression.js b/test/non-regression.js index 1890edc6..a4ad1728 100644 --- a/test/non-regression.js +++ b/test/non-regression.js @@ -1,7 +1,7 @@ /*eslint-env mocha*/ "use strict"; var eslint = require("eslint"); -var unpad = require("../utils/unpad"); +var unpad = require("dedent"); function verifyAndAssertMessages(code, rules, expectedMessages, sourceType, overrideConfig) { var config = { @@ -31,7 +31,7 @@ function verifyAndAssertMessages(code, rules, expectedMessages, sourceType, over var messages = eslint.linter.verify(code, config); if (messages.length !== expectedMessages.length) { - throw new Error(`Expected ${expectedMessages.length} message(s), got ${messages.length} ${JSON.stringify(messages)}`); + throw new Error(`Expected ${expectedMessages.length} message(s), got ${messages.length}\n${JSON.stringify(messages, null, 2)}`); } messages.forEach((message, i) => { @@ -132,7 +132,7 @@ describe("verify", () => { }); it("ArrayComprehension", () => { verifyAndAssertMessages( - "[for const x of arr: x]", + "[...for const x of arr: x]", {}, [] ); @@ -150,7 +150,7 @@ x = if a: b else: c }); it("ObjectComprehension", () => { verifyAndAssertMessages( - "{for idx i, elem x in arr: (i, x)}", + "{...for idx i, elem x in arr: ({[i]: x})}", {}, [] ); @@ -217,7 +217,10 @@ x = if a: b else: c it("ExistentialExpression", () => { verifyAndAssertMessages( - "x?", + unpad(` +'use @oigroup/lightscript with existential' +x? + `), {}, [] ); @@ -282,12 +285,12 @@ a = b -> c it("crash 2", () => { verifyAndAssertMessages( unpad(` -x = 3 + x = 3 -Predicate() - + Predicate() - -match x: - | ~Predicate(): x + match x: + | ~Predicate(): x `), { "no-unexpected-multiline": 1 }, [] @@ -297,41 +300,41 @@ match x: it("crash regex-linting", () => { verifyAndAssertMessages( unpad(` -// comment -import { ReduxComponent, action, selector } from 'redux-components' -{ assign } = Object + // comment + import { ReduxComponent, action, selector } from 'redux-components' + { assign } = Object -initialState = { compiler: 'latest' } + initialState = { compiler: 'latest' } -export default class Config extends ReduxComponent: - static verbs = ['SET_COMPILER', 'SET_FEATURES', 'SET_PLUGINS', 'SET_OPTIONS'] + export default class Config extends ReduxComponent: + static verbs = ['SET_COMPILER', 'SET_FEATURES', 'SET_PLUGINS', 'SET_OPTIONS'] - reducer(state = initialState, action) -> - match action.type: - | this.SET_COMPILER: ({}~assign(state, { compiler: action.payload })) - | this.SET_FEATURES: ({}~assign(state, { features: action.payload })) - | this.SET_PLUGINS: ({}~assign(state, { plugins: action.payload })) - | this.SET_OPTIONS: ({}~assign(state, { options: action.payload })) - | else: state + reducer(state = initialState, action) -> + match action.type: + | this.SET_COMPILER: ({}~assign(state, { compiler: action.payload })) + | this.SET_FEATURES: ({}~assign(state, { features: action.payload })) + | this.SET_PLUGINS: ({}~assign(state, { plugins: action.payload })) + | this.SET_OPTIONS: ({}~assign(state, { options: action.payload })) + | else: state - @action({isDispatcher: true}) - setCompiler(value) -> - ({ type: this.SET_COMPILER, payload: value }) + @action({isDispatcher: true}) + setCompiler(value) -> + ({ type: this.SET_COMPILER, payload: value }) - @action({isDispatcher: true}) - setPlugins(value) -> - ({ type: this.SET_PLUGINS, payload: value }) + @action({isDispatcher: true}) + setPlugins(value) -> + ({ type: this.SET_PLUGINS, payload: value }) - @action({isDispatcher: true}) - setFeatures(value) -> - ({ type: this.SET_FEATURES, payload: value }) + @action({isDispatcher: true}) + setFeatures(value) -> + ({ type: this.SET_FEATURES, payload: value }) - @action({isDispatcher: true}) - setOptions(value) -> - ({ type: this.SET_OPTIONS, payload: value }) + @action({isDispatcher: true}) + setOptions(value) -> + ({ type: this.SET_OPTIONS, payload: value }) - @selector({isObservable: true}) - get(state) -> state + @selector({isObservable: true}) + get(state) -> state `), { "no-empty-character-class": 1, "no-regex-spaces": 1 }, [] @@ -341,8 +344,8 @@ export default class Config extends ReduxComponent: it("crash no-extra-semi", () => { verifyAndAssertMessages( unpad(` -class C: - get(state) -> state + class C: + get(state) -> state `), { "no-extra-semi": 1 }, [] @@ -352,43 +355,31 @@ class C: it("for idx unused", () => { verifyAndAssertMessages( unpad(` -for idx i, elem e in arr: - e + for idx i, elem e in arr: + e `), { "no-unused-vars": 1 }, - ["2:9 'i' is assigned a value but never used. no-unused-vars"] + ["1:9 'i' is assigned a value but never used. no-unused-vars"] ); }); it("no-unexpected-multiline false positive", () => { verifyAndAssertMessages( unpad(` -[for idx i, elem e in arr: - e -] + [...for idx i, elem e in arr: + e + ] `), { "no-unexpected-multiline": 1 }, [] ); }); - it("unmapped nodes 1", () => { - verifyAndAssertMessages( - unpad(` -TranspiledOutput = enhance(TranspiledOutput(props) -> - code = props.compiled?.js or props.compiled?.errorMessage -) - `), - {}, - [] - ); - }); - it("false positive no-unused-vars", () => { verifyAndAssertMessages( unpad(` -match x: - | with [a] if a > 2: true + match x: + | with [a] if a > 2: true `), { "no-unused-vars": 2 }, [] @@ -398,32 +389,37 @@ match x: it("config directives", () => { verifyAndAssertMessages( unpad(` -'use @oigroup/lightscript' -a -.b + 'use @oigroup/lightscript' + a + .b `), {}, - ["4:1 Parsing error: Indentation required."] + ["3:1 Parsing error: Indentation required."] ); }); it("placeholder args", () => { verifyAndAssertMessages( unpad(` -x = -> [_, ..._] -y = -> [_0, ..._] + 'use @oigroup/lightscript with placeholderArgs' + x = -> [_, ..._] + y = -> [_0, ..._] `), { "no-undef": 2 }, [] ); }); - it("pipe operator", () => { + it("no-else-return disabled", () => { verifyAndAssertMessages( unpad(` -1 |> (x -> x) |> (y -> y) + f() -> + if true: + { three: 3 } + else: + {} `), - {}, + { "no-else-return": 2 }, [] ); }); @@ -604,17 +600,133 @@ y = -> [_0, ..._] ); }); - // TODO: fix; for lightscript - xit("type parameters", () => { + it("interface declaration", () => { + verifyAndAssertMessages( + unpad(` + interface Foo {}; + interface Bar { + foo: Foo, + }; + `), + { "no-unused-vars": 1, "no-undef": 1 }, + [ "2:11 'Bar' is defined but never used. no-unused-vars" ] + ); + }); + + it("type parameter bounds (classes)", () => { + verifyAndAssertMessages( + unpad(` + import type {Foo, Foo2} from 'foo'; + import Base from 'base'; + class Log extends Base { + messages: {[T1]: T2}; + } + new Log(); + `), + { "no-unused-vars": 1, "no-undef": 1 }, + [ "3:34 'T4' is defined but never used. no-unused-vars" ] + ); + }); + + it("type parameter scope (classes)", () => { + verifyAndAssertMessages( + unpad(` + T; + class Foo {} + T; + new Foo(); + `), + { "no-unused-vars": 1, "no-undef": 1 }, + [ "1:1 'T' is not defined. no-undef", + "2:11 'T' is defined but never used. no-unused-vars", + "3:1 'T' is not defined. no-undef" ] + ); + }); + + it("type parameter bounds (interfaces)", () => { + verifyAndAssertMessages( + unpad(` + import type {Foo, Foo2, Bar} from ''; + interface Log extends Bar { + messages: {[T1]: T2}; + } + `), + { "no-unused-vars": 1, "no-undef": 1 }, + [ "2:11 'Log' is defined but never used. no-unused-vars", + "2:38 'T4' is defined but never used. no-unused-vars" ] + ); + }); + + it("type parameter scope (interfaces)", () => { + verifyAndAssertMessages( + unpad(` + T; + interface Foo {}; + T; + Foo; + `), + { "no-unused-vars": 1, "no-undef": 1 }, + [ "1:1 'T' is not defined. no-undef", + "2:15 'T' is defined but never used. no-unused-vars", + "3:1 'T' is not defined. no-undef" ] + ); + }); + + it("type parameter bounds (type aliases)", () => { + verifyAndAssertMessages( + unpad(` + import type {Foo, Foo2, Foo3} from 'foo'; + type Log = { + messages: {[T1]: T2}; + delay: Foo3; + }; + `), + { "no-unused-vars": 1, "no-undef": 1 }, + [ "2:6 'Log' is defined but never used. no-unused-vars", + "2:29 'T3' is defined but never used. no-unused-vars" ] + ); + }); + + it("type parameter scope (type aliases)", () => { + verifyAndAssertMessages( + unpad(` + T; + type Foo = {}; + T; + Foo; + `), + { "no-unused-vars": 1, "no-undef": 1 }, + [ "1:1 'T' is not defined. no-undef", + "2:10 'T' is defined but never used. no-unused-vars", + "3:1 'T' is not defined. no-undef" ] + ); + }); + + it("type parameter bounds (functions)", () => { verifyAndAssertMessages( unpad(` import type Foo from 'foo'; import type Foo2 from 'foo'; - function log(a: T1, b: T2) { return a + b; } - log(1, 2); + function log(a: T1, b: T2): T3 { return a + b; } + log(1, 2); `), { "no-unused-vars": 1, "no-undef": 1 }, - [] + [ "3:37 'T4' is defined but never used. no-unused-vars" ] + ); + }); + + it("type parameter scope (functions)", () => { + verifyAndAssertMessages( + unpad(` + T; + function log() {} + T; + log; + `), + { "no-unused-vars": 1, "no-undef": 1 }, + [ "1:1 'T' is not defined. no-undef", + "2:14 'T' is defined but never used. no-unused-vars", + "3:1 'T' is not defined. no-undef" ] ); }); @@ -759,7 +871,8 @@ y = -> [_0, ..._] unpad(` import type Promise from 'bluebird'; type Operation = () => Promise; - x: Operation; + let x = null; + (x: Operation); `), { "no-unused-vars": 1, "no-undef": 1 }, [] @@ -840,6 +953,18 @@ y = -> [_0, ..._] ); }); + it("supports type spreading", () => { + verifyAndAssertMessages( + unpad(` + type U = {}; + type T = {a: number, ...U, ...V}; + `), + { "no-undef": 1, "no-unused-vars": 1 }, + [ "2:6 'T' is defined but never used. no-unused-vars", + "2:31 'V' is not defined. no-undef" ] + ); + }); + it("1", () => { verifyAndAssertMessages( unpad(` diff --git a/utils/unpad.js b/utils/unpad.js deleted file mode 100644 index bf91100e..00000000 --- a/utils/unpad.js +++ /dev/null @@ -1,14 +0,0 @@ -// Remove padding from a string. -function unpad(str) { - const lines = str.split("\n"); - const m = lines[1] && lines[1].match(/^\s+/); - if (!m) { - return str; - } - const spaces = m[0].length; - return lines.map( - (line) => line.slice(spaces) - ).join("\n").trim(); -} - -module.exports = unpad; diff --git a/yarn.lock b/yarn.lock index 88528a6a..f75d2314 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8,21 +8,21 @@ acorn-jsx@^3.0.0: dependencies: acorn "^3.0.4" +acorn@4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.4.tgz#17a8d6a7a6c4ef538b814ec9abac2779293bf30a" + acorn@^3.0.4: version "3.3.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" -acorn@^4.0.1: - version "4.0.4" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.4.tgz#17a8d6a7a6c4ef538b814ec9abac2779293bf30a" - ajv-keywords@^1.0.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.0.tgz#c11e6859eafff83e0dafc416929472eca946aa2c" + version "1.5.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" ajv@^4.7.0: - version "4.10.4" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.10.4.tgz#c0974dd00b3464984892d6010aa9c2c945933254" + version "4.11.5" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.5.tgz#b6ee74657b993a01dce44b7944d56f485828d5bd" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" @@ -59,15 +59,7 @@ arrify@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" -babel-code-frame@^6.16.0: - version "6.20.0" - resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.20.0.tgz#b968f839090f9a8bc6d41938fb96cb84f7387b26" - dependencies: - chalk "^1.1.0" - esutils "^2.0.2" - js-tokens "^2.0.0" - -babel-code-frame@^6.20.0, babel-code-frame@^6.22.0: +babel-code-frame@^6.16.0, babel-code-frame@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" dependencies: @@ -75,115 +67,30 @@ babel-code-frame@^6.20.0, babel-code-frame@^6.22.0: esutils "^2.0.2" js-tokens "^3.0.0" -babel-core@^6.24.0: - version "6.24.0" - resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.24.0.tgz#8f36a0a77f5c155aed6f920b844d23ba56742a02" - dependencies: - babel-code-frame "^6.22.0" - babel-generator "^6.24.0" - babel-helpers "^6.23.0" - babel-messages "^6.23.0" - babel-register "^6.24.0" - babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.1" - babel-types "^6.23.0" - babylon "^6.11.0" - convert-source-map "^1.1.0" - debug "^2.1.1" - json5 "^0.5.0" - lodash "^4.2.0" - minimatch "^3.0.2" - path-is-absolute "^1.0.0" - private "^0.1.6" - slash "^1.0.0" - source-map "^0.5.0" - -babel-eslint@^7.2.1: - version "7.2.1" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-7.2.1.tgz#079422eb73ba811e3ca0865ce87af29327f8c52f" - dependencies: - babel-code-frame "^6.22.0" - babel-traverse "^6.23.1" - babel-types "^6.23.0" - babylon "^6.16.1" - -babel-generator@^6.24.0: - version "6.24.0" - resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.24.0.tgz#eba270a8cc4ce6e09a61be43465d7c62c1f87c56" - dependencies: - babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-types "^6.23.0" - detect-indent "^4.0.0" - jsesc "^1.3.0" - lodash "^4.2.0" - source-map "^0.5.0" - trim-right "^1.0.1" - -babel-helpers@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.23.0.tgz#4f8f2e092d0b6a8808a4bde79c27f1e2ecf0d992" +babel-eslint@^7.0.0: + version "7.1.1" + resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-7.1.1.tgz#8a6a884f085aa7060af69cfc77341c2f99370fb2" dependencies: - babel-runtime "^6.22.0" - babel-template "^6.23.0" + babel-code-frame "^6.16.0" + babel-traverse "^6.15.0" + babel-types "^6.15.0" + babylon "^6.13.0" + lodash.pickby "^4.6.0" -babel-messages@^6.23.0, babel-messages@^6.8.0: +babel-messages@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" dependencies: babel-runtime "^6.22.0" -babel-plugin-lightscript@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/babel-plugin-lightscript/-/babel-plugin-lightscript-0.4.0.tgz#d6d6f380217212d549befe2010ee8e1066f1f379" - dependencies: - babylon-lightscript "^0.4.1" - -babel-register@^6.24.0: - version "6.24.0" - resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.24.0.tgz#5e89f8463ba9970356d02eb07dabe3308b080cfd" - dependencies: - babel-core "^6.24.0" - babel-runtime "^6.22.0" - core-js "^2.4.0" - home-or-tmp "^2.0.0" - lodash "^4.2.0" - mkdirp "^0.5.1" - source-map-support "^0.4.2" - -babel-runtime@^6.20.0, babel-runtime@^6.22.0: +babel-runtime@^6.22.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b" dependencies: core-js "^2.4.0" regenerator-runtime "^0.10.0" -babel-template@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.23.0.tgz#04d4f270adbb3aa704a8143ae26faa529238e638" - dependencies: - babel-runtime "^6.22.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" - babylon "^6.11.0" - lodash "^4.2.0" - -babel-traverse@^6.15.0: - version "6.21.0" - resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.21.0.tgz#69c6365804f1a4f69eb1213f85b00a818b8c21ad" - dependencies: - babel-code-frame "^6.20.0" - babel-messages "^6.8.0" - babel-runtime "^6.20.0" - babel-types "^6.21.0" - babylon "^6.11.0" - debug "^2.2.0" - globals "^9.0.0" - invariant "^2.2.0" - lodash "^4.2.0" - -babel-traverse@^6.23.0, babel-traverse@^6.23.1: +babel-traverse@^6.15.0, babel-traverse@^6.23.1: version "6.23.1" resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.23.1.tgz#d3cb59010ecd06a97d81310065f966b699e14f48" dependencies: @@ -197,16 +104,7 @@ babel-traverse@^6.23.0, babel-traverse@^6.23.1: invariant "^2.2.0" lodash "^4.2.0" -babel-types@^6.15.0: - version "6.21.0" - resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.21.0.tgz#314b92168891ef6d3806b7f7a917fdf87c11a4b2" - dependencies: - babel-runtime "^6.20.0" - esutils "^2.0.2" - lodash "^4.2.0" - to-fast-properties "^1.0.1" - -babel-types@^6.21.0, babel-types@^6.23.0: +babel-types@^6.15.0, babel-types@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.23.0.tgz#bb17179d7538bad38cd0c9e115d340f77e7e9acf" dependencies: @@ -215,17 +113,9 @@ babel-types@^6.21.0, babel-types@^6.23.0: lodash "^4.2.0" to-fast-properties "^1.0.1" -babylon-lightscript@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/babylon-lightscript/-/babylon-lightscript-0.4.1.tgz#084413b7c46dc72abf2c8f9bcaa12927cea1ffde" - -babylon@^6.11.0, babylon@^6.13.0, babylon@^6.15.0: - version "6.15.0" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e" - -babylon@^6.16.1: - version "6.16.1" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3" +babylon@^6.13.0, babylon@^6.15.0, babylon@^6.17.0: + version "6.17.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.0.tgz#37da948878488b9c4e3c4038893fa3314b3fc932" balanced-match@^0.4.1: version "0.4.2" @@ -298,7 +188,7 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.4.6: +concat-stream@^1.5.2: version "1.6.0" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" dependencies: @@ -306,10 +196,6 @@ concat-stream@^1.4.6: readable-stream "^2.2.2" typedarray "^0.0.6" -convert-source-map@^1.1.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.4.0.tgz#e3dad195bf61bfe13a7a3c73e9876ec14a0268f3" - core-js@^2.4.0: version "2.4.1" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" @@ -318,11 +204,11 @@ core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" -d@^0.1.1, d@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/d/-/d-0.1.1.tgz#da184c535d18d8ee7ba2aa229b914009fae11309" +d@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f" dependencies: - es5-ext "~0.10.2" + es5-ext "^0.10.9" debug@2.2.0: version "2.2.0" @@ -331,11 +217,15 @@ debug@2.2.0: ms "0.7.1" debug@^2.1.1, debug@^2.2.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.0.tgz#bc596bcabe7617f11d9fa15361eded5608b8499b" + version "2.6.3" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.3.tgz#0f7eb8c30965ec08c72accfa0130c8b79984141d" dependencies: ms "0.7.2" +dedent@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" + deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" @@ -352,74 +242,68 @@ del@^2.0.2: pinkie-promise "^2.0.0" rimraf "^2.2.8" -detect-indent@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" - dependencies: - repeating "^2.0.0" - diff@1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" -doctrine@^1.2.2: - version "1.5.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa" +doctrine@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.0.tgz#c73d8d2909d22291e1a007a395804da8b665fe63" dependencies: esutils "^2.0.2" isarray "^1.0.0" -es5-ext@^0.10.7, es5-ext@^0.10.8, es5-ext@~0.10.11, es5-ext@~0.10.2, es5-ext@~0.10.7: - version "0.10.12" - resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.12.tgz#aa84641d4db76b62abba5e45fd805ecbab140047" +es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14: + version "0.10.15" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.15.tgz#c330a5934c1ee21284a7c081a86e5fd937c91ea6" dependencies: es6-iterator "2" es6-symbol "~3.1" -es6-iterator@2: - version "2.0.0" - resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.0.tgz#bd968567d61635e33c0b80727613c9cb4b096bac" +es6-iterator@2, es6-iterator@^2.0.1, es6-iterator@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.1.tgz#8e319c9f0453bf575d374940a655920e59ca5512" dependencies: - d "^0.1.1" - es5-ext "^0.10.7" - es6-symbol "3" + d "1" + es5-ext "^0.10.14" + es6-symbol "^3.1" es6-map@^0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/es6-map/-/es6-map-0.1.4.tgz#a34b147be224773a4d7da8072794cefa3632b897" - dependencies: - d "~0.1.1" - es5-ext "~0.10.11" - es6-iterator "2" - es6-set "~0.1.3" - es6-symbol "~3.1.0" - event-emitter "~0.3.4" - -es6-set@~0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.4.tgz#9516b6761c2964b92ff479456233a247dc707ce8" - dependencies: - d "~0.1.1" - es5-ext "~0.10.11" - es6-iterator "2" - es6-symbol "3" - event-emitter "~0.3.4" - -es6-symbol@3, es6-symbol@~3.1, es6-symbol@~3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.0.tgz#94481c655e7a7cad82eba832d97d5433496d7ffa" + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-map/-/es6-map-0.1.5.tgz#9136e0503dcc06a301690f0bb14ff4e364e949f0" + dependencies: + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-set "~0.1.5" + es6-symbol "~3.1.1" + event-emitter "~0.3.5" + +es6-set@~0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1" + dependencies: + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-symbol "3.1.1" + event-emitter "~0.3.5" + +es6-symbol@3.1.1, es6-symbol@^3.1, es6-symbol@^3.1.1, es6-symbol@~3.1, es6-symbol@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" dependencies: - d "~0.1.1" - es5-ext "~0.10.11" + d "1" + es5-ext "~0.10.14" es6-weak-map@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.1.tgz#0d2bbd8827eb5fb4ba8f97fbfea50d43db21ea81" + version "2.0.2" + resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" dependencies: - d "^0.1.1" - es5-ext "^0.10.8" - es6-iterator "2" - es6-symbol "3" + d "1" + es5-ext "^0.10.14" + es6-iterator "^2.0.1" + es6-symbol "^3.1.1" escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" @@ -438,27 +322,24 @@ eslint-config-babel@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/eslint-config-babel/-/eslint-config-babel-6.0.0.tgz#66feedf6ce6e04abe585cec1a65b5bcc96bed50a" -eslint-plugin-babel@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-babel/-/eslint-plugin-babel-4.0.0.tgz#a92114e2c493ac3034b030d7ecf96e174a76ef3f" - -eslint-plugin-flowtype@^2.4.0: - version "2.29.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.29.2.tgz#91b4fde0400c4c37ca4440b43bdbc95fc405bea9" +eslint-plugin-flowtype@^2.30.3: + version "2.30.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.30.3.tgz#57835d2c0ed388da7a2725803ec32af2f437c301" dependencies: lodash "^4.15.0" -eslint@^3.9.1: - version "3.13.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.13.1.tgz#564d2646b5efded85df96985332edd91a23bff25" +eslint@^3.18.0: + version "3.18.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.18.0.tgz#647e985c4ae71502d20ac62c109f66d5104c8a4b" dependencies: babel-code-frame "^6.16.0" chalk "^1.1.3" - concat-stream "^1.4.6" + concat-stream "^1.5.2" debug "^2.1.1" - doctrine "^1.2.2" + doctrine "^2.0.0" escope "^3.6.0" - espree "^3.3.1" + espree "^3.4.0" + esquery "^1.0.0" estraverse "^4.2.0" esutils "^2.0.2" file-entry-cache "^2.0.0" @@ -487,16 +368,22 @@ eslint@^3.9.1: text-table "~0.2.0" user-home "^2.0.0" -espree@^3.3.1: - version "3.3.2" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.3.2.tgz#dbf3fadeb4ecb4d4778303e50103b3d36c88b89c" +espree@^3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.4.0.tgz#41656fa5628e042878025ef467e78f125cb86e1d" dependencies: - acorn "^4.0.1" + acorn "4.0.4" acorn-jsx "^3.0.0" -esprima@^2.6.0: - version "2.7.3" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" +esprima@^3.1.1: + version "3.1.3" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" + +esquery@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.0.tgz#cfba8b57d7fba93f17298a8a006a04cda13d80fa" + dependencies: + estraverse "^4.0.0" esrecurse@^4.1.0: version "4.1.0" @@ -505,7 +392,7 @@ esrecurse@^4.1.0: estraverse "~4.1.0" object-assign "^4.0.1" -estraverse@^4.1.1, estraverse@^4.2.0: +estraverse@^4.0.0, estraverse@^4.1.1, estraverse@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" @@ -517,12 +404,12 @@ esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" -event-emitter@~0.3.4: - version "0.3.4" - resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.4.tgz#8d63ddfb4cfe1fae3b32ca265c4c720222080bb5" +event-emitter@~0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" dependencies: - d "~0.1.1" - es5-ext "~0.10.7" + d "1" + es5-ext "~0.10.14" exit-hook@^1.0.0: version "1.1.1" @@ -592,8 +479,8 @@ glob@^7.0.0, glob@^7.0.3, glob@^7.0.5: path-is-absolute "^1.0.0" globals@^9.0.0, globals@^9.14.0: - version "9.14.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-9.14.0.tgz#8859936af0038741263053b39d0e76ca241e4034" + version "9.16.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.16.0.tgz#63e903658171ec2d9f51b1d31de5e2b8dc01fb80" globby@^5.0.0: version "5.0.0" @@ -628,16 +515,9 @@ has-flag@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" -home-or-tmp@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" - dependencies: - os-homedir "^1.0.0" - os-tmpdir "^1.0.1" - ignore@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.2.0.tgz#8d88f03c3002a0ac52114db25d2c673b0bf1e435" + version "3.2.6" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.2.6.tgz#26e8da0644be0bb4cb39516f6c79f0e0f4ffe48c" imurmurhash@^0.1.4: version "0.1.4" @@ -682,12 +562,6 @@ invariant@^2.2.0: dependencies: loose-envify "^1.0.0" -is-finite@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" - dependencies: - number-is-nan "^1.0.0" - is-fullwidth-code-point@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" @@ -699,8 +573,8 @@ is-fullwidth-code-point@^2.0.0: resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" is-my-json-valid@^2.10.0: - version "2.15.0" - resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz#936edda3ca3c211fd98f3b2d3e08da43f7b2915b" + version "2.16.0" + resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz#f079dd9bfdae65ee2038aae8acbc86ab109e3693" dependencies: generate-function "^2.0.0" generate-object-property "^1.1.0" @@ -737,24 +611,16 @@ isarray@^1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" -js-tokens@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-2.0.0.tgz#79903f5563ee778cc1162e6dcf1a0027c97f9cb5" - js-tokens@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" js-yaml@^3.5.1: - version "3.7.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.7.0.tgz#5c967ddd837a9bfdca5f2de84253abe8a1c03b80" + version "3.8.2" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.2.tgz#02d3e2c0f6beab20248d412c352203827d786721" dependencies: argparse "^1.0.7" - esprima "^2.6.0" - -jsesc@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" + esprima "^3.1.1" json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: version "1.0.1" @@ -766,10 +632,6 @@ json3@3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" -json5@^0.5.0: - version "0.5.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" - jsonify@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" @@ -836,15 +698,15 @@ lodash.pickby@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.pickby/-/lodash.pickby-4.6.0.tgz#7dea21d8c18d7703a27c704c15d3b84a67e33aff" -lodash@^4.0.0, lodash@^4.15.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0: +lodash@^4.0.0, lodash@^4.15.0, lodash@^4.2.0, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" loose-envify@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.0.tgz#6b26248c42f6d4fa4b0d8542f78edfcde35642a8" + version "1.3.1" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" dependencies: - js-tokens "^2.0.0" + js-tokens "^3.0.0" minimatch@^3.0.2: version "3.0.3" @@ -899,8 +761,8 @@ number-is-nan@^1.0.0: resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" object-assign@^4.0.1, object-assign@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0" + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" once@^1.3.0: version "1.4.0" @@ -927,10 +789,6 @@ os-homedir@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" -os-tmpdir@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" @@ -939,6 +797,10 @@ path-is-inside@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" +path-parse@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" + pify@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" @@ -961,10 +823,6 @@ prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" -private@^0.1.6: - version "0.1.7" - resolved "https://registry.yarnpkg.com/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1" - process-nextick-args@~1.0.6: version "1.0.7" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" @@ -974,8 +832,8 @@ progress@^1.1.8: resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" readable-stream@^2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.2.tgz#a9e6fec3c7dda85f8bb1b3ba7028604556fc825e" + version "2.2.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.6.tgz#8b43aed76e71483938d12a8d46c6cf1a00b1f816" dependencies: buffer-shims "^1.0.0" core-util-is "~1.0.0" @@ -1000,14 +858,8 @@ rechoir@^0.6.2: resolve "^1.1.6" regenerator-runtime@^0.10.0: - version "0.10.1" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.1.tgz#257f41961ce44558b18f7814af48c17559f9faeb" - -repeating@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" - dependencies: - is-finite "^1.0.0" + version "0.10.3" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.3.tgz#8c4367a904b51ea62a908ac310bf99ff90a82a3e" require-uncached@^1.0.2: version "1.0.3" @@ -1021,8 +873,10 @@ resolve-from@^1.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" resolve@^1.1.6: - version "1.2.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.2.0.tgz#9589c3f2f6149d1417a40becc1663db6ec6bc26c" + version "1.3.2" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.3.2.tgz#1f0442c9e0cbb8136e87b9305f932f46c7f28235" + dependencies: + path-parse "^1.0.5" restore-cursor@^1.0.1: version "1.0.1" @@ -1032,8 +886,8 @@ restore-cursor@^1.0.1: onetime "^1.0.0" rimraf@^2.2.8: - version "2.5.4" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" + version "2.6.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" dependencies: glob "^7.0.5" @@ -1048,31 +902,17 @@ rx-lite@^3.1.2: resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102" shelljs@^0.7.5: - version "0.7.6" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.6.tgz#379cccfb56b91c8601e4793356eb5382924de9ad" + version "0.7.7" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.7.tgz#b2f5c77ef97148f4b4f6e22682e10bba8667cff1" dependencies: glob "^7.0.0" interpret "^1.0.0" rechoir "^0.6.2" -slash@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" - slice-ansi@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" -source-map-support@^0.4.2: - version "0.4.13" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.13.tgz#9782e6f7deb424d5f173327a1879eb46453bdcd4" - dependencies: - source-map "^0.5.6" - -source-map@^0.5.0, source-map@^0.5.6: - version "0.5.6" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" - sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" @@ -1143,10 +983,6 @@ to-fast-properties@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" -trim-right@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" - tryit@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb"