eslint 6.1.0 → 6.2.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.
@@ -99,7 +99,8 @@ const KNOWN_NODES = new Set([
99
99
  "ImportDeclaration",
100
100
  "ImportSpecifier",
101
101
  "ImportDefaultSpecifier",
102
- "ImportNamespaceSpecifier"
102
+ "ImportNamespaceSpecifier",
103
+ "ImportExpression"
103
104
  ]);
104
105
 
105
106
  /*
@@ -1109,7 +1110,6 @@ module.exports = {
1109
1110
 
1110
1111
  CallExpression: addFunctionCallIndent,
1111
1112
 
1112
-
1113
1113
  "ClassDeclaration[superClass], ClassExpression[superClass]"(node) {
1114
1114
  const classToken = sourceCode.getFirstToken(node);
1115
1115
  const extendsToken = sourceCode.getTokenBefore(node.superClass, astUtils.isNotOpeningParenToken);
@@ -1236,6 +1236,17 @@ module.exports = {
1236
1236
  }
1237
1237
  },
1238
1238
 
1239
+ ImportExpression(node) {
1240
+ const openingParen = sourceCode.getFirstToken(node, 1);
1241
+ const closingParen = sourceCode.getLastToken(node);
1242
+
1243
+ parameterParens.add(openingParen);
1244
+ parameterParens.add(closingParen);
1245
+ offsets.setDesiredOffset(openingParen, sourceCode.getTokenBefore(openingParen), 0);
1246
+
1247
+ addElementListIndent([node.source], openingParen, closingParen, options.CallExpression.arguments);
1248
+ },
1249
+
1239
1250
  "MemberExpression, JSXMemberExpression, MetaProperty"(node) {
1240
1251
  const object = node.type === "MetaProperty" ? node.meta : node.object;
1241
1252
  const firstNonObjectToken = sourceCode.getFirstTokenBetween(object, node.property, astUtils.isNotClosingParenToken);
@@ -46,6 +46,7 @@ module.exports = new LazyLoadingRuleMap(Object.entries({
46
46
  "func-name-matching": () => require("./func-name-matching"),
47
47
  "func-names": () => require("./func-names"),
48
48
  "func-style": () => require("./func-style"),
49
+ "function-call-argument-newline": () => require("./function-call-argument-newline"),
49
50
  "function-paren-newline": () => require("./function-paren-newline"),
50
51
  "generator-star-spacing": () => require("./generator-star-spacing"),
51
52
  "getter-return": () => require("./getter-return"),
@@ -23,7 +23,8 @@ const CAPS_ALLOWED = [
23
23
  "Object",
24
24
  "RegExp",
25
25
  "String",
26
- "Symbol"
26
+ "Symbol",
27
+ "BigInt"
27
28
  ];
28
29
 
29
30
  /**
@@ -120,7 +120,7 @@ module.exports = {
120
120
  }
121
121
 
122
122
  // Skip if the name is not static.
123
- if (!name) {
123
+ if (name === null) {
124
124
  return;
125
125
  }
126
126
 
@@ -33,17 +33,19 @@ module.exports = {
33
33
 
34
34
  return {
35
35
  SwitchStatement(node) {
36
- const mapping = {};
36
+ const previousKeys = new Set();
37
37
 
38
- node.cases.forEach(switchCase => {
39
- const key = sourceCode.getText(switchCase.test);
38
+ for (const switchCase of node.cases) {
39
+ if (switchCase.test) {
40
+ const key = sourceCode.getText(switchCase.test);
40
41
 
41
- if (mapping[key]) {
42
- context.report({ node: switchCase, messageId: "unexpected" });
43
- } else {
44
- mapping[key] = switchCase;
42
+ if (previousKeys.has(key)) {
43
+ context.report({ node: switchCase, messageId: "unexpected" });
44
+ } else {
45
+ previousKeys.add(key);
46
+ }
45
47
  }
46
- });
48
+ }
47
49
  }
48
50
  };
49
51
  }
@@ -98,6 +98,7 @@ module.exports = {
98
98
  grandparent.type === "CallExpression" &&
99
99
  grandparent.callee === parent &&
100
100
  grandparent.arguments.length === 1 &&
101
+ grandparent.arguments[0].type !== "SpreadElement" &&
101
102
  parent.type === "MemberExpression" &&
102
103
  parent.object === node &&
103
104
  astUtils.getStaticPropertyName(parent) === "bind"
@@ -50,8 +50,8 @@ module.exports = {
50
50
  /**
51
51
  * Check if a node is in a context where its value would be coerced to a boolean at runtime.
52
52
  *
53
- * @param {Object} node The node
54
- * @param {Object} parent Its parent
53
+ * @param {ASTNode} node The node
54
+ * @param {ASTNode} parent Its parent
55
55
  * @returns {boolean} If it is in a boolean context
56
56
  */
