eslint 6.0.0 → 6.2.1

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +3 -5
  3. package/bin/eslint.js +4 -1
  4. package/conf/config-schema.js +1 -0
  5. package/conf/environments.js +72 -15
  6. package/lib/cli-engine/cascading-config-array-factory.js +15 -3
  7. package/lib/cli-engine/cli-engine.js +13 -3
  8. package/lib/cli-engine/config-array/config-array.js +7 -0
  9. package/lib/cli-engine/config-array/extracted-config.js +16 -1
  10. package/lib/cli-engine/config-array-factory.js +9 -6
  11. package/lib/cli-engine/file-enumerator.js +5 -13
  12. package/lib/init/config-initializer.js +19 -9
  13. package/lib/init/npm-utils.js +2 -2
  14. package/lib/linter/code-path-analysis/code-path-analyzer.js +1 -0
  15. package/lib/linter/linter.js +49 -16
  16. package/lib/rule-tester/rule-tester.js +1 -1
  17. package/lib/rules/accessor-pairs.js +195 -35
  18. package/lib/rules/arrow-body-style.js +2 -2
  19. package/lib/rules/class-methods-use-this.js +10 -3
  20. package/lib/rules/dot-location.js +21 -17
  21. package/lib/rules/dot-notation.js +6 -2
  22. package/lib/rules/func-call-spacing.js +30 -20
  23. package/lib/rules/func-names.js +4 -0
  24. package/lib/rules/function-call-argument-newline.js +120 -0
  25. package/lib/rules/function-paren-newline.js +34 -22
  26. package/lib/rules/indent.js +13 -2
  27. package/lib/rules/index.js +1 -0
  28. package/lib/rules/new-cap.js +2 -1
  29. package/lib/rules/no-dupe-keys.js +1 -1
  30. package/lib/rules/no-duplicate-case.js +10 -8
  31. package/lib/rules/no-extra-bind.js +1 -0
  32. package/lib/rules/no-extra-boolean-cast.js +44 -5
  33. package/lib/rules/no-extra-parens.js +295 -39
  34. package/lib/rules/no-mixed-operators.js +48 -13
  35. package/lib/rules/no-param-reassign.js +12 -1
  36. package/lib/rules/no-restricted-syntax.js +2 -2
  37. package/lib/rules/no-unused-vars.js +1 -1
  38. package/lib/rules/prefer-const.js +9 -3
  39. package/lib/rules/prefer-template.js +1 -10
  40. package/lib/rules/sort-keys.js +11 -3
  41. package/lib/rules/utils/ast-utils.js +45 -3
  42. package/lib/rules/yoda.js +1 -1
  43. package/lib/{cli-engine → shared}/naming.js +0 -0
  44. package/lib/shared/types.js +2 -0
  45. package/messages/extend-config-missing.txt +2 -0
  46. package/messages/print-config-with-directory-path.txt +2 -0
  47. package/package.json +22 -21
@@ -52,16 +52,7 @@ function isOctalEscapeSequence(node) {
52
52
  return false;
53
53
  }
54
54
 
55
- const match = node.raw.match(/^([^\\]|\\[^0-7])*\\([0-7]{1,3})/u);
56
-
57
- if (match) {
58
-
59
- // \0 is actually not considered an octal
60
- if (match[2] !== "0" || typeof match[3] !== "undefined") {
61
- return true;
62
- }
63
- }
64
- return false;
55
+ return astUtils.hasOctalEscapeSequence(node.raw);
65
56
  }
66
57
 
67
58
  /**
@@ -29,7 +29,13 @@ const astUtils = require("./utils/ast-utils"),
29
29
  * @private
30
30
  */
31
31
  function getPropertyName(node) {
32
- return astUtils.getStaticPropertyName(node) || node.key.name || null;
32
+ const staticName = astUtils.getStaticPropertyName(node);
33
+
34
+ if (staticName !== null) {
35
+ return staticName;
36
+ }
37
+
38
+ return node.key.name || null;
33
39
  }
34
40
 
