]> git.proxmox.com Git - pve-eslint.git/commitdiff
update to 7.1.0 sources
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 25 May 2020 11:00:39 +0000 (13:00 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 25 May 2020 11:00:39 +0000 (13:00 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
76 files changed:
Makefile
eslint/.github/ISSUE_TEMPLATE.md
eslint/.github/ISSUE_TEMPLATE/BUG_REPORT.md
eslint/.github/ISSUE_TEMPLATE/CHANGE.md
eslint/.github/ISSUE_TEMPLATE/NEW_RULE.md
eslint/.github/ISSUE_TEMPLATE/QUESTION.md
eslint/.github/ISSUE_TEMPLATE/RULE_CHANGE.md
eslint/.github/ISSUE_TEMPLATE/SECURITY.md
eslint/.github/PULL_REQUEST_TEMPLATE.md
eslint/CHANGELOG.md
eslint/README.md
eslint/SUPPORT.md
eslint/docs/developer-guide/contributing/changes.md
eslint/docs/developer-guide/contributing/new-rules.md
eslint/docs/developer-guide/contributing/reporting-bugs.md
eslint/docs/developer-guide/nodejs-api.md
eslint/docs/maintainer-guide/governance.md
eslint/docs/rules/arrow-parens.md
eslint/docs/rules/max-lines-per-function.md
eslint/docs/rules/no-array-constructor.md
eslint/docs/rules/no-loss-of-precision.md [new file with mode: 0644]
eslint/docs/rules/no-return-await.md
eslint/lib/init/config-initializer.js
eslint/lib/linter/linter.js
eslint/lib/rules/accessor-pairs.js
eslint/lib/rules/arrow-parens.js
eslint/lib/rules/block-spacing.js
eslint/lib/rules/callback-return.js
eslint/lib/rules/global-require.js
eslint/lib/rules/handle-callback-err.js
eslint/lib/rules/index.js
eslint/lib/rules/linebreak-style.js
eslint/lib/rules/max-lines-per-function.js
eslint/lib/rules/no-buffer-constructor.js
eslint/lib/rules/no-loss-of-precision.js [new file with mode: 0644]
eslint/lib/rules/no-mixed-requires.js
eslint/lib/rules/no-new-func.js
eslint/lib/rules/no-new-require.js
eslint/lib/rules/no-new-symbol.js
eslint/lib/rules/no-path-concat.js
eslint/lib/rules/no-process-env.js
eslint/lib/rules/no-process-exit.js
eslint/lib/rules/no-restricted-modules.js
eslint/lib/rules/no-sync.js
eslint/lib/rules/one-var-declaration-per-line.js
eslint/lib/rules/padded-blocks.js
eslint/lib/rules/rest-spread-spacing.js
eslint/lib/rules/semi-spacing.js
eslint/lib/rules/utils/ast-utils.js
eslint/lib/source-code/source-code.js
eslint/messages/extend-config-missing.txt
eslint/messages/no-config-found.txt
eslint/messages/plugin-conflict.txt
eslint/messages/plugin-missing.txt
eslint/messages/whitespace-found.txt
eslint/package.json
eslint/tests/fixtures/parsers/linter-test-parsers.js
eslint/tests/fixtures/parsers/non-js-parser.js [new file with mode: 0644]
eslint/tests/lib/init/config-initializer.js
eslint/tests/lib/linter/linter.js
eslint/tests/lib/rules/arrow-parens.js
eslint/tests/lib/rules/block-spacing.js
eslint/tests/lib/rules/comma-dangle.js
eslint/tests/lib/rules/linebreak-style.js
eslint/tests/lib/rules/max-lines-per-function.js
eslint/tests/lib/rules/no-loss-of-precision.js [new file with mode: 0644]
eslint/tests/lib/rules/no-new-func.js
eslint/tests/lib/rules/no-new-symbol.js
eslint/tests/lib/rules/one-var-declaration-per-line.js
eslint/tests/lib/rules/padded-blocks.js
eslint/tests/lib/rules/require-await.js
eslint/tests/lib/rules/rest-spread-spacing.js
eslint/tests/lib/rules/semi-spacing.js
eslint/tests/lib/rules/semi.js
eslint/tests/lib/rules/utils/ast-utils.js
eslint/tools/rule-types.json

index 05bc8e07aa4a54eed31af4a4785a78c289619f58..2dc6bd25573c095bea657d9855a90031e8f5aeed 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,7 @@ DSC=${PACKAGE}_${DEB_VERSION_UPSTREAM_REVISION}.dsc
 
 SRCDIR=src
 UPSTREAM=eslint
-UPSTREAMTAG=v7.0.0
+UPSTREAMTAG=v7.1.0
 BUILDSRC=${UPSTREAM}-${UPSTREAMTAG}
 
 all: ${DEB}
index 2e492e48c19bb753219c518270645d345d0455b3..44fe78004d025e78fbd73a5b80182c7d5ef08271 100644 (file)
@@ -1,12 +1,13 @@
 <!--
-    ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct).
+    ESLint adheres to the Open JS Foundation Code of Conduct:
+    https://eslint.org/conduct
 
     This template is for bug reports. If you are here for another reason, please see below:
 
     1. To propose a new rule: https://eslint.org/docs/developer-guide/contributing/new-rules
     2. To request a rule change: https://eslint.org/docs/developer-guide/contributing/rule-changes
     3. To request a change that is not a bug fix, rule change, or new rule: https://eslint.org/docs/developer-guide/contributing/changes
-    4. If you have any questions, please stop by our chatroom: https://gitter.im/eslint/eslint
+    4. If you have any questions, please stop by our chatroom: https://eslint.org/chat
 
     Note that leaving sections blank will make it difficult for us to troubleshoot and we may have to close the issue.
 -->
@@ -50,4 +51,3 @@
 **What did you expect to happen?**
 
 **What actually happened? Please include the actual, raw output from ESLint.**
-
index dd7c10d14061d9eb2fe7a7d79845cc6f17a7e7b7..175871510d784721779bf3b44c4c2a5df693a520 100644 (file)
@@ -8,18 +8,20 @@ assignees: ''
 ---
 
 <!--
-    ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct).
+    ESLint adheres to the Open JS Foundation Code of Conduct:
+    https://eslint.org/conduct
 
     This template is for bug reports. If you are here for another reason, please see below:
 
     1. To propose a new rule: https://eslint.org/docs/developer-guide/contributing/new-rules
     2. To request a rule change: https://eslint.org/docs/developer-guide/contributing/rule-changes
     3. To request a change that is not a bug fix, rule change, or new rule: https://eslint.org/docs/developer-guide/contributing/changes
-    4. If you have any questions, please stop by our chatroom: https://gitter.im/eslint/eslint
+    4. If you have any questions, please stop by our chatroom: https://eslint.org/chat
 
     Note that leaving sections blank will make it difficult for us to troubleshoot and we may have to close the issue.
 -->
 
+
 **Tell us about your environment**
 
 <!--
index 6cf64254222084ef44b632138b80041a3c7630f1..ef8437a4ef69edd9bd4522a09ef85d33b592d66a 100644 (file)
@@ -8,18 +8,21 @@ assignees: ''
 ---
 
 <!--
-    ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct).
+    ESLint adheres to the Open JS Foundation Code of Conduct:
+    https://eslint.org/conduct
 
     This template is for requesting a change that is not a bug fix, rule change, or new rule. If you are here for another reason, please see below:
 
     1. To report a bug: https://eslint.org/docs/developer-guide/contributing/reporting-bugs
     2. To request a rule change: https://eslint.org/docs/developer-guide/contributing/rule-changes
     3. To propose a new rule: https://eslint.org/docs/developer-guide/contributing/new-rules
-    4. If you have any questions, please stop by our chatroom: https://gitter.im/eslint/eslint
+    4. If you have any questions, please stop by our chatroom: https://eslint.org/chat
 
     Note that leaving sections blank will make it difficult for us to troubleshoot and we may have to close the issue.
 -->
 
+
+
 **The version of ESLint you are using.**
 
 
index 598e89c0f9a182cb856915ecd604da9fe9845a2a..31dfc8cb38bfa8f566d34093b2ae53e980479771 100644 (file)
@@ -8,25 +8,31 @@ assignees: ''
 ---
 
 <!--
-    ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct).
+    ESLint adheres to the Open JS Foundation Code of Conduct:
+    https://eslint.org/conduct
 
     This template is for new rule proposals. If you are proposing a new rule, please continue on. If you are here for another reason, please see below:
 
     1. To report a bug: https://eslint.org/docs/developer-guide/contributing/reporting-bugs
     2. To request a rule change: https://eslint.org/docs/developer-guide/contributing/rule-changes
     3. To request a change that is not a bug fix, rule change, or new rule: https://eslint.org/docs/developer-guide/contributing/changes
-    4. If you have any questions, please stop by our chatroom: https://gitter.im/eslint/eslint
+    4. If you have any questions, please stop by our chatroom: https://eslint.org/chat
 
     Note that leaving sections blank will make it difficult for us to troubleshoot and we may have to close the issue.
 -->
 
+
 **Please describe what the rule should do:**
 
+
+**What new ECMAScript feature does this rule relate to?**
+
+<!-- New rules must be related to ECMAScript features added within the last 12 months -->
+
 **What category of rule is this? (place an "X" next to just one item)**
 
 [ ] Warns about a potential error (problem)
 [ ] Suggests an alternate way of doing something (suggestion)
-[ ] Enforces code style (layout)
 [ ] Other (please specify:)
 
 **Provide 2-3 code examples that this rule will warn about:**
index 375e2170ac9f2281cf4d0aa0420cbc963528b995..cbcfec682392e40c41ab32a66eceb1c68d4dbd41 100644 (file)
@@ -1,6 +1,6 @@
 ---
 name: "â›” Question"
-about: Please go to https://gitter.im/eslint/eslint
+about: Please go to https://eslint.org/chat
 title: ''
 labels: ''
 assignees: ''
@@ -8,13 +8,13 @@ assignees: ''
 ---
 
 <!--
-    ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct).
-
+    ESLint adheres to the Open JS Foundation Code of Conduct:
+    https://eslint.org/conduct
 
     Please do not use GitHub for asking questions. Instead,
     please visit our chatroom:
 
-        https://gitter.im/eslint/eslint
+        https://eslint.org/chat
 
     Or our mailing list:
 
index d735010f60d3219189cee1b6072777722a526cf4..ced29fac37b6bf90b40b40845e8b93eb16d48f1a 100644 (file)
@@ -8,18 +8,20 @@ assignees: ''
 ---
 
 <!--
-    ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct).
+    ESLint adheres to the Open JS Foundation Code of Conduct:
+    https://eslint.org/conduct
 
     This template is for requesting a rule change. If you are here for another reason, please see below:
 
     1. To report a bug: https://eslint.org/docs/developer-guide/contributing/reporting-bugs
     2. To propose a new rule: https://eslint.org/docs/developer-guide/contributing/new-rules
     3. To request a change that is not a bug fix, rule change, or new rule: https://eslint.org/docs/developer-guide/contributing/changes
-    4. If you have any questions, please stop by our chatroom: https://gitter.im/eslint/eslint
+    4. If you have any questions, please stop by our chatroom: https://eslint.org/chat
 
     Note that leaving sections blank will make it difficult for us to troubleshoot and we may have to close the issue.
 -->
 
+
 **What rule do you want to change?**
 
 **Does this change cause the rule to produce more or fewer warnings?**
index c04f525365a636540ccd97f6139af8c76a7edcbf..d69aa7f8c1023a008d084af3c719554377c9a6fc 100644 (file)
@@ -8,7 +8,8 @@ assignees: ''
 ---
 
 <!--
-    ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct).
+    ESLint adheres to the Open JS Foundation Code of Conduct:
+    https://eslint.org/conduct
 
 
     STOP! Please do not use GitHub for filing security issues.
