eslint 5.11.1 → 5.12.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 CHANGED
@@ -1,3 +1,11 @@
1
+ v5.12.0 - January 4, 2019
2
+
3
+ * [`0d91e7d`](https://github.com/eslint/eslint/commit/0d91e7d28e5eba79a6032165cdef5d4549d26462) Update: Add sort-imports ignoreDeclarationSort (fixes #11019) (#11040) (Remco Haszing)
4
+ * [`f92d6f0`](https://github.com/eslint/eslint/commit/f92d6f05c4dcd4a3a0616871e10b31edae9dfad5) Build: Add karma-chrome-launcher support (#11027) (薛定谔的猫)
5
+ * [`166853d`](https://github.com/eslint/eslint/commit/166853d9c59db493f0b1bb68a67ad868662a4205) Upgrade: eslint-plugin-eslint-plugin@2.0.1 (#11220) (薛定谔的猫)
6
+ * [`bfff77a`](https://github.com/eslint/eslint/commit/bfff77ad4eaa02e2e62481c986634df38d5db6e5) Fix: no-param-reassign parameter in ternary operator (fixes #11236) (#11239) (周昊宇)
7
+ * [`258b654`](https://github.com/eslint/eslint/commit/258b6541f61dc3a9ae64e200680766a11c3dd316) Upgrade: require-uncached renamed to import-fresh (#11066) (薛定谔的猫)
8
+
1
9
  v5.11.1 - December 26, 2018
2
10
 
3
11
  * [`de79f10`](https://github.com/eslint/eslint/commit/de79f1026b7035f0296d7876f1db64f225cca1b8) Fix: handle optional catch bindings in no-useless-catch (#11205) (Colin Ihrig)
@@ -18,7 +18,7 @@ const fs = require("fs"),
18
18
  pathIsInside = require("path-is-inside"),
19
19
  stripComments = require("strip-json-comments"),
20
20
  stringify = require("json-stable-stringify-without-jsonify"),
21
- requireUncached = require("require-uncached");
21
+ importFresh = require("import-fresh");
22
22
 
23
23
  const debug = require("debug")("eslint:config-file");
24
24
 
@@ -156,7 +156,7 @@ function loadLegacyConfigFile(filePath) {
156
156
  function loadJSConfigFile(filePath) {
157
157
  debug(`Loading JS config file: ${filePath}`);
158
158
  try {
159
- return requireUncached(filePath);
159
+ return importFresh(filePath);
160
160
  } catch (e) {
161
161
  debug(`Error reading JavaScript file: ${filePath}`);
162
162
  e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
@@ -29,8 +29,8 @@ module.exports = {
29
29
  ],
30
30
 
31
31
  messages: {
32
- missing: "Requires a space {{location}} '{{token}}'",
33
- extra: "Unexpected space(s) {{location}} '{{token}}'"
32
+ missing: "Requires a space {{location}} '{{token}}'.",
33
+ extra: "Unexpected space(s) {{location}} '{{token}}'."
34
34
  }
35
35
  },
36
36
 
@@ -137,8 +137,8 @@ module.exports = {
137
137
  ],
138
138
 
139
139
  messages: {
140
- unexpectedLowercaseComment: "Comments should not begin with a lowercase character",
141
- unexpectedUppercaseComment: "Comments should not begin with an uppercase character"
140
+ unexpectedLowercaseComment: "Comments should not begin with a lowercase character.",
141
+ unexpectedUppercaseComment: "Comments should not begin with an uppercase character."
142
142
  }
143
143
  },
144
144
 
@@ -92,10 +92,10 @@ module.exports = {
92
92
  },
93
93
 
94
94
  messages: {
95
- matchProperty: "Function name `{{funcName}}` should match property name `{{name}}`",
96
- matchVariable: "Function name `{{funcName}}` should match variable name `{{name}}`",
97
- notMatchProperty: "Function name `{{funcName}}` should not match property name `{{name}}`",
98
- notMatchVariable: "Function name `{{funcName}}` should not match variable name `{{name}}`"
95
+ matchProperty: "Function name `{{funcName}}` should match property name `{{name}}`.",
96
+ matchVariable: "Function name `{{funcName}}` should match variable name `{{name}}`.",
97
+ notMatchProperty: "Function name `{{funcName}}` should not match property name `{{name}}`.",
98
+ notMatchVariable: "Function name `{{funcName}}` should not match variable name `{{name}}`."
99
99
  }
100
100
  },
101
101
 
@@ -32,7 +32,7 @@ module.exports = {
32
32
  ],
33
33
 
34
34
  messages: {
35
- maximumExceeded: "Number of classes per file must not exceed {{ max }}"
35
+ maximumExceeded: "Number of classes per file must not exceed {{ max }}."
36
36
  }
37
37
  },
38
38
  create(context) {
@@ -107,6 +107,14 @@ module.exports = {
107
107
 
108
108
  break;
109
109
 
110
+ // EXCLUDES: e.g. (foo ? a : b).c = bar;
111
+ case "ConditionalExpression":
112
+ if (parent.test === node) {
113
+ return false;
114
+ }
115
+
116
+ break;
117
+
110
118
  // no default
111
119
  }
112
120
 
@@ -226,8 +226,8 @@ module.exports = {
226
226
  fixable: "code",
227
227
 
228
228
  messages: {
229
- useSpreadMessage: "Use an object spread instead of `Object.assign` eg: `{ ...foo }`",
230
- useLiteralMessage: "Use an object literal instead of `Object.assign`. eg: `{ foo: bar }`"
229
+ useSpreadMessage: "Use an object spread instead of `Object.assign` eg: `{ ...foo }`.",
230
+ useLiteralMessage: "Use an object literal instead of `Object.assign`. eg: `{ foo: bar }`."
231
231
  }
232
232
  },
233
233
 
@@ -36,6 +36,9 @@ module.exports = {
36
36
  minItems: 4,
37
37
  maxItems: 4
38
38
  },
39
+ ignoreDeclarationSort: {
40
+ type: "boolean"
41
+ },
39
42
  ignoreMemberSort: {
40
43
  type: "boolean"
41
44
  }
@@ -51,6 +54,7 @@ module.exports = {
51
54
 
52
55
  const configuration = context.options[0] || {},
53
56
  ignoreCase = configuration.ignoreCase || false,
57
+ ignoreDeclarationSort = configuration.ignoreDeclarationSort || false,
54
58
  ignoreMemberSort = configuration.ignoreMemberSort || false,
55
59
  memberSyntaxSortOrder = configuration.memberSyntaxSortOrder || ["none", "all", "multiple", "single"],
56
60
  sourceCode = context.getSourceCode();
@@ -105,44 +109,48 @@ module.exports = {
105
109
 
106
110
  return {
107
111
  ImportDeclaration(node) {
108
- if (previousDeclaration) {
109
- const currentMemberSyntaxGroupIndex = getMemberParameterGroupIndex(node),
110
- previousMemberSyntaxGroupIndex = getMemberParameterGroupIndex(previousDeclaration);
111
- let currentLocalMemberName = getFirstLocalMemberName(node),
112
- previousLocalMemberName = getFirstLocalMemberName(previousDeclaration);
113
-
114
- if (ignoreCase) {
115
- previousLocalMemberName = previousLocalMemberName && previousLocalMemberName.toLowerCase();
116
- currentLocalMemberName = currentLocalMemberName && currentLocalMemberName.toLowerCase();
117
- }
118
-
119
- /*
120
- * When the current declaration uses a different member syntax,
121
- * then check if the ordering is correct.
122
- * Otherwise, make a default string compare (like rule sort-vars to be consistent) of the first used local member name.
123
- */
124
- if (currentMemberSyntaxGroupIndex !== previousMemberSyntaxGroupIndex) {
125
- if (currentMemberSyntaxGroupIndex < previousMemberSyntaxGroupIndex) {
126
- context.report({
127
- node,
128
- message: "Expected '{{syntaxA}}' syntax before '{{syntaxB}}' syntax.",
129
- data: {
130
- syntaxA: memberSyntaxSortOrder[currentMemberSyntaxGroupIndex],
131
- syntaxB: memberSyntaxSortOrder[previousMemberSyntaxGroupIndex]
132
- }
133
- });
112
+ if (!ignoreDeclarationSort) {
113
+ if (previousDeclaration) {
114
+ const currentMemberSyntaxGroupIndex = getMemberParameterGroupIndex(node),
115
+ previousMemberSyntaxGroupIndex = getMemberParameterGroupIndex(previousDeclaration);
116
+ let currentLocalMemberName = getFirstLocalMemberName(node),
117
+ previousLocalMemberName = getFirstLocalMemberName(previousDeclaration);
118
+
119
+ if (ignoreCase) {
120
+ previousLocalMemberName = previousLocalMemberName && previousLocalMemberName.toLowerCase();
121
+ currentLocalMemberName = currentLocalMemberName && currentLocalMemberName.toLowerCase();
134
122
  }
135
- } else {
136
- if (previousLocalMemberName &&
137
- currentLocalMemberName &&
138
- currentLocalMemberName < previousLocalMemberName
139
- ) {
140
- context.report({
141
- node,
142
- message: "Imports should be sorted alphabetically."
143
- });
123
+
124
+ /*
125
+ * When the current declaration uses a different member syntax,
126
+ * then check if the ordering is correct.
127
+ * Otherwise, make a default string compare (like rule sort-vars to be consistent) of the first used local member name.
128
+ */
129
+ if (currentMemberSyntaxGroupIndex !== previousMemberSyntaxGroupIndex) {
130
+ if (currentMemberSyntaxGroupIndex < previousMemberSyntaxGroupIndex) {
131
+ context.report({
132
+ node,
133
+ message: "Expected '{{syntaxA}}' syntax before '{{syntaxB}}' syntax.",
134
+ data: {
135
+ syntaxA: memberSyntaxSortOrder[currentMemberSyntaxGroupIndex],
136
+ syntaxB: memberSyntaxSortOrder[previousMemberSyntaxGroupIndex]
137
+ }
138
+ });
139
+ }
140
+ } else {
141
+ if (previousLocalMemberName &&
142
+ currentLocalMemberName &&
143
+ currentLocalMemberName < previousLocalMemberName
144
+ ) {
145
+ context.report({
146
+ node,
147
+ message: "Imports should be sorted alphabetically."
148
+ });
149
+ }
144
150
  }
145
151
  }
152
+
153
+ previousDeclaration = node;
146
154
  }
147
155
 
148
156
  if (!ignoreMemberSort) {
@@ -191,8 +199,6 @@ module.exports = {
191
199
  });
192
200
  }
193
201
  }
194
-
195
- previousDeclaration = node;
196
202
  }
197
203
  };
198
204
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "5.11.1",
3
+ "version": "5.12.0",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -52,6 +52,7 @@
52
52
  "glob": "^7.1.2",
53
53
  "globals": "^11.7.0",
54
54
  "ignore": "^4.0.6",
55
+ "import-fresh": "^3.0.0",
55
56
  "imurmurhash": "^0.1.4",
56
57
  "inquirer": "^6.1.0",
57
58
  "js-yaml": "^3.12.0",
@@ -66,7 +67,6 @@
66
67
  "pluralize": "^7.0.0",
67
68
  "progress": "^2.0.0",
68
69
  "regexpp": "^2.0.1",
69
- "require-uncached": "^1.0.3",
70
70
  "semver": "^5.5.1",
71
71
  "strip-ansi": "^4.0.0",
72
72
  "strip-json-comments": "^2.0.1",
@@ -86,7 +86,7 @@
86
86
  "coveralls": "^3.0.1",
87
87
  "dateformat": "^3.0.3",
88
88
  "ejs": "^2.6.1",
89
- "eslint-plugin-eslint-plugin": "^1.4.1",
89
+ "eslint-plugin-eslint-plugin": "^2.0.1",
90
90
  "eslint-plugin-node": "^8.0.0",
91
91
  "eslint-plugin-rulesdir": "^0.1.0",
92
92
  "eslint-release": "^1.2.0",
@@ -97,17 +97,17 @@
97
97
  "jsdoc": "^3.5.5",
98
98
  "karma": "^3.0.0",
99
99
  "karma-babel-preprocessor": "^7.0.0",
100
+ "karma-chrome-launcher": "^2.2.0",
100
101
  "karma-mocha": "^1.3.0",
101
102
  "karma-mocha-reporter": "^2.2.3",
102
- "karma-phantomjs-launcher": "^1.0.4",
103
103
  "leche": "^2.2.3",
104
104
  "load-perf": "^0.2.0",
105
105
  "markdownlint": "^0.11.0",
106
106
  "mocha": "^5.0.5",
107
107
  "mock-fs": "^4.6.0",
108
108
  "npm-license": "^0.3.3",
109
- "phantomjs-prebuilt": "^2.1.16",
110
109
  "proxyquire": "^2.0.1",
110
+ "puppeteer": "^1.9.0",
111
111
  "shelljs": "^0.8.2",
112
112
  "sinon": "^3.3.0",
113
113
  "temp": "^0.8.3",