eslint 7.20.0 → 7.21.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,16 @@
1
+ v7.21.0 - February 27, 2021
2
+
3
+ * [`3cd5440`](https://github.com/eslint/eslint/commit/3cd5440b94d5fa4f11a09f50b685f6150f0c2d41) Upgrade: @eslint/eslintrc to 0.4.0 (#14147) (Brandon Mills)
4
+ * [`c0b8c71`](https://github.com/eslint/eslint/commit/c0b8c71df4d0b3f54b20587432d9133741985d5c) Upgrade: Puppeteer to 7.1.0 (#14122) (Tim van der Lippe)
5
+ * [`08ae31e`](https://github.com/eslint/eslint/commit/08ae31e539e381cd0eabf6393fa5c20f1d59125f) New: Implement cacheStrategy (refs eslint/rfcs#63) (#14119) (Manu Chambon)
6
+ * [`5e51fd2`](https://github.com/eslint/eslint/commit/5e51fd28dc773c11c924450d24088f97f2824f00) Update: do not ignore symbolic links (fixes #13551, fixes #13615) (#14126) (Pig Fang)
7
+ * [`87c43a5`](https://github.com/eslint/eslint/commit/87c43a5d7ea2018cffd6d9b5c431ecb60caaf0d6) Chore: improve a few comments and fix typos (#14125) (Tobias Nießen)
8
+ * [`e19c51e`](https://github.com/eslint/eslint/commit/e19c51ea2ef2cf666d94218c66f6b223bb2e9dae) Sponsors: Sync README with website (ESLint Jenkins)
9
+ * [`b8aea99`](https://github.com/eslint/eslint/commit/b8aea9988b6451b6a05af4f3ede8d6ed5c1d9926) Fix: pluralize 'line' to 'lines' in max-lines-per-function description (#14115) (Trevin Hofmann)
10
+ * [`f5b53e2`](https://github.com/eslint/eslint/commit/f5b53e285ab5286ea382d73b379b820f649c20d0) Sponsors: Sync README with website (ESLint Jenkins)
11
+ * [`eee1213`](https://github.com/eslint/eslint/commit/eee12134ce0956e9f825c1630776b1731551a948) Sponsors: Sync README with website (ESLint Jenkins)
12
+ * [`5c4d7ea`](https://github.com/eslint/eslint/commit/5c4d7ea8d2e8d137c42b918dc99a84b4a5fed9b3) Sponsors: Sync README with website (ESLint Jenkins)
13
+
1
14
  v7.20.0 - February 12, 2021
2
15
 
3
16
  * [`f4ac3b0`](https://github.com/eslint/eslint/commit/f4ac3b0e7072fbd3c14e9c64ff0c2c255a4eb730) Docs: fix sibling selector descriptions (#14099) (Milos Djermanovic)
package/README.md CHANGED
@@ -281,9 +281,9 @@ The following companies, organizations, and individuals support ESLint's ongoing
281
281
  <!--sponsorsstart-->
282
282
  <h3>Platinum Sponsors</h3>
283
283
  <p><a href="https://automattic.com"><img src="https://images.opencollective.com/photomatt/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
284
- <p><a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="96"></a> <a href="https://google.com/chrome"><img src="https://images.opencollective.com/chrome/dc55bd4/logo.png" alt="Chrome's Web Framework & Tools Performance Fund" height="96"></a> <a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/e780cd4/logo.png" alt="Shopify" height="96"></a> <a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a> <a href="https://aka.ms/microsoftfossfund"><img src="https://avatars.githubusercontent.com/u/67931232?u=7fddc652a464d7151b97e8f108392af7d54fa3e8&v=4" alt="Microsoft FOSS Fund Sponsorships" height="96"></a></p><h3>Silver Sponsors</h3>
284
+ <p><a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="96"></a> <a href="https://google.com/chrome"><img src="https://images.opencollective.com/chrome/dc55bd4/logo.png" alt="Chrome's Web Framework & Tools Performance Fund" height="96"></a> <a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/e780cd4/logo.png" alt="Shopify" height="96"></a> <a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a> <a href="https://substack.com/"><img src="https://avatars.githubusercontent.com/u/53023767?v=4" alt="Substack" height="96"></a> <a href="https://aka.ms/microsoftfossfund"><img src="https://avatars.githubusercontent.com/u/67931232?u=7fddc652a464d7151b97e8f108392af7d54fa3e8&v=4" alt="Microsoft FOSS Fund Sponsorships" height="96"></a></p><h3>Silver Sponsors</h3>
285
285
  <p><a href="https://retool.com/"><img src="https://images.opencollective.com/retool/98ea68e/logo.png" alt="Retool" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <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>
286
- <p><a href="https://writersperhour.com"><img src="https://images.opencollective.com/writersperhour/5787d4b/logo.png" alt="Writers Per Hour" height="32"></a> <a href="https://www.betacalendars.com/march-calendar.html"><img src="https://images.opencollective.com/betacalendars/9334b33/logo.png" alt="March 2021 calendar" height="32"></a> <a href="https://buy.fineproxy.org/eng/"><img src="https://images.opencollective.com/buy-fineproxy-org/b282e39/logo.png" alt="Buy.Fineproxy.Org" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="null"><img src="https://images.opencollective.com/bugsnag-stability-monitoring/c2cef36/logo.png" alt="Bugsnag Stability Monitoring" height="32"></a> <a href="https://mixpanel.com"><img src="https://images.opencollective.com/mixpanel/cd682f7/logo.png" alt="Mixpanel" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" 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/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a></p>
286
+ <p><a href="https://papersowl.com/pay-for-research-paper"><img src="https://images.opencollective.com/papersowl2/9ef85ac/logo.png" alt="Papersowl" height="32"></a> <a href="https://writersperhour.com"><img src="https://images.opencollective.com/writersperhour/5787d4b/logo.png" alt="Writers Per Hour" height="32"></a> <a href="https://www.betacalendars.com/march-calendar.html"><img src="https://images.opencollective.com/betacalendars/9334b33/logo.png" alt="March 2021 calendar" height="32"></a> <a href="https://buy.fineproxy.org/eng/"><img src="https://images.opencollective.com/buy-fineproxy-org/b282e39/logo.png" alt="Buy.Fineproxy.Org" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="null"><img src="https://images.opencollective.com/bugsnag-stability-monitoring/c2cef36/logo.png" alt="Bugsnag Stability Monitoring" height="32"></a> <a href="https://mixpanel.com"><img src="https://images.opencollective.com/mixpanel/cd682f7/logo.png" alt="Mixpanel" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" 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/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a></p>
287
287
  <!--sponsorsend-->
288
288
 
289
289
  ## <a name="technology-sponsors"></a>Technology Sponsors
@@ -24,6 +24,7 @@ module.exports = {
24
24
  */
25
25
  cacheLocation: "",
26
26
  cacheFile: ".eslintcache",
27
+ cacheStrategy: "metadata",
27
28
  fix: false,
28
29
  allowInlineConfig: true,
29
30
  reportUnusedDisableDirectives: void 0,
@@ -589,7 +589,7 @@ class CLIEngine {
589
589
  ignore: options.ignore
590
590
  });
591
591
  const lintResultCache =
592
- options.cache ? new LintResultCache(cacheFilePath) : null;
592
+ options.cache ? new LintResultCache(cacheFilePath, options.cacheStrategy) : null;
593
593
  const linter = new Linter({ cwd: options.cwd });
594
594
 
595
595
  /** @type {ConfigArray[]} */
@@ -433,9 +433,14 @@ class FileEnumerator {
433
433
  // Enumerate the files of this directory.
434
434
  for (const entry of readdirSafeSync(directoryPath)) {
435
435
  const filePath = path.join(directoryPath, entry.name);
436
+ const fileInfo = entry.isSymbolicLink() ? statSafeSync(filePath) : entry;
437
+
438
+ if (!fileInfo) {
439
+ continue;
440
+ }
436
441
 
437
442
  // Check if the file is matched.
438
- if (entry.isFile()) {
443
+ if (fileInfo.isFile()) {
439
444
  if (!config) {
440
445
  config = configArrayFactory.getConfigArrayForFile(
441
446
  filePath,
@@ -471,7 +476,7 @@ class FileEnumerator {
471
476
  }
472
477
 
473
478
  // Dive into the sub directory.
474
- } else if (options.recursive && entry.isDirectory()) {
479
+ } else if (options.recursive && fileInfo.isDirectory()) {
475
480
  if (!config) {
476
481
  config = configArrayFactory.getConfigArrayForFile(
477
482
  filePath,
@@ -15,6 +15,8 @@ const stringify = require("json-stable-stringify-without-jsonify");
15
15
  const pkg = require("../../package.json");
16
16
  const hash = require("./hash");
17
17
 
18
+ const debug = require("debug")("eslint:lint-result-cache");
19
+
18
20
  //-----------------------------------------------------------------------------
19
21
  // Helpers
20
22
  //-----------------------------------------------------------------------------
@@ -22,6 +24,22 @@ const hash = require("./hash");
22
24
  const configHashCache = new WeakMap();
23
25
  const nodeVersion = process && process.version;
24
26
 
27
+ const validCacheStrategies = ["metadata", "content"];
28
+ const invalidCacheStrategyErrorMessage = `Cache strategy must be one of: ${validCacheStrategies
29
+ .map(strategy => `"${strategy}"`)
30
+ .join(", ")}`;
31
+
32
+ /**
33
+ * Tests whether a provided cacheStrategy is valid
34
+ * @param {string} cacheStrategy The cache strategy to use
35
+ * @returns {boolean} true if `cacheStrategy` is one of `validCacheStrategies`; false otherwise
36
+ */
37
+ function isValidCacheStrategy(cacheStrategy) {
38
+ return (
39
+ validCacheStrategies.indexOf(cacheStrategy) !== -1
40
+ );
41
+ }
42
+
25
43
  /**
26
44
  * Calculates the hash of the config
27
45
  * @param {ConfigArray} config The config.
@@ -50,11 +68,30 @@ class LintResultCache {
50
68
  * Creates a new LintResultCache instance.
51
69
  * @param {string} cacheFileLocation The cache file location.
52
70
  * configuration lookup by file path).
71
+ * @param {"metadata" | "content"} cacheStrategy The cache strategy to use.
53
72
  */
54
- constructor(cacheFileLocation) {
73
+ constructor(cacheFileLocation, cacheStrategy) {
55
74
  assert(cacheFileLocation, "Cache file location is required");
56
-
57
- this.fileEntryCache = fileEntryCache.create(cacheFileLocation);
75
+ assert(cacheStrategy, "Cache strategy is required");
76
+ assert(
77
+ isValidCacheStrategy(cacheStrategy),
78
+ invalidCacheStrategyErrorMessage
79
+ );
80
+
81
+ debug(`Caching results to ${cacheFileLocation}`);
82
+
83
+ const useChecksum = cacheStrategy === "content";
84
+
85
+ debug(
86
+ `Using "${cacheStrategy}" strategy to detect changes`
87
+ );
88
+
89
+ this.fileEntryCache = fileEntryCache.create(
90
+ cacheFileLocation,
91
+ void 0,
92
+ useChecksum
93
+ );
94
+ this.cacheFileLocation = cacheFileLocation;
58
95
  }
59
96
 
60
97
  /**
@@ -76,17 +113,28 @@ class LintResultCache {
76
113
  * was previously linted
77
114
  * If any of these are not true, we will not reuse the lint results.
78
115
  */
79
-
80
116
  const fileDescriptor = this.fileEntryCache.getFileDescriptor(filePath);
81
117
  const hashOfConfig = hashOfConfigFor(config);
82
- const changed = fileDescriptor.changed || fileDescriptor.meta.hashOfConfig !== hashOfConfig;
118
+ const changed =
119
+ fileDescriptor.changed ||
120
+ fileDescriptor.meta.hashOfConfig !== hashOfConfig;
121
+
122
+ if (fileDescriptor.notFound) {
123
+ debug(`File not found on the file system: ${filePath}`);
124
+ return null;
125
+ }
83
126
 
84
- if (fileDescriptor.notFound || changed) {
127
+ if (changed) {
128
+ debug(`Cache entry not found or no longer valid: ${filePath}`);
85
129
  return null;
86
130
  }
87
131
 
88
132
  // If source is present but null, need to reread the file from the filesystem.
89
- if (fileDescriptor.meta.results && fileDescriptor.meta.results.source === null) {
133
+ if (
134
+ fileDescriptor.meta.results &&
135
+ fileDescriptor.meta.results.source === null
136
+ ) {
137
+ debug(`Rereading cached result source from filesystem: ${filePath}`);
90
138
  fileDescriptor.meta.results.source = fs.readFileSync(filePath, "utf-8");
91
139
  }
92
140
 
@@ -112,6 +160,7 @@ class LintResultCache {
112
160
  const fileDescriptor = this.fileEntryCache.getFileDescriptor(filePath);
113
161
 
114
162
  if (fileDescriptor && !fileDescriptor.notFound) {
163
+ debug(`Updating cached result: ${filePath}`);
115
164
 
116
165
  // Serialize the result, except that we want to remove the file source if present.
117
166
  const resultToSerialize = Object.assign({}, result);
@@ -135,6 +184,7 @@ class LintResultCache {
135
184
  * @returns {void}
136
185
  */
137
186
  reconcile() {
187
+ debug(`Persisting cached results: ${this.cacheFileLocation}`);
138
188
  this.fileEntryCache.reconcile();
139
189
  }
140
190
  }
package/lib/cli.js CHANGED
@@ -62,6 +62,7 @@ function translateOptions({
62
62
  cache,
63
63
  cacheFile,
64
64
  cacheLocation,
65
+ cacheStrategy,
65
66
  config,
66
67
  env,
67
68
  errorOnUnmatchedPattern,
@@ -88,6 +89,7 @@ function translateOptions({
88
89
  allowInlineConfig: inlineConfig,
89
90
  cache,
90
91
  cacheLocation: cacheLocation || cacheFile,
92
+ cacheStrategy,
91
93
  errorOnUnmatchedPattern,
92
94
  extensions: ext,
93
95
  fix: (fix || fixDryRun) && (quiet ? quietFixPredicate : true),
@@ -43,6 +43,7 @@ const { version } = require("../../package.json");
43
43
  * @property {ConfigData} [baseConfig] Base config object, extended by all configs used with this instance
44
44
  * @property {boolean} [cache] Enable result caching.
45
45
  * @property {string} [cacheLocation] The cache file to use instead of .eslintcache.
46
+ * @property {"metadata" | "content"} [cacheStrategy] The strategy used to detect changed files.
46
47
  * @property {string} [cwd] The value to use for the current working directory.
47
48
  * @property {boolean} [errorOnUnmatchedPattern] If `false` then `ESLint#lintFiles()` doesn't throw even if no target files found. Defaults to `true`.
48
49
  * @property {string[]} [extensions] An array of file extensions to check.
@@ -157,6 +158,7 @@ function processOptions({
157
158
  baseConfig = null,
158
159
  cache = false,
159
160
  cacheLocation = ".eslintcache",
161
+ cacheStrategy = "metadata",
160
162
  cwd = process.cwd(),
161
163
  errorOnUnmatchedPattern = true,
162
164
  extensions = null, // ← should be null by default because if it's an array then it suppresses RFC20 feature.
@@ -216,6 +218,12 @@ function processOptions({
216
218
  if (!isNonEmptyString(cacheLocation)) {
217
219
  errors.push("'cacheLocation' must be a non-empty string.");
218
220
  }
221
+ if (
222
+ cacheStrategy !== "metadata" &&
223
+ cacheStrategy !== "content"
224
+ ) {
225
+ errors.push("'cacheStrategy' must be any of \"metadata\", \"content\".");
226
+ }
219
227
  if (!isNonEmptyString(cwd) || !path.isAbsolute(cwd)) {
220
228
  errors.push("'cwd' must be an absolute path.");
221
229
  }
@@ -284,6 +292,7 @@ function processOptions({
284
292
  baseConfig,
285
293
  cache,
286
294
  cacheLocation,
295
+ cacheStrategy,
287
296
  configFile: overrideConfigFile,
288
297
  cwd,
289
298
  errorOnUnmatchedPattern,
package/lib/options.js CHANGED
@@ -214,6 +214,14 @@ module.exports = optionator({
214
214
  type: "path::String",
215
215
  description: "Path to the cache file or directory"
216
216
  },
217
+ {
218
+ option: "cache-strategy",
219
+ dependsOn: ["cache"],
220
+ type: "String",
221
+ default: "metadata",
222
+ enum: ["metadata", "content"],
223
+ description: "Strategy to use for detecting changed files in the cache"
224
+ },
217
225
  {
218
226
  heading: "Miscellaneous"
219
227
  },
@@ -954,7 +954,7 @@ module.exports = {
954
954
  }
955
955
 
956
956
  /**
957
- * Checks wether a return statement is wrapped in ()
957
+ * Checks whether a return statement is wrapped in ()
958
958
  * @param {ASTNode} node node to examine
959
959
  * @returns {boolean} the result
960
960
  */
@@ -71,7 +71,7 @@ module.exports = {
71
71
  type: "suggestion",
72
72
 
73
73
  docs: {
74
- description: "enforce a maximum number of line of code in a function",
74
+ description: "enforce a maximum number of lines of code in a function",
75
75
  category: "Stylistic Issues",
76
76
  recommended: false,
77
77
  url: "https://eslint.org/docs/rules/max-lines-per-function"
@@ -105,9 +105,9 @@ module.exports = {
105
105
  }
106
106
 
107
107
  /**
108
- * Converts an integer to to an object containing the the integer's coefficient and order of magnitude
108
+ * Converts an integer to to an object containing the integer's coefficient and order of magnitude
109
109
  * @param {string} stringInteger the string representation of the integer being converted
110
- * @returns {Object} the object containing the the integer's coefficient and order of magnitude
110
+ * @returns {Object} the object containing the integer's coefficient and order of magnitude
111
111
  */
112
112
  function normalizeInteger(stringInteger) {
113
113
  const significantDigits = removeTrailingZeros(removeLeadingZeros(stringInteger));
@@ -120,9 +120,9 @@ module.exports = {
120
120
 
121
121
  /**
122
122
  *
123
- * Converts a float to to an object containing the the floats's coefficient and order of magnitude
123
+ * Converts a float to to an object containing the floats's coefficient and order of magnitude
124
124
  * @param {string} stringFloat the string representation of the float being converted
125
- * @returns {Object} the object containing the the integer's coefficient and order of magnitude
125
+ * @returns {Object} the object containing the integer's coefficient and order of magnitude
126
126
  */
127
127
  function normalizeFloat(stringFloat) {
128
128
  const trimmedFloat = removeLeadingZeros(stringFloat);
@@ -168,7 +168,7 @@ module.exports = {
168
168
  * Assignment expression is not fixed.
169
169
  * Array destructuring is not fixed.
170
170
  * Renamed property is not fixed.
171
- * @param {ASTNode} node the the node to evaluate
171
+ * @param {ASTNode} node the node to evaluate
172
172
  * @returns {boolean} whether or not the node should be fixed
173
173
  */
174
174
  function shouldFix(node) {
@@ -101,7 +101,7 @@ module.exports = {
101
101
  }
102
102
 
103
103
  /**
104
- * Checks the the given `CallExpression` node for `.indexOf(NaN)` and `.lastIndexOf(NaN)`.
104
+ * Checks the given `CallExpression` node for `.indexOf(NaN)` and `.lastIndexOf(NaN)`.
105
105
  * @param {ASTNode} node The node to check.
106
106
  * @returns {void}
107
107
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "7.20.0",
3
+ "version": "7.21.0",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -47,7 +47,7 @@
47
47
  "bugs": "https://github.com/eslint/eslint/issues/",
48
48
  "dependencies": {
49
49
  "@babel/code-frame": "7.12.11",
50
- "@eslint/eslintrc": "^0.3.0",
50
+ "@eslint/eslintrc": "^0.4.0",
51
51
  "ajv": "^6.10.0",
52
52
  "chalk": "^4.0.0",
53
53
  "cross-spawn": "^7.0.2",
@@ -60,7 +60,7 @@
60
60
  "espree": "^7.3.1",
61
61
  "esquery": "^1.4.0",
62
62
  "esutils": "^2.0.2",
63
- "file-entry-cache": "^6.0.0",
63
+ "file-entry-cache": "^6.0.1",
64
64
  "functional-red-black-tree": "^1.0.1",
65
65
  "glob-parent": "^5.0.0",
66
66
  "globals": "^12.1.0",
@@ -123,7 +123,7 @@
123
123
  "npm-license": "^0.3.3",
124
124
  "nyc": "^15.0.1",
125
125
  "proxyquire": "^2.0.1",
126
- "puppeteer": "^4.0.0",
126
+ "puppeteer": "^7.1.0",
127
127
  "recast": "^0.19.0",
128
128
  "regenerator-runtime": "^0.13.2",
129
129
  "shelljs": "^0.8.2",