35
41
  /**
@@ -151,9 +157,11 @@ module.exports = {
151
157
  const numKeys = stack.numKeys;
152
158
  const thisName = getPropertyName(node);
153
159
 
154
- stack.prevName = thisName || prevName;
160
+ if (thisName !== null) {
161
+ stack.prevName = thisName;
162
+ }
155
163
 
156
- if (!prevName || !thisName || numKeys < minKeys) {
164
+ if (prevName === null || thisName === null || numKeys < minKeys) {
157
165
  return;
158
166
  }
159
167
 
@@ -37,6 +37,9 @@ const LINEBREAKS = new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]);
37
37
  // A set of node types that can contain a list of statements
38
38
  const STATEMENT_LIST_PARENTS = new Set(["Program", "BlockStatement", "SwitchCase"]);
39
39
 
40
+ const DECIMAL_INTEGER_PATTERN = /^(0|[1-9]\d*)$/u;
41
+ const OCTAL_ESCAPE_PATTERN = /^(?:[^\\]|\\[^0-7]|\\0(?![0-9]))*\\(?:[1-7]|0[0-9])/u;
42
+
40
43
  /**
41
44
  * Checks reference if is non initializer and writable.
42
45
  * @param {Reference} reference - A reference to check.
@@ -283,6 +286,16 @@ function isCommaToken(token) {
283
286
  return token.value === "," && token.type === "Punctuator";
284
287
  }
285
288
 
289
+ /**
290
+ * Checks if the given token is a dot token or not.
291
+ *
292
+ * @param {Token} token - The token to check.
293
+ * @returns {boolean} `true` if the token is a dot token.
294
+ */
295
+ function isDotToken(token) {
296
+ return token.value === "." && token.type === "Punctuator";
297
+ }
298
+
286
299
  /**
287
300
  * Checks if the given token is a semicolon token or not.
288
301
  *
@@ -462,12 +475,14 @@ module.exports = {
462
475
  isColonToken,
463
476
  isCommaToken,
464
477
  isCommentToken,
478
+ isDotToken,
465
479
  isKeywordToken,
466
480
  isNotClosingBraceToken: negate(isClosingBraceToken),
467
481
  isNotClosingBracketToken: negate(isClosingBracketToken),
468
482
  isNotClosingParenToken: negate(isClosingParenToken),
469
483
  isNotColonToken: negate(isColonToken),
470
484
  isNotCommaToken: negate(isCommaToken),
485
+ isNotDotToken: negate(isDotToken),
471
486
  isNotOpeningBraceToken: negate(isOpeningBraceToken),
472
487
  isNotOpeningBracketToken: negate(isOpeningBracketToken),
473
488
  isNotOpeningParenToken: negate(isOpeningParenToken),
@@ -833,6 +848,7 @@ module.exports = {
833
848
  return 17;
834
849
 
835
850
  case "CallExpression":
851
+ case "ImportExpression":
836
852
  return 18;
837
853
 
838
854
  case "NewExpression":
@@ -988,7 +1004,18 @@ module.exports = {
988
1004
  * '5' // false
989
1005
  */
990
1006
  isDecimalInteger(node) {
991
- return node.type === "Literal" && typeof node.value === "number" && /^(0|[1-9]\d*)$/u.test(node.raw);
1007
+ return node.type === "Literal" && typeof node.value === "number" &&
1008
+ DECIMAL_INTEGER_PATTERN.test(node.raw);
1009
+ },
1010
+
1011
+ /**
1012
+ * Determines whether this token is a decimal integer numeric token.
1013
+ * This is similar to isDecimalInteger(), but for tokens.
1014
+ * @param {Token} token - The token to check.
1015
+ * @returns {boolean} `true` if this token is a decimal integer.
1016
+ */
1017
+ isDecimalIntegerNumericToken(token) {
1018
+ return token.type === "Numeric" && DECIMAL_INTEGER_PATTERN.test(token.value);
992
1019
  },
993
1020
 
