eslint 6.0.0-alpha.2 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/README.md +4 -11
- package/bin/eslint.js +4 -1
- package/lib/cli-engine/cascading-config-array-factory.js +15 -3
- package/lib/cli-engine/cli-engine.js +13 -3
- package/lib/cli-engine/config-array/config-array.js +1 -2
- package/lib/cli-engine/config-array/override-tester.js +11 -1
- package/lib/cli-engine/config-array-factory.js +7 -6
- package/lib/cli-engine/file-enumerator.js +5 -13
- package/lib/cli-engine/formatters/junit.js +14 -2
- package/lib/init/config-initializer.js +19 -9
- package/lib/linter/linter.js +2 -4
- package/lib/linter/node-event-generator.js +6 -4
- package/lib/rule-tester/rule-tester.js +41 -11
- package/lib/rules/arrow-body-style.js +2 -2
- package/lib/rules/arrow-parens.js +21 -0
- package/lib/rules/dot-location.js +21 -17
- package/lib/rules/max-len.js +7 -0
- package/lib/rules/multiline-comment-style.js +2 -1
- package/lib/rules/no-else-return.js +127 -0
- package/lib/rules/no-extra-parens.js +241 -17
- package/lib/rules/no-octal.js +1 -1
- package/lib/rules/no-param-reassign.js +12 -1
- package/lib/rules/no-restricted-imports.js +18 -14
- package/lib/rules/no-useless-escape.js +6 -1
- package/lib/rules/no-var.js +14 -1
- package/lib/rules/prefer-const.js +9 -3
- package/lib/rules/require-atomic-updates.js +63 -84
- package/lib/rules/sort-keys.js +11 -3
- package/lib/rules/utils/ast-utils.js +26 -1
- package/lib/rules/valid-typeof.js +1 -1
- package/lib/{cli-engine → shared}/naming.js +0 -0
- package/messages/extend-config-missing.txt +2 -0
- package/messages/print-config-with-directory-path.txt +2 -0
- package/package.json +24 -27
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,77 @@
|
|
1
|
+
v6.1.0 - July 20, 2019
|
2
|
+
|
3
|
+
* [`8f86cca`](https://github.com/eslint/eslint/commit/8f86ccaa89daf10123370868c5dcb48c1fcbef7d) Upgrade: eslint-scope@^5.0.0 (#12011) (Kevin Partington)
|
4
|
+
* [`d08683e`](https://github.com/eslint/eslint/commit/d08683e3c807f92daf266894093c70f8d5ac6afa) Fix: glob processing (fixes #11940) (#11986) (Toru Nagashima)
|
5
|
+
* [`bfcf8b2`](https://github.com/eslint/eslint/commit/bfcf8b21011466b570b536ca31ec10fd228b3dca) Fix: dot-location errors with parenthesized objects (fixes #11868) (#11933) (Milos Djermanovic)
|
6
|
+
* [`79e8d09`](https://github.com/eslint/eslint/commit/79e8d099bbbebfa4d804484eeeeea9c074ede870) Fix: add parens for sequence expr in arrow-body-style (fixes #11917) (#11918) (Pig Fang)
|
7
|
+
* [`105c098`](https://github.com/eslint/eslint/commit/105c098f3cece8b83ab8d1566b8ea41dd94a60b9) Docs: update docs for object-curly-spacing (fixes #11634) (#12009) (Chiawen Chen)
|
8
|
+
* [`c90a12c`](https://github.com/eslint/eslint/commit/c90a12c283698befcafd2c86f8bd8942428fe80b) Chore: update release script for new website repo (#12006) (Kai Cataldo)
|
9
|
+
* [`e2c08a9`](https://github.com/eslint/eslint/commit/e2c08a9c8d86238955ecc8fd5a626584ee91eba5) Sponsors: Sync README with website (ESLint Jenkins)
|
10
|
+
* [`b974fcb`](https://github.com/eslint/eslint/commit/b974fcbd3321ab382a914520018d4c051b2e5c62) Update: Check computed property keys in no-extra-parens (#11952) (Milos Djermanovic)
|
11
|
+
* [`222d27c`](https://github.com/eslint/eslint/commit/222d27c32a6d6d8828233b3b99e93ecefa94c603) Update: Add for-in and for-of checks for props in no-param-reassign (#11941) (Milos Djermanovic)
|
12
|
+
* [`e4c450f`](https://github.com/eslint/eslint/commit/e4c450febc9bd77b33f6473667afa9f955be6b71) Fix: no-extra-parens autofix with `in` in a for-loop init (fixes #11706) (#11848) (Milos Djermanovic)
|
13
|
+
* [`2dafe2d`](https://github.com/eslint/eslint/commit/2dafe2d288d1e0d353bb938d12a5da888091cfdb) Fix: prefer-const produces invalid autofix (fixes #11699) (#11827) (Milos Djermanovic)
|
14
|
+
* [`cb475fd`](https://github.com/eslint/eslint/commit/cb475fd8c0bbfcb00340459966b6780f39ea87a7) Fix: Cache file error handling on read-only file system. (fixes #11945) (#11946) (Cuki)
|
15
|
+
* [`89412c3`](https://github.com/eslint/eslint/commit/89412c3cbc52e556dba590fa94e10bf40faf1fdf) Docs: Fixed a typo (fixes #11999) (#12000) (Eddie Olson)
|
16
|
+
* [`6669f78`](https://github.com/eslint/eslint/commit/6669f78a3dd305aef6191e7eea24fae2ae4fd2e8) Fix: --init with Vue.js failed (fixes #11970) (#11985) (Toru Nagashima)
|
17
|
+
* [`93633c2`](https://github.com/eslint/eslint/commit/93633c2b3716b17816bcb3dc221c49b75db41317) Upgrade: Upgrade lodash dependency (fixes #11992) (#11994) (Cyd La Luz)
|
18
|
+
* [`776dae7`](https://github.com/eslint/eslint/commit/776dae71f2f5c7b5f0650ea3c277eca26e324e41) Docs: fix wrong Node.js version in getting started (#11993) (Toru Nagashima)
|
19
|
+
* [`4448261`](https://github.com/eslint/eslint/commit/4448261f5d217d8a06eb0ef898401928b54a34e3) Docs: some typos and optimization points (#11960) (Jason Lee)
|
20
|
+
* [`2a10856`](https://github.com/eslint/eslint/commit/2a10856d1ed5880a09a5ba452bd80d49c1be4e6c) Chore: Add temporary test files to .gitignore (#11978) (Milos Djermanovic)
|
21
|
+
* [`d83b233`](https://github.com/eslint/eslint/commit/d83b23382de3b80056a7e6330ed5846316c94147) Chore: update path for release bundles (#11977) (Kai Cataldo)
|
22
|
+
* [`1fb3620`](https://github.com/eslint/eslint/commit/1fb362093a65b99456a11029967d9ee0c31fd697) Fix: creating of enabledGlobals object without prototype (fixes #11929) (#11935) (finico)
|
23
|
+
* [`c2f2db9`](https://github.com/eslint/eslint/commit/c2f2db97c6d6a415b78ee7b3e8924853d465e757) Docs: Replace global true and false with writable and readonly in rules (#11956) (Milos Djermanovic)
|
24
|
+
* [`19335b8`](https://github.com/eslint/eslint/commit/19335b8f47029b2f742d5507ba39484eaf68d07b) Fix: actual messageId and expected messageId are switched in rule tester (#11928) (Milos Djermanovic)
|
25
|
+
* [`8b216e0`](https://github.com/eslint/eslint/commit/8b216e04fb0dd0a1a4d3730ebe4b24780020b09c) Docs: Fix incorrect example comments for unicode-bom rule (fixes #11937) (#11938) (Brandon Yeager)
|
26
|
+
* [`cc3885b`](https://github.com/eslint/eslint/commit/cc3885b028e29ebc575c900f43af81cb0dabffb6) Chore: add v8-compile-cache to speed up instantiation time (#11921) (薛定谔的猫)
|
27
|
+
* [`d8f2688`](https://github.com/eslint/eslint/commit/d8f26886f19a17f2e1cdcb91e2db84fc7ba3fdfb) Upgrade: deps (#11904) (薛定谔的猫)
|
28
|
+
* [`e5f1ccc`](https://github.com/eslint/eslint/commit/e5f1ccc9e2d07ad0acf149027ffc382021d54da1) Docs: add 'stricter rule config validating' in migrating docs (#11905) (薛定谔的猫)
|
29
|
+
|
30
|
+
v6.0.1 - June 24, 2019
|
31
|
+
|
32
|
+
* [`b5bde06`](https://github.com/eslint/eslint/commit/b5bde0669bd6a7a6b8e38cdf204d8d4b932cea63) Fix: --rulesdir option didn't work (fixes #11888) (#11890) (Toru Nagashima)
|
33
|
+
* [`13f0418`](https://github.com/eslint/eslint/commit/13f041897ee31982808a57b4d06450b57c9b27dc) Fix: improve error message on --print-config (fixes #11874) (#11885) (Toru Nagashima)
|
34
|
+
* [`056c2aa`](https://github.com/eslint/eslint/commit/056c2aaf39a5f8d06de24f06946dda95032a0361) Fix: improve diagnostics for shareable-config-missing errors (#11880) (Teddy Katz)
|
35
|
+
* [`566b7aa`](https://github.com/eslint/eslint/commit/566b7aa5d61fb31cd47fe4da7820b07cf9bde1ec) Docs: Update no-confusing-arrow with the new default option (#11886) (Yuping Zuo)
|
36
|
+
* [`d07f3fa`](https://github.com/eslint/eslint/commit/d07f3fae19b901c30cf4998f10722cb3182bd237) Fix: CLIEngine#getRules() contains plugin rules (fixes #11871) (#11872) (Toru Nagashima)
|
37
|
+
* [`21f4a80`](https://github.com/eslint/eslint/commit/21f4a8057ccc941f72bb617ae3b5c135a774f6c0) Docs: Fix inconsistent linking in migration guide (#11881) (Teddy Katz)
|
38
|
+
* [`f3a0774`](https://github.com/eslint/eslint/commit/f3a0774a8879b08777a4aedc76677f13d5156242) Docs: Fix typo in 6.0.0 migration guide (#11870) (Kevin Partington)
|
39
|
+
|
40
|
+
v6.0.0 - June 21, 2019
|
41
|
+
|
42
|
+
* [`81aa06b`](https://github.com/eslint/eslint/commit/81aa06b4cc49e9c15234a2c4d27659a03fea53d8) Upgrade: espree@6.0.0 (#11869) (Teddy Katz)
|
43
|
+
* [`5f022bc`](https://github.com/eslint/eslint/commit/5f022bc91d0d93d140876ceb1ee4e08b1b7cfd49) Fix: no-else-return autofix produces name collisions (fixes #11069) (#11867) (Milos Djermanovic)
|
44
|
+
* [`ded9548`](https://github.com/eslint/eslint/commit/ded9548d881b15e771ca79b844e8159601f30f70) Fix: multiline-comment-style incorrect message (#11864) (golopot)
|
45
|
+
* [`cad074d`](https://github.com/eslint/eslint/commit/cad074d4ddb34a59183b5965ca50170713b5a711) Docs: Add JSHint W047 compat to no-floating-decimal (#11861) (Timo Tijhof)
|
46
|
+
* [`41f6304`](https://github.com/eslint/eslint/commit/41f6304ce641a82ee729251b448dceb9fb0d501d) Upgrade: sinon (#11855) (Toru Nagashima)
|
47
|
+
* [`167ce87`](https://github.com/eslint/eslint/commit/167ce87e908ec04b0d3d79960278d45c883c4285) Chore: remove unuseable profile command (#11854) (Toru Nagashima)
|
48
|
+
* [`c844c6f`](https://github.com/eslint/eslint/commit/c844c6f2ff314cfa8c6ca0e35a1ef58b7e297b79) Fix: max-len properly ignore trailing comments (fixes #11838) (#11841) (ZYSzys)
|
49
|
+
* [`1b5661a`](https://github.com/eslint/eslint/commit/1b5661ae467c227c0239e06cc1466480004aa799) Fix: no-var should not fix variables named 'let' (fixes #11830) (#11832) (Milos Djermanovic)
|
50
|
+
* [`4d75956`](https://github.com/eslint/eslint/commit/4d75956147b6fd662ee90eb21d3f762816463b88) Build: CI with Azure Pipelines (#11845) (Toru Nagashima)
|
51
|
+
* [`1db3462`](https://github.com/eslint/eslint/commit/1db346220889305a427b45a00afcf362b81b3767) Chore: rm superfluous argument & fix perf-multifiles-targets (#11834) (薛定谔的猫)
|
52
|
+
* [`c57a4a4`](https://github.com/eslint/eslint/commit/c57a4a4a993193c4208c6419df331a7bc644a536) Upgrade: @babel/polyfill => core-js v3 (#11833) (薛定谔的猫)
|
53
|
+
* [`65faa04`](https://github.com/eslint/eslint/commit/65faa04e8b42eecd4505111bbff296951179f033) Docs: Clarify prefer-destructuring array/object difference (fixes #9970) (#11851) (Oliver Sieweke)
|
54
|
+
* [`81c3823`](https://github.com/eslint/eslint/commit/81c382378923a45015bafe58362f6c8faa5c3d5f) Fix: require-atomic-updates reports parameters (fixes #11723) (#11774) (Toru Nagashima)
|
55
|
+
* [`aef8ea1`](https://github.com/eslint/eslint/commit/aef8ea1a44b9f13d468f48536c4c93f79f201d9b) Sponsors: Sync README with website (ESLint Jenkins)
|
56
|
+
|
57
|
+
v6.0.0-rc.0 - June 9, 2019
|
58
|
+
|
59
|
+
* [`f403b07`](https://github.com/eslint/eslint/commit/f403b07283f91f1285d8318d6acea851dd765755) Update: introduce minKeys option to sort-keys rule (fixes #11624) (#11625) (Christian)
|
60
|
+
* [`87451f4`](https://github.com/eslint/eslint/commit/87451f4779bc4c0ec874042b6854920f947ee258) Fix: no-octal should report NonOctalDecimalIntegerLiteral (fixes #11794) (#11805) (Milos Djermanovic)
|
61
|
+
* [`e4ab053`](https://github.com/eslint/eslint/commit/e4ab0531c4e44c23494c6a802aa2329d15ac90e5) Update: support "bigint" in valid-typeof rule (#11802) (Colin Ihrig)
|
62
|
+
* [`e0fafc8`](https://github.com/eslint/eslint/commit/e0fafc8ef59a80a6137f4170bbe46582d6fbcafc) Chore: removes unnecessary assignment in loop (#11780) (Dimitri Mitropoulos)
|
63
|
+
* [`20908a3`](https://github.com/eslint/eslint/commit/20908a38f489c285abf8fceef4d9d13bf8b87f22) Docs: removed '>' prefix from from docs/working-with-rules (#11818) (Alok Takshak)
|
64
|
+
* [`1c43eef`](https://github.com/eslint/eslint/commit/1c43eef605a9cf02a157881424ea62dcae747f69) Sponsors: Sync README with website (ESLint Jenkins)
|
65
|
+
* [`21f3131`](https://github.com/eslint/eslint/commit/21f3131aa1636afa8e5c01053e0e870f968425b1) Fix: `overrides` handle relative paths as expected (fixes #11577) (#11799) (Toru Nagashima)
|
66
|
+
* [`5509cdf`](https://github.com/eslint/eslint/commit/5509cdfa1b3d575248eef89a935f79c82e3f3071) Fix: fails the test case if autofix made syntax error (fixes #11615) (#11798) (Toru Nagashima)
|
67
|
+
* [`cb1922b`](https://github.com/eslint/eslint/commit/cb1922bdc07e58de0e55c13fd992dd8faf3292a4) Fix: show custom message for namespace import (fixes #11580) (#11791) (Pig Fang)
|
68
|
+
* [`37e5193`](https://github.com/eslint/eslint/commit/37e5193102d7544f155cdcb09c7c50dc602914d4) Update: add `endColumn` to no-useless-escape (fixes #11629) (#11790) (Pig Fang)
|
69
|
+
* [`ad4b048`](https://github.com/eslint/eslint/commit/ad4b048c6d034cbd7fd97deb4390d059bde8803f) Build: Fix typo in blog post template (fixes #11614) (#11782) (Kai Cataldo)
|
70
|
+
* [`9590587`](https://github.com/eslint/eslint/commit/9590587cef74c936ef9b7ce2d22a71e2fd0fbbc4) Update: improve reported location of arrow-parens (fixes #11773) (#11775) (Pig Fang)
|
71
|
+
* [`d662b17`](https://github.com/eslint/eslint/commit/d662b178c7dad193201564d16f7977af2f81ebcf) New: Add classname attribute to JUnit testcase (refs #11068) (#11683) (Fabio Pitino)
|
72
|
+
* [`8eaa9b2`](https://github.com/eslint/eslint/commit/8eaa9b259dc08dfb48269b1e4413d0d47698ed87) Chore: remove incorrect comment (#11769) (薛定谔的猫)
|
73
|
+
* [`4039a49`](https://github.com/eslint/eslint/commit/4039a49177f2fefacd747050b420c0c4560b7d4b) Chore: add .github/funding.yml (#11764) (Toru Nagashima)
|
74
|
+
|
1
75
|
v6.0.0-alpha.2 - May 25, 2019
|
2
76
|
|
3
77
|
* [`9b87fee`](https://github.com/eslint/eslint/commit/9b87fee9dc7b1d99a50b924cb6b81255ebb5c4a2) Chore: Fix formatter documentation generation (#11767) (Ilya Volodin)
|
package/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
[![NPM version][npm-image]][npm-url]
|
2
|
-
[![build
|
3
|
-
[![Build status][appveyor-image]][appveyor-url]
|
2
|
+
[](https://dev.azure.com/eslint/eslint/_build/latest?definitionId=1&branchName=master)
|
4
3
|
[![Downloads][downloads-image]][downloads-url]
|
5
4
|
[](https://www.bountysource.com/trackers/282608-eslint?utm_source=282608&utm_medium=shield&utm_campaign=TRACKER_BADGE)
|
6
5
|
[](https://gitter.im/eslint/eslint?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
@@ -259,9 +258,9 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
|
259
258
|
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
260
259
|
<!--sponsorsstart-->
|
261
260
|
<h3>Gold Sponsors</h3>
|
262
|
-
<p><a href="
|
263
|
-
<p><a href="https://www.ampproject.org/"><img src="https://images.opencollective.com/amp/logo.png" alt="AMP Project" height="64"></a></p><h3>Bronze Sponsors</h3>
|
264
|
-
<p><a href="https://
|
261
|
+
<p><a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/eeb91aa/logo.png" alt="Shopify" height="96"></a> <a href="http://salesforce.com"><img src="https://images.opencollective.com/salesforce/853ecef/logo.png" alt="Salesforce" height="96"></a> <a href="https://badoo.com/team?utm_source=eslint"><img src="https://images.opencollective.com/badoo/2826a3b/logo.png" alt="Badoo" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/001a341/logo.png" alt="Airbnb" height="96"></a> <a href="https://code.facebook.com/projects/"><img src="https://images.opencollective.com/fbopensource/fbb8a5b/logo.png" alt="Facebook Open Source" height="96"></a></p><h3>Silver Sponsors</h3>
|
262
|
+
<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>
|
263
|
+
<p><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/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> <a href="https://jsheroes.io/"><img src="https://images.opencollective.com/jsheroes1/9fedf0b/logo.png" alt="JSHeroes " height="32"></a> <a href="https://faithlife.com/ref/about"><img src="https://images.opencollective.com/faithlife/534b832/logo.png" alt="Faithlife" height="32"></a></p>
|
265
264
|
<!--sponsorsend-->
|
266
265
|
|
267
266
|
## <a name="technology-sponsors"></a>Technology Sponsors
|
@@ -271,11 +270,5 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
|
271
270
|
|
272
271
|
[npm-image]: https://img.shields.io/npm/v/eslint.svg?style=flat-square
|
273
272
|
[npm-url]: https://www.npmjs.com/package/eslint
|
274
|
-
[travis-image]: https://img.shields.io/travis/eslint/eslint/master.svg?style=flat-square
|
275
|
-
[travis-url]: https://travis-ci.org/eslint/eslint
|
276
|
-
[appveyor-image]: https://ci.appveyor.com/api/projects/status/iwxmiobcvbw3b0av/branch/master?svg=true
|
277
|
-
[appveyor-url]: https://ci.appveyor.com/project/nzakas/eslint/branch/master
|
278
|
-
[coveralls-image]: https://img.shields.io/coveralls/eslint/eslint/master.svg?style=flat-square
|
279
|
-
[coveralls-url]: https://coveralls.io/r/eslint/eslint?branch=master
|
280
273
|
[downloads-image]: https://img.shields.io/npm/dm/eslint.svg?style=flat-square
|
281
274
|
[downloads-url]: https://www.npmjs.com/package/eslint
|
package/bin/eslint.js
CHANGED
@@ -9,6 +9,9 @@
|
|
9
9
|
|
10
10
|
"use strict";
|
11
11
|
|
12
|
+
// to use V8's code cache to speed up instantiation time
|
13
|
+
require("v8-compile-cache");
|
14
|
+
|
12
15
|
//------------------------------------------------------------------------------
|
13
16
|
// Helpers
|
14
17
|
//------------------------------------------------------------------------------
|
@@ -45,7 +48,7 @@ process.once("uncaughtException", err => {
|
|
45
48
|
const pkg = require("../package.json");
|
46
49
|
|
47
50
|
console.error("\nOops! Something went wrong! :(");
|
48
|
-
console.error(`\nESLint: ${pkg.version}.\n${template(err.messageData || {})}`);
|
51
|
+
console.error(`\nESLint: ${pkg.version}.\n\n${template(err.messageData || {})}`);
|
49
52
|
} else {
|
50
53
|
|
51
54
|
console.error(err.stack);
|
@@ -27,7 +27,7 @@ const os = require("os");
|
|
27
27
|
const path = require("path");
|
28
28
|
const { validateConfigArray } = require("../shared/config-validator");
|
29
29
|
const { ConfigArrayFactory } = require("./config-array-factory");
|
30
|
-
const { ConfigDependency } = require("./config-array");
|
30
|
+
const { ConfigArray, ConfigDependency } = require("./config-array");
|
31
31
|
const loadRules = require("./load-rules");
|
32
32
|
const debug = require("debug")("eslint:cascading-config-array-factory");
|
33
33
|
|
@@ -225,11 +225,22 @@ class CascadingConfigArrayFactory {
|
|
225
225
|
|
226
226
|
/**
|
227
227
|
* Get the config array of a given file.
|
228
|
-
*
|
228
|
+
* If `filePath` was not given, it returns the config which contains only
|
229
|
+
* `baseConfigData` and `cliConfigData`.
|
230
|
+
* @param {string} [filePath] The file path to a file.
|
229
231
|
* @returns {ConfigArray} The config array of the file.
|
230
232
|
*/
|
231
233
|
getConfigArrayForFile(filePath) {
|
232
|
-
const {
|
234
|
+
const {
|
235
|
+
baseConfigArray,
|
236
|
+
cliConfigArray,
|
237
|
+
cwd
|
238
|
+
} = internalSlotsMap.get(this);
|
239
|
+
|
240
|
+
if (!filePath) {
|
241
|
+
return new ConfigArray(...baseConfigArray, ...cliConfigArray);
|
242
|
+
}
|
243
|
+
|
233
244
|
const directoryPath = path.dirname(path.resolve(cwd, filePath));
|
234
245
|
|
235
246
|
debug(`Load config files for ${directoryPath}.`);
|
@@ -302,6 +313,7 @@ class CascadingConfigArrayFactory {
|
|
302
313
|
|
303
314
|
if (configArray.length > 0 && configArray.isRoot()) {
|
304
315
|
debug("Stop traversing because of 'root:true'.");
|
316
|
+
configArray.unshift(...baseConfigArray);
|
305
317
|
return this._cacheConfig(directoryPath, configArray);
|
306
318
|
}
|
307
319
|
|
@@ -20,6 +20,7 @@ const path = require("path");
|
|
20
20
|
const defaultOptions = require("../../conf/default-cli-options");
|
21
21
|
const pkg = require("../../package.json");
|
22
22
|
const ConfigOps = require("../shared/config-ops");
|
23
|
+
const naming = require("../shared/naming");
|
23
24
|
const ModuleResolver = require("../shared/relative-module-resolver");
|
24
25
|
const { Linter } = require("../linter");
|
25
26
|
const builtInRules = require("../rules");
|
@@ -29,7 +30,6 @@ const { FileEnumerator } = require("./file-enumerator");
|
|
29
30
|
const hash = require("./hash");
|
30
31
|
const { IgnoredPaths } = require("./ignored-paths");
|
31
32
|
const LintResultCache = require("./lint-result-cache");
|
32
|
-
const naming = require("./naming");
|
33
33
|
|
34
34
|
const debug = require("debug")("eslint:cli-engine");
|
35
35
|
const validFixTypes = new Set(["problem", "suggestion", "layout"]);
|
@@ -573,7 +573,7 @@ class CLIEngine {
|
|
573
573
|
const linter = new Linter();
|
574
574
|
|
575
575
|
/** @type {ConfigArray[]} */
|
576
|
-
const lastConfigArrays = [];
|
576
|
+
const lastConfigArrays = [configArrayFactory.getConfigArrayForFile()];
|
577
577
|
|
578
578
|
// Store private data.
|
579
579
|
internalSlotsMap.set(this, {
|
@@ -734,7 +734,10 @@ class CLIEngine {
|
|
734
734
|
try {
|
735
735
|
fs.unlinkSync(cacheFilePath);
|
736
736
|
} catch (error) {
|
737
|
-
|
737
|
+
const errorCode = error && error.code;
|
738
|
+
|
739
|
+
// Ignore errors when no such file exists or file system is read only (and cache file does not exist)
|
740
|
+
if (errorCode !== "ENOENT" && !(errorCode === "EROFS" && !fs.existsSync(cacheFilePath))) {
|
738
741
|
throw error;
|
739
742
|
}
|
740
743
|
}
|
@@ -904,6 +907,13 @@ class CLIEngine {
|
|
904
907
|
const { configArrayFactory, options } = internalSlotsMap.get(this);
|
905
908
|
const absolutePath = path.resolve(options.cwd, filePath);
|
906
909
|
|
910
|
+
if (directoryExists(absolutePath)) {
|
911
|
+
throw Object.assign(
|
912
|
+
new Error("'filePath' should not be a directory path."),
|
913
|
+
{ messageTemplate: "print-config-with-directory-path" }
|
914
|
+
);
|
915
|
+
}
|
916
|
+
|
907
917
|
return configArrayFactory
|
908
918
|
.getConfigArrayForFile(absolutePath)
|
909
919
|
.extractConfig(absolutePath)
|
@@ -231,7 +231,6 @@ function mergeRuleConfigs(target, source) {
|
|
231
231
|
* @returns {ExtractedConfig} The extracted config.
|
232
232
|
*/
|
233
233
|
function createConfig(instance, indices) {
|
234
|
-
const slots = internalSlotsMap.get(instance);
|
235
234
|
const config = new ExtractedConfig();
|
236
235
|
|
237
236
|
// Merge elements.
|
@@ -256,7 +255,7 @@ function createConfig(instance, indices) {
|
|
256
255
|
mergeWithoutOverwrite(config.globals, element.globals);
|
257
256
|
mergeWithoutOverwrite(config.parserOptions, element.parserOptions);
|
258
257
|
mergeWithoutOverwrite(config.settings, element.settings);
|
259
|
-
mergePlugins(config.plugins, element.plugins
|
258
|
+
mergePlugins(config.plugins, element.plugins);
|
260
259
|
mergeRuleConfigs(config.rules, element.rules);
|
261
260
|
}
|
262
261
|
|
@@ -55,7 +55,17 @@ function toMatcher(patterns) {
|
|
55
55
|
if (patterns.length === 0) {
|
56
56
|
return null;
|
57
57
|
}
|
58
|
-
return patterns.map(pattern =>
|
58
|
+
return patterns.map(pattern => {
|
59
|
+
if (/^\.[/\\]/u.test(pattern)) {
|
60
|
+
return new Minimatch(
|
61
|
+
pattern.slice(2),
|
62
|
+
|
63
|
+
// `./*.js` should not match with `subdir/foo.js`
|
64
|
+
{ ...minimatchOpts, matchBase: false }
|
65
|
+
);
|
66
|
+
}
|
67
|
+
return new Minimatch(pattern, minimatchOpts);
|
68
|
+
});
|
59
69
|
}
|
60
70
|
|
61
71
|
/**
|
@@ -38,9 +38,9 @@ const path = require("path");
|
|
38
38
|
const importFresh = require("import-fresh");
|
39
39
|
const stripComments = require("strip-json-comments");
|
40
40
|
const { validateConfigSchema } = require("../shared/config-validator");
|
41
|
+
const naming = require("../shared/naming");
|
41
42
|
const ModuleResolver = require("../shared/relative-module-resolver");
|
42
43
|
const { ConfigArray, ConfigDependency, OverrideTester } = require("./config-array");
|
43
|
-
const naming = require("./naming");
|
44
44
|
const debug = require("debug")("eslint:config-array-factory");
|
45
45
|
|
46
46
|
//------------------------------------------------------------------------------
|
@@ -224,15 +224,16 @@ function loadPackageJSONConfigFile(filePath) {
|
|
224
224
|
/**
|
225
225
|
* Creates an error to notify about a missing config to extend from.
|
226
226
|
* @param {string} configName The name of the missing config.
|
227
|
+
* @param {string} importerName The name of the config that imported the missing config
|
227
228
|
* @returns {Error} The error object to throw
|
228
229
|
* @private
|
229
230
|
*/
|
230
|
-
function configMissingError(configName) {
|
231
|
+
function configMissingError(configName, importerName) {
|
231
232
|
return Object.assign(
|
232
233
|
new Error(`Failed to load config "${configName}" to extend from.`),
|
233
234
|
{
|
234
235
|
messageTemplate: "extend-config-missing",
|
235
|
-
messageData: { configName }
|
236
|
+
messageData: { configName, importerName }
|
236
237
|
}
|
237
238
|
);
|
238
239
|
}
|
@@ -637,7 +638,7 @@ class ConfigArrayFactory {
|
|
637
638
|
return this._loadConfigData(eslintAllPath, name);
|
638
639
|
}
|
639
640
|
|
640
|
-
throw configMissingError(extendName);
|
641
|
+
throw configMissingError(extendName, importerName);
|
641
642
|
}
|
642
643
|
|
643
644
|
/**
|
@@ -670,7 +671,7 @@ class ConfigArrayFactory {
|
|
670
671
|
);
|
671
672
|
}
|
672
673
|
|
673
|
-
throw plugin.error || configMissingError(extendName);
|
674
|
+
throw plugin.error || configMissingError(extendName, importerPath);
|
674
675
|
}
|
675
676
|
|
676
677
|
/**
|
@@ -704,7 +705,7 @@ class ConfigArrayFactory {
|
|
704
705
|
} catch (error) {
|
705
706
|
/* istanbul ignore else */
|
706
707
|
if (error && error.code === "MODULE_NOT_FOUND") {
|
707
|
-
throw configMissingError(extendName);
|
708
|
+
throw configMissingError(extendName, importerPath);
|
708
709
|
}
|
709
710
|
throw error;
|
710
711
|
}
|
@@ -292,26 +292,18 @@ class FileEnumerator {
|
|
292
292
|
_iterateFiles(pattern) {
|
293
293
|
const { cwd, globInputPaths } = internalSlotsMap.get(this);
|
294
294
|
const absolutePath = path.resolve(cwd, pattern);
|
295
|
-
|
296
|
-
if (globInputPaths && isGlobPattern(pattern)) {
|
297
|
-
return this._iterateFilesWithGlob(
|
298
|
-
absolutePath,
|
299
|
-
dotfilesPattern.test(pattern)
|
300
|
-
);
|
301
|
-
}
|
302
|
-
|
295
|
+
const isDot = dotfilesPattern.test(pattern);
|
303
296
|
const stat = statSafeSync(absolutePath);
|
304
297
|
|
305
298
|
if (stat && stat.isDirectory()) {
|
306
|
-
return this._iterateFilesWithDirectory(
|
307
|
-
absolutePath,
|
308
|
-
dotfilesPattern.test(pattern)
|
309
|
-
);
|
299
|
+
return this._iterateFilesWithDirectory(absolutePath, isDot);
|
310
300
|
}
|
311
|
-
|
312
301
|
if (stat && stat.isFile()) {
|
313
302
|
return this._iterateFilesWithFile(absolutePath);
|
314
303
|
}
|
304
|
+
if (globInputPaths && isGlobPattern(pattern)) {
|
305
|
+
return this._iterateFilesWithGlob(absolutePath, isDot);
|
306
|
+
}
|
315
307
|
|
316
308
|
return [];
|
317
309
|
}
|
@@ -5,6 +5,7 @@
|
|
5
5
|
"use strict";
|
6
6
|
|
7
7
|
const xmlEscape = require("../xml-escape");
|
8
|
+
const path = require("path");
|
8
9
|
|
9
10
|
//------------------------------------------------------------------------------
|
10
11
|
// Helper Functions
|
@@ -24,6 +25,16 @@ function getMessageType(message) {
|
|
24
25
|
|
25
26
|
}
|
26
27
|
|
28
|
+
/**
|
29
|
+
* Returns a full file path without extension
|
30
|
+
* @param {string} filePath input file path
|
31
|
+
* @returns {string} file path without extension
|
32
|
+
* @private
|
33
|
+
*/
|
34
|
+
function pathWithoutExt(filePath) {
|
35
|
+
return path.posix.join(path.posix.dirname(filePath), path.basename(filePath, path.extname(filePath)));
|
36
|
+
}
|
37
|
+
|
27
38
|
//------------------------------------------------------------------------------
|
28
39
|
// Public Interface
|
29
40
|
//------------------------------------------------------------------------------
|
@@ -38,13 +49,14 @@ module.exports = function(results) {
|
|
38
49
|
results.forEach(result => {
|
39
50
|
|
40
51
|
const messages = result.messages;
|
52
|
+
const classname = pathWithoutExt(result.filePath);
|
41
53
|
|
42
54
|
if (messages.length > 0) {
|
43
55
|
output += `<testsuite package="org.eslint" time="0" tests="${messages.length}" errors="${messages.length}" name="${result.filePath}">\n`;
|
44
56
|
messages.forEach(message => {
|
45
57
|
const type = message.fatal ? "error" : "failure";
|
46
58
|
|
47
|
-
output += `<testcase time="0" name="org.eslint.${message.ruleId || "unknown"}">`;
|
59
|
+
output += `<testcase time="0" name="org.eslint.${message.ruleId || "unknown"}" classname="${classname}">`;
|
48
60
|
output += `<${type} message="${xmlEscape(message.message || "")}">`;
|
49
61
|
output += "<![CDATA[";
|
50
62
|
output += `line ${message.line || 0}, col `;
|
@@ -58,7 +70,7 @@ module.exports = function(results) {
|
|
58
70
|
output += "</testsuite>\n";
|
59
71
|
} else {
|
60
72
|
output += `<testsuite package="org.eslint" time="0" tests="1" errors="0" name="${result.filePath}">\n`;
|
61
|
-
output += `<testcase time="0" name="${result.filePath}" />\n`;
|
73
|
+
output += `<testcase time="0" name="${result.filePath}" classname="${classname}" />\n`;
|
62
74
|
output += "</testsuite>\n";
|
63
75
|
}
|
64
76
|
|
@@ -18,6 +18,7 @@ const util = require("util"),
|
|
18
18
|
recConfig = require("../../conf/eslint-recommended"),
|
19
19
|
ConfigOps = require("../shared/config-ops"),
|
20
20
|
log = require("../shared/logging"),
|
21
|
+
naming = require("../shared/naming"),
|
21
22
|
ModuleResolver = require("../shared/relative-module-resolver"),
|
22
23
|
autoconfig = require("./autoconfig.js"),
|
23
24
|
ConfigFile = require("./config-file"),
|
@@ -97,17 +98,26 @@ function getModulesList(config, installESLint) {
|
|
97
98
|
// Create a list of modules which should be installed based on config
|
98
99
|
if (config.plugins) {
|
99
100
|
for (const plugin of config.plugins) {
|
100
|
-
|
101
|
+
const moduleName = naming.normalizePackageName(plugin, "eslint-plugin");
|
102
|
+
|
103
|
+
modules[moduleName] = "latest";
|
101
104
|
}
|
102
105
|
}
|
103
|
-
if (config.extends
|
104
|
-
const
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
106
|
+
if (config.extends) {
|
107
|
+
const extendList = Array.isArray(config.extends) ? config.extends : [config.extends];
|
108
|
+
|
109
|
+
for (const extend of extendList) {
|
110
|
+
if (extend.startsWith("eslint:") || extend.startsWith("plugin:")) {
|
111
|
+
continue;
|
112
|
+
}
|
113
|
+
const moduleName = naming.normalizePackageName(extend, "eslint-config");
|
114
|
+
|
115
|
+
modules[moduleName] = "latest";
|
116
|
+
Object.assign(
|
117
|
+
modules,
|
118
|
+
getPeerDependencies(`${moduleName}@latest`)
|
119
|
+
);
|
120
|
+
}
|
111
121
|
}
|
112
122
|
|
113
123
|
if (installESLint === false) {
|
package/lib/linter/linter.js
CHANGED
@@ -262,7 +262,7 @@ function createDisableDirectives(options) {
|
|
262
262
|
*/
|
263
263
|
function getDirectiveComments(filename, ast, ruleMapper) {
|
264
264
|
const configuredRules = {};
|
265
|
-
const enabledGlobals =
|
265
|
+
const enabledGlobals = Object.create(null);
|
266
266
|
const exportedVariables = {};
|
267
267
|
const problems = [];
|
268
268
|
const disableDirectives = [];
|
@@ -929,13 +929,11 @@ function getEnv(slots, envId) {
|
|
929
929
|
* Get a rule.
|
930
930
|
* @param {LinterInternalSlots} slots The internal slots of Linter.
|
931
931
|
* @param {string} ruleId The rule ID to get.
|
932
|
-
* @returns {Rule} The rule.
|
932
|
+
* @returns {Rule|null} The rule.
|
933
933
|
*/
|
934
934
|
function getRule(slots, ruleId) {
|
935
935
|
return (
|
936
936
|
(slots.lastConfigArray && slots.lastConfigArray.pluginRules.get(ruleId)) ||
|
937
|
-
|
938
|
-
// This returns the stub for missing rules if the rule does not exist.
|
939
937
|
slots.ruleMap.get(ruleId)
|
940
938
|
);
|
941
939
|
}
|
@@ -221,17 +221,19 @@ class NodeEventGenerator {
|
|
221
221
|
const selector = parseSelector(rawSelector);
|
222
222
|
|
223
223
|
if (selector.listenerTypes) {
|
224
|
-
selector.
|
225
|
-
const typeMap = selector.isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType;
|
224
|
+
const typeMap = selector.isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType;
|
226
225
|
|
226
|
+
selector.listenerTypes.forEach(nodeType => {
|
227
227
|
if (!typeMap.has(nodeType)) {
|
228
228
|
typeMap.set(nodeType, []);
|
229
229
|
}
|
230
230
|
typeMap.get(nodeType).push(selector);
|
231
231
|
});
|
232
|
-
|
233
|
-
(selector.isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors).push(selector);
|
232
|
+
return;
|
234
233
|
}
|
234
|
+
const selectors = selector.isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors;
|
235
|
+
|
236
|
+
selectors.push(selector);
|
235
237
|
});
|
236
238
|
|
237
239
|
this.anyTypeEnterSelectors.sort(compareSpecificity);
|
@@ -123,6 +123,18 @@ function freezeDeeply(x) {
|
|
123
123
|
}
|
124
124
|
}
|
125
125
|
|
126
|
+
/**
|
127
|
+
* Replace control characters by `\u00xx` form.
|
128
|
+
* @param {string} text The text to sanitize.
|
129
|
+
* @returns {string} The sanitized text.
|
130
|
+
*/
|
131
|
+
function sanitize(text) {
|
132
|
+
return text.replace(
|
133
|
+
/[\u0000-\u001f]/gu, // eslint-disable-line no-control-regex
|
134
|
+
c => `\\u${c.codePointAt(0).toString(16).padStart(4, "0")}`
|
135
|
+
);
|
136
|
+
}
|
137
|
+
|
126
138
|
//------------------------------------------------------------------------------
|
127
139
|
// Public Interface
|
128
140
|
//------------------------------------------------------------------------------
|
@@ -313,7 +325,7 @@ class RuleTester {
|
|
313
325
|
*/
|
314
326
|
function runRuleForItem(item) {
|
315
327
|
let config = lodash.cloneDeep(testerConfig),
|
316
|
-
code, filename, beforeAST, afterAST;
|
328
|
+
code, filename, output, beforeAST, afterAST;
|
317
329
|
|
318
330
|
if (typeof item === "string") {
|
319
331
|
code = item;
|
@@ -396,8 +408,29 @@ class RuleTester {
|
|
396
408
|
|
397
409
|
validate(config, "rule-tester", id => (id === ruleName ? rule : null));
|
398
410
|
|
411
|
+
// Verify the code.
|
412
|
+
const messages = linter.verify(code, config, filename);
|
413
|
+
|
414
|
+
// Ignore syntax errors for backward compatibility if `errors` is a number.
|
415
|
+
if (typeof item.errors !== "number") {
|
416
|
+
const errorMessage = messages.find(m => m.fatal);
|
417
|
+
|
418
|
+
assert(!errorMessage, `A fatal parsing error occurred: ${errorMessage && errorMessage.message}`);
|
419
|
+
}
|
420
|
+
|
421
|
+
// Verify if autofix makes a syntax error or not.
|
422
|
+
if (messages.some(m => m.fix)) {
|
423
|
+
output = SourceCodeFixer.applyFixes(code, messages).output;
|
424
|
+
const errorMessageInFix = linter.verify(output, config, filename).find(m => m.fatal);
|
425
|
+
|
426
|
+
assert(!errorMessageInFix, `A fatal parsing error occurred in autofix: ${errorMessageInFix && errorMessageInFix.message}`);
|
427
|
+
} else {
|
428
|
+
output = code;
|
429
|
+
}
|
430
|
+
|
399
431
|
return {
|
400
|
-
messages
|
432
|
+
messages,
|
433
|
+
output,
|
401
434
|
beforeAST,
|
402
435
|
afterAST: cloneDeeplyExcludesParent(afterAST)
|
403
436
|
};
|
@@ -488,7 +521,6 @@ class RuleTester {
|
|
488
521
|
const error = item.errors[i];
|
489
522
|
const message = messages[i];
|
490
523
|
|
491
|
-
assert(!message.fatal, `A fatal parsing error occurred: ${message.message}`);
|
492
524
|
assert(hasMessageOfThisRule, "Error rule name should be the same as the name of the rule being tested");
|
493
525
|
|
494
526
|
if (typeof error === "string" || error instanceof RegExp) {
|
@@ -517,8 +549,8 @@ class RuleTester {
|
|
517
549
|
assert(false, `Invalid messageId '${error.messageId}'. Expected one of ${friendlyIDList}.`);
|
518
550
|
}
|
519
551
|
assert.strictEqual(
|
520
|
-
error.messageId,
|
521
552
|
message.messageId,
|
553
|
+
error.messageId,
|
522
554
|
`messageId '${message.messageId}' does not match expected messageId '${error.messageId}'.`
|
523
555
|
);
|
524
556
|
if (hasOwnProperty(error, "data")) {
|
@@ -574,14 +606,12 @@ class RuleTester {
|
|
574
606
|
if (Object.prototype.hasOwnProperty.call(item, "output")) {
|
575
607
|
if (item.output === null) {
|
576
608
|
assert.strictEqual(
|
577
|
-
|
578
|
-
|
609
|
+
result.output,
|
610
|
+
item.code,
|
579
611
|
"Expected no autofixes to be suggested"
|
580
612
|
);
|
581
613
|
} else {
|
582
|
-
|
583
|
-
|
584
|
-
assert.strictEqual(fixResult.output, item.output, "Output is incorrect.");
|
614
|
+
assert.strictEqual(result.output, item.output, "Output is incorrect.");
|
585
615
|
}
|
586
616
|
}
|
587
617
|
|
@@ -595,7 +625,7 @@ class RuleTester {
|
|
595
625
|
RuleTester.describe(ruleName, () => {
|
596
626
|
RuleTester.describe("valid", () => {
|
597
627
|
test.valid.forEach(valid => {
|
598
|
-
RuleTester.it(typeof valid === "object" ? valid.code : valid, () => {
|
628
|
+
RuleTester.it(sanitize(typeof valid === "object" ? valid.code : valid), () => {
|
599
629
|
testValidTemplate(valid);
|
600
630
|
});
|
601
631
|
});
|
@@ -603,7 +633,7 @@ class RuleTester {
|
|
603
633
|
|
604
634
|
RuleTester.describe("invalid", () => {
|
605
635
|
test.invalid.forEach(invalid => {
|
606
|
-
RuleTester.it(invalid.code, () => {
|
636
|
+
RuleTester.it(sanitize(invalid.code), () => {
|
607
637
|
testInvalidTemplate(invalid);
|
608
638
|
});
|
609
639
|
});
|
@@ -175,10 +175,10 @@ module.exports = {
|
|
175
175
|
}
|
176
176
|
|
177
177
|
/*
|
178
|
-
* If the first token of the reutrn value is `{
|
178
|
+
* If the first token of the reutrn value is `{` or the return value is a sequence expression,
|
179
179
|
* enclose the return value by parentheses to avoid syntax error.
|
180
180
|
*/
|
181
|
-
if (astUtils.isOpeningBraceToken(firstValueToken)) {
|
181
|
+
if (astUtils.isOpeningBraceToken(firstValueToken) || blockBody[0].argument.type === "SequenceExpression") {
|
182
182
|
fixes.push(
|
183
183
|
fixer.insertTextBefore(firstValueToken, "("),
|
184
184
|
fixer.insertTextAfter(lastValueToken, ")")
|