57
57
  function isInBooleanContext(node, parent) {
@@ -65,6 +65,15 @@ module.exports = {
65
65
  );
66
66
  }
67
67
 
68
+ /**
69
+ * Check if a node has comments inside.
70
+ *
71
+ * @param {ASTNode} node The node to check.
72
+ * @returns {boolean} `true` if it has comments inside.
73
+ */
74
+ function hasCommentsInside(node) {
75
+ return Boolean(sourceCode.getCommentsInside(node).length);
76
+ }
68
77
 
69
78
  return {
70
79
  UnaryExpression(node) {
@@ -89,7 +98,12 @@ module.exports = {
89
98
  context.report({
90
99
  node,
91
100
  messageId: "unexpectedNegation",
92
- fix: fixer => fixer.replaceText(parent, sourceCode.getText(node.argument))
101
+ fix: fixer => {
102
+ if (hasCommentsInside(parent)) {
103
+ return null;
104
+ }
105
+ return fixer.replaceText(parent, sourceCode.getText(node.argument));
106
+ }
93
107
  });
94
108
  }
95
109
  },
@@ -106,10 +120,35 @@ module.exports = {
106
120
  messageId: "unexpectedCall",
107
121
  fix: fixer => {
108
122
  if (!node.arguments.length) {
109
- return fixer.replaceText(parent, "true");
123
+ if (parent.type === "UnaryExpression" && parent.operator === "!") {
124
+
125
+ // !Boolean() -> true
126
+
127
+ if (hasCommentsInside(parent)) {
128
+ return null;
129
+ }
130
+
131
+ const replacement = "true";
132
+ let prefix = "";
133
+ const tokenBefore = sourceCode.getTokenBefore(parent);
134
+
135
+ if (tokenBefore && tokenBefore.range[1] === parent.range[0] &&
136
+ !astUtils.canTokensBeAdjacent(tokenBefore, replacement)) {
137
+ prefix = " ";
138
+ }
139
+
140
+ return fixer.replaceText(parent, prefix + replacement);
141
+ }
142
+
143
+ // Boolean() -> false
144
+ if (hasCommentsInside(node)) {
145
+ return null;
146
+ }
147
+ return fixer.replaceText(node, "false");
110
148
  }
111
149
 
112
- if (node.arguments.length > 1 || node.arguments[0].type === "SpreadElement") {
150
+ if (node.arguments.length > 1 || node.arguments[0].type === "SpreadElement" ||
151
+ hasCommentsInside(node)) {
113
152
  return null;
114
153
  }
115
154
 
@@ -8,6 +8,7 @@
8
8
  // Rule Definition
9
9
  //------------------------------------------------------------------------------
10
10
 
11
+ const { isParenthesized: isParenthesizedRaw } = require("eslint-utils");
11
12
  const astUtils = require("./utils/ast-utils.js");
12
13
 
13
14
  module.exports = {
@@ -68,7 +69,6 @@ module.exports = {
68
69
  const sourceCode = context.getSourceCode();
69
70
 
70
71
  const tokensToIgnore = new WeakSet();
71
- const isParenthesised = astUtils.isParenthesised.bind(astUtils, sourceCode);
72
72
  const precedence = astUtils.getPrecedence;
73
73
  const ALL_NODES = context.options[0] !== "functions";
74
74
  const EXCEPT_COND_ASSIGN = ALL_NODES && context.options[1] && context.options[1].conditionalAssign === false;
@@ -118,6 +118,16 @@ module.exports = {
118
118
  return ALL_NODES || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
119
119
  }
120
120
 
121
+ /**
122
+ * Determines if a node is surrounded by parentheses.
123
+ * @param {ASTNode} node - The node to be checked.
124
+ * @returns {boolean} True if the node is parenthesised.
125
+ * @private
126
+ */
127
+ function isParenthesised(node) {
128
+ return isParenthesizedRaw(1, node, sourceCode);
129
+ }
130
+
121
131
  /**
122
132
  * Determines if a node is surrounded by parentheses twice.
123
133
  * @param {ASTNode} node - The node to be checked.
@@ -125,12 +135,7 @@ module.exports = {
125
135
  * @private
126
136
  */
127
137
  function isParenthesisedTwice(node) {
128
- const previousToken = sourceCode.getTokenBefore(node, 1),
129
- nextToken = sourceCode.getTokenAfter(node, 1);
130
-
131
- return isParenthesised(node) && previousToken && nextToken &&
132
- astUtils.isOpeningParenToken(previousToken) && previousToken.range[1] <= node.range[0] &&
133
- astUtils.isClosingParenToken(nextToken) && nextToken.range[0] >= node.range[1];
138
+ return isParenthesizedRaw(2, node, sourceCode);
134
139
  }
135
140
 
136
141
  /**
@@ -406,15 +411,9 @@ module.exports = {
406
411
  report(node.callee);
407
412
  }
408
413
  }
409
- if (node.arguments.length === 1) {
410
- if (hasDoubleExcessParens(node.arguments[0]) && precedence(node.arguments[0]) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) {
411
- report(node.arguments[0]);
412
- }
413
- } else {
414
- node.arguments
415
- .filter(arg => hasExcessParens(arg) && precedence(arg) >= PRECEDENCE_OF_ASSIGNMENT_EXPR)
416
- .forEach(report);
417
- }
414
+ node.arguments
415
+ .filter(arg => hasExcessParens(arg) && precedence(arg) >= PRECEDENCE_OF_ASSIGNMENT_EXPR)
416
+ .forEach(report);
418
417
  }
419
418
 
420
419
  /**
@@ -686,6 +685,13 @@ module.exports = {
686
685
 
687
686
  CallExpression: checkCallNew,
688
687
 
688
+ ClassBody(node) {
689
+ node.body
690
+ .filter(member => member.type === "MethodDefinition" && member.computed &&
691
+ member.key && hasExcessParens(member.key) && precedence(member.key) >= PRECEDENCE_OF_ASSIGNMENT_EXPR)
692
+ .forEach(member => report(member.key));
693
+ },
694
+
689
695
  ConditionalExpression(node) {
690
696
  if (isReturnAssignException(node)) {
691
697
  return;
@@ -705,7 +711,7 @@ module.exports = {
705
711
  },
706
712
 
707
713
  DoWhileStatement(node) {
708
- if (hasDoubleExcessParens(node.test) && !isCondAssignException(node)) {
714
+ if (hasExcessParens(node.test) && !isCondAssignException(node)) {
709
715
  report(node.test);
710
716
  }
711
717
  },
@@ -830,11 +836,23 @@ module.exports = {
830
836
  },
831
837
 
832
838
  IfStatement(node) {
833
- if (hasDoubleExcessParens(node.test) && !isCondAssignException(node)) {
839
+ if (hasExcessParens(node.test) && !isCondAssignException(node)) {
834
840
  report(node.test);
835
841
  }
836
842
  },
837
843
 
844
+ ImportExpression(node) {
845
+ const { source } = node;
846
+
847
+ if (source.type === "SequenceExpression") {
848
+ if (hasDoubleExcessParens(source)) {
849
+ report(source);
850
+ }
851
+ } else if (hasExcessParens(source)) {
852
+ report(source);
853
+ }
854
+ },
855
+
838
856
  LogicalExpression: checkBinaryLogical,
839
857
 
840
858
  MemberExpression(node) {
@@ -917,7 +935,7 @@ module.exports = {
917
935
  },
918
936
 
919
937
  SwitchStatement(node) {
920
- if (hasDoubleExcessParens(node.discriminant)) {
938
+ if (hasExcessParens(node.discriminant)) {
921
939
  report(node.discriminant);
922
940
  }
923
941
  },
@@ -945,13 +963,13 @@ module.exports = {
945
963
  },
946
964
 
947
965
  WhileStatement(node) {
948
- if (hasDoubleExcessParens(node.test) && !isCondAssignException(node)) {
966
+ if (hasExcessParens(node.test) && !isCondAssignException(node)) {
949
967
  report(node.test);
950
968
  }
951
969
  },
952
970
 
953
971
  WithStatement(node) {
954
- if (hasDoubleExcessParens(node.object)) {
972
+ if (hasExcessParens(node.object)) {
955
973
  report(node.object);
956
974
  }
957
975
  },
@@ -973,7 +991,21 @@ module.exports = {
973
991
 
974
992
  SpreadElement: checkSpreadOperator,
975
993
  SpreadProperty: checkSpreadOperator,
976
- ExperimentalSpreadProperty: checkSpreadOperator
994
+ ExperimentalSpreadProperty: checkSpreadOperator,
995
+
996
+ TemplateLiteral(node) {
997
+ node.expressions
998
+ .filter(e => e && hasExcessParens(e))
999
+ .forEach(report);
1000
+ },
1001
+
1002
+ AssignmentPattern(node) {
1003
+ const { right } = node;
1004
+
1005
+ if (right && hasExcessParens(right) && precedence(right) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) {
1006
+ report(right);
1007
+ }
1008
+ }
977
1009
  };
978
1010
 
979
1011
  }
@@ -20,12 +20,14 @@ const BITWISE_OPERATORS = ["&", "|", "^", "~", "<<", ">>", ">>>"];
20
20
  const COMPARISON_OPERATORS = ["==", "!=", "===", "!==", ">", ">=", "<", "<="];
21
21
  const LOGICAL_OPERATORS = ["&&", "||"];
22
22
  const RELATIONAL_OPERATORS = ["in", "instanceof"];
23
+ const TERNARY_OPERATOR = ["?:"];
23
24
  const ALL_OPERATORS = [].concat(
24
25
  ARITHMETIC_OPERATORS,
25
26
  BITWISE_OPERATORS,
26
27
  COMPARISON_OPERATORS,
27
28
  LOGICAL_OPERATORS,
28
- RELATIONAL_OPERATORS
29
+ RELATIONAL_OPERATORS,
30
+ TERNARY_OPERATOR
29
31
  );
30
32
  const DEFAULT_GROUPS = [
31
33
  ARITHMETIC_OPERATORS,
@@ -34,7 +36,7 @@ const DEFAULT_GROUPS = [
34
36
  LOGICAL_OPERATORS,
35
37
  RELATIONAL_OPERATORS
36
38
  ];
37
- const TARGET_NODE_TYPE = /^(?:Binary|Logical)Expression$/u;
39
+ const TARGET_NODE_TYPE = /^(?:Binary|Logical|Conditional)Expression$/u;
38
40
 
39
41
  /**
40
42
  * Normalizes options.
@@ -65,6 +67,18 @@ function includesBothInAGroup(groups, left, right) {
65
67
  return groups.some(group => group.indexOf(left) !== -1 && group.indexOf(right) !== -1);
66
68
  }
67
69
 
70
+ /**
71
+ * Checks whether the given node is a conditional expression and returns the test node else the left node.
72
+ *
73
+ * @param {ASTNode} node - A node which can be a BinaryExpression or a LogicalExpression node.
74
+ * This parent node can be BinaryExpression, LogicalExpression
75
+ * , or a ConditionalExpression node
76
+ * @returns {ASTNode} node the appropriate node(left or test).
77
+ */
78
+ function getChildNode(node) {
79
+ return node.type === "ConditionalExpression" ? node.test : node.left;
80
+ }
81
+
68
82
  //------------------------------------------------------------------------------
69
83
  // Rule Definition
70
84
  //------------------------------------------------------------------------------
@@ -121,7 +135,7 @@ module.exports = {
121
135
  const b = node.parent;
122
136
 
123
137
  return (
124
- !includesBothInAGroup(options.groups, a.operator, b.operator) ||
138
+ !includesBothInAGroup(options.groups, a.operator, b.type === "ConditionalExpression" ? "?:" : b.operator) ||
125
139
  (
126
140
  options.allowSamePrecedence &&
127
141
  astUtils.getPrecedence(a) === astUtils.getPrecedence(b)
@@ -139,12 +153,25 @@ module.exports = {
139
153
  * @returns {boolean} `true` if the node was mixed.
140
154
  */
141
155
  function isMixedWithParent(node) {
156
+
142
157
  return (
143
158
  node.operator !== node.parent.operator &&
144
159
  !astUtils.isParenthesised(sourceCode, node)
145
160
  );
146
161
  }
147
162
 
163
+ /**
164
+ * Checks whether the operator of a given node is mixed with a
165
+ * conditional expression.
166
+ *
167
+ * @param {ASTNode} node - A node to check. This is a conditional
168
+ * expression node
169
+ * @returns {boolean} `true` if the node was mixed.
170
+ */
171
+ function isMixedWithConditionalParent(node) {
172
+ return !astUtils.isParenthesised(sourceCode, node) && !astUtils.isParenthesised(sourceCode, node.test);
173
+ }
174
+
148
175
  /**
149
176
  * Gets the operator token of a given node.
150
177
  *
@@ -153,7 +180,7 @@ module.exports = {
153
180
  * @returns {Token} The operator token of the node.
154
181
  */
155
182
  function getOperatorToken(node) {
156
- return sourceCode.getTokenAfter(node.left, astUtils.isNotClosingParenToken);
183
+ return sourceCode.getTokenAfter(getChildNode(node), astUtils.isNotClosingParenToken);
157
184
  }
158
185
 
159
186
  /**
@@ -167,13 +194,13 @@ module.exports = {
167
194
  */
168
195
  function reportBothOperators(node) {
169
196
  const parent = node.parent;
170
- const left = (parent.left === node) ? node : parent;
171
- const right = (parent.left !== node) ? node : parent;
197
+ const left = (getChildNode(parent) === node) ? node : parent;
198
+ const right = (getChildNode(parent) !== node) ? node : parent;
172
199
  const message =
173
200
  "Unexpected mix of '{{leftOperator}}' and '{{rightOperator}}'.";
174
201
  const data = {
175
- leftOperator: left.operator,
176
- rightOperator: right.operator
202
+ leftOperator: left.operator || "?:",
203
+ rightOperator: right.operator || "?:"
177
204
  };
178
205
 
179
206
  context.report({
@@ -198,17 +225,25 @@ module.exports = {
198
225
  * @returns {void}
199
226
  */
200
227
  function check(node) {
201
- if (TARGET_NODE_TYPE.test(node.parent.type) &&
202
- isMixedWithParent(node) &&
203
- !shouldIgnore(node)
204
- ) {
205
- reportBothOperators(node);
228
+ if (TARGET_NODE_TYPE.test(node.parent.type)) {
229
+ if (node.parent.type === "ConditionalExpression" && !shouldIgnore(node) && isMixedWithConditionalParent(node.parent)) {
230
+ reportBothOperators(node);
231
+ } else {
232
+ if (TARGET_NODE_TYPE.test(node.parent.type) &&
233
+ isMixedWithParent(node) &&
234
+ !shouldIgnore(node)
235
+ ) {
236
+ reportBothOperators(node);
237
+ }
238
+ }
206
239
  }
240
+
207
241
  }
208
242
 
209
243
  return {
210
244
  BinaryExpression: check,
211
245
  LogicalExpression: check
246
+
212
247
  };
213
248
  }
214
249
  };
@@ -21,7 +21,7 @@ module.exports = {
21
21
 
22
22
  schema: {
23
23
  type: "array",
24
- items: [{
24
+ items: {
25
25
  oneOf: [
26
26
  {
27
27
  type: "string"
@@ -36,7 +36,7 @@ module.exports = {
36
36
  additionalProperties: false
37
37
  }
38
38
  ]
39
- }],
39
+ },
40
40
  uniqueItems: true,
41
41
  minItems: 0
42
42
  }
@@ -507,7 +507,7 @@ module.exports = {
507
507
  const childScopes = scope.childScopes;
508
508
  let i, l;
509
509
 
510
- if (scope.type !== "TDZ" && (scope.type !== "global" || config.vars === "all")) {
510
+ if (scope.type !== "global" || config.vars === "all") {
511
511
  for (i = 0, l = variables.length; i < l; ++i) {
512
512
  const variable = variables[i];
513
513
 
@@ -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
 
@@ -38,6 +38,7 @@ const LINEBREAKS = new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]);
38
38
  const STATEMENT_LIST_PARENTS = new Set(["Program", "BlockStatement", "SwitchCase"]);
39
39
 
40
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;
41
42
 
42
43
  /**
43
44
  * Checks reference if is non initializer and writable.
@@ -847,6 +848,7 @@ module.exports = {
847
848
  return 17;
848
849
 
849
850
  case "CallExpression":
851
+ case "ImportExpression":
850
852
  return 18;
851
853
 
852
854
  case "NewExpression":
@@ -1101,7 +1103,7 @@ module.exports = {
1101
1103
  } else {
1102
1104
  const name = module.exports.getStaticPropertyName(parent);
1103
1105
 
1104
- if (name) {
1106
+ if (name !== null) {
1105
1107
  tokens.push(`'${name}'`);
1106
1108
  }
1107
1109
  }
@@ -1301,7 +1303,7 @@ module.exports = {
1301
1303
  * set `node.value` to a unicode regex. To make sure a literal is actually `null`, check
1302
1304
  * `node.regex` instead. Also see: https://github.com/eslint/eslint/issues/8020
1303
1305
  */
1304
- return node.type === "Literal" && node.value === null && !node.regex;
1306
+ return node.type === "Literal" && node.value === null && !node.regex && !node.bigint;
1305
1307
  },
1306
1308
 
1307
1309
  /**
@@ -1373,5 +1375,20 @@ module.exports = {
1373
1375
  "/*".length +
1374
1376
  (match ? match.index + 1 : 0)
1375
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);
1376
1393
  }
1377
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)
@@ -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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -50,9 +50,9 @@
50
50
  "debug": "^4.0.1",
51
51
  "doctrine": "^3.0.0",
52
52
  "eslint-scope": "^5.0.0",
53
- "eslint-utils": "^1.3.1",
54
- "eslint-visitor-keys": "^1.0.0",
55
- "espree": "^6.0.0",
53
+ "eslint-utils": "^1.4.0",
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",
@@ -84,7 +84,7 @@
84
84
  "devDependencies": {
85
85
  "@babel/core": "^7.4.3",
86
86
  "@babel/preset-env": "^7.4.3",
87
- "acorn": "^6.1.1",
87
+ "acorn": "^7.0.0",
88
88
  "babel-loader": "^8.0.5",
89
89
  "chai": "^4.0.1",
90
90
  "cheerio": "^0.22.0",