994
1021
  /**
@@ -1076,7 +1103,7 @@ module.exports = {
1076
1103
  } else {
1077
1104
  const name = module.exports.getStaticPropertyName(parent);
1078
1105
 
1079
- if (name) {
1106
+ if (name !== null) {
1080
1107
  tokens.push(`'${name}'`);
1081
1108
  }
1082
1109
  }
@@ -1276,7 +1303,7 @@ module.exports = {
1276
1303
  * set `node.value` to a unicode regex. To make sure a literal is actually `null`, check
1277
1304
  * `node.regex` instead. Also see: https://github.com/eslint/eslint/issues/8020
1278
1305
  */
1279
- return node.type === "Literal" && node.value === null && !node.regex;
1306
+ return node.type === "Literal" && node.value === null && !node.regex && !node.bigint;
1280
1307
  },
1281
1308
 
1282
1309
  /**
@@ -1348,5 +1375,20 @@ module.exports = {
1348
1375
  "/*".length +
1349
1376
  (match ? match.index + 1 : 0)
1350
1377
  );
1378
+ },
1379
+
1380
+ /**
1381
+ * Determines whether the given raw string contains an octal escape sequence.
1382
+ *
1383
+ * "\1", "\2" ... "\7"
1384
+ * "\00", "\01" ... "\09"
1385
+ *
1386
+ * "\0", when not followed by a digit, is not an octal escape sequence.
1387
+ *
1388
+ * @param {string} rawString A string in its raw representation.
1389
+ * @returns {boolean} `true` if the string contains at least one octal escape sequence.
1390
+ */
1391
+ hasOctalEscapeSequence(rawString) {
1392
+ return OCTAL_ESCAPE_PATTERN.test(rawString);
1351
1393
  }
1352
1394
  };
