eslint 4.4.0 → 4.6.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,59 @@
1
+ v4.6.1 - September 3, 2017
2
+
3
+ * bdec46d Build: avoid process leak when generating website (#9217) (Teddy Katz)
4
+ * cb74b87 Fix: avoid adding globals when an env is used with `false` (fixes #9202) (#9203) (Teddy Katz)
5
+ * f9b7544 Docs: Correct a typo in generator-star-spacing documentation (#9205) (Ethan Rutherford)
6
+ * e5c5e83 Build: Fixing issue with docs generation (Fixes #9199) (#9200) (Ilya Volodin)
7
+
8
+ v4.6.0 - September 1, 2017
9
+
10
+ * 56dd769 Docs: fix link format in prefer-arrow-callback.md (#9198) (Vse Mozhet Byt)
11
+ * 6becf91 Update: add eslint version to error output. (fixes #9037) (#9071) (薛定谔的猫)
12
+ * 0e09973 New: function-paren-newline rule (fixes #6074) (#8102) (Teddy Katz)
13
+ * 88a64cc Chore: Make parseJsonConfig() a pure function in Linter (#9186) (Teddy Katz)
14
+ * 1bbac51 Fix: avoid breaking eslint-plugin-eslint-comments (fixes #9193) (#9196) (Teddy Katz)
15
+ * 3e8b70a Fix: off-by-one error in eslint-disable comment checking (#9195) (Teddy Katz)
16
+ * 73815f6 Docs: rewrite prefer-arrow-callback documentation (fixes #8950) (#9077) (Charles E. Morgan)
17
+ * 0d3a854 Chore: avoid mutating report descriptors in report-translator (#9189) (Teddy Katz)
18
+ * 2db356b Update: no-unused-vars Improve message to include the allowed patterns (#9176) (Eli White)
19
+ * 8fbaf0a Update: Add configurability to generator-star-spacing (#8985) (Ethan Rutherford)
20
+ * 8ed779c Chore: remove currentScopes property from Linter instances (refs #9161) (#9187) (Teddy Katz)
21
+ * af4ad60 Fix: Handle error when running init without npm (#9169) (Gabriel Aumala)
22
+ * 4b94c6c Chore: make parse() a pure function in Linter (refs #9161) (#9183) (Teddy Katz)
23
+ * 1be5634 Chore: don't make Linter a subclass of EventEmitter (refs #9161) (#9177) (Teddy Katz)
24
+ * e95af9b Chore: don't include internal test helpers in npm package (#9160) (Teddy Katz)
25
+ * 6fb32e1 Chore: avoid using private Linter APIs in astUtils tests (refs #9161) (#9173) (Teddy Katz)
26
+ * de6dccd Docs: add documentation for Linter methods (refs #6525) (#9151) (Teddy Katz)
27
+ * 2d90030 Chore: remove unused assignment. (#9182) (薛定谔的猫)
28
+ * d672aef Chore: refactor reporting logic (refs #9161) (#9168) (Teddy Katz)
29
+ * 5ab0434 Fix: indent crash on sparse arrays with "off" option (fixes #9157) (#9166) (Teddy Katz)
30
+ * c147b97 Chore: Make SourceCodeFixer accept text instead of a SourceCode instance (#9178) (Teddy Katz)
31
+ * f127423 Chore: avoid using private Linter APIs in Linter tests (refs #9161) (#9175) (Teddy Katz)
32
+ * 2334335 Chore: avoid using private Linter APIs in SourceCode tests (refs #9161) (#9174) (Teddy Katz)
33
+ * 2dc243a Chore: avoid using internal Linter APIs in RuleTester (refs #9161) (#9172) (Teddy Katz)
34
+ * d6e436f Fix: no-extra-parens reported some parenthesized IIFEs (fixes #9140) (#9158) (Teddy Katz)
35
+ * e6b115c Build: Add an edit link to the rule docs’ metadata (#9049) (Jed Fox)
36
+ * fcb7bb4 Chore: avoid unnecessarily complex forEach calls in no-extra-parens (#9159) (Teddy Katz)
37
+ * ffa021e Docs: quotes rule - when does \n require backticks (#9135) (avimar)
38
+ * 60c5148 Chore: improve coverage in lib/*.js (#9130) (Teddy Katz)
39
+
40
+ v4.5.0 - August 18, 2017
41
+
42
+ * decdd2c Update: allow arbitrary nodes to be ignored in `indent` (fixes #8594) (#9105) (Teddy Katz)
43
+ * 79062f3 Update: fix indentation of multiline `new.target` expressions (#9116) (Teddy Katz)
44
+ * d00e24f Upgrade: `chalk` to 2.x release (#9115) (Stephen Edgar)
45
+ * 6ef734a Docs: add missing word in processor documentation (#9106) (Teddy Katz)
46
+ * a4f53ba Fix: Include files with no messages in junit results (#9093) (#9094) (Sean DuBois)
47
+ * 1d6a9c0 Chore: enable eslint-plugin/test-case-shorthand-strings (#9067) (薛定谔的猫)
48
+ * f8add8f Fix: don't autofix with linter.verifyAndFix when `fix: false` is used (#9098) (Teddy Katz)
49
+ * 77bcee4 Docs: update instructions for adding TSC members (#9086) (Teddy Katz)
50
+ * bd09cd5 Update: avoid requiring NaN spaces of indentation (fixes #9083) (#9085) (Teddy Katz)
51
+ * c93a853 Chore: Remove extra space in blogpost template (#9088) (Kai Cataldo)
52
+
53
+ v4.4.1 - August 7, 2017
54
+
55
+ * ec93614 Fix: no-multi-spaces to avoid reporting consecutive tabs (fixes #9079) (#9087) (Teddy Katz)
56
+
1
57
  v4.4.0 - August 5, 2017
2
58
 
3
59
  * 89196fd Upgrade: Espree to 3.5.0 (#9074) (Gyandeep Singh)
package/bin/eslint.js CHANGED
@@ -43,9 +43,10 @@ process.once("uncaughtException", err => {
43
43
 
44
44
  if (typeof err.messageTemplate === "string" && err.messageTemplate.length > 0) {
45
45
  const template = lodash.template(fs.readFileSync(path.resolve(__dirname, `../messages/${err.messageTemplate}.txt`), "utf-8"));
46
+ const pkg = require("../package.json");
46
47
 
47
48
  console.error("\nOops! Something went wrong! :(");
48
- console.error(`\n${template(err.messageData || {})}`);
49
+ console.error(`\nESLint: ${pkg.version}.\n${template(err.messageData || {})}`);
49
50
  } else {
50
51
 
51
52
  console.error(err.message);
@@ -44,6 +44,7 @@ module.exports = {
44
44
  "func-name-matching": "off",
45
45
  "func-names": "off",
46
46
  "func-style": "off",
47
+ "function-paren-newline": "off",
47
48
  "generator-star-spacing": "off",
48
49
  "getter-return": "off",
49
50
  "global-require": "off",
package/lib/ast-utils.js CHANGED
@@ -655,16 +655,15 @@ module.exports = {
655
655
  // [Foo = function() { ... }] = a;
656
656
  case "AssignmentExpression":
657
657
  case "AssignmentPattern":
658
- if (parent.right === node) {
659
- if (parent.left.type === "MemberExpression") {
660
- return false;
661
- }
662
- if (isAnonymous &&
663
- parent.left.type === "Identifier" &&
664
- startsWithUpperCase(parent.left.name)
665
- ) {
666
- return false;
667
- }
658
+ if (parent.left.type === "MemberExpression") {
659
+ return false;
660
+ }
661
+ if (
662
+ isAnonymous &&
663
+ parent.left.type === "Identifier" &&
664
+ startsWithUpperCase(parent.left.name)
665
+ ) {
666
+ return false;
668
667
  }
669
668
  return true;
670
669
 
@@ -809,19 +808,14 @@ module.exports = {
809
808
  return 17;
810
809
 
811
810
  case "CallExpression":
812
-
813
- // IIFE is allowed to have parens in any position (#655)
814
- if (node.callee.type === "FunctionExpression") {
815
- return -1;
816
- }
817
811
  return 18;
818
812
 
819
813
  case "NewExpression":
820
814
  return 19;
821
815
 
822
- // no default
816
+ default:
817
+ return 20;
823
818
  }
824
- return 20;
825
819
  },
826
820
 
827
821
  /**
@@ -154,7 +154,8 @@ function forwardCurrentToHead(analyzer, node) {
154
154
  analyzer.emitter.emit(
155
155
  "onCodePathSegmentEnd",
156
156
  currentSegment,
157
- node);
157
+ node
158
+ );
158
159
  }
159
160
  }
160
161
  }
@@ -175,7 +176,8 @@ function forwardCurrentToHead(analyzer, node) {
175
176
  analyzer.emitter.emit(
176
177
  "onCodePathSegmentStart",
177
178
  headSegment,
178
- node);
179
+ node
180
+ );
179
181
  }
180
182
  }
181
183
  }
@@ -202,7 +204,8 @@ function leaveFromCurrentSegment(analyzer, node) {
202
204
  analyzer.emitter.emit(
203
205
  "onCodePathSegmentEnd",
204
206
  currentSegment,
205
- node);
207
+ node
208
+ );
206
209
  }
207
210
  }
208
211
 
@@ -369,7 +372,8 @@ function processCodePathToEnter(analyzer, node) {
369
372
  case "SwitchStatement":
370
373
  state.pushSwitchContext(
371
374
  node.cases.some(isCaseNode),
372
- astUtils.getLabel(node));
375
+ astUtils.getLabel(node)
376
+ );
373
377
  break;
374
378
 
375
379
  case "TryStatement":
@@ -164,7 +164,8 @@ class CodePathSegment {
164
164
  return new CodePathSegment(
165
165
  id,
166
166
  flattenUnusedSegments(allPrevSegments),
167
- allPrevSegments.some(isReachable));
167
+ allPrevSegments.some(isReachable)
168
+ );
168
169
  }
169
170
 
170
171
  /**
@@ -855,9 +855,12 @@ class CodePathState {
855
855
  prevSegsOfLeavingSegment.push(thrown.segmentsList[j][i]);
856
856
  }
857
857
 
858
- segments.push(CodePathSegment.newNext(
859
- this.idGenerator.next(),
860
- prevSegsOfLeavingSegment));
858
+ segments.push(
859
+ CodePathSegment.newNext(
860
+ this.idGenerator.next(),
861
+ prevSegsOfLeavingSegment
862
+ )
863
+ );
861
864
  }
862
865
 
863
866
  this.pushForkContext(true);
@@ -992,7 +995,8 @@ class CodePathState {
992
995
  makeLooped(
993
996
  this,
994
997
  forkContext.head,
995
- context.continueDestSegments);
998
+ context.continueDestSegments
999
+ );
996
1000
  break;
997
1001
 
998
1002
  case "DoWhileStatement": {
@@ -1013,7 +1017,8 @@ class CodePathState {
1013
1017
  makeLooped(
1014
1018
  this,
1015
1019
  segmentsList[i],
1016
- context.entrySegments);
1020
+ context.entrySegments
1021
+ );
1017
1022
  }
1018
1023
  break;
1019
1024
  }
@@ -1024,7 +1029,8 @@ class CodePathState {
1024
1029
  makeLooped(
1025
1030
  this,
1026
1031
  forkContext.head,
1027
- context.leftSegments);
1032
+ context.leftSegments
1033
+ );
1028
1034
  break;
1029
1035
 
1030
1036
  /* istanbul ignore next */
@@ -1149,7 +1155,8 @@ class CodePathState {
1149
1155
  finalizeTestSegmentsOfFor(
1150
1156
  context,
1151
1157
  choiceContext,
1152
- forkContext.head);
1158
+ forkContext.head
1159
+ );
1153
1160
  } else {
1154
1161
  context.endOfInitSegments = forkContext.head;
1155
1162
  }
@@ -1180,13 +1187,15 @@ class CodePathState {
1180
1187
  makeLooped(
1181
1188
  this,
1182
1189
  context.endOfUpdateSegments,
1183
- context.testSegments);
1190
+ context.testSegments
1191
+ );
1184
1192
  }
1185
1193
  } else if (context.testSegments) {
1186
1194
  finalizeTestSegmentsOfFor(
1187
1195
  context,
1188
1196
  choiceContext,
1189
- forkContext.head);
1197
+ forkContext.head
1198
+ );
1190
1199
  } else {
1191
1200
  context.endOfInitSegments = forkContext.head;
1192
1201
  }
@@ -51,7 +51,8 @@ class CodePath {
51
51
  Object.defineProperty(
52
52
  this,
53
53
  "internal",
54
- { value: new CodePathState(new IdGenerator(`${id}_`), onLooped) });
54
+ { value: new CodePathState(new IdGenerator(`${id}_`), onLooped) }
55
+ );
55
56
 
56
57
  // Adds this into `childCodePaths` of `upper`.
57
58
  if (upper) {
@@ -254,7 +254,8 @@ class ForkContext {
254
254
  return new ForkContext(
255
255
  parentContext.idGenerator,
256
256
  parentContext,
257
- (forkLeavingPath ? 2 : 1) * parentContext.count);
257
+ (forkLeavingPath ? 2 : 1) * parentContext.count
258
+ );
258
259
  }
259
260
  }
260
261
 
@@ -65,6 +65,7 @@ function writeFile(config, format) {
65
65
  * @param {string} moduleName The module name to get.
66
66
  * @returns {Object} The peer dependencies of the given module.
67
67
  * This object is the object of `peerDependencies` field of `package.json`.
68
+ * Returns null if npm was not found.
68
69
  */
69
70
  function getPeerDependencies(moduleName) {
70
71
  let result = getPeerDependencies.cache.get(moduleName);
@@ -356,7 +357,8 @@ function hasESLintVersionConflict(answers) {
356
357
  // Get the required range of ESLint version.
357
358
  const configName = getStyleGuideName(answers);
358
359
  const moduleName = `eslint-config-${configName}@latest`;
359
- const requiredESLintVersionRange = getPeerDependencies(moduleName).eslint;
360
+ const peerDependencies = getPeerDependencies(moduleName) || {};
361
+ const requiredESLintVersionRange = peerDependencies.eslint;
360
362
 
361
363
  if (!requiredESLintVersionRange) {
362
364
  return false;
package/lib/config.js CHANGED
@@ -24,7 +24,7 @@ const debug = require("debug")("eslint:config");
24
24
  // Constants
25
25
  //------------------------------------------------------------------------------
26
26
 
27
- const PERSONAL_CONFIG_DIR = os.homedir() || null;
27
+ const PERSONAL_CONFIG_DIR = os.homedir();
28
28
  const SUBCONFIG_SEP = ":";
29
29
 
30
30
  //------------------------------------------------------------------------------
@@ -148,15 +148,13 @@ class Config {
148
148
  getPersonalConfig() {
149
149
  if (typeof this.personalConfig === "undefined") {
150
150
  let config;
151
+ const filename = ConfigFile.getFilenameForDirectory(PERSONAL_CONFIG_DIR);
151
152
 
152
- if (PERSONAL_CONFIG_DIR) {
153
- const filename = ConfigFile.getFilenameForDirectory(PERSONAL_CONFIG_DIR);
154
-
155
- if (filename) {
156
- debug("Using personal config");
157
- config = ConfigFile.load(filename, this);
158
- }
153
+ if (filename) {
154
+ debug("Using personal config");
155
+ config = ConfigFile.load(filename, this);
159
156
  }
157
+
160
158
  this.personalConfig = config || null;
161
159
  }
162
160
 
@@ -351,10 +349,8 @@ class Config {
351
349
  config = ConfigOps.merge(config, { parser: this.parser });
352
350
  }
353
351
 
354
- // Step 4: Apply environments to the config if present
355
- if (config.env) {
356
- config = ConfigOps.applyEnvironments(config, this.linterContext.environments);
357
- }
352
+ // Step 4: Apply environments to the config
353
+ config = ConfigOps.applyEnvironments(config, this.linterContext.environments);
358
354
 
359
355
  this.configCache.setMergedConfig(vector, config);
360
356
 
@@ -39,10 +39,7 @@ module.exports = function(results) {
39
39
 
40
40
  const messages = result.messages;
41
41
 
42
- if (messages.length) {
43
- output += `<testsuite package="org.eslint" time="0" tests="${messages.length}" errors="${messages.length}" name="${result.filePath}">\n`;
44
- }
45
-
42
+ output += `<testsuite package="org.eslint" time="0" tests="${messages.length}" errors="${messages.length}" name="${result.filePath}">\n`;
46
43
  messages.forEach(message => {
47
44
  const type = message.fatal ? "error" : "failure";
48
45
 
@@ -57,10 +54,7 @@ module.exports = function(results) {
57
54
  output += `</${type}>`;
58
55
  output += "</testcase>\n";
59
56
  });
60
-
61
- if (messages.length) {
62
- output += "</testsuite>\n";
63
- }
57
+ output += "</testsuite>\n";
64
58
 
65
59
  });
66
60
 
@@ -5,6 +5,7 @@
5
5
  "use strict";
6
6
 
7
7
  const chalk = require("chalk"),
8
+ stripAnsi = require("strip-ansi"),
8
9
  table = require("text-table");
9
10
 
10
11
  //------------------------------------------------------------------------------
@@ -71,7 +72,7 @@ module.exports = function(results) {
71
72
  {
72
73
  align: ["", "r", "l"],
73
74
  stringLength(str) {
74
- return chalk.stripColor(str).length;
75
+ return stripAnsi(str).length;
75
76
  }
76
77
  }
77
78
  ).split("\n").map(el => el.replace(/(\d+)\s+(\d+)/, (m, p1, p2) => chalk.dim(`${p1}:${p2}`))).join("\n")}\n\n`;
@@ -47,8 +47,6 @@ const DEFAULT_OPTIONS = {
47
47
  * @returns {string} Path of ignore file or an empty string.
48
48
  */
49
49
  function findFile(cwd, name) {
50
- cwd = cwd || DEFAULT_OPTIONS.cwd;
51
-
52
50
  const ignoreFilePath = path.resolve(cwd, name);
53
51
 
54
52
  return fs.existsSync(ignoreFilePath) && fs.statSync(ignoreFilePath).isFile() ? ignoreFilePath : "";