index 792638ec54ec6729d2a05cdb2a14e999900faed4..6a57d0e6b65caf2ee59e696e30b7c422f58db0c0 100644 (file)
@@ -7,7 +7,6 @@
 #### Prerequisites checklist
 
 - [ ] I have read the [contributing guidelines](https://github.com/eslint/eslint/blob/master/CONTRIBUTING.md).
-- [ ] The team has reached consensus on the changes proposed in this pull request. If not, I understand that the evaluation process will begin with this pull request and won't be merged until the team has reached consensus.
 
 #### What is the purpose of this pull request? (put an "X" next to an item)
 
index 3ab86f0c0d30254fc7cef426e70c5063d1b73e8c..3321fe6db254c7548d39f2d6642050293acfc2d1 100644 (file)
@@ -1,3 +1,32 @@
+v7.1.0 - May 22, 2020
+
+* [`a93083a`](https://github.com/eslint/eslint/commit/a93083af89c6f9714dcdd4a7f27c8655a0b0dba6) Fix: astUtils.getNextLocation returns invalid location after CRLF (#13275) (Milos Djermanovic)
+* [`df01af1`](https://github.com/eslint/eslint/commit/df01af184d93b3d64b37cee786cad59bd0d7aacb) Update: padded-blocks loc position changes (refs #12334) (#13328) (Anix)
+* [`bd3f092`](https://github.com/eslint/eslint/commit/bd3f092efa579944f75bfbc277b35f85e6d966ed) Fix: max-lines-per-function flagging arrow IIFEs (fixes #13332) (#13336) (cherryblossom000)
+* [`25462b2`](https://github.com/eslint/eslint/commit/25462b23eac4ed1ded97eeae6187b5d8baa58e78) Update: block-spacing changed loc for extra (refs #12334) (#13314) (Anix)
+* [`de0aab9`](https://github.com/eslint/eslint/commit/de0aab95005f172db72196fc3fd18e91ee9a5880) Fix: report end loc in one-var-declaration-per-line (refs #12334) (#13326) (YeonJuan)
+* [`1710296`](https://github.com/eslint/eslint/commit/1710296082083602a904b080908657bb431fb56c) Fix: no-new-symbol false positive with Symbol as an argument (#13337) (Milos Djermanovic)
+* [`cc01451`](https://github.com/eslint/eslint/commit/cc014514c29626e556acb0a528e3478b3725e284) Fix: arrow-parens no reporting for comments inside (fixes #12995) (#13312) (Anix)
+* [`a195141`](https://github.com/eslint/eslint/commit/a19514193a42f4f00732559ff828b33a6ec9d7c5) Update: reporting location for semi-spacing (refs #12334) (#13285) (Anix)
+* [`e3e4c41`](https://github.com/eslint/eslint/commit/e3e4c41ab625a5af8d4614d1c6d32c656f104f6b) Fix: fix false positives of no-new-func (#13333) (Pig Fang)
+* [`611c676`](https://github.com/eslint/eslint/commit/611c676dfd671013d81810724f184e2a9c5ad5d7) Docs: Update new rules policies (#13343) (Nicholas C. Zakas)
+* [`3a5fbb3`](https://github.com/eslint/eslint/commit/3a5fbb3d634be688615950c0a5fa8aead6ff08b5) Chore: correct fileoverview doc in accessor-pairs (#13335) (YeonJuan)
+* [`b0a6b81`](https://github.com/eslint/eslint/commit/b0a6b8134e3b399beeb69432a02232a1037f7c46) Update: Improve report location for rest-spread-spacing (refs #12334) (#13313) (Milos Djermanovic)
+* [`68c8ee3`](https://github.com/eslint/eslint/commit/68c8ee3ab70187972aef4c4e866bcf29da70a207) Fix: Stop path analyzer on unknown nodes (#13305) (Ilya Volodin)
+* [`89e1081`](https://github.com/eslint/eslint/commit/89e10811c4df666216aae58bff5f855cd9df738b) Update: Improve report location for linebreak-style (refs #12334) (#13317) (Milos Djermanovic)
+* [`0891379`](https://github.com/eslint/eslint/commit/08913798b4ec420b261b8fbc470504f9f248c840) Docs: Document the "correct" way to build an array with values (#13246) (Ed S)
+* [`88127d7`](https://github.com/eslint/eslint/commit/88127d74d56b88cc5a0758856995716050021131) Chore: remove checkbox from PR template prerequesites (#13330) (Kai Cataldo)
+* [`c636d57`](https://github.com/eslint/eslint/commit/c636d5708c461a8ff1ea55e5df56d4f76f9c4044) New: no-loss-of-precision (fixes #11279) (#12747) (jmoore914)
+* [`72a4e10`](https://github.com/eslint/eslint/commit/72a4e1044592057c4a3f39dbb1dbe61b00ea8af6) Chore: Mark SourceCode getComments() method as deprecated (fixes #13293) (#13296) (SuperOleg39)
+* [`7f14846`](https://github.com/eslint/eslint/commit/7f1484690665b4f4b9cd9680ca8bb7b5cf56e48a) Docs: fix broken link in Node.js API docs (#13307) (Kai Cataldo)
+* [`02aeba1`](https://github.com/eslint/eslint/commit/02aeba19afb301140514097235a9f2a00a9acb2a) Sponsors: Sync README with website (ESLint Jenkins)
+* [`1f17533`](https://github.com/eslint/eslint/commit/1f175338cba29960aab67a540f516051f9d428c8) Docs: Gitter -> Discord URL (refs #13039) (#13308) (Nicholas C. Zakas)
+* [`82a448a`](https://github.com/eslint/eslint/commit/82a448a7deff24e9207f60dfe77622c00102bd99) Docs: improve documentation of no-return-await (#13215) (Linus Unnebäck)
+* [`742941d`](https://github.com/eslint/eslint/commit/742941d7fdc3fd79ff8c5d2588413e0d3a5a525b) Update: added typescript-eslint/recommended configs for init (#13235) (Anix)
+* [`3d03df0`](https://github.com/eslint/eslint/commit/3d03df08c8000403a85baffe2a000287f3335114) Sponsors: Sync README with website (ESLint Jenkins)
+* [`f44a6b4`](https://github.com/eslint/eslint/commit/f44a6b4fd92602af8e2c75d5852f796ec064aa8e) Chore: fix invalid syntax in require-await tests (#13277) (Milos Djermanovic)
+* [`2c778fb`](https://github.com/eslint/eslint/commit/2c778fb6e31b7943bb27a47a6e15dcbfd8336f39) Fix: remove custom plugins from replacedBy metadata (#13274) (Kai Cataldo)
+* [`0db3b1d`](https://github.com/eslint/eslint/commit/0db3b1d5cc5e4e1de21462679581b7a4d89ff36e) Sponsors: Sync README with website (ESLint Jenkins)
 v7.0.0 - May 8, 2020
 
 * [`b98d8bd`](https://github.com/eslint/eslint/commit/b98d8bda4630fe8278c5aa2b6650630770568fe5) Upgrade: eslint-release@2.0.0 (#13271) (Kai Cataldo)
index 427544bad668c08671ee7497e7b2296e0df2207b..1838496e238d0f27ac5a530cc59189e4dcc877a3 100644 (file)
@@ -5,7 +5,6 @@
 <br />
 [![Open Collective Backers](https://img.shields.io/opencollective/backers/eslint)](https://opencollective.com/eslint)
 [![Open Collective Sponsors](https://img.shields.io/opencollective/sponsors/eslint)](https://opencollective.com/eslint)
-[![Join the chat at https://gitter.im/eslint/eslint](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/eslint/eslint?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
 [![Follow us on Twitter](https://img.shields.io/twitter/follow/geteslint?label=Follow&style=social)](https://twitter.com/intent/user?screen_name=geteslint)
 
 # ESLint
@@ -18,7 +17,7 @@
 [Code of Conduct](https://js.foundation/community/code-of-conduct) |
 [Twitter](https://twitter.com/geteslint) |
 [Mailing List](https://groups.google.com/group/eslint) |
-[Chat Room](https://gitter.im/eslint/eslint)
+[Chat Room](https://eslint.org/chat)
 
 ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. In many ways, it is similar to JSLint and JSHint with a few exceptions:
 
@@ -134,7 +133,7 @@ Once a language feature has been adopted into the ECMAScript standard (stage 4 a
 
 ### Where to ask for help?
 
-Join our [Mailing List](https://groups.google.com/group/eslint) or [Chatroom](https://gitter.im/eslint/eslint).
+Join our [Mailing List](https://groups.google.com/group/eslint) or [Chatroom](https://eslint.org/chat).
 
 ## <a name="releases"></a>Releases
 
@@ -252,7 +251,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
 <h3>Gold Sponsors</h3>
 <p><a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/e780cd4/logo.png" alt="Shopify" height="96"></a> <a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a></p><h3>Silver Sponsors</h3>
 <p><a href="https://www.ampproject.org/"><img src="https://images.opencollective.com/amp/c8a3b25/logo.png" alt="AMP Project" height="64"></a></p><h3>Bronze Sponsors</h3>
-<p><a href="https://www.casinotop.com/"><img src="https://images.opencollective.com/casinotop-com/10fd95b/logo.png" alt="CasinoTop.com" height="32"></a> <a href="https://www.casinotopp.net/"><img src="https://images.opencollective.com/casino-topp/1dd399a/logo.png" alt="Casino Topp" height="32"></a> <a href="https://writersperhour.com/urgent-essay-writing-service"><img src="https://images.opencollective.com/writersperhour/5787d4b/logo.png" alt="Writers Per Hour" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://cooltechzone.com/netflix-vpn"><img src="https://images.opencollective.com/vpn-netflix/4850160/logo.png" alt="vpn netflix" height="32"></a> <a href="https://www.kasinot.fi"><img src="https://images.opencollective.com/kasinot-fi/e09aa2e/logo.png" alt="Kasinot.fi" height="32"></a> <a href="https://www.pelisivut.com"><img src="https://images.opencollective.com/pelisivut/04f08f2/logo.png" alt="Pelisivut" height="32"></a> <a href="https://www.nettikasinot.org"><img src="https://images.opencollective.com/nettikasinot-org/bbd887f/logo.png" alt="Nettikasinot.org" height="32"></a> <a href="https://www.bonus.com.de/freispiele"><img src="https://images.opencollective.com/bonusfinder-deutschland/646169e/logo.png" alt="BonusFinder Deutschland" height="32"></a> <a href="https://medium.com/@niksundin/best-web-design-companies-1872e445775f"><img src="https://images.opencollective.com/top-web-design-agencies/d92d747/logo.png" alt="Top Web Design Agencies" height="32"></a> <a href="https://www.bugsnag.com/platforms?utm_source=Open Collective&utm_medium=Website&utm_content=open-source&utm_campaign=2019-community&utm_term="><img src="https://images.opencollective.com/bugsnag-stability-monitoring/c2cef36/logo.png" alt="Bugsnag Stability Monitoring" height="32"></a> <a href="https://mixpanel.com"><img src="https://images.opencollective.com/mixpanel/cd682f7/logo.png" alt="Mixpanel" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/0b37d14/logo.png" alt="Free Icons by Icons8" height="32"></a> <a href="https://uxplanet.org/top-ui-ux-design-agencies-user-experience-firms-8c54697e290"><img src="https://images.opencollective.com/ui-ux-design-agencies/cae5dfe/logo.png" alt="UI UX Design Agencies" height="32"></a> <a href="https://clay.global"><img src="https://images.opencollective.com/clayglobal/2468f34/logo.png" alt="clay" height="32"></a> <a href="https://discordapp.com"><img src="https://images.opencollective.com/discordapp/7e3d9a9/logo.png" alt="Discord" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://tekhattan.com"><img src="https://images.opencollective.com/tekhattan/bc73c28/logo.png" alt="TekHattan" height="32"></a> <a href="https://www.marfeel.com/"><img src="https://images.opencollective.com/marfeel/4b88e30/logo.png" alt="Marfeel" height="32"></a> <a href="http://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a></p>
+<p><a href="https://bruce.agency"><img src="https://images.opencollective.com/brucemade/0c70c59/logo.png" alt="Bruce" height="32"></a> <a href="https://edubirdie.com/"><img src="https://images.opencollective.com/edubirdie2/b1d51ab/logo.png" alt="EduBirdie" height="32"></a> <a href="https://www.casinotop.com/"><img src="https://images.opencollective.com/casinotop-com/10fd95b/logo.png" alt="CasinoTop.com" height="32"></a> <a href="https://www.casinotopp.net/"><img src="https://images.opencollective.com/casino-topp/1dd399a/logo.png" alt="Casino Topp" height="32"></a> <a href="https://writersperhour.com/urgent-essay-writing-service"><img src="https://images.opencollective.com/writersperhour/5787d4b/logo.png" alt="Writers Per Hour" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://cooltechzone.com/netflix-vpn"><img src="https://images.opencollective.com/vpn-netflix/4850160/logo.png" alt="vpn netflix" height="32"></a> <a href="https://www.kasinot.fi"><img src="https://images.opencollective.com/kasinot-fi/e09aa2e/logo.png" alt="Kasinot.fi" height="32"></a> <a href="https://www.pelisivut.com"><img src="https://images.opencollective.com/pelisivut/04f08f2/logo.png" alt="Pelisivut" height="32"></a> <a href="https://www.nettikasinot.org"><img src="https://images.opencollective.com/nettikasinot-org/bbd887f/logo.png" alt="Nettikasinot.org" height="32"></a> <a href="https://www.bonus.com.de/freispiele"><img src="https://images.opencollective.com/bonusfinder-deutschland/646169e/logo.png" alt="BonusFinder Deutschland" height="32"></a> <a href="https://www.bugsnag.com/platforms?utm_source=Open Collective&utm_medium=Website&utm_content=open-source&utm_campaign=2019-community&utm_term="><img src="https://images.opencollective.com/bugsnag-stability-monitoring/c2cef36/logo.png" alt="Bugsnag Stability Monitoring" height="32"></a> <a href="https://mixpanel.com"><img src="https://images.opencollective.com/mixpanel/cd682f7/logo.png" alt="Mixpanel" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/0b37d14/logo.png" alt="Free Icons by Icons8" height="32"></a> <a href="https://discordapp.com"><img src="https://images.opencollective.com/discordapp/7e3d9a9/logo.png" alt="Discord" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://tekhattan.com"><img src="https://images.opencollective.com/tekhattan/bc73c28/logo.png" alt="TekHattan" height="32"></a> <a href="https://www.marfeel.com/"><img src="https://images.opencollective.com/marfeel/4b88e30/logo.png" alt="Marfeel" height="32"></a> <a href="http://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a></p>
 <!--sponsorsend-->
 
 ## <a name="technology-sponsors"></a>Technology Sponsors
index 08942601a15dbabf4d017425db57d9908d57a19b..1eb428dd9f90ebd9572d02ec751b2e0db103df89 100644 (file)
@@ -1 +1 @@
-If you have a question about how to use ESLint, please ask it in our [Gitter channel](https://gitter.im/eslint/eslint).
+If you have a question about how to use ESLint, please ask it in our [chatroom](https://eslint.org/chat).
index 6b5f1590107fea17842c8de7274bed12b0f93daa..3c13051c39cb8ddc10ffd7f348863ab9622c4084 100644 (file)
@@ -14,4 +14,4 @@ If you're requesting a change to a rule, it's helpful to include this informatio
 
 Please include as much detail as possible to help us properly address your issue. If we need to triage issues and constantly ask people for more detail, that's time taken away from actually fixing issues. Help us be as efficient as possible by including a lot of detail in your issues.
 
-**Note:** If you just have a question that won't necessarily result in a change to ESLint, such as asking how something works or how to contribute, please use the [mailing list](https://groups.google.com/group/eslint) or [chat](https://gitter.im/eslint/eslint) instead of filing an issue.
+**Note:** If you just have a question that won't necessarily result in a change to ESLint, such as asking how something works or how to contribute, please use the [mailing list](https://groups.google.com/group/eslint) or [chat](https://eslint.org/chat) instead of filing an issue.
index a3513773d24a4a8afc3813f33a06d8a3838c24e4..e4a19e486f5688845ba1964a1ec2bbf5547b7ec1 100644 (file)
@@ -2,7 +2,7 @@
 
 ESLint is all about rules. For most of the project's lifetime, we've had over 200 rules, and that list continues to grow. However, we can't just accept any proposed rule because all rules need to work cohesively together. As such, we have some guidelines around which rules can be part of the ESLint core and which are better off as custom rules and plugins.
 
-**Note:** As of 2016, we accept only rules that are deemed extremely important for inclusion. We prefer that new rules be implemented in plugins.
+**Note:** As of 2020, we only accept rules related to new ECMAScript features. We prefer that new rules be implemented in plugins.
 
 ## Core Rule Guidelines
 
@@ -29,7 +29,7 @@ In order for a rule to be accepted in the ESLint core, it must:
 
 1. Fulfill all the criteria listed in the "Core Rule Guidelines" section
 1. Have an ESLint team member champion inclusion of the rule
-1. Be very important for ESLint users because it either catches a serious problem or allows styling of code in accordance with a popular style guide
+1. Be related to an ECMAScript feature that has reached stage 4 in the preceding 12 months
 
 Keep in mind that we have over 200 rules, and that is daunting both for end users and the ESLint team (who has to maintain them). As such, any new rules must be deemed of high importance to be considered for inclusion in ESLint.
 
index 81f5e8562e7e6091ddb197de9a4c0ed19ca36113..4dd0da02f08cfc2b06a992841aa9e3b6e1ac1695 100644 (file)
@@ -4,4 +4,4 @@ If you think you've found a bug in ESLint, please [create a new issue](https://g
 
 Please include as much detail as possible to help us properly address your issue. If we need to triage issues and constantly ask people for more detail, that's time taken away from actually fixing issues. Help us be as efficient as possible by including a lot of detail in your issues.
 
-**Note:** If you just have a question that won't necessarily result in a change to ESLint, such as asking how something works or how to contribute, please use the [mailing list](https://groups.google.com/group/eslint) or [chat](https://gitter.im/eslint/eslint) instead of filing an issue.
+**Note:** If you just have a question that won't necessarily result in a change to ESLint, such as asking how something works or how to contribute, please use the [mailing list](https://groups.google.com/group/eslint) or [chat](https://eslint.org/chat) instead of filing an issue.
index e980445447c567113aaa2a6a8550405984240f00..991a1cbcd26ee706f7b38d9b97b7266beba3fd74 100644 (file)
@@ -1378,7 +1378,7 @@ ruleTester.run("my-rule", myRule, {
 
 ---
 
-[configuration object]: ../user-guide/configuring.md
+[configuration object]: ../user-guide/configuring
 [builtin-formatters]: https://eslint.org/docs/user-guide/formatters/
 [thirdparty-formatters]: https://www.npmjs.com/search?q=eslintformatter
 [eslint]: #eslint-class
index b393d194452e64cb0856ad9c1d99cc9fe7a98df6..06280a5b14ec105a4f0986ced350b1389c1b3cac 100644 (file)
@@ -48,7 +48,7 @@ A Committer who shows an above-average level of contribution to the project, par
 1. Send email congratulating the new committer and confirming that they would like to accept. This should also outline the responsibilities of a committer with a link to the maintainer guide.
 1. Add the GitHub user to the "ESLint Team" team
 1. Add committer email to the ESLint team mailing list
-1. Invite to Gitter team chatroom
+1. Invite to Discord team channel
 1. Tweet congratulations to the new committer from the ESLint Twitter account
 
 ### Reviewers
@@ -113,7 +113,7 @@ A Reviewer is invited to become a TSC member by existing TSC members. A nominati
 1. Add the GitHub user to the "ESLint TSC" GitHub team
 1. Set the GitHub user to be have the "Owner" role for the ESLint organization
 1. Send a welcome email with a link to the [maintainer guide](./) and the [npm 2FA guide](./npm-2fa).
-1. Invite to the Gitter TSC chatroom
+1. Invite to the Discord TSC channel
 1. Make the TSC member an admin on the ESLint team mailing list
 1. Add the TSC member to the recurring TSC meeting event on Google Calendar
 1. Add the TSC member as an admin to ESLint Twitter Account on Tweetdeck
@@ -122,8 +122,7 @@ A Reviewer is invited to become a TSC member by existing TSC members. A nominati
 
 #### TSC Meetings
 
-The TSC meets every other week in the [TSC Meeting](https://gitter.im/eslint/tsc-meetings) chatroom. The meeting is run by
-a designated moderator approved by the TSC.
+The TSC meets every other week in the TSC Meeting [Discord](https://eslint.org/chat) channel. The meeting is run by a designated moderator approved by the TSC.
 
 Items are added to the TSC agenda which are considered contentious or
 are modifications of governance, contribution policy, TSC membership,
index fbcdbaeff93b9c5da85e97d9dba6750f88881f75..e4fc5845af2412c0efb9d93bfa3bf235b96fa6a3 100644 (file)
@@ -159,6 +159,9 @@ Examples of **incorrect** code for this rule with the `"as-needed"` option:
 a.then((foo) => {});
 a.then((foo) => a);
 a((foo) => { if (true) {} });
+const f = /** @type {number} */(a) => a + a;
+const g = /* comment */ (a) => a + a;
+const h = (a) /* comment */ => a + a;
 ```
 
 Examples of **correct** code for this rule with the `"as-needed"` option:
@@ -177,6 +180,9 @@ a.then(foo => { if (true) {} });
 (a = 10) => a;
 ([a, b]) => a;
 ({a, b}) => a;
+const f = (/** @type {number} */a) => a + a;
+const g = (/* comment */ a) => a + a;
+const h = (a /* comment */) => a + a;
 ```
 
 ### requireForBlockBody
index 22ffea79f41329efaf090fa9915a6f3f4d92bfe1..d3b13615b42f28ed770b0e0fe25ff2eef8611e10 100644 (file)
@@ -165,6 +165,10 @@ Examples of **incorrect** code for this rule with the `{ "IIFEs": true }` option
 (function(){
     var x = 0;
 }());
+
+(() => {
+    var x = 0;
+})();
 ```
 
 Examples of **correct** code for this rule with the `{ "IIFEs": true }` option:
@@ -174,6 +178,10 @@ Examples of **correct** code for this rule with the `{ "IIFEs": true }` option:
 (function(){
     var x = 0;
 }());
+
+(() => {
+    var x = 0;
+})();
 ```
 
 ## When Not To Use It
index 863f56d0b77a4a5a797ce897b57cb8b71923ac9d..22fbde64ef05faef1230f5e2f8e05480cf646910 100644 (file)
@@ -16,10 +16,6 @@ Examples of **incorrect** code for this rule:
 /*eslint no-array-constructor: "error"*/
 
 Array(0, 1, 2)
-```
-
-```js
-/*eslint no-array-constructor: "error"*/
 
 new Array(0, 1, 2)
 ```
@@ -30,12 +26,10 @@ Examples of **correct** code for this rule:
 /*eslint no-array-constructor: "error"*/
 
 Array(500)
-```
-
-```js
-/*eslint no-array-constructor: "error"*/
 
 new Array(someOtherArray.length)
+
+[0, 1, 2]
 ```
 
 ## When Not To Use It
diff --git a/eslint/docs/rules/no-loss-of-precision.md b/eslint/docs/rules/no-loss-of-precision.md
new file mode 100644 (file)
index 0000000..e1fcc4e
--- /dev/null
@@ -0,0 +1,32 @@
+# Disallow Number Literals That Lose Precision (no-loss-of-precision)
+
+This rule would disallow the use of number literals that immediately lose precision at runtime when converted to a JS `Number` due to 64-bit floating-point rounding.
+
+## Rule Details
+
+In JS, `Number`s are stored as double-precision floating-point numbers according to the [IEEE 754 standard](https://en.wikipedia.org/wiki/IEEE_754). Because of this, numbers can only retain accuracy up to a certain amount of digits. If the programmer enters additional digits, those digits will be lost in the conversion to the `Number` type and will result in unexpected behavior.
+
+Examples of **incorrect** code for this rule:
+
+```js
+/*eslint no-loss-of-precision: "error"*/
+
+const x = 9007199254740993
+const x = 5123000000000000000000000000001
+const x = 1230000000000000000000000.0
+const x = .1230000000000000000000000
+const x = 0X20000000000001
+```
+
+Examples of **correct** code for this rule:
+
+```js
+/*eslint no-loss-of-precision: "error"*/
+
+const x = 12345
+const x = 123.456
+const x = 123e34
+const x = 12300000000000000000000000
+const x = 0x1FFFFFFFFFFFFF
+const x = 9007199254740991
+```
index a79a46d8483de31473b677a78aaae5e31778c827..b1c60f092ae4b8694750f215c4e83ffa6ebc3c1c 100644 (file)
@@ -1,6 +1,8 @@
 # Disallows unnecessary `return await` (no-return-await)
 
-Inside an `async function`, `return await` is seldom useful. Since the return value of an `async function` is always wrapped in `Promise.resolve`, `return await` doesn’t actually do anything except add extra time before the overarching Promise resolves or rejects. The only valid exception is if `return await` is used in a try/catch statement to catch errors from another Promise-based function.
+Using `return await` inside an `async function` keeps the current function in the call stack until the Promise that is being awaited has resolved, at the cost of an extra microtask before resolving the outer Promise. `return await` can also be used in a try/catch statement to catch errors from another function that returns a Promise.
+
+You can avoid the extra microtask by not awaiting the return value, with the trade off of the function no longer being a part of the stack trace if an error is thrown asynchronously from the Promise being returned. This can make debugging more difficult.
 
 ## Rule Details
 
@@ -42,7 +44,11 @@ In the last example the `await` is necessary to be able to catch errors thrown f
 
 ## When Not To Use It
 
-If you want to use `await` to denote a value that is a thenable, even when it is not necessary; or if you do not want the performance benefit of avoiding `return await`, you can turn off this rule.
+There are a few reasons you might want to turn this rule off:
+
+- If you want to use `await` to denote a value that is a thenable
+- If you do not want the performance benefit of avoiding `return await`
+- If you want the functions to show up in stack traces (useful for debugging purposes)
 
 ## Further Reading
 
index 70f0a250ad1dd69ab0412271920c9b4e615f1c80..00f17678fc66c0e3bdd1c2dabc6711c30be153bc 100644 (file)
@@ -326,6 +326,7 @@ function processAnswers(answers) {
     }
     if (answers.typescript && config.extends.includes("eslint:recommended")) {
         config.extends.push("plugin:@typescript-eslint/eslint-recommended");
+        config.extends.push("plugin:@typescript-eslint/recommended");
     }
 
     // normalize extends
index 1d021d1e82e7fb1a62a72f63219554b9ff11af15..f9f38790b3c4d1aa3bc3407ef45f52f656247291 100644 (file)
@@ -938,7 +938,8 @@ function runRules(sourceCode, configuredRules, ruleMapper, parserOptions, parser
         });
     });
 
-    const eventGenerator = new CodePathAnalyzer(new NodeEventGenerator(emitter));
+    // only run code path analyzer if the top level node is "Program", skip otherwise
+    const eventGenerator = nodeQueue[0].node.type === "Program" ? new CodePathAnalyzer(new NodeEventGenerator(emitter)) : new NodeEventGenerator(emitter);
 
     nodeQueue.forEach(traversalInfo => {
         currentNode = traversalInfo.node;
index 02548258ca2e28e8c86796bd8801e011b3123f77..cf994ad257446bb7ff27b121a9b9ff7b8976d9b7 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * @fileoverview Rule to flag wrapping non-iife in parens
+ * @fileoverview Rule to enforce getter and setter pairs in objects and classes.
  * @author Gyandeep Singh
  */
 
index dc3c3825791a6821c3b6ca77943f02d8ee1051f6..bfd32447ac6f3d9dec93fd9f5ce5b2df874b1068 100644 (file)
@@ -105,10 +105,27 @@ module.exports = {
                 ], `${shouldAddSpaceForAsync ? " " : ""}${paramToken.value}`);
             }
 
+            /**
+             * Checks whether there are comments inside the params or not.
+             * @returns {boolean} `true` if there are comments inside of parens, else `false`
+             */
+            function hasCommentsInParens() {
+                if (astUtils.isOpeningParenToken(firstTokenOfParam)) {
+                    const closingParenToken = sourceCode.getTokenAfter(node.params[0], astUtils.isClosingParenToken);
+
+                    return closingParenToken && sourceCode.commentsExistBetween(firstTokenOfParam, closingParenToken);
+                }
+                return false;
+
+            }
+
+            if (hasCommentsInParens()) {
+                return;
+            }
+
             // "as-needed", { "requireForBlockBody": true }: x => x
             if (
                 requireForBlockBody &&
-                node.params.length === 1 &&
                 node.params[0].type === "Identifier" &&
                 !node.params[0].typeAnnotation &&
                 node.body.type !== "BlockStatement" &&
@@ -144,7 +161,6 @@ module.exports = {
 
             // "as-needed": x => x
             if (asNeeded &&
-                node.params.length === 1 &&
                 node.params[0].type === "Identifier" &&
                 !node.params[0].typeAnnotation &&
                 !node.returnType
@@ -178,7 +194,7 @@ module.exports = {
         }
 
         return {
-            ArrowFunctionExpression: parens
+            "ArrowFunctionExpression[params.length=1]": parens
         };
     }
 };
index c6ed44a2798a6be0aa49bf09c09fbda3b3466545..c4b30b0b70b9839bd145fdd36c5e947d0d1d1a72 100644 (file)
@@ -102,9 +102,18 @@ module.exports = {
 
             // Check.
             if (!isValid(openBrace, firstToken)) {
+                let loc = openBrace.loc;
+
+                if (messageId === "extra") {
+                    loc = {
+                        start: openBrace.loc.end,
+                        end: firstToken.loc.start
+                    };
+                }
+
                 context.report({
                     node,
-                    loc: openBrace.loc.start,
+                    loc,
                     messageId,
                     data: {
                         location: "after",
@@ -120,9 +129,17 @@ module.exports = {
                 });
             }
             if (!isValid(lastToken, closeBrace)) {
+                let loc = closeBrace.loc;
+
+                if (messageId === "extra") {
+                    loc = {
+                        start: lastToken.loc.end,
+                        end: closeBrace.loc.start
+                    };
+                }
                 context.report({
                     node,
-                    loc: closeBrace.loc.start,
+                    loc,
                     messageId,
                     data: {
                         location: "before",
index 5df792d436341e449cb9b2648ea659df6bee64ca..ba13c9a648176856a61d0c2b12c16cf88fbc153c 100644 (file)
@@ -12,7 +12,7 @@ module.exports = {
     meta: {
         deprecated: true,
 
-        replacedBy: ["node/callback-return"],
+        replacedBy: [],
 
         type: "suggestion",
 
index 9bd073b88546d6307d0630a9b9485883b2975c9e..469c0175d2556b5bdb4a319174e554729867fd9f 100644 (file)
@@ -50,7 +50,7 @@ module.exports = {
     meta: {
         deprecated: true,
 
-        replacedBy: ["node/global-require"],
+        replacedBy: [],
 
         type: "suggestion",
 
index 8ad63bbd53a77b29f4c98137ef57d54c22cfe721..b92490ad16bdafda8592f0ce7282d640773dad7e 100644 (file)
@@ -13,7 +13,7 @@ module.exports = {
     meta: {
         deprecated: true,
 
-        replacedBy: ["node/handle-callback-err"],
+        replacedBy: [],
 
         type: "suggestion",
 
index 7f563eb2ebfb9624c3109c9506880c6aca272ed7..9e5571dd97d4cca4b07af50b8e11c31b574719cf 100644 (file)
@@ -148,6 +148,7 @@ module.exports = new LazyLoadingRuleMap(Object.entries({
     "no-lone-blocks": () => require("./no-lone-blocks"),
     "no-lonely-if": () => require("./no-lonely-if"),
     "no-loop-func": () => require("./no-loop-func"),
+    "no-loss-of-precision": () => require("./no-loss-of-precision"),
     "no-magic-numbers": () => require("./no-magic-numbers"),
     "no-misleading-character-class": () => require("./no-misleading-character-class"),
     "no-mixed-operators": () => require("./no-mixed-operators"),
index 078eaf2cd268d29b9e844624d8355515a3ed9062..b3b393ead77de84984d2bdf7044ed4c0547da61a 100644 (file)
@@ -86,8 +86,14 @@ module.exports = {
                     context.report({
                         node,
                         loc: {
-                            line: i,
-                            column: sourceCode.lines[i - 1].length
+                            start: {
+                                line: i,
+                                column: sourceCode.lines[i - 1].length
+                            },
+                            end: {
+                                line: i + 1,
+                                column: 0
+                            }
                         },
                         messageId: expectedLF ? "expectedLF" : "expectedCRLF",
                         fix: createFix(range, expectedLFChars)
index 03539fae470078ebb250f7585ca91d98000b7806..aa423a60a1faaa3c6b1dba20cf50d47e7db4d4a9 100644 (file)
@@ -134,7 +134,7 @@ module.exports = {
          * @returns {boolean} True if it's an IIFE
          */
         function isIIFE(node) {
-            return node.type === "FunctionExpression" && node.parent && node.parent.type === "CallExpression" && node.parent.callee === node;
+            return (node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") && node.parent && node.parent.type === "CallExpression" && node.parent.callee === node;
         }
 
         /**
index 5dce047b92312efad66a70692c8f71503c7c5958..152dda0ceae2cec2998371c925e0f4a74adb7479 100644 (file)
@@ -12,7 +12,7 @@ module.exports = {
     meta: {
         deprecated: true,
 
-        replacedBy: ["node/no-deprecated-api"],
+        replacedBy: [],
 
         type: "problem",
 
diff --git a/eslint/lib/rules/no-loss-of-precision.js b/eslint/lib/rules/no-loss-of-precision.js
new file mode 100644 (file)
index 0000000..b95677c
--- /dev/null
@@ -0,0 +1,198 @@
+/**
+ * @fileoverview Rule to flag numbers that will lose significant figure precision at runtime
+ * @author Jacob Moore
+ */
+
+"use strict";
+
+//------------------------------------------------------------------------------
+// Rule Definition
+//------------------------------------------------------------------------------
+
+module.exports = {
+    meta: {
+        type: "problem",
+
+        docs: {
+            description: "disallow literal numbers that lose precision",
+            category: "Possible Errors",
+            recommended: false,
+            url: "https://eslint.org/docs/rules/no-loss-of-precision"
+        },
+        schema: [],
+        messages: {
+            noLossOfPrecision: "This number literal will lose precision at runtime."
+        }
+    },
+
+    create(context) {
+
+        /**
+         * Returns whether the node is number literal
+         * @param {Node} node the node literal being evaluated
+         * @returns {boolean} true if the node is a number literal
+         */
+        function isNumber(node) {
+            return typeof node.value === "number";
+        }
+
+
+        /**
+         * Checks whether the number is  base ten
+         * @param {ASTNode} node the node being evaluated
+         * @returns {boolean} true if the node is in base ten
+         */
+        function isBaseTen(node) {
+            const prefixes = ["0x", "0X", "0b", "0B", "0o", "0O"];
+
+            return prefixes.every(prefix => !node.raw.startsWith(prefix)) &&
+            !/^0[0-7]+$/u.test(node.raw);
+        }
+
+        /**
+         * Checks that the user-intended non-base ten number equals the actual number after is has been converted to the Number type
+         * @param {Node} node the node being evaluated
+         * @returns {boolean} true if they do not match
+         */
+        function notBaseTenLosesPrecision(node) {
+            const rawString = node.raw.toUpperCase();
+            let base = 0;
+
+            if (rawString.startsWith("0B")) {
+                base = 2;
+            } else if (rawString.startsWith("0X")) {
+                base = 16;
+            } else {
+                base = 8;
+            }
+
+            return !rawString.endsWith(node.value.toString(base).toUpperCase());
+        }
+
+        /**
+         * Adds a decimal point to the numeric string at index 1
+         * @param {string} stringNumber the numeric string without any decimal point
+         * @returns {string} the numeric string with a decimal point in the proper place
+         */
+        function addDecimalPointToNumber(stringNumber) {
+            return `${stringNumber.slice(0, 1)}.${stringNumber.slice(1)}`;
+        }
+
+        /**
+         * Returns the number stripped of leading zeros
+         * @param {string} numberAsString the string representation of the number
+         * @returns {string} the stripped string
+         */
+        function removeLeadingZeros(numberAsString) {
+            return numberAsString.replace(/^0*/u, "");
+        }
+
+        /**
+         * Returns the number stripped of trailing zeros
+         * @param {string} numberAsString the string representation of the number
+         * @returns {string} the stripped string
+         */
+        function removeTrailingZeros(numberAsString) {
+            return numberAsString.replace(/0*$/u, "");
+        }
+
+        /**
+         * Converts an integer to to an object containing the the integer's coefficient and order of magnitude
+         * @param {string} stringInteger the string representation of the integer being converted
+         * @returns {Object} the object containing the the integer's coefficient and order of magnitude
+         */
+        function normalizeInteger(stringInteger) {
+            const significantDigits = removeTrailingZeros(removeLeadingZeros(stringInteger));
+
+            return {
+                magnitude: stringInteger.startsWith("0") ? stringInteger.length - 2 : stringInteger.length - 1,
+                coefficient: addDecimalPointToNumber(significantDigits)
+            };
+        }
+
+        /**
+         *
+         * Converts a float to to an object containing the the floats's coefficient and order of magnitude
+         * @param {string} stringFloat the string representation of the float being converted
+         * @returns {Object} the object containing the the integer's coefficient and order of magnitude
+         */
+        function normalizeFloat(stringFloat) {
+            const trimmedFloat = removeLeadingZeros(stringFloat);
+
+            if (trimmedFloat.startsWith(".")) {
+                const decimalDigits = trimmedFloat.split(".").pop();
+                const significantDigits = removeLeadingZeros(decimalDigits);
+
+                return {
+                    magnitude: significantDigits.length - decimalDigits.length - 1,
+                    coefficient: addDecimalPointToNumber(significantDigits)
+                };
+
+            }
+            return {
+                magnitude: trimmedFloat.indexOf(".") - 1,
+                coefficient: addDecimalPointToNumber(trimmedFloat.replace(".", ""))
+
+            };
+        }
+
+
+        /**
+         * Converts a base ten number to proper scientific notation
+         * @param {string} stringNumber the string representation of the base ten number to be converted
+         * @returns {string} the number converted to scientific notation
+         */
+        function convertNumberToScientificNotation(stringNumber) {
+            const splitNumber = stringNumber.replace("E", "e").split("e");
+            const originalCoefficient = splitNumber[0];
+            const normalizedNumber = stringNumber.includes(".") ? normalizeFloat(originalCoefficient)
+                : normalizeInteger(originalCoefficient);
+            const normalizedCoefficient = normalizedNumber.coefficient;
+            const magnitude = splitNumber.length > 1 ? (parseInt(splitNumber[1], 10) + normalizedNumber.magnitude)
+                : normalizedNumber.magnitude;
+
+            return `${normalizedCoefficient}e${magnitude}`;
+
+        }
+
+        /**
+         * Checks that the user-intended base ten number equals the actual number after is has been converted to the Number type
+         * @param {Node} node the node being evaluated
+         * @returns {boolean} true if they do not match
+         */
+        function baseTenLosesPrecision(node) {
+            const normalizedRawNumber = convertNumberToScientificNotation(node.raw);
+            const requestedPrecision = normalizedRawNumber.split("e")[0].replace(".", "").length;
+
+            if (requestedPrecision > 100) {
+                return true;
+            }
+            const storedNumber = node.value.toPrecision(requestedPrecision);
+            const normalizedStoredNumber = convertNumberToScientificNotation(storedNumber);
+
+            return normalizedRawNumber !== normalizedStoredNumber;
+        }
+
+
+        /**
+         * Checks that the user-intended number equals the actual number after is has been converted to the Number type
+         * @param {Node} node the node being evaluated
+         * @returns {boolean} true if they do not match
+         */
+        function losesPrecision(node) {
+            return isBaseTen(node) ? baseTenLosesPrecision(node) : notBaseTenLosesPrecision(node);
+        }
+
+
+        return {
+            Literal(node) {
+                if (node.value && isNumber(node) && losesPrecision(node)) {
+                    context.report({
+                        messageId: "noLossOfPrecision",
+                        node
+                    });
+                }
+            }
+        };
+    }
+};
index bfe9b7aa97858a70704aa79194a6dbf170603973..a02de9104bdd88670fa6091097b36e0c1e132537 100644 (file)
@@ -13,7 +13,7 @@ module.exports = {
     meta: {
         deprecated: true,
 
-        replacedBy: ["node/no-mixed-requires"],
+        replacedBy: [],
 
         type: "suggestion",
 
index d1360e9dee036db7a1ce990575938f7ae3634478..9af4e31cabf6d44fe55905bcaa1a7ac129270095 100644 (file)
@@ -29,26 +29,29 @@ module.exports = {
 
     create(context) {
 
-        //--------------------------------------------------------------------------
-        // Helpers
-        //--------------------------------------------------------------------------
-
-        /**
-         * Reports a node.
-         * @param {ASTNode} node The node to report
-         * @returns {void}
-         * @private
-         */
-        function report(node) {
-            context.report({
-                node,
-                messageId: "noFunctionConstructor"
-            });
-        }
-
         return {
-            "NewExpression[callee.name = 'Function']": report,
-            "CallExpression[callee.name = 'Function']": report
+            "Program:exit"() {
+                const globalScope = context.getScope();
+                const variable = globalScope.set.get("Function");
+
+                if (variable && variable.defs.length === 0) {
+                    variable.references.forEach(ref => {
+                        const node = ref.identifier;
+                        const { parent } = node;
+
+                        if (
+                            parent &&
+                            (parent.type === "NewExpression" || parent.type === "CallExpression") &&
+                            node === parent.callee
+                        ) {
+                            context.report({
+                                node: parent,
+                                messageId: "noFunctionConstructor"
+                            });
+                        }
+                    });
+                }
+            }
         };
 
     }
index 7f81e83fd782c33b3f18260cb9c4fc52b105b148..063f783e70cc3c7d0107f5d5ab2a952b777cd691 100644 (file)
@@ -13,7 +13,7 @@ module.exports = {
     meta: {
         deprecated: true,
 
-        replacedBy: ["node/no-new-require"],
+        replacedBy: [],
 
         type: "suggestion",
 
index cb7e4f0fc88d6994470fb0392f6a5670a17d3bb1..aeb509c0d9c1424396f4a5a684fd62fb14cb75da 100644 (file)
@@ -37,8 +37,9 @@ module.exports = {
                 if (variable && variable.defs.length === 0) {
                     variable.references.forEach(ref => {
                         const node = ref.identifier;
+                        const parent = node.parent;
 
-                        if (node.parent && node.parent.type === "NewExpression") {
+                        if (parent && parent.type === "NewExpression" && parent.callee === node) {
                             context.report({
                                 node,
                                 messageId: "noNewSymbol"
index 77a03a7f952b047afe9bc0b3b25a1ea280cf4b55..fc1f894f878988f0f995aac46034e3d071ac2e07 100644 (file)
@@ -12,7 +12,7 @@ module.exports = {
     meta: {
         deprecated: true,
 
-        replacedBy: ["node/no-path-concat"],
+        replacedBy: [],
 
         type: "suggestion",
 
index 24bb9f9971d5c923d59cbd492267e31bf870e33e..49d1734906e81f567c8edb98e99da9d6af22b637 100644 (file)
@@ -12,7 +12,7 @@ module.exports = {
     meta: {
         deprecated: true,
 
-        replacedBy: ["node/no-process-env"],
+        replacedBy: [],
 
         type: "suggestion",
 
index 9c70ea8808b4c4c6495ed77a53f09ead75db0165..77c9cfd7cbd3429c6b0171fc983d380967be06b1 100644 (file)
@@ -12,7 +12,7 @@ module.exports = {
     meta: {
         deprecated: true,
 
-        replacedBy: ["node/no-process-exit"],
+        replacedBy: [],
 
         type: "suggestion",
 
index 61834ceeb444d3544df8f1b0434f2842649b6612..d0b8a78a507fa80930e83dcf6832db9d461c84a5 100644 (file)
@@ -42,7 +42,7 @@ module.exports = {
     meta: {
         deprecated: true,
 
-        replacedBy: ["node/no-restricted-require"],
+        replacedBy: [],
 
         type: "suggestion",
 
index 9790d1f94bb20c7c77363d0a2cd61991e4a7f9ce..06424e0b38f33fb39e993d253b405f0d53707355 100644 (file)
@@ -15,7 +15,7 @@ module.exports = {
     meta: {
         deprecated: true,
 
-        replacedBy: ["node/no-sync"],
+        replacedBy: [],
 
         type: "suggestion",
 
index 30ca2cf49834fe3eef91b9b97ac01f6463323754..db4674760a0f273a5d622fe6c96c924a75bb966f 100644 (file)
@@ -71,7 +71,7 @@ module.exports = {
                         context.report({
                             node,
                             messageId: "expectVarOnNewline",
-                            loc: current.loc.start,
+                            loc: current.loc,
                             fix: fixer => fixer.insertTextBefore(current, "\n")
                         });
                     }
index f58a7535ba86c2dadadbe4a45958196a5d6c0433..fa65eae4e0222d5001831d9cebcca0cdbccb031d 100644 (file)
@@ -203,10 +203,14 @@ module.exports = {
             }
 
             if (requirePaddingFor(node)) {
+
                 if (!blockHasTopPadding) {
                     context.report({
                         node,
-                        loc: { line: tokenBeforeFirst.loc.start.line, column: tokenBeforeFirst.loc.start.column },
+                        loc: {
+                            start: tokenBeforeFirst.loc.start,
+                            end: firstBlockToken.loc.start
+                        },
                         fix(fixer) {
                             return fixer.insertTextAfter(tokenBeforeFirst, "\n");
                         },
@@ -216,7 +220,10 @@ module.exports = {
                 if (!blockHasBottomPadding) {
                     context.report({
                         node,
-                        loc: { line: tokenAfterLast.loc.end.line, column: tokenAfterLast.loc.end.column - 1 },
+                        loc: {
+                            end: tokenAfterLast.loc.start,
+                            start: lastBlockToken.loc.end
+                        },
                         fix(fixer) {
                             return fixer.insertTextBefore(tokenAfterLast, "\n");
                         },
@@ -228,7 +235,10 @@ module.exports = {
 
                     context.report({
                         node,
-                        loc: { line: tokenBeforeFirst.loc.start.line, column: tokenBeforeFirst.loc.start.column },
+                        loc: {
+                            start: tokenBeforeFirst.loc.start,
+                            end: firstBlockToken.loc.start
+                        },
                         fix(fixer) {
                             return fixer.replaceTextRange([tokenBeforeFirst.range[1], firstBlockToken.range[0] - firstBlockToken.loc.start.column], "\n");
                         },
@@ -240,7 +250,10 @@ module.exports = {
 
                     context.report({
                         node,
-                        loc: { line: tokenAfterLast.loc.end.line, column: tokenAfterLast.loc.end.column - 1 },
+                        loc: {
+                            end: tokenAfterLast.loc.start,
+                            start: lastBlockToken.loc.end
+                        },
                         messageId: "neverPadBlock",
                         fix(fixer) {
                             return fixer.replaceTextRange([lastBlockToken.range[1], tokenAfterLast.range[0] - tokenAfterLast.loc.start.column], "\n");
index 4bb5f787c6c5687d25d49c3d057789eedd586448..8cb9814f0c9129e1328eb4933f115bd1559e4a8e 100644 (file)
@@ -79,10 +79,7 @@ module.exports = {
             if (alwaysSpace && !hasWhitespace) {
                 context.report({
                     node,
-                    loc: {
-                        line: operator.loc.end.line,
-                        column: operator.loc.end.column
-                    },
+                    loc: operator.loc,
                     messageId: "expectedWhitespace",
                     data: {
                         type
@@ -95,8 +92,8 @@ module.exports = {
                 context.report({
                     node,
                     loc: {
-                        line: operator.loc.end.line,
-                        column: operator.loc.end.column
+                        start: operator.loc.end,
+                        end: nextToken.loc.start
                     },
                     messageId: "unexpectedWhitespace",
                     data: {
index 92948533d2789e22ac3569fa336661b7cc0056ff..936e7661ef4fb3ce1827cc793d976c62e0463527 100644 (file)
@@ -117,6 +117,18 @@ module.exports = {
         }
 
         /**
+         * Report location example :
+         *
+         * for unexpected space `before`
+         *
+         * var a = 'b'   ;
+         *            ^^^
+         *
+         * for unexpected space `after`
+         *
+         * var a = 'b';  c = 10;
+         *             ^^
+         *
          * Reports if the given token has invalid spacing.
          * @param {Token} token The semicolon token to check.
          * @param {ASTNode} node The corresponding node of the token.
@@ -124,16 +136,19 @@ module.exports = {
          */
         function checkSemicolonSpacing(token, node) {
             if (astUtils.isSemicolonToken(token)) {
-                const location = token.loc.start;
-
                 if (hasLeadingSpace(token)) {
                     if (!requireSpaceBefore) {
+                        const tokenBefore = sourceCode.getTokenBefore(token);
+                        const loc = {
+                            start: tokenBefore.loc.end,
+                            end: token.loc.start
+                        };
+
                         context.report({
                             node,
-                            loc: location,
+                            loc,
                             messageId: "unexpectedWhitespaceBefore",
                             fix(fixer) {
-                                const tokenBefore = sourceCode.getTokenBefore(token);
 
                                 return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
                             }
@@ -141,9 +156,11 @@ module.exports = {
                     }
                 } else {
                     if (requireSpaceBefore) {
+                        const loc = token.loc;
+
                         context.report({
                             node,
-                            loc: location,
+                            loc,
                             messageId: "missingWhitespaceBefore",
                             fix(fixer) {
                                 return fixer.insertTextBefore(token, " ");
@@ -155,12 +172,17 @@ module.exports = {
                 if (!isFirstTokenInCurrentLine(token) && !isLastTokenInCurrentLine(token) && !isBeforeClosingParen(token)) {
                     if (hasTrailingSpace(token)) {
                         if (!requireSpaceAfter) {
+                            const tokenAfter = sourceCode.getTokenAfter(token);
+                            const loc = {
+                                start: token.loc.end,
+                                end: tokenAfter.loc.start
+                            };
+
                             context.report({
                                 node,
-                                loc: location,
+                                loc,
                                 messageId: "unexpectedWhitespaceAfter",
                                 fix(fixer) {
-                                    const tokenAfter = sourceCode.getTokenAfter(token);
 
                                     return fixer.removeRange([token.range[1], tokenAfter.range[0]]);
                                 }
@@ -168,9 +190,11 @@ module.exports = {
                         }
                     } else {
                         if (requireSpaceAfter) {
+                            const loc = token.loc;
+
                             context.report({
                                 node,
-                                loc: location,
+                                loc,
                                 messageId: "missingWhitespaceAfter",
                                 fix(fixer) {
                                     return fixer.insertTextAfter(token, " ");
index e6a3cb4cac58be5b63da4891a3409c01b5b028da..83ecf69434dafbd4e1a988457366c2217179972a 100644 (file)
@@ -1243,19 +1243,64 @@ module.exports = {
 
     /**
      * Gets next location when the result is not out of bound, otherwise returns null.
+     *
+     * Assumptions:
+     *
+     * - The given location represents a valid location in the given source code.
+     * - Columns are 0-based.
+     * - Lines are 1-based.
+     * - Column immediately after the last character in a line (not incl. linebreaks) is considered to be a valid location.
+     * - If the source code ends with a linebreak, `sourceCode.lines` array will have an extra element (empty string) at the end.
+     *   The start (column 0) of that extra line is considered to be a valid location.
+     *
+     * Examples of successive locations (line, column):
+     *
+     * code: foo
+     * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> null
+     *
+     * code: foo<LF>
+     * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null
+     *
+     * code: foo<CR><LF>
+     * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null
+     *
+     * code: a<LF>b
+     * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> null
+     *
+     * code: a<LF>b<LF>
+     * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null
+     *
+     * code: a<CR><LF>b<CR><LF>
+     * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null
+     *
+     * code: a<LF><LF>
+     * locations: (1, 0) -> (1, 1) -> (2, 0) -> (3, 0) -> null
+     *
+     * code: <LF>
+     * locations: (1, 0) -> (2, 0) -> null
+     *
+     * code:
+     * locations: (1, 0) -> null
      * @param {SourceCode} sourceCode The sourceCode
      * @param {{line: number, column: number}} location The location
      * @returns {{line: number, column: number} | null} Next location
      */
-    getNextLocation(sourceCode, location) {
-        const index = sourceCode.getIndexFromLoc(location);
+    getNextLocation(sourceCode, { line, column }) {
+        if (column < sourceCode.lines[line - 1].length) {
+            return {
+                line,
+                column: column + 1
+            };
+        }
 
-        // Avoid out of bound location
-        if (index + 1 > sourceCode.text.length) {
-            return null;
+        if (line < sourceCode.lines.length) {
+            return {
+                line: line + 1,
+                column: 0
+            };
         }
 
-        return sourceCode.getLocFromIndex(index + 1);
+        return null;
     },
 
     /**
index 591d5a7e454ee2152c006fce5c5668057f6cf283..6b20495b6fc807a07b82cc9c4325c9f5f78203fd 100644 (file)
@@ -305,6 +305,7 @@ class SourceCode extends TokenStore {
      * @returns {Object} An object containing a leading and trailing array
      *      of comments indexed by their position.
      * @public
+     * @deprecated replaced by getCommentsBefore(), getCommentsAfter(), and getCommentsInside().
      */
     getComments(node) {
         if (this._commentCache.has(node)) {
index 0411819ec4e18f82dac458bda5fa96a45b1443eb..f7c5f71ebe32568b474ece0b90377c262cf6d292 100644 (file)
@@ -2,4 +2,4 @@ ESLint couldn't find the config "<%- configName %>" to extend from. Please check
 
 The config "<%- configName %>" was referenced from the config file in "<%- importerName %>".
 
-If you still have problems, please stop by https://gitter.im/eslint/eslint to chat with the team.
+If you still have problems, please stop by https://eslint.org/chat to chat with the team.
index 348f6dcd25f62f116fbb03556f0e7f78dcc5e9f7..f1f7beb63b19a08a7500896897b76d7642678e32 100644 (file)
@@ -4,4 +4,4 @@ ESLint couldn't find a configuration file. To set up a configuration file for th
 
 ESLint looked for configuration files in <%= directoryPath %> and its ancestors. If it found none, it then looked in your home directory.
 
-If you think you already have a configuration file or if you need more help, please stop by the ESLint chat room: https://gitter.im/eslint/eslint
+If you think you already have a configuration file or if you need more help, please stop by the ESLint chat room: https://eslint.org/chat
index 6fcf7c83115d703b55446e8da5b7c6541a171668..f8b60631c58ea183ca928822326d1ad951b3b246 100644 (file)
@@ -4,4 +4,4 @@ ESLint couldn't determine the plugin "<%- pluginId %>" uniquely.
 
 Please remove the "plugins" setting from either config or remove either plugin installation.
 
-If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.
+If you still can't figure out the problem, please stop by https://eslint.org/chat to chat with the team.
index 32e9f0ae5de585d58a3cf4635229b3f99c4be8e0..3d376733085667662b70c01d246d0c4788be6730 100644 (file)
@@ -8,4 +8,4 @@ It's likely that the plugin isn't installed correctly. Try reinstalling by runni
 
 The plugin "<%- pluginName %>" was referenced from the config file in "<%- importerName %>".
 
-If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.
+If you still can't figure out the problem, please stop by https://eslint.org/chat to chat with the team.
index eea4efccedb1d1c69c14da5165626921c843219a..7d72149a8fd4fb030694719e5e19884f8ef6cb66 100644 (file)
@@ -1,3 +1,3 @@
 ESLint couldn't find the plugin "<%- pluginName %>". because there is whitespace in the name. Please check your configuration and remove all whitespace from the plugin name.
 
-If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.
+If you still can't figure out the problem, please stop by https://eslint.org/chat to chat with the team.
index b775ebda86f844348934ab04c5bc81e51b378110..dddf620c0dd30c8c2f175bb8a406efa815d6a557 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "eslint",
-  "version": "7.0.0",
+  "version": "7.1.0",
   "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
   "description": "An AST-based pattern checker for JavaScript.",
   "bin": {
index dc81e34ecb9e55fe2a151bbbe6f16fa6a3d3301c..9f871a4b5831f0f5a74074f20e1f5aad1982d851 100644 (file)
@@ -10,5 +10,6 @@ module.exports = {
     noLineError: require("./no-line-error"),
     enhancedParser2: require("./enhanced-parser2"),
     enhancedParser3: require("./enhanced-parser3"),
-    throwsWithOptions: require("./throws-with-options")
+    throwsWithOptions: require("./throws-with-options"),
+    nonJSParser: require('./non-js-parser')
 };
diff --git a/eslint/tests/fixtures/parsers/non-js-parser.js b/eslint/tests/fixtures/parsers/non-js-parser.js
new file mode 100644 (file)
index 0000000..86b6d93
--- /dev/null
@@ -0,0 +1,238 @@
+/**
+ * Source code:
+ * function foo(a: number=0): Foo { }
+ */
+
+exports.parseForESLint = () => ({
+    ast: {
+        "kind": "Document",
+        "definitions": [
+            {
+                "kind": "ObjectTypeExtension",
+                "name": {
+                    "kind": "Name",
+                    "value": "Query",
+                    "loc": {
+                        "start": 12,
+                        "end": 17
+                    },
+                    "type": "Name"
+                },
+                "interfaces": [],
+                "directives": [],
+                "fields": [
+                    {
+                        "kind": "FieldDefinition",
+                        "name": {
+                            "kind": "Name",
+                            "value": "login",
+                            "loc": {
+                                "start": 24,
+                                "end": 29
+                            },
+                            "type": "Name"
+                        },
+                        "arguments": [
+                            {
+                                "kind": "InputValueDefinition",
+                                "name": {
+                                    "kind": "Name",
+                                    "value": "input",
+                                    "loc": {
+                                        "start": 30,
+                                        "end": 35
+                                    },
+                                    "type": "Name"
+                                },
+                                "type": "InputValueDefinition",
+                                "directives": [],
+                                "loc": {
+                                    "start": 30,
+                                    "end": 49
+                                },
+                                "fieldType": {
+                                    "kind": "NonNullType",
+                                    "type": "NonNullType",
+                                    "loc": {
+                                        "start": 37,
+                                        "end": 49
+                                    },
+                                    "fieldType": {
+                                        "kind": "NamedType",
+                                        "name": {
+                                            "kind": "Name",
+                                            "value": "Credentials",
+                                            "loc": {
+                                                "start": 37,
+                                                "end": 48
+                                            },
+                                            "type": "Name"
+                                        },
+                                        "loc": {
+                                            "start": 37,
+                                            "end": 48
+                                        },
+                                        "type": "NamedType"
+                                    }
+                                }
+                            }
+                        ],
+                        "type": "FieldDefinition",
+                        "directives": [],
+                        "loc": {
+                            "start": 24,
+                            "end": 63
+                        },
+                        "fieldType": {
+                            "kind": "NamedType",
+                            "name": {
+                                "kind": "Name",
+                                "value": "UserProfile",
+                                "loc": {
+                                    "start": 52,
+                                    "end": 63
+                                },
+                                "type": "Name"
+                            },
+                            "loc": {
+                                "start": 52,
+                                "end": 63
+                            },
+                            "type": "NamedType"
+                        }
+                    }
+                ],
+                "loc": {
+                    "start": 0,
+                    "end": 65
+                },
+                "type": "ObjectTypeExtension"
+            },
+            {
+                "kind": "InputObjectTypeDefinition",
+                "name": {
+                    "kind": "Name",
+                    "value": "Credentials",
+                    "loc": {
+                        "start": 73,
+                        "end": 84
+                    },
+                    "type": "Name"
+                },
+                "directives": [],
+                "fields": [
+                    {
+                        "kind": "InputValueDefinition",
+                        "name": {
+                            "kind": "Name",
+                            "value": "login",
+                            "loc": {
+                                "start": 91,
+                                "end": 96
+                            },
+                            "type": "Name"
+                        },
+                        "type": "InputValueDefinition",
+                        "directives": [],
+                        "loc": {
+                            "start": 91,
+                            "end": 105
+                        },
+                        "fieldType": {
+                            "kind": "NonNullType",
+                            "type": "NonNullType",
+                            "loc": {
+                                "start": 98,
+                                "end": 105
+                            },
+                            "fieldType": {
+                                "kind": "NamedType",
+                                "name": {
+                                    "kind": "Name",
+                                    "value": "String",
+                                    "loc": {
+                                        "start": 98,
+                                        "end": 104
+                                    },
+                                    "type": "Name"
+                                },
+                                "loc": {
+                                    "start": 98,
+                                    "end": 104
+                                },
+                                "type": "NamedType"
+                            }
+                        }
+                    },
+                    {
+                        "kind": "InputValueDefinition",
+                        "name": {
+                            "kind": "Name",
+                            "value": "password",
+                            "loc": {
+                                "start": 110,
+                                "end": 118
+                            },
+                            "type": "Name"
+                        },
+                        "type": "InputValueDefinition",
+                        "directives": [],
+                        "loc": {
+                            "start": 110,
+                            "end": 127
+                        },
+                        "fieldType": {
+                            "kind": "NonNullType",
+                            "type": "NonNullType",
+                            "loc": {
+                                "start": 120,
+                                "end": 127
+                            },
+                            "fieldType": {
+                                "kind": "NamedType",
+                                "name": {
+                                    "kind": "Name",
+                                    "value": "String",
+                                    "loc": {
+                                        "start": 120,
+                                        "end": 126
+                                    },
+                                    "type": "Name"
+                                },
+                                "loc": {
+                                    "start": 120,
+                                    "end": 126
+                                },
+                                "type": "NamedType"
+                            }
+                        }
+                    }
+                ],
+                "loc": {
+                    "start": 67,
+                    "end": 129
+                },
+                "type": "InputObjectTypeDefinition"
+            }
+        ],
+        "loc": {
+            "start": 0,
+            "end": 130
+        },
+        "type": "Document",
+        "tokens": [],
+        "comments": [],
+        "range": {}
+    },
+    services: {},
+    scopeManager: { variables: [], scopes: [{ set: new Map(), variables: [], through: [] }], getDeclaredVariables: () => {} },
+    visitorKeys: {
+        Document: ['definitions'],
+        ObjectTypeDefinition: ['interfaces', 'directives', 'fields'],
+        ObjectTypeExtension: ['interfaces', 'directives', 'fields'],
+        InputObjectTypeDefinition: ['directives', 'fields'],
+        InputValueDefinition: ['directives', 'fieldType'],
+        FieldDefinition: ['directives', 'fieldType', 'arguments'],
+        EnumTypeDefinition: ['directives', 'values']
+    }
+});
index 5f4690adfa8539a8a4e01b3d5df4b1760d3feb35..fe9120f7de108c0a0a121e697bbd085846e9b3bb 100644 (file)
@@ -176,7 +176,7 @@ describe("configInitializer", () => {
 
                 assert.strictEqual(config.parser, "@typescript-eslint/parser");
                 assert.deepStrictEqual(config.plugins, ["@typescript-eslint"]);
-                assert.deepStrictEqual(config.extends, ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended"]);
+                assert.deepStrictEqual(config.extends, ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended"]);
             });
 
             it("should enable typescript parser and plugin with vue", () => {
@@ -184,6 +184,7 @@ describe("configInitializer", () => {
                 answers.typescript = true;
                 const config = init.processAnswers(answers);
 
+                assert.deepStrictEqual(config.extends, ["eslint:recommended", "plugin:vue/essential", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended"]);
                 assert.strictEqual(config.parserOptions.parser, "@typescript-eslint/parser");
                 assert.deepStrictEqual(config.plugins, ["vue", "@typescript-eslint"]);
             });
index 56d028e5c62908c423bc341888ab1fcd0835f92b..f2efc00c946bb644cb662dbabf64b42db9074e46 100644 (file)
@@ -5247,6 +5247,30 @@ var a = "test2";
             assert.strictEqual(messages.length, 0);
         });
 
+        it("should not throw or return errors when the custom parser returns unknown AST nodes", () => {
+            const code = "foo && bar %% baz";
+
+            const nodes = [];
+
+            linter.defineRule("collect-node-types", () => ({
+                "*"(node) {
+                    nodes.push(node.type);
+                }
+            }));
+
+            linter.defineParser("non-js-parser", testParsers.nonJSParser);
+
+            const messages = linter.verify(code, {
+                parser: "non-js-parser",
+                rules: {
+                    "collect-node-types": "error"
+                }
+            }, filename, true);
+
+            assert.strictEqual(messages.length, 0);
+            assert.isTrue(nodes.length > 0);
+        });
+
         it("should strip leading line: prefix from parser error", () => {
             linter.defineParser("line-error", testParsers.lineError);
             const messages = linter.verify(";", { parser: "line-error" }, "filename");
index 3e796c1ec3c41b7d0b8a95de9007a2627f8b29ce..edd1ae6da8a3e3e10bd5cdc98017b3ca93093a4f 100644 (file)
@@ -29,6 +29,12 @@ const valid = [
     "(a) => {\n}",
     "a.then((foo) => {});",
     "a.then((foo) => { if (true) {}; });",
+    "const f = (/* */a) => a + a;",
+    "const f = (a/** */) => a + a;",
+    "const f = (a//\n) => a + a;",
+    "const f = (//\na) => a + a;",
+    "const f = (/*\n */a//\n) => a + a;",
+    "const f = (/** @type {number} */a/**hello*/) => a + a;",
     { code: "a.then(async (foo) => { if (true) {}; });", parserOptions: { ecmaVersion: 8 } },
 
     // "always" (explicit)
@@ -68,7 +74,69 @@ const valid = [
     { code: "async a => ({})", options: ["as-needed", { requireForBlockBody: true }], parserOptions: { ecmaVersion: 8 } },
     { code: "async a => a", options: ["as-needed", { requireForBlockBody: true }], parserOptions: { ecmaVersion: 8 } },
     { code: "(a: T) => a", options: ["as-needed", { requireForBlockBody: true }], parser: parser("identifer-type") },
-    { code: "(a): T => a", options: ["as-needed", { requireForBlockBody: true }], parser: parser("return-type") }
+    { code: "(a): T => a", options: ["as-needed", { requireForBlockBody: true }], parser: parser("return-type") },
+    {
+        code: "const f = (/** @type {number} */a/**hello*/) => a + a;",
+        options: ["as-needed"]
+    },
+    {
+        code: "const f = (/* */a) => a + a;",
+        options: ["as-needed"]
+    },
+    {
+        code: "const f = (a/** */) => a + a;",
+        options: ["as-needed"]
+    },
+    {
+        code: "const f = (a//\n) => a + a;",
+        options: ["as-needed"]
+    },
+    {
+        code: "const f = (//\na) => a + a;",
+        options: ["as-needed"]
+    },
+    {
+        code: "const f = (/*\n */a//\n) => a + a;",
+        options: ["as-needed"]
+    },
+    {
+        code: "var foo = (a,/**/) => b;",
+        parserOptions: { ecmaVersion: 2017 },
+        options: ["as-needed"]
+    },
+    {
+        code: "var foo = (a , /**/) => b;",
+        parserOptions: { ecmaVersion: 2017 },
+        options: ["as-needed"]
+    },
+    {
+        code: "var foo = (a\n,\n/**/) => b;",
+        parserOptions: { ecmaVersion: 2017 },
+        options: ["as-needed"]
+    },
+    {
+        code: "var foo = (a,//\n) => b;",
+        parserOptions: { ecmaVersion: 2017 },
+        options: ["as-needed"]
+    },
+    {
+        code: "const i = (a/**/,) => a + a;",
+        parserOptions: { ecmaVersion: 2017 },
+        options: ["as-needed"]
+    },
+    {
+        code: "const i = (a \n /**/,) => a + a;",
+        parserOptions: { ecmaVersion: 2017 },
+        options: ["as-needed"]
+    },
+    {
+        code: "var bar = ({/*comment here*/a}) => a",
+        options: ["as-needed"]
+    },
+    {
+        code: "var bar = (/*comment here*/{a}) => a",
+        options: ["as-needed"]
+    }
 ];
 
 const type = "ArrowFunctionExpression";
@@ -271,7 +339,78 @@ const invalid = [
             messageId: "unexpectedParensInline",
             type
         }]
+    },
+    {
+        code: "const f = /** @type {number} */(a)/**hello*/ => a + a;",
+        options: ["as-needed"],
+        output: "const f = /** @type {number} */a/**hello*/ => a + a;",
+        errors: [{
+            line: 1,
+            column: 33,
+            type,
+            messageId: "unexpectedParens",
+            endLine: 1,
+            endColumn: 34
+        }]
+    },
+    {
+        code: "const f = //\n(a) => a + a;",
+        output: "const f = //\na => a + a;",
+        options: ["as-needed"],
+        errors: [{
+            line: 2,
+            column: 2,
+            type,
+            messageId: "unexpectedParens",
+            endLine: 2,
+            endColumn: 3
+        }]
+    },
+    {
+        code: "var foo = /**/ a => b;",
+        output: "var foo = /**/ (a) => b;",
+        errors: [{
+            line: 1,
+            column: 16,
+            type: "ArrowFunctionExpression",
+            messageId: "expectedParens",
+            endLine: 1,
+            endColumn: 17
+        }]
+    },
+    {
+        code: "var bar = a /**/ =>  b;",
+        output: "var bar = (a) /**/ =>  b;",
+        errors: [{
+            line: 1,
+            column: 11,
+            type: "ArrowFunctionExpression",
+            messageId: "expectedParens",
+            endLine: 1,
+            endColumn: 12
+        }]
+    },
+    {
+        code: `const foo = a => {};
+
+// comment between 'a' and an unrelated closing paren
+
+bar();`,
+        output: `const foo = (a) => {};
+
+// comment between 'a' and an unrelated closing paren
+
+bar();`,
+        errors: [{
+            line: 1,
+            column: 13,
+            type: "ArrowFunctionExpression",
+            messageId: "expectedParens",
+            endLine: 1,
+            endColumn: 14
+        }]
     }
+
 ];
 
 ruleTester.run("arrow-parens", rule, {
index 95d9d8cc089c8debe7a3cfe87155bf771324bbfa..a80d07cc7d4a8a93ae58fdee6f2e24c068d73036 100644 (file)
@@ -182,12 +182,60 @@ ruleTester.run("block-spacing", rule, {
             code: "try {foo();} catch (e) {foo();} finally {foo();}",
             output: "try { foo(); } catch (e) { foo(); } finally { foo(); }",
             errors: [
-                { type: "BlockStatement", line: 1, column: 5, messageId: "missing", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 12, messageId: "missing", data: { location: "before", token: "}" } },
-                { type: "BlockStatement", line: 1, column: 24, messageId: "missing", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 31, messageId: "missing", data: { location: "before", token: "}" } },
-                { type: "BlockStatement", line: 1, column: 41, messageId: "missing", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 48, messageId: "missing", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "missing",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 5,
+                    endLine: 1,
+                    endColumn: 6
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "missing",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 12,
+                    endLine: 1,
+                    endColumn: 13
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "missing",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 24,
+                    endLine: 1,
+                    endColumn: 25
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "missing",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 31,
+                    endLine: 1,
+                    endColumn: 32
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "missing",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 41,
+                    endLine: 1,
+                    endColumn: 42
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "missing",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 48,
+                    endLine: 1,
+                    endColumn: 49
+                }
             ]
         },
         {
@@ -229,7 +277,18 @@ ruleTester.run("block-spacing", rule, {
             output: "if (a) { //comment\n foo(); }",
             parserOptions: { ecmaVersion: 6 },
             errors: [
-                { type: "BlockStatement", line: 1, column: 8, messageId: "missing", data: { location: "after", token: "{" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "missing",
+                    data: {
+                        location: "after",
+                        token: "{"
+                    },
+                    line: 1,
+                    column: 8,
+                    endLine: 1,
+                    endColumn: 9
+                }
             ]
         },
 
@@ -240,8 +299,24 @@ ruleTester.run("block-spacing", rule, {
             output: "{foo();}",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 1, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 10, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 2,
+                    endLine: 1,
+                    endColumn: 3
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 9,
+                    endLine: 1,
+                    endColumn: 10
+                }
             ]
         },
         {
@@ -249,7 +324,18 @@ ruleTester.run("block-spacing", rule, {
             output: "{foo();}",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 1, messageId: "extra", data: { location: "after", token: "{" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: {
+                        location: "after",
+                        token: "{"
+                    },
+                    line: 1,
+                    column: 2,
+                    endLine: 1,
+                    endColumn: 3
+                }
             ]
         },
         {
@@ -257,7 +343,18 @@ ruleTester.run("block-spacing", rule, {
             output: "{foo();}",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 9, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: {
+                        location: "before",
+                        token: "}"
+                    },
+                    line: 1,
+                    column: 8,
+                    endLine: 1,
+                    endColumn: 9
+                }
             ]
         },
         {
@@ -265,7 +362,18 @@ ruleTester.run("block-spacing", rule, {
             output: "{\nfoo();}",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 2, column: 8, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: {
+                        location: "before",
+                        token: "}"
+                    },
+                    line: 2,
+                    column: 7,
+                    endLine: 2,
+                    endColumn: 8
+                }
             ]
         },
         {
@@ -273,7 +381,18 @@ ruleTester.run("block-spacing", rule, {
             output: "{foo();\n}",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 1, messageId: "extra", data: { location: "after", token: "{" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: {
+                        location: "after",
+                        token: "{"
+                    },
+                    line: 1,
+                    column: 2,
+                    endLine: 1,
+                    endColumn: 3
+                }
             ]
         },
         {
@@ -281,8 +400,24 @@ ruleTester.run("block-spacing", rule, {
             output: "if (a) {foo();}",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 8, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 17, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 9,
+                    endLine: 1,
+                    endColumn: 10
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 16,
+                    endLine: 1,
+                    endColumn: 17
+                }
             ]
         },
         {
@@ -290,8 +425,24 @@ ruleTester.run("block-spacing", rule, {
             output: "if (a) {} else {foo();}",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 16, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 25, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 17,
+                    endLine: 1,
+                    endColumn: 18
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 24,
+                    endLine: 1,
+                    endColumn: 25
+                }
             ]
         },
         {
@@ -299,8 +450,24 @@ ruleTester.run("block-spacing", rule, {
             output: "switch (a) {case 0: foo();}",
             options: ["never"],
             errors: [
-                { type: "SwitchStatement", line: 1, column: 12, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "SwitchStatement", line: 1, column: 29, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "SwitchStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 13,
+                    endLine: 1,
+                    endColumn: 14
+                },
+                {
+                    type: "SwitchStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 28,
+                    endLine: 1,
+                    endColumn: 29
+                }
             ]
         },
         {
@@ -308,8 +475,24 @@ ruleTester.run("block-spacing", rule, {
             output: "while (a) {foo();}",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 11, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 20, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 12,
+                    endLine: 1,
+                    endColumn: 13
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 19,
+                    endLine: 1,
+                    endColumn: 20
+                }
             ]
         },
         {
@@ -317,8 +500,24 @@ ruleTester.run("block-spacing", rule, {
             output: "do {foo();} while (a);",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 4, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 13, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 5,
+                    endLine: 1,
+                    endColumn: 6
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 12,
+                    endLine: 1,
+                    endColumn: 13
+                }
             ]
         },
         {
@@ -326,8 +525,24 @@ ruleTester.run("block-spacing", rule, {
             output: "for (;;) {foo();}",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 10, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 19, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 11,
+                    endLine: 1,
+                    endColumn: 12
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 18,
+                    endLine: 1,
+                    endColumn: 19
+                }
             ]
         },
         {
@@ -335,8 +550,24 @@ ruleTester.run("block-spacing", rule, {
             output: "for (var a in b) {foo();}",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 18, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 27, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 19,
+                    endLine: 1,
+                    endColumn: 20
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 26,
+                    endLine: 1,
+                    endColumn: 27
+                }
             ]
         },
         {
@@ -345,8 +576,24 @@ ruleTester.run("block-spacing", rule, {
             options: ["never"],
             parserOptions: { ecmaVersion: 6 },
             errors: [
-                { type: "BlockStatement", line: 1, column: 18, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 27, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 19,
+                    endLine: 1,
+                    endColumn: 20
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 26,
+                    endLine: 1,
+                    endColumn: 27
+                }
             ]
         },
         {
@@ -354,12 +601,60 @@ ruleTester.run("block-spacing", rule, {
             output: "try {foo();} catch (e) {foo();} finally {foo();}",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 5, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 14, messageId: "extra", data: { location: "before", token: "}" } },
-                { type: "BlockStatement", line: 1, column: 26, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 35, messageId: "extra", data: { location: "before", token: "}" } },
-                { type: "BlockStatement", line: 1, column: 45, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 54, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 6,
+                    endLine: 1,
+                    endColumn: 7
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 13,
+                    endLine: 1,
+                    endColumn: 14
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 27,
+                    endLine: 1,
+                    endColumn: 28
+                },
+                {
+                    type: "BlockStatement",
+                    line: 1,
+                    column: 34,
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    endLine: 1,
+                    endColumn: 35
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 46,
+                    endLine: 1,
+                    endColumn: 47
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 53,
+                    endLine: 1,
+                    endColumn: 54
+                }
             ]
         },
         {
@@ -367,8 +662,24 @@ ruleTester.run("block-spacing", rule, {
             output: "function foo() {bar();}",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 16, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 25, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 17,
+                    endLine: 1,
+                    endColumn: 18
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 24,
+                    endLine: 1,
+                    endColumn: 25
+                }
             ]
         },
         {
@@ -376,8 +687,24 @@ ruleTester.run("block-spacing", rule, {
             output: "(function() {bar();});",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 13, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 22, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 14,
+                    endLine: 1,
+                    endColumn: 15
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 21,
+                    endLine: 1,
+                    endColumn: 22
+                }
             ]
         },
         {
@@ -386,8 +713,24 @@ ruleTester.run("block-spacing", rule, {
             options: ["never"],
             parserOptions: { ecmaVersion: 6 },
             errors: [
-                { type: "BlockStatement", line: 1, column: 8, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 17, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 9,
+                    endLine: 1,
+                    endColumn: 10
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 16,
+                    endLine: 1,
+                    endColumn: 17
+                }
             ]
         },
         {
@@ -395,8 +738,84 @@ ruleTester.run("block-spacing", rule, {
             output: "if (a) {/* comment */ foo(); /* comment */}",
             options: ["never"],
             errors: [
-                { type: "BlockStatement", line: 1, column: 8, messageId: "extra", data: { location: "after", token: "{" } },
-                { type: "BlockStatement", line: 1, column: 45, messageId: "extra", data: { location: "before", token: "}" } }
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 9,
+                    endLine: 1,
+                    endColumn: 10
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 44,
+                    endLine: 1,
+                    endColumn: 45
+                }
+            ]
+        },
+        {
+            code: "(() => {   bar();});",
+            output: "(() => {bar();});",
+            options: ["never"],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 9,
+                    endLine: 1,
+                    endColumn: 12
+                }
+            ]
+        },
+        {
+            code: "(() => {bar();   });",
+            output: "(() => {bar();});",
+            options: ["never"],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 15,
+                    endLine: 1,
+                    endColumn: 18
+                }
+            ]
+        },
+        {
+            code: "(() => {   bar();   });",
+            output: "(() => {bar();});",
+            options: ["never"],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "after", token: "{" },
+                    line: 1,
+                    column: 9,
+                    endLine: 1,
+                    endColumn: 12
+                },
+                {
+                    type: "BlockStatement",
+                    messageId: "extra",
+                    data: { location: "before", token: "}" },
+                    line: 1,
+                    column: 18,
+                    endLine: 1,
+                    endColumn: 21
+                }
             ]
         }
     ]
index 3a4f0aa735a63a72016bc833622e5648ee1c0d12..2ef7a008e2eb38bca5093ad4c3b48921ac22b339 100644 (file)
@@ -672,6 +672,21 @@ ruleTester.run("comma-dangle", rule, {
                 }
             ]
         },
+        {
+            code: "var foo = {\nbar: 'baz'\r\n}",
+            output: "var foo = {\nbar: 'baz',\r\n}",
+            options: ["always"],
+            errors: [
+                {
+                    messageId: "missing",
+                    type: "Property",
+                    line: 2,
+                    column: 11,
+                    endLine: 3,
+                    endColumn: 1
+                }
+            ]
+        },
         {
             code: "foo({ bar: 'baz', qux: 'quux' });",
             output: "foo({ bar: 'baz', qux: 'quux', });",
index 7603288d8fa06c087ef525859687dc64fd504344..60f247d39cb4ec9d35b36c6ef8a30f5d2ad23087 100644 (file)
@@ -46,6 +46,8 @@ ruleTester.run("linebreak-style", rule, {
             errors: [{
                 line: 1,
                 column: 13,
+                endLine: 2,
+                endColumn: 1,
                 messageId: "expectedLF"
             }]
         },
@@ -56,6 +58,8 @@ ruleTester.run("linebreak-style", rule, {
             errors: [{
                 line: 1,
                 column: 13,
+                endLine: 2,
+                endColumn: 1,
                 messageId: "expectedLF"
             }]
         },
@@ -66,6 +70,8 @@ ruleTester.run("linebreak-style", rule, {
             errors: [{
                 line: 1,
                 column: 13,
+                endLine: 2,
+                endColumn: 1,
                 messageId: "expectedCRLF"
             }]
         },
@@ -75,11 +81,15 @@ ruleTester.run("linebreak-style", rule, {
             errors: [{
                 line: 4,
                 column: 24,
+                endLine: 5,
+                endColumn: 1,
                 messageId: "expectedLF"
             },
             {
                 line: 6,
                 column: 3,
+                endLine: 7,
+                endColumn: 1,
                 messageId: "expectedLF"
             }]
         },
@@ -90,16 +100,46 @@ ruleTester.run("linebreak-style", rule, {
             errors: [{
                 line: 3,
                 column: 1,
+                endLine: 4,
+                endColumn: 1,
                 messageId: "expectedCRLF"
             },
             {
                 line: 5,
                 column: 1,
+                endLine: 6,
+                endColumn: 1,
                 messageId: "expectedCRLF"
             },
             {
                 line: 6,
                 column: 17,
+                endLine: 7,
+                endColumn: 1,
+                messageId: "expectedCRLF"
+            }]
+        },
+        {
+            code: "\r\n",
+            output: "\n",
+            options: ["unix"],
+            errors: [{
+                line: 1,
+                column: 1,
+                endLine: 2,
+                endColumn: 1,
+                messageId: "expectedLF"
+            }]
+        },
+        {
+            code: "\n",
+            output: "\r\n",
+            options: ["windows"],
+            errors: [{
+                line: 1,
+                column: 1,
+                endLine: 2,
+                endColumn: 1,
                 messageId: "expectedCRLF"
             }]
         }
index 9107cd69f0f34a583da8b8b271b5da677ab22592..008f2b01acb7de48d0bb56a9661bb43d7a82bb14 100644 (file)
@@ -164,6 +164,30 @@ if ( x === y ) {
     return bar;
 }());`,
             options: [{ max: 2, skipComments: true, skipBlankLines: false, IIFEs: false }]
+        },
+
+        // Arrow IIFEs should be recognised if IIFEs: true
+        {
+            code: `(() => {
+    let x = 0;
+    let y = 0;
+    let z = x + y;
+    let foo = {};
+    return bar;
+})();`,
+            options: [{ max: 7, skipComments: true, skipBlankLines: false, IIFEs: true }]
+        },
+
+        // Arrow IIFEs should not be recognised if IIFEs: false
+        {
+            code: `(() => {
+    let x = 0;
+    let y = 0;
+    let z = x + y;
+    let foo = {};
+    return bar;
+})();`,
+            options: [{ max: 2, skipComments: true, skipBlankLines: false, IIFEs: false }]
         }
     ],
 
@@ -435,6 +459,21 @@ if ( x === y ) {
             errors: [
                 { messageId: "exceed", data: { name: "Function", lineCount: 7, maxLines: 2 } }
             ]
+        },
+
+        // Test the IIFEs option includes arrow IIFEs
+        {
+            code: `(() => {
+    let x = 0;
+    let y = 0;
+    let z = x + y;
+    let foo = {};
+    return bar;
+})();`,
+            options: [{ max: 2, skipComments: true, skipBlankLines: false, IIFEs: true }],
+            errors: [
+                { messageId: "exceed", data: { name: "Arrow function", lineCount: 7, maxLines: 2 } }
+            ]
         }
     ]
 });
diff --git a/eslint/tests/lib/rules/no-loss-of-precision.js b/eslint/tests/lib/rules/no-loss-of-precision.js
new file mode 100644 (file)
index 0000000..fd2fb20
--- /dev/null
@@ -0,0 +1,159 @@
+/**
+ *@fileoverview Tests for no-loss-of-precision rule.
+ *@author Jacob Moore
+ */
+
+"use strict";
+
+//------------------------------------------------------------------------------
+// Requirements
+//------------------------------------------------------------------------------
+
+const rule = require("../../../lib/rules/no-loss-of-precision"),
+    { RuleTester } = require("../../../lib/rule-tester");
+
+//------------------------------------------------------------------------------
+// Helpers
+//------------------------------------------------------------------------------
+
+const ruleTester = new RuleTester();
+
+ruleTester.run("no-loss-of-precision", rule, {
+    valid: [
+        "var x = 12345",
+        "var x = 123.456",
+        "var x = -123.456",
+        "var x = -123456",
+        "var x = 123e34",
+        "var x = 123.0e34",
+        "var x = 123e-34",
+        "var x = -123e34",
+        "var x = -123e-34",
+        "var x = 12.3e34",
+        "var x = 12.3e-34",
+        "var x = -12.3e34",
+        "var x = -12.3e-34",
+        "var x = 12300000000000000000000000",
+        "var x = -12300000000000000000000000",
+        "var x = 0.00000000000000000000000123",
+        "var x = -0.00000000000000000000000123",
+        "var x = 9007199254740991",
+        "var x = 0",
+        "var x = 0.0",
+        "var x = 0.000000000000000000000000000000000000000000000000000000000000000000000000000000",
+        "var x = -0",
+        "var x = 123.0000000000000000000000",
+        "var x = 019.5",
+        "var x = 0195",
+        "var x = 0e5",
+
+
+        { code: "var x = 0b11111111111111111111111111111111111111111111111111111", parserOptions: { ecmaVersion: 6 } },
+        { code: "var x = 0B11111111111111111111111111111111111111111111111111111", parserOptions: { ecmaVersion: 6 } },
+
+        { code: "var x = 0o377777777777777777", parserOptions: { ecmaVersion: 6 } },
+        { code: "var x = 0O377777777777777777", parserOptions: { ecmaVersion: 6 } },
+        "var x = 0377777777777777777",
+
+        "var x = 0x1FFFFFFFFFFFFF",
+        "var x = 0X1FFFFFFFFFFFFF",
+        "var x = true",
+        "var x = 'abc'",
+        "var x = ''",
+        "var x = null",
+        "var x = undefined",
+        "var x = {}",
+        "var x = ['a', 'b']",
+        "var x = new Date()",
+        "var x = '9007199254740993'"
+
+    ],
+    invalid: [
+        {
+            code: "var x = 9007199254740993",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 9007199254740.993e3",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 9.007199254740993e15",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = -9007199254740993",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 900719.9254740994",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = -900719.9254740994",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+
+        {
+            code: "var x = 5123000000000000000000000000001",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = -5123000000000000000000000000001",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 1230000000000000000000000.0",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 1.0000000000000000000000123",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 2e999",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = .1230000000000000000000000",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 0b100000000000000000000000000000000000000000000000000001",
+            parserOptions: { ecmaVersion: 6 },
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 0B100000000000000000000000000000000000000000000000000001",
+            parserOptions: { ecmaVersion: 6 },
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 0o400000000000000001",
+            parserOptions: { ecmaVersion: 6 },
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 0O400000000000000001",
+            parserOptions: { ecmaVersion: 6 },
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 0400000000000000001",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 0x20000000000001",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        },
+        {
+            code: "var x = 0X20000000000001",
+            errors: [{ messageId: "noLossOfPrecision" }]
+        }
+
+    ]
+});
index bcb35e343ec66de583f35a2a4f90402929adfb19..aa0542090e24229bf28b5b1948b252bea1030bb3 100644 (file)
@@ -21,7 +21,24 @@ const ruleTester = new RuleTester();
 ruleTester.run("no-new-func", rule, {
     valid: [
         "var a = new _function(\"b\", \"c\", \"return b+c\");",
-        "var a = _function(\"b\", \"c\", \"return b+c\");"
+        "var a = _function(\"b\", \"c\", \"return b+c\");",
+        {
+            code: "class Function {}; new Function()",
+            parserOptions: {
+                ecmaVersion: 2015
+            }
+        },
+        {
+            code: "const fn = () => { class Function {}; new Function() }",
+            parserOptions: {
+                ecmaVersion: 2015
+            }
+        },
+        "function Function() {}; Function()",
+        "var fn = function () { function Function() {}; Function() }",
+        "var x = function Function() { Function(); }",
+        "call(Function)",
+        "new Class(Function)"
     ],
     invalid: [
         {
@@ -37,6 +54,23 @@ ruleTester.run("no-new-func", rule, {
                 messageId: "noFunctionConstructor",
                 type: "CallExpression"
             }]
+        },
+        {
+            code: "const fn = () => { class Function {} }; new Function('', '')",
+            parserOptions: {
+                ecmaVersion: 2015
+            },
+            errors: [{
+                messageId: "noFunctionConstructor",
+                type: "NewExpression"
+            }]
+        },
+        {
+            code: "var fn = function () { function Function() {} }; Function('', '')",
+            errors: [{
+                messageId: "noFunctionConstructor",
+                type: "CallExpression"
+            }]
         }
     ]
 });
index 4868592a2a21d41e501b96e6bf2d4176081852e8..198cc50e1f37ee338c7ccb43c07fb15221ed4f9f 100644 (file)
@@ -22,7 +22,9 @@ ruleTester.run("no-new-symbol", rule, {
     valid: [
         "var foo = Symbol('foo');",
         "function bar(Symbol) { var baz = new Symbol('baz');}",
-        "function Symbol() {} new Symbol();"
+        "function Symbol() {} new Symbol();",
+        "new foo(Symbol);",
+        "new foo(bar, Symbol);"
     ],
     invalid: [
         {
index 59af6205452e800c34cb3be616d3274baef26ede..3103ef2d705578035179f0acf5bed1e674f73907 100644 (file)
@@ -68,6 +68,7 @@ ruleTester.run("one-var-declaration-per-line", rule, {
     ],
 
     invalid: [
+        { code: "var foo, bar;", output: "var foo, \nbar;", options: ["always"], errors: [{ line: 1, column: 10, endLine: 1, endColumn: 13 }] },
         { code: "var a, b;", output: "var a, \nb;", options: ["always"], errors: [errorAt(1, 8)] },
         { code: "let a, b;", output: "let a, \nb;", options: ["always"], parserOptions: { ecmaVersion: 6 }, errors: [errorAt(1, 8)] },
         { code: "var a, b = 0;", output: "var a, \nb = 0;", options: ["always"], errors: [errorAt(1, 8)] },
@@ -76,6 +77,7 @@ ruleTester.run("one-var-declaration-per-line", rule, {
         { code: "let a, b = 0;", output: "let a, \nb = 0;", options: ["always"], parserOptions: { ecmaVersion: 6 }, errors: [errorAt(1, 8)] },
         { code: "const a = 0, b = 0;", output: "const a = 0, \nb = 0;", options: ["always"], parserOptions: { ecmaVersion: 6 }, errors: [errorAt(1, 14)] },
 
+        { code: "var foo, bar, baz = 0;", output: "var foo, bar, \nbaz = 0;", options: ["initializations"], errors: [{ line: 1, column: 15, endLine: 1, endColumn: 22 }] },
         { code: "var a, b, c = 0;", output: "var a, b, \nc = 0;", options: ["initializations"], errors: [errorAt(1, 11)] },
         { code: "var a, b,\nc = 0, d;", output: "var a, b,\nc = 0, \nd;", options: ["initializations"], errors: [errorAt(2, 8)] },
         { code: "var a, b,\nc = 0, d = 0;", output: "var a, b,\nc = 0, \nd = 0;", options: ["initializations"], errors: [errorAt(2, 8)] },
index 99d2e0a53e25b409de6d87dab536ba624e302db0..1e15da4d24596f6d7219696137c00f3966cd56b8 100644 (file)
@@ -36,6 +36,7 @@ ruleTester.run("padded-blocks", rule, {
         { code: "{\n\na();\n\n/* comment */ }", options: ["always"] },
         { code: "{\n\na();\n\n/* comment */ }", options: [{ blocks: "always" }] },
 
+
         { code: "switch (a) {}", options: [{ switches: "always" }] },
         { code: "switch (a) {\n\ncase 0: foo();\ncase 1: bar();\n\n}", options: ["always"] },
         { code: "switch (a) {\n\ncase 0: foo();\ncase 1: bar();\n\n}", options: [{ switches: "always" }] },
@@ -95,7 +96,9 @@ ruleTester.run("padded-blocks", rule, {
                 {
                     messageId: "alwaysPadBlock",
                     line: 1,
-                    column: 1
+                    column: 1,
+                    endLine: 2,
+                    endColumn: 1
                 }
             ]
         },
@@ -106,7 +109,9 @@ ruleTester.run("padded-blocks", rule, {
                 {
                     messageId: "alwaysPadBlock",
                     line: 1,
-                    column: 3
+                    column: 3,
+                    endLine: 2,
+                    endColumn: 1
                 }
             ]
         },
@@ -116,8 +121,10 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "alwaysPadBlock",
-                    line: 5,
-                    column: 1
+                    line: 4,
+                    column: 10,
+                    endLine: 5,
+                    endColumn: 1
                 }
             ]
         },
@@ -127,8 +134,10 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "alwaysPadBlock",
-                    line: 5,
-                    column: 1
+                    line: 4,
+                    column: 10,
+                    endLine: 5,
+                    endColumn: 1
                 }
             ]
         },
@@ -138,7 +147,10 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "alwaysPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 1,
+                    endLine: 2,
+                    endColumn: 1
                 }
             ]
         },
@@ -148,7 +160,10 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "alwaysPadBlock",
-                    line: 4
+                    line: 3,
+                    column: 5,
+                    endLine: 4,
+                    endColumn: 1
                 }
             ]
         },
@@ -158,11 +173,17 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "alwaysPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 1,
+                    endLine: 2,
+                    endColumn: 1
                 },
                 {
                     messageId: "alwaysPadBlock",
-                    line: 3
+                    line: 2,
+                    column: 5,
+                    endLine: 3,
+                    endColumn: 1
                 }
             ]
         },
@@ -172,11 +193,17 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "alwaysPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 1,
+                    endLine: 2,
+                    endColumn: 1
                 },
                 {
                     messageId: "alwaysPadBlock",
-                    line: 3
+                    line: 2,
+                    column: 5,
+                    endLine: 3,
+                    endColumn: 1
                 }
             ]
         },
@@ -186,11 +213,17 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "alwaysPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 1,
+                    endLine: 2,
+                    endColumn: 1
                 },
                 {
                     messageId: "alwaysPadBlock",
-                    line: 2
+                    line: 2,
+                    column: 5,
+                    endLine: 2,
+                    endColumn: 5
                 }
             ]
         },
@@ -200,11 +233,17 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "alwaysPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 1,
+                    endLine: 1,
+                    endColumn: 2
                 },
                 {
                     messageId: "alwaysPadBlock",
-                    line: 2
+                    line: 1,
+                    column: 6,
+                    endLine: 2,
+                    endColumn: 1
                 }
             ]
         },
@@ -215,11 +254,17 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "alwaysPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 1,
+                    endLine: 1,
+                    endColumn: 2
                 },
                 {
                     messageId: "alwaysPadBlock",
-                    line: 2
+                    line: 1,
+                    column: 6,
+                    endLine: 2,
+                    endColumn: 1
                 }
             ]
         },
@@ -231,12 +276,16 @@ ruleTester.run("padded-blocks", rule, {
                 {
                     messageId: "alwaysPadBlock",
                     line: 1,
-                    column: 12
+                    column: 12,
+                    endLine: 2,
+                    endColumn: 1
                 },
                 {
                     messageId: "alwaysPadBlock",
-                    line: 4,
-                    column: 1
+                    line: 3,
+                    column: 15,
+                    endLine: 4,
+                    endColumn: 1
                 }
             ]
         },
@@ -248,12 +297,16 @@ ruleTester.run("padded-blocks", rule, {
                 {
                     messageId: "alwaysPadBlock",
                     line: 1,
-                    column: 12
+                    column: 12,
+                    endLine: 2,
+                    endColumn: 1
                 },
                 {
                     messageId: "alwaysPadBlock",
-                    line: 4,
-                    column: 1
+                    line: 3,
+                    column: 15,
+                    endLine: 4,
+                    endColumn: 1
                 }
             ]
         },
@@ -265,12 +318,16 @@ ruleTester.run("padded-blocks", rule, {
                 {
                     messageId: "alwaysPadBlock",
                     line: 1,
-                    column: 12
+                    column: 12,
+                    endLine: 2,
+                    endColumn: 1
                 },
                 {
                     messageId: "alwaysPadBlock",
-                    line: 4,
-                    column: 1
+                    line: 3,
+                    column: 24,
+                    endLine: 4,
+                    endColumn: 1
                 }
             ]
         },
@@ -283,12 +340,16 @@ ruleTester.run("padded-blocks", rule, {
                 {
                     messageId: "alwaysPadBlock",
                     line: 1,
-                    column: 9
+                    column: 9,
+                    endLine: 2,
+                    endColumn: 1
                 },
                 {
                     messageId: "alwaysPadBlock",
-                    line: 3,
-                    column: 1
+                    line: 2,
+                    column: 16,
+                    endLine: 3,
+                    endColumn: 1
                 }
             ]
         },
@@ -301,12 +362,16 @@ ruleTester.run("padded-blocks", rule, {
                 {
                     messageId: "alwaysPadBlock",
                     line: 1,
-                    column: 9
+                    column: 9,
+                    endLine: 2,
+                    endColumn: 1
                 },
                 {
                     messageId: "alwaysPadBlock",
-                    line: 3,
-                    column: 1
+                    line: 2,
+                    column: 16,
+                    endLine: 3,
+                    endColumn: 1
                 }
             ]
         },
@@ -316,11 +381,17 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "alwaysPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 1,
+                    endLine: 1,
+                    endColumn: 2
                 },
                 {
                     messageId: "alwaysPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 6,
+                    endLine: 1,
+                    endColumn: 6
                 }
             ]
         },
@@ -331,7 +402,10 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "neverPadBlock",
-                    line: 5
+                    line: 3,
+                    column: 10,
+                    endLine: 5,
+                    endColumn: 1
                 }
             ]
         },
@@ -342,11 +416,17 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "neverPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 1,
+                    endLine: 3,
+                    endColumn: 1
                 },
                 {
                     messageId: "neverPadBlock",
-                    line: 5
+                    line: 3,
+                    column: 5,
+                    endLine: 5,
+                    endColumn: 1
                 }
             ]
         },
@@ -357,11 +437,17 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "neverPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 1,
+                    endLine: 3,
+                    endColumn: 1
                 },
                 {
                     messageId: "neverPadBlock",
-                    line: 5
+                    line: 3,
+                    column: 5,
+                    endLine: 5,
+                    endColumn: 1
                 }
             ]
         },
@@ -372,11 +458,17 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "neverPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 1,
+                    endLine: 4,
+                    endColumn: 3
                 },
                 {
                     messageId: "neverPadBlock",
-                    line: 7
+                    line: 4,
+                    column: 7,
+                    endLine: 7,
+                    endColumn: 1
                 }
             ]
         },
@@ -387,7 +479,10 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "neverPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 1,
+                    endLine: 3,
+                    endColumn: 1
                 }
             ]
         },
@@ -398,7 +493,10 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "neverPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 1,
+                    endLine: 3,
+                    endColumn: 2
                 }
             ]
         },
@@ -409,7 +507,10 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "neverPadBlock",
-                    line: 4
+                    line: 2,
+                    column: 5,
+                    endLine: 4,
+                    endColumn: 1
                 }
             ]
         },
@@ -420,7 +521,10 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "neverPadBlock",
-                    line: 4
+                    line: 2,
+                    column: 9,
+                    endLine: 4,
+                    endColumn: 3
                 }
             ]
         },
@@ -432,7 +536,9 @@ ruleTester.run("padded-blocks", rule, {
                 {
                     messageId: "alwaysPadBlock",
                     line: 1,
-                    column: 1
+                    column: 1,
+                    endLine: 2,
+                    endColumn: 1
                 }
             ]
         },
@@ -444,7 +550,9 @@ ruleTester.run("padded-blocks", rule, {
                 {
                     messageId: "neverPadBlock",
                     line: 1,
-                    column: 1
+                    column: 1,
+                    endLine: 3,
+                    endColumn: 1
                 }
             ]
         },
@@ -456,7 +564,9 @@ ruleTester.run("padded-blocks", rule, {
                 {
                     messageId: "neverPadBlock",
                     line: 1,
-                    column: 1
+                    column: 1,
+                    endLine: 3,
+                    endColumn: 1
                 }
             ]
         },
@@ -468,12 +578,16 @@ ruleTester.run("padded-blocks", rule, {
                 {
                     messageId: "neverPadBlock",
                     line: 1,
-                    column: 12
+                    column: 12,
+                    endLine: 3,
+                    endColumn: 1
                 },
                 {
                     messageId: "neverPadBlock",
-                    line: 5,
-                    column: 1
+                    line: 3,
+                    column: 15,
+                    endLine: 5,
+                    endColumn: 1
                 }
             ]
         },
@@ -485,7 +599,9 @@ ruleTester.run("padded-blocks", rule, {
                 {
                     messageId: "neverPadBlock",
                     line: 1,
-                    column: 12
+                    column: 12,
+                    endLine: 3,
+                    endColumn: 1
                 }
             ]
         },
@@ -496,8 +612,10 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "neverPadBlock",
-                    line: 4,
-                    column: 3
+                    line: 2,
+                    column: 15,
+                    endLine: 4,
+                    endColumn: 3
                 }
             ]
         },
@@ -509,19 +627,31 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "neverPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 9,
+                    endLine: 3,
+                    endColumn: 1
                 },
                 {
                     messageId: "neverPadBlock",
-                    line: 3
+                    line: 3,
+                    column: 14,
+                    endLine: 5,
+                    endColumn: 1
                 },
                 {
                     messageId: "neverPadBlock",
-                    line: 7
+                    line: 5,
+                    column: 7,
+                    endLine: 7,
+                    endColumn: 1
                 },
                 {
                     messageId: "neverPadBlock",
-                    line: 9
+                    line: 7,
+                    column: 2,
+                    endLine: 9,
+                    endColumn: 1
                 }
             ]
         },
@@ -533,11 +663,17 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "neverPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 9,
+                    endLine: 3,
+                    endColumn: 1
                 },
                 {
                     messageId: "neverPadBlock",
-                    line: 9
+                    line: 7,
+                    column: 2,
+                    endLine: 9,
+                    endColumn: 1
                 }
             ]
         },
@@ -549,19 +685,31 @@ ruleTester.run("padded-blocks", rule, {
             errors: [
                 {
                     messageId: "neverPadBlock",
-                    line: 1
+                    line: 1,
+                    column: 9,
+                    endLine: 3,
+                    endColumn: 1
                 },
                 {
                     messageId: "neverPadBlock",
-                    line: 3
+                    line: 3,
+                    column: 14,
+                    endLine: 5,
+                    endColumn: 1
                 },
                 {
                     messageId: "neverPadBlock",
-                    line: 7
+                    line: 5,
+                    column: 7,
+                    endLine: 7,
+                    endColumn: 1
                 },
                 {
                     messageId: "neverPadBlock",
-                    line: 9
+                    line: 7,
+                    column: 2,
+                    endLine: 9,
+                    endColumn: 1
                 }
             ]
         },
index 4ed598dc86c35db7a800fbfc1f1522526c1473fe..5ed2fe09367c2a1232de75f8b9998c65f18c9a31 100644 (file)
@@ -31,7 +31,7 @@ ruleTester.run("require-await", rule, {
         "({ async foo() { await doSomething() } })",
         "class A { async foo() { await doSomething() } }",
         "(class { async foo() { await doSomething() } })",
-        "async function foo() { await async () => { await doSomething() } }",
+        "async function foo() { await (async () => { await doSomething() }) }",
 
         // empty functions are ok.
         "async function foo() {}",
@@ -152,7 +152,7 @@ ruleTester.run("require-await", rule, {
             }]
         },
         {
-            code: "async function foo() { await async () => { doSomething() } }",
+            code: "async function foo() { await (async () => { doSomething() }) }",
             errors: [{
                 messageId: "missingAwait",
                 data: { name: "Async arrow function" }
index 9e38502a0009842a1c48bb8902d8bb0c7353c532..bcef06424af15117940e0f27d4776c1d62b65d29 100644 (file)
@@ -56,6 +56,21 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 7,
+                endLine: 1,
+                endColumn: 8,
+                messageId: "unexpectedWhitespace",
+                data: { type: "spread" },
+                type: "SpreadElement"
+            }]
+        },
+        {
+            code: "fn(...  args)",
+            output: "fn(...args)",
+            errors: [{
+                line: 1,
+                column: 7,
+                endLine: 1,
+                endColumn: 9,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -67,6 +82,21 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 7,
+                endLine: 1,
+                endColumn: 8,
+                messageId: "unexpectedWhitespace",
+                data: { type: "spread" },
+                type: "SpreadElement"
+            }]
+        },
+        {
+            code: "fn(... \t args)",
+            output: "fn(...args)",
+            errors: [{
+                line: 1,
+                column: 7,
+                endLine: 1,
+                endColumn: 10,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -78,6 +108,34 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 7,
+                endLine: 2,
+                endColumn: 1,
+                messageId: "unexpectedWhitespace",
+                data: { type: "spread" },
+                type: "SpreadElement"
+            }]
+        },
+        {
+            code: "fn(...\n    args)",
+            output: "fn(...args)",
+            errors: [{
+                line: 1,
+                column: 7,
+                endLine: 2,
+                endColumn: 5,
+                messageId: "unexpectedWhitespace",
+                data: { type: "spread" },
+                type: "SpreadElement"
+            }]
+        },
+        {
+            code: "fn(...\n\targs)",
+            output: "fn(...args)",
+            errors: [{
+                line: 1,
+                column: 7,
+                endLine: 2,
+                endColumn: 2,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -90,6 +148,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 7,
+                endLine: 1,
+                endColumn: 8,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -102,6 +162,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 7,
+                endLine: 1,
+                endColumn: 8,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -114,6 +176,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 7,
+                endLine: 2,
+                endColumn: 1,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -125,7 +189,9 @@ ruleTester.run("rest-spread-spacing", rule, {
             options: ["always"],
             errors: [{
                 line: 1,
-                column: 7,
+                column: 4,
+                endLine: 1,
+                endColumn: 7,
                 messageId: "expectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -137,6 +203,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 7,
+                endLine: 1,
+                endColumn: 8,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -148,6 +216,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 7,
+                endLine: 1,
+                endColumn: 8,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -159,7 +229,9 @@ ruleTester.run("rest-spread-spacing", rule, {
             options: ["always"],
             errors: [{
                 line: 1,
-                column: 7,
+                column: 4,
+                endLine: 1,
+                endColumn: 7,
                 messageId: "expectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -171,7 +243,9 @@ ruleTester.run("rest-spread-spacing", rule, {
             options: ["always"],
             errors: [{
                 line: 1,
-                column: 7,
+                column: 4,
+                endLine: 1,
+                endColumn: 7,
                 messageId: "expectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -183,6 +257,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 5,
+                endLine: 1,
+                endColumn: 6,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -194,6 +270,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 5,
+                endLine: 1,
+                endColumn: 6,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -205,6 +283,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 5,
+                endLine: 2,
+                endColumn: 1,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -217,6 +297,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 5,
+                endLine: 1,
+                endColumn: 6,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -229,6 +311,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 5,
+                endLine: 1,
+                endColumn: 6,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -241,6 +325,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 5,
+                endLine: 2,
+                endColumn: 1,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -252,7 +338,9 @@ ruleTester.run("rest-spread-spacing", rule, {
             options: ["always"],
             errors: [{
                 line: 1,
-                column: 5,
+                column: 2,
+                endLine: 1,
+                endColumn: 5,
                 messageId: "expectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -264,6 +352,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 5,
+                endLine: 1,
+                endColumn: 6,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -275,6 +365,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 5,
+                endLine: 1,
+                endColumn: 6,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -286,7 +378,9 @@ ruleTester.run("rest-spread-spacing", rule, {
             options: ["always"],
             errors: [{
                 line: 1,
-                column: 5,
+                column: 2,
+                endLine: 1,
+                endColumn: 5,
                 messageId: "expectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -298,7 +392,9 @@ ruleTester.run("rest-spread-spacing", rule, {
             options: ["always"],
             errors: [{
                 line: 1,
-                column: 5,
+                column: 2,
+                endLine: 1,
+                endColumn: 5,
                 messageId: "expectedWhitespace",
                 data: { type: "spread" },
                 type: "SpreadElement"
@@ -310,6 +406,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 15,
+                endLine: 1,
+                endColumn: 16,
                 messageId: "unexpectedWhitespace",
                 data: { type: "rest" },
                 type: "RestElement"
@@ -321,6 +419,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 15,
+                endLine: 1,
+                endColumn: 16,
                 messageId: "unexpectedWhitespace",
                 data: { type: "rest" },
                 type: "RestElement"
@@ -332,6 +432,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 15,
+                endLine: 2,
+                endColumn: 1,
                 messageId: "unexpectedWhitespace",
                 data: { type: "rest" },
                 type: "RestElement"
@@ -344,6 +446,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 15,
+                endLine: 1,
+                endColumn: 16,
                 messageId: "unexpectedWhitespace",
                 data: { type: "rest" },
                 type: "RestElement"
@@ -356,6 +460,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 15,
+                endLine: 1,
+                endColumn: 16,
                 messageId: "unexpectedWhitespace",
                 data: { type: "rest" },
                 type: "RestElement"
@@ -368,6 +474,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 15,
+                endLine: 2,
+                endColumn: 1,
                 messageId: "unexpectedWhitespace",
                 data: { type: "rest" },
                 type: "RestElement"
@@ -379,7 +487,9 @@ ruleTester.run("rest-spread-spacing", rule, {
             options: ["always"],
             errors: [{
                 line: 1,
-                column: 15,
+                column: 12,
+                endLine: 1,
+                endColumn: 15,
                 messageId: "expectedWhitespace",
                 data: { type: "rest" },
                 type: "RestElement"
@@ -392,6 +502,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 20,
+                endLine: 1,
+                endColumn: 21,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread property" },
                 type: "SpreadElement"
@@ -404,6 +516,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 20,
+                endLine: 1,
+                endColumn: 21,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread property" },
                 type: "SpreadElement"
@@ -416,6 +530,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 20,
+                endLine: 2,
+                endColumn: 1,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread property" },
                 type: "SpreadElement"
@@ -429,6 +545,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 20,
+                endLine: 1,
+                endColumn: 21,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread property" },
                 type: "SpreadElement"
@@ -442,6 +560,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 20,
+                endLine: 1,
+                endColumn: 21,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread property" },
                 type: "SpreadElement"
@@ -455,6 +575,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 20,
+                endLine: 2,
+                endColumn: 1,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread property" },
                 type: "SpreadElement"
@@ -467,7 +589,9 @@ ruleTester.run("rest-spread-spacing", rule, {
             parserOptions: { ecmaVersion: 2018 },
             errors: [{
                 line: 1,
-                column: 20,
+                column: 17,
+                endLine: 1,
+                endColumn: 20,
                 messageId: "expectedWhitespace",
                 data: { type: "spread property" },
                 type: "SpreadElement"
@@ -481,6 +605,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 20,
+                endLine: 1,
+                endColumn: 21,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread property" },
                 type: "SpreadElement"
@@ -494,6 +620,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 20,
+                endLine: 1,
+                endColumn: 21,
                 messageId: "unexpectedWhitespace",
                 data: { type: "spread property" },
                 type: "SpreadElement"
@@ -506,7 +634,9 @@ ruleTester.run("rest-spread-spacing", rule, {
             parserOptions: { ecmaVersion: 2018 },
             errors: [{
                 line: 1,
-                column: 20,
+                column: 17,
+                endLine: 1,
+                endColumn: 20,
                 messageId: "expectedWhitespace",
                 data: { type: "spread property" },
                 type: "SpreadElement"
@@ -519,7 +649,9 @@ ruleTester.run("rest-spread-spacing", rule, {
             parserOptions: { ecmaVersion: 2018 },
             errors: [{
                 line: 1,
-                column: 20,
+                column: 17,
+                endLine: 1,
+                endColumn: 20,
                 messageId: "expectedWhitespace",
                 data: { type: "spread property" },
                 type: "SpreadElement"
@@ -532,6 +664,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 16,
+                endLine: 1,
+                endColumn: 17,
                 messageId: "unexpectedWhitespace",
                 data: { type: "rest property" },
                 type: "RestElement"
@@ -544,6 +678,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 16,
+                endLine: 1,
+                endColumn: 17,
                 messageId: "unexpectedWhitespace",
                 data: { type: "rest property" },
                 type: "RestElement"
@@ -556,6 +692,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 16,
+                endLine: 2,
+                endColumn: 1,
                 messageId: "unexpectedWhitespace",
                 data: { type: "rest property" },
                 type: "RestElement"
@@ -569,6 +707,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 16,
+                endLine: 1,
+                endColumn: 17,
                 messageId: "unexpectedWhitespace",
                 data: { type: "rest property" },
                 type: "RestElement"
@@ -582,6 +722,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 16,
+                endLine: 1,
+                endColumn: 17,
                 messageId: "unexpectedWhitespace",
                 data: { type: "rest property" },
                 type: "RestElement"
@@ -595,6 +737,8 @@ ruleTester.run("rest-spread-spacing", rule, {
             errors: [{
                 line: 1,
                 column: 16,
+                endLine: 2,
+                endColumn: 1,
                 messageId: "unexpectedWhitespace",
                 data: { type: "rest property" },
                 type: "RestElement"
@@ -607,7 +751,9 @@ ruleTester.run("rest-spread-spacing", rule, {
             parserOptions: { ecmaVersion: 2018 },
             errors: [{
                 line: 1,
-                column: 16,
+                column: 13,
+                endLine: 1,
+                endColumn: 16,
                 messageId: "expectedWhitespace",
                 data: { type: "rest property" },
                 type: "RestElement"
index c1098df6f8ec3c4bb49d5879ae135e50116434a0..6582a5ca690e90e8b873a76f0502f09a5d5a76a0 100644 (file)
@@ -58,92 +58,171 @@ ruleTester.run("semi-spacing", rule, {
         { code: "for ( var i = 0;i < results.length; ) {}", options: [{ after: false }] }
     ],
     invalid: [
+        {
+            code: "var a = 'b'  ;",
+            output: "var a = 'b';",
+            errors: [
+                {
+                    messageId: "unexpectedWhitespaceBefore",
+                    type: "VariableDeclaration",
+                    line: 1,
+                    column: 12,
+                    endLine: 1,
+                    endColumn: 14
+                }
+            ]
+        },
         {
             code: "var a = 'b' ;",
             output: "var a = 'b';",
-            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "VariableDeclaration", line: 1, column: 13 }]
+            errors: [
+                {
+                    messageId: "unexpectedWhitespaceBefore",
+                    type: "VariableDeclaration",
+                    line: 1,
+                    column: 12,
+                    endLine: 1,
+                    endColumn: 13
+                }
+            ]
         },
         {
             code: "var a = 'b',\nc = 'd' ;",
             output: "var a = 'b',\nc = 'd';",
-            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "VariableDeclaration", line: 2, column: 9 }]
+            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "VariableDeclaration", line: 2, column: 8 }]
         },
         {
             code: "var a = function() {} ;",
             output: "var a = function() {};",
-            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "VariableDeclaration", line: 1, column: 23 }]
+            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "VariableDeclaration", line: 1, column: 22 }]
         },
         {
             code: "var a = function() {\n} ;",
             output: "var a = function() {\n};",
-            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "VariableDeclaration", line: 2, column: 3 }]
+            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "VariableDeclaration", line: 2, column: 2 }]
         },
         {
             code: "/^a$/.test('b') ;",
             output: "/^a$/.test('b');",
-            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "ExpressionStatement", line: 1, column: 17 }]
+            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "ExpressionStatement", line: 1, column: 16 }]
         },
         {
             code: ";(function(){}()) ;",
             output: ";(function(){}());",
-            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "ExpressionStatement", line: 1, column: 19 }]
+            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "ExpressionStatement", line: 1, column: 18 }]
         },
         {
             code: "while (true) { break ; }",
             output: "while (true) { break; }",
-            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "BreakStatement", line: 1, column: 22 }]
+            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "BreakStatement", line: 1, column: 21 }]
         },
         {
             code: "while (true) { continue ; }",
             output: "while (true) { continue; }",
-            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "ContinueStatement", line: 1, column: 25 }]
+            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "ContinueStatement", line: 1, column: 24 }]
         },
         {
             code: "debugger ;",
             output: "debugger;",
-            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "DebuggerStatement", line: 1, column: 10 }]
+            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "DebuggerStatement", line: 1, column: 9 }]
         },
         {
             code: "function foo() { return ; }",
             output: "function foo() { return; }",
-            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "ReturnStatement", line: 1, column: 25 }]
+            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "ReturnStatement", line: 1, column: 24 }]
         },
         {
             code: "throw new Error('foo') ;",
             output: "throw new Error('foo');",
-            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "ThrowStatement", line: 1, column: 24 }]
+            errors: [{ messageId: "unexpectedWhitespaceBefore", type: "ThrowStatement", line: 1, column: 23 }]
         },
         {
             code: "for (var i = 0 ; i < 10 ; i++) {}",
             output: "for (var i = 0; i < 10; i++) {}",
             errors: [
-                { messageId: "unexpectedWhitespaceBefore", type: "ForStatement", line: 1, column: 16 },
-                { messageId: "unexpectedWhitespaceBefore", type: "ForStatement", line: 1, column: 25 }
+                { messageId: "unexpectedWhitespaceBefore", type: "ForStatement", line: 1, column: 15 },
+                { messageId: "unexpectedWhitespaceBefore", type: "ForStatement", line: 1, column: 24 }
             ]
         },
         {
             code: "var a = 'b';c = 'd';",
             output: "var a = 'b'; c = 'd';",
-            errors: [{ messageId: "missingWhitespaceAfter", type: "VariableDeclaration", line: 1, column: 12 }]
+            errors: [
+                {
+                    messageId: "missingWhitespaceAfter",
+                    type: "VariableDeclaration",
+                    line: 1,
+                    column: 12,
+                    endLine: 1,
+                    endColumn: 13
+                }
+            ]
         },
         {
             code: "var a = 'b';",
             output: "var a = 'b' ;",
             options: [{ before: true, after: true }],
-            errors: [{ messageId: "missingWhitespaceBefore", type: "VariableDeclaration", line: 1, column: 12 }]
+            errors: [
+                {
+                    messageId: "missingWhitespaceBefore",
+                    type: "VariableDeclaration",
+                    line: 1,
+                    column: 12,
+                    endLine: 1,
+                    endColumn: 13
+                }
+            ]
         },
         {
             code: "var a = 'b'; c = 'd';",
             output: "var a = 'b';c = 'd';",
             options: [{ before: false, after: false }],
-            errors: [{ messageId: "unexpectedWhitespaceAfter", type: "VariableDeclaration", line: 1, column: 12 }]
+            errors: [
+                {
+                    messageId: "unexpectedWhitespaceAfter",
+                    type: "VariableDeclaration",
+                    line: 1,
+                    column: 13,
+                    endLine: 1,
+                    endColumn: 14
+                }
+            ]
+        },
+        {
+            code: "var a = 'b';   c = 'd';",
+            output: "var a = 'b';c = 'd';",
+            options: [{ before: false, after: false }],
+            errors: [
+                {
+                    messageId: "unexpectedWhitespaceAfter",
+                    type: "VariableDeclaration",
+                    line: 1,
+                    column: 13,
+                    endLine: 1,
+                    endColumn: 16
+                }
+            ]
         },
         {
             code: "for (var i = 0;i < 10;i++) {}",
             output: "for (var i = 0; i < 10; i++) {}",
             errors: [
-                { messageId: "missingWhitespaceAfter", type: "ForStatement", line: 1, column: 15 },
-                { messageId: "missingWhitespaceAfter", type: "ForStatement", line: 1, column: 22 }
+                {
+                    messageId: "missingWhitespaceAfter",
+                    type: "ForStatement",
+                    line: 1,
+                    column: 15,
+                    endLine: 1,
+                    endColumn: 16
+                },
+                {
+                    messageId: "missingWhitespaceAfter",
+                    type: "ForStatement",
+                    line: 1,
+                    column: 22,
+                    endLine: 1,
+                    endColumn: 23
+                }
             ]
         },
         {
@@ -151,8 +230,22 @@ ruleTester.run("semi-spacing", rule, {
             output: "for (var i = 0 ; i < 10 ; i++) {}",
             options: [{ before: true, after: true }],
             errors: [
-                { messageId: "missingWhitespaceBefore", type: "ForStatement", line: 1, column: 15 },
-                { messageId: "missingWhitespaceBefore", type: "ForStatement", line: 1, column: 23 }
+                {
+                    messageId: "missingWhitespaceBefore",
+                    type: "ForStatement",
+                    line: 1,
+                    column: 15,
+                    endLine: 1,
+                    endColumn: 16
+                },
+                {
+                    messageId: "missingWhitespaceBefore",
+                    type: "ForStatement",
+                    line: 1,
+                    column: 23,
+                    endLine: 1,
+                    endColumn: 24
+                }
             ]
         },
         {
@@ -160,8 +253,8 @@ ruleTester.run("semi-spacing", rule, {
             output: "for (var i = 0;i < 10;i++) {}",
             options: [{ before: false, after: false }],
             errors: [
-                { messageId: "unexpectedWhitespaceAfter", type: "ForStatement", line: 1, column: 15 },
-                { messageId: "unexpectedWhitespaceAfter", type: "ForStatement", line: 1, column: 23 }
+                { messageId: "unexpectedWhitespaceAfter", type: "ForStatement", line: 1, column: 16 },
+                { messageId: "unexpectedWhitespaceAfter", type: "ForStatement", line: 1, column: 24 }
             ]
         },
         {
@@ -170,7 +263,7 @@ ruleTester.run("semi-spacing", rule, {
             options: [{ before: false, after: true }],
             parserOptions: { ecmaVersion: 6, sourceType: "module" },
             errors: [
-                { messageId: "unexpectedWhitespaceBefore", type: "ImportDeclaration", line: 1, column: 23 }
+                { messageId: "unexpectedWhitespaceBefore", type: "ImportDeclaration", line: 1, column: 22 }
             ]
         },
         {
@@ -179,7 +272,7 @@ ruleTester.run("semi-spacing", rule, {
             options: [{ before: false, after: true }],
             parserOptions: { ecmaVersion: 6, sourceType: "module" },
             errors: [
-                { messageId: "unexpectedWhitespaceBefore", type: "ImportDeclaration", line: 1, column: 28 }
+                { messageId: "unexpectedWhitespaceBefore", type: "ImportDeclaration", line: 1, column: 27 }
             ]
         },
         {
@@ -188,7 +281,7 @@ ruleTester.run("semi-spacing", rule, {
             options: [{ before: false, after: true }],
             parserOptions: { ecmaVersion: 6, sourceType: "module" },
             errors: [
-                { messageId: "unexpectedWhitespaceBefore", type: "ExportNamedDeclaration", line: 1, column: 27 }
+                { messageId: "unexpectedWhitespaceBefore", type: "ExportNamedDeclaration", line: 1, column: 26 }
             ]
         },
         {
@@ -197,7 +290,7 @@ ruleTester.run("semi-spacing", rule, {
             options: [{ before: false, after: true }],
             parserOptions: { ecmaVersion: 6, sourceType: "module" },
             errors: [
-                { messageId: "unexpectedWhitespaceBefore", type: "ExportAllDeclaration", line: 1, column: 21 }
+                { messageId: "unexpectedWhitespaceBefore", type: "ExportAllDeclaration", line: 1, column: 20 }
             ]
         },
         {
@@ -206,7 +299,76 @@ ruleTester.run("semi-spacing", rule, {
             options: [{ before: false, after: true }],
             parserOptions: { ecmaVersion: 6, sourceType: "module" },
             errors: [
-                { messageId: "unexpectedWhitespaceBefore", type: "ExportDefaultDeclaration", line: 1, column: 20 }
+                { messageId: "unexpectedWhitespaceBefore", type: "ExportDefaultDeclaration", line: 1, column: 19 }
+            ]
+        },
+        {
+            code: "while(foo) {continue   ;}",
+            output: "while(foo) {continue;}",
+            options: [{ before: false, after: true }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [
+                {
+                    messageId: "unexpectedWhitespaceBefore",
+                    type: "ContinueStatement",
+                    line: 1,
+                    column: 21,
+                    endLine: 1,
+                    endColumn: 24
+                }
+            ]
+        },
+        {
+            code: "if(foo) {throw new Error()   ;  }",
+            output: "if(foo) {throw new Error();  }",
+            options: [{ before: false, after: false }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [
+                {
+                    messageId: "unexpectedWhitespaceBefore",
+                    type: "ThrowStatement",
+                    line: 1,
+                    column: 27,
+                    endLine: 1,
+                    endColumn: 30
+                }
+            ]
+        },
+        {
+            code: "for(a ; ; );",
+            output: "for(a;; );",
+            options: [{ before: false, after: false }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [{
+                type: "ForStatement",
+                messageId: "unexpectedWhitespaceBefore",
+                line: 1,
+                column: 6,
+                endLine: 1,
+                endColumn: 7
+            },
+            {
+                type: "ForStatement",
+                messageId: "unexpectedWhitespaceAfter",
+                line: 1,
+                column: 8,
+                endLine: 1,
+                endColumn: 9
+            }]
+        },
+        {
+            code: "for(a ; \n ; );",
+            output: "for(a; \n ; );",
+            options: [{ before: false, after: false }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [{
+                type: "ForStatement",
+                messageId: "unexpectedWhitespaceBefore",
+                line: 1,
+                column: 6,
+                endLine: 1,
+                endColumn: 7
+            }
             ]
         }
     ]
index d38fc89284bc4d94d06c6fc2e6c6b1b5d488dc15..ce6310e1be012ecd0a1eb5322abedc335f2511df 100644 (file)
@@ -359,6 +359,17 @@ ruleTester.run("semi", rule, {
                 endColumn: 1
             }]
         },
+        {
+            code: "foo()\r\n",
+            output: "foo();\r\n",
+            errors: [{
+                messageId: "missingSemi",
+                type: "ExpressionStatement",
+                column: 6,
+                endLine: 2,
+                endColumn: 1
+            }]
+        },
         {
             code: "foo()\nbar();",
             output: "foo();\nbar();",
@@ -370,6 +381,17 @@ ruleTester.run("semi", rule, {
                 endColumn: 1
             }]
         },
+        {
+            code: "foo()\r\nbar();",
+            output: "foo();\r\nbar();",
+            errors: [{
+                messageId: "missingSemi",
+                type: "ExpressionStatement",
+                column: 6,
+                endLine: 2,
+                endColumn: 1
+            }]
+        },
         {
             code: "for (var a in b) var i ",
             output: "for (var a in b) var i; ",
index dfa494fb6dc4c5814ae71a6b08ff194318686d6c..683e5ed2a6e337b6c4e149152148c8e940d3e4a4 100644 (file)
@@ -914,38 +914,49 @@ describe("ast-utils", () => {
     });
 
     describe("getNextLocation", () => {
-        const code = "foo;\n";
-        const ast = espree.parse(code, ESPREE_CONFIG);
-        const sourceCode = new SourceCode(code, ast);
-
-        it("should handle normal case", () => {
-            assert.deepStrictEqual(
-                astUtils.getNextLocation(
-                    sourceCode,
-                    { line: 1, column: 0 }
-                ),
-                { line: 1, column: 1 }
-            );
-        });
 
-        it("should handle linebreaks", () => {
-            assert.deepStrictEqual(
-                astUtils.getNextLocation(
-                    sourceCode,
-                    { line: 1, column: 4 }
-                ),
-                { line: 2, column: 0 }
-            );
-        });
+        /* eslint-disable quote-props */
+        const expectedResults = {
+            "": [[1, 0], null],
+            "\n": [[1, 0], [2, 0], null],
+            "\r\n": [[1, 0], [2, 0], null],
+            "foo": [[1, 0], [1, 1], [1, 2], [1, 3], null],
+            "foo\n": [[1, 0], [1, 1], [1, 2], [1, 3], [2, 0], null],
+            "foo\r\n": [[1, 0], [1, 1], [1, 2], [1, 3], [2, 0], null],
+            "foo;\n": [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [2, 0], null],
+            "a\nb": [[1, 0], [1, 1], [2, 0], [2, 1], null],
+            "a\nb\n": [[1, 0], [1, 1], [2, 0], [2, 1], [3, 0], null],
+            "a\r\nb\r\n": [[1, 0], [1, 1], [2, 0], [2, 1], [3, 0], null],
+            "a\nb\r\n": [[1, 0], [1, 1], [2, 0], [2, 1], [3, 0], null],
+            "a\n\n": [[1, 0], [1, 1], [2, 0], [3, 0], null],
+            "a\r\n\r\n": [[1, 0], [1, 1], [2, 0], [3, 0], null],
+            "\n\r\n\n\r\n": [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], null],
+            "ab\u2029c": [[1, 0], [1, 1], [1, 2], [2, 0], [2, 1], null],
+            "ab\ncde\n": [[1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [2, 3], [3, 0], null],
+            "a ": [[1, 0], [1, 1], [1, 2], null],
+            "a\t": [[1, 0], [1, 1], [1, 2], null],
+            "a \n": [[1, 0], [1, 1], [1, 2], [2, 0], null]
+        };
+        /* eslint-enable quote-props */
 
-        it("should return null when result is out of bound", () => {
-            assert.strictEqual(
-                astUtils.getNextLocation(
-                    sourceCode,
-                    { line: 2, column: 0 }
-                ),
-                null
-            );
+        Object.keys(expectedResults).forEach(code => {
+            it(`should return expected locations for "${code}".`, () => {
+                const ast = espree.parse(code, ESPREE_CONFIG);
+                const sourceCode = new SourceCode(code, ast);
+                const locations = expectedResults[code];
+
+                for (let i = 0; i < locations.length - 1; i++) {
+                    const location = { line: locations[i][0], column: locations[i][1] };
+                    const expectedNextLocation = locations[i + 1]
+                        ? { line: locations[i + 1][0], column: locations[i + 1][1] }
+                        : null;
+
+                    assert.deepStrictEqual(
+                        astUtils.getNextLocation(sourceCode, location),
+                        expectedNextLocation
+                    );
+                }
+            });
         });
     });
 
index c3c2498556b6bc5e0c9933880615e8bd2f0e5666..f33aa1b66783dd7cb469e6db635bb92313d62325 100644 (file)
     "no-lone-blocks": "suggestion",
     "no-lonely-if": "suggestion",
     "no-loop-func": "suggestion",
+    "no-loss-of-precision": "problem",
     "no-magic-numbers": "suggestion",
     "no-misleading-character-class": "problem",
     "no-mixed-operators": "suggestion",
     "wrap-regex": "layout",
     "yield-star-spacing": "layout",
     "yoda": "suggestion"
-}
+}
\ No newline at end of file