package/lib/rules/yoda.js CHANGED
@@ -119,7 +119,7 @@ function same(a, b) {
119
119
  const nameA = astUtils.getStaticPropertyName(a);
120
120
 
121
121
  // x.y = x["y"]
122
- if (nameA) {
122
+ if (nameA !== null) {
123
123
  return (
124
124
  same(a.object, b.object) &&
125
125
  nameA === astUtils.getStaticPropertyName(b)
File without changes
@@ -30,6 +30,7 @@ module.exports = {};
30
30
  * @property {Record<string, boolean>} [env] The environment settings.
31
31
  * @property {string | string[]} [extends] The path to other config files or the package name of shareable configs.
32
32
  * @property {Record<string, GlobalConf>} [globals] The global variable settings.
33
+ * @property {boolean} [noInlineConfig] The flag that disables directive comments.
33
34
  * @property {OverrideConfigData[]} [overrides] The override settings per kind of files.
34
35
  * @property {string} [parser] The path to a parser or the package name of a parser.
35
36
  * @property {ParserOptions} [parserOptions] The parser options.
@@ -47,6 +48,7 @@ module.exports = {};
47
48
  * @property {string | string[]} [extends] The path to other config files or the package name of shareable configs.
48
49
  * @property {string | string[]} files The glob pattarns for target files.
49
50
  * @property {Record<string, GlobalConf>} [globals] The global variable settings.
51
+ * @property {boolean} [noInlineConfig] The flag that disables directive comments.
50
52
  * @property {OverrideConfigData[]} [overrides] The override settings per kind of files.
51
53
  * @property {string} [parser] The path to a parser or the package name of a parser.
52
54
  * @property {ParserOptions} [parserOptions] The parser options.
@@ -1,3 +1,5 @@
1
1
  ESLint couldn't find the config "<%- configName %>" to extend from. Please check that the name of the config is correct.
2
2
 
3
+ The config "<%- configName %>" was referenced from the config file in "<%- importerName %>".
4
+
3
5
  If you still have problems, please stop by https://gitter.im/eslint/eslint to chat with the team.
@@ -0,0 +1,2 @@
1
+ The '--print-config' CLI option requires a path to a source code file rather than a directory.
2
+ See also: https://eslint.org/docs/user-guide/command-line-interface#--print-config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "6.0.0",
3
+ "version": "6.2.1",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -49,41 +49,42 @@
49
49
  "cross-spawn": "^6.0.5",
50
50
  "debug": "^4.0.1",
51
51
  "doctrine": "^3.0.0",
52
- "eslint-scope": "^4.0.3",
53
- "eslint-utils": "^1.3.1",
54
- "eslint-visitor-keys": "^1.0.0",
55
- "espree": "^6.0.0",
52
+ "eslint-scope": "^5.0.0",
53
+ "eslint-utils": "^1.4.2",
54
+ "eslint-visitor-keys": "^1.1.0",
55
+ "espree": "^6.1.0",
56
56
  "esquery": "^1.0.1",
57
57
  "esutils": "^2.0.2",
58
58
  "file-entry-cache": "^5.0.1",
59
59
  "functional-red-black-tree": "^1.0.1",
60
- "glob-parent": "^3.1.0",
60
+ "glob-parent": "^5.0.0",
61
61
  "globals": "^11.7.0",
62
62
  "ignore": "^4.0.6",
63
63
  "import-fresh": "^3.0.0",
64
64
  "imurmurhash": "^0.1.4",
65
- "inquirer": "^6.2.2",
65
+ "inquirer": "^6.4.1",
66
66
  "is-glob": "^4.0.0",
67
67
  "js-yaml": "^3.13.1",
68
68
  "json-stable-stringify-without-jsonify": "^1.0.1",
69
69
  "levn": "^0.3.0",
70
- "lodash": "^4.17.11",
70
+ "lodash": "^4.17.14",
71
71
  "minimatch": "^3.0.4",
72
72
  "mkdirp": "^0.5.1",
73
73
  "natural-compare": "^1.4.0",
74
74
  "optionator": "^0.8.2",
75
75
  "progress": "^2.0.0",
76
76
  "regexpp": "^2.0.1",
77
- "semver": "^5.5.1",
78
- "strip-ansi": "^4.0.0",
79
- "strip-json-comments": "^2.0.1",
77
+ "semver": "^6.1.2",
78
+ "strip-ansi": "^5.2.0",
79
+ "strip-json-comments": "^3.0.1",
80
80
  "table": "^5.2.3",
81
- "text-table": "^0.2.0"
81
+ "text-table": "^0.2.0",
82
+ "v8-compile-cache": "^2.0.3"
82
83
  },
83
84
  "devDependencies": {
84
85
  "@babel/core": "^7.4.3",
85
86
  "@babel/preset-env": "^7.4.3",
86
- "acorn": "^6.1.1",
87
+ "acorn": "^7.0.0",
87
88
  "babel-loader": "^8.0.5",
88
89
  "chai": "^4.0.1",
89
90
  "cheerio": "^0.22.0",
@@ -109,22 +110,22 @@
109
110
  "leche": "^2.2.3",
110
111
  "lint-staged": "^8.1.5",
111
112
  "load-perf": "^0.2.0",
112
- "markdownlint": "^0.13.0",
113
- "markdownlint-cli": "^0.15.0",
114
- "metro-memory-fs": "^0.53.1",
113
+ "markdownlint": "^0.15.0",
114
+ "markdownlint-cli": "^0.17.0",
115
+ "metro-memory-fs": "^0.54.1",
115
116
  "mocha": "^6.1.2",
116
117
  "mocha-junit-reporter": "^1.23.0",
117
118
  "npm-license": "^0.3.3",
118
- "nyc": "^13.3.0",
119
+ "nyc": "^14.1.1",
119
120
  "proxyquire": "^2.0.1",
120
- "puppeteer": "^1.14.0",
121
- "recast": "^0.17.6",
121
+ "puppeteer": "^1.18.0",
122
+ "recast": "^0.18.1",
122
123
  "regenerator-runtime": "^0.13.2",
123
124
  "shelljs": "^0.8.2",
124
125
  "sinon": "^7.3.2",
125
126
  "temp": "^0.9.0",
126
- "webpack": "^4.29.6",
127
- "webpack-cli": "^3.3.0",
127
+ "webpack": "^4.35.0",
128
+ "webpack-cli": "^3.3.5",
128
129
  "yorkie": "^2.0.0"
129
130
  },
130
131
  "keywords": [