eslint 8.8.0 → 8.11.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/README.md CHANGED
@@ -48,19 +48,19 @@ Prerequisites: [Node.js](https://nodejs.org/) (`^12.22.0`, `^14.17.0`, or `>=16.
48
48
  You can install ESLint using npm:
49
49
 
50
50
  ```sh
51
- $ npm install eslint --save-dev
51
+ npm install eslint --save-dev
52
52
  ```
53
53
 
54
54
  You should then set up a configuration file:
55
55
 
56
56
  ```sh
57
- $ npm init @eslint/config
57
+ npm init @eslint/config
58
58
  ```
59
59
 
60
60
  After that, you can run ESLint on any file or directory like this:
61
61
 
62
62
  ```sh
63
- $ ./node_modules/.bin/eslint yourfile.js
63
+ ./node_modules/.bin/eslint yourfile.js
64
64
  ```
65
65
 
66
66
  ## <a name="configuration"></a>Configuration
@@ -129,7 +129,7 @@ ESLint has full support for ECMAScript 3, 5 (default), 2015, 2016, 2017, 2018, 2
129
129
 
130
130
  ESLint's parser only officially supports the latest final ECMAScript standard. We will make changes to core rules in order to avoid crashes on stage 3 ECMAScript syntax proposals (as long as they are implemented using the correct experimental ESTree syntax). We may make changes to core rules to better work with language extensions (such as JSX, Flow, and TypeScript) on a case-by-case basis.
131
131
 
132
- In other cases (including if rules need to warn on more or fewer cases due to new syntax, rather than just not crashing), we recommend you use other parsers and/or rule plugins. If you are using Babel, you can use the [babel-eslint](https://github.com/babel/babel-eslint) parser and [eslint-plugin-babel](https://github.com/babel/eslint-plugin-babel) to use any option available in Babel.
132
+ In other cases (including if rules need to warn on more or fewer cases due to new syntax, rather than just not crashing), we recommend you use other parsers and/or rule plugins. If you are using Babel, you can use [@babel/eslint-parser](https://www.npmjs.com/package/@babel/eslint-parser) and [@babel/eslint-plugin](https://www.npmjs.com/package/@babel/eslint-plugin) to use any option available in Babel.
133
133
 
134
134
  Once a language feature has been adopted into the ECMAScript standard (stage 4 according to the [TC39 process](https://tc39.github.io/process-document/)), we will accept issues and pull requests related to the new feature, subject to our [contributing guidelines](https://eslint.org/docs/developer-guide/contributing). Until then, please use the appropriate parser and plugin(s) for your experimental feature.
135
135
 
@@ -292,9 +292,9 @@ The following companies, organizations, and individuals support ESLint's ongoing
292
292
  <!--sponsorsstart-->
293
293
  <h3>Platinum Sponsors</h3>
294
294
  <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
295
- <p><a href="https://contra.com"><img src="https://images.opencollective.com/contra1/c70f93f/logo.png" alt="Contra" height="96"></a> <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.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://coinbase.com"><img src="https://avatars.githubusercontent.com/u/1885080?v=4" alt="Coinbase" height="96"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="96"></a> <a href="https://substack.com/"><img src="https://avatars.githubusercontent.com/u/53023767?v=4" alt="Substack" height="96"></a></p><h3>Silver Sponsors</h3>
295
+ <p><a href="https://contra.com"><img src="https://images.opencollective.com/contra1/c70f93f/logo.png" alt="Contra" height="96"></a> <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://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://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="96"></a> <a href="https://substack.com/"><img src="https://avatars.githubusercontent.com/u/53023767?v=4" alt="Substack" height="96"></a></p><h3>Silver Sponsors</h3>
296
296
  <p><a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a></p><h3>Bronze Sponsors</h3>
297
- <p><a href="https://launchdarkly.com"><img src="https://images.opencollective.com/launchdarkly/574bb9e/logo.png" alt="launchdarkly" 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="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://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/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.practiceignition.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Practice Ignition" height="32"></a></p>
297
+ <p><a href="https://launchdarkly.com"><img src="https://images.opencollective.com/launchdarkly/574bb9e/logo.png" alt="launchdarkly" 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="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS" 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://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/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.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a></p>
298
298
  <!--sponsorsend-->
299
299
 
300
300
  ## <a name="technology-sponsors"></a>Technology Sponsors
@@ -616,8 +616,8 @@ class CLIEngine {
616
616
  useEslintrc: options.useEslintrc,
617
617
  builtInRules,
618
618
  loadRules,
619
- eslintRecommendedPath: path.resolve(__dirname, "../../conf/eslint-recommended.js"),
620
- eslintAllPath: path.resolve(__dirname, "../../conf/eslint-all.js")
619
+ getEslintRecommendedConfig: () => require("../../conf/eslint-recommended.js"),
620
+ getEslintAllConfig: () => require("../../conf/eslint-all.js")
621
621
  });
622
622
  const fileEnumerator = new FileEnumerator({
623
623
  configArrayFactory,
@@ -215,8 +215,8 @@ class FileEnumerator {
215
215
  cwd = process.cwd(),
216
216
  configArrayFactory = new CascadingConfigArrayFactory({
217
217
  cwd,
218
- eslintRecommendedPath: path.resolve(__dirname, "../../conf/eslint-recommended.js"),
219
- eslintAllPath: path.resolve(__dirname, "../../conf/eslint-all.js")
218
+ getEslintRecommendedConfig: () => require("../../conf/eslint-recommended.js"),
219
+ getEslintAllConfig: () => require("../../conf/eslint-all.js")
220
220
  }),
221
221
  extensions = null,
222
222
  globInputPaths = true,
@@ -39,6 +39,8 @@ function pageTemplate(it) {
39
39
  <head>
40
40
  <meta charset="UTF-8">
41
41
  <title>ESLint Report</title>
42
+ <link rel="icon" type="image/png" sizes="any" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAHaAAAB2gGFomX7AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAABD1JREFUWMPFl11sk2UUx3/nbYtjxS1MF7MLMTECMgSTtSSyrQkLhAj7UBPnDSEGoxegGzMwojhXVpmTAA5iYpSoMQa8GBhFOrMFk03buei6yRAlcmOM0SEmU9d90b19jxcM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5Ljg0NyBjMi4xMDIsMy42NCw1Ljk4Niw1LjUwMSwxMC4xOSw1LjUwMWgxMTUuNzM1YzQuMjAzLDAsOC4wODctMS44MDUsMTAuMTg4LTUuNDQ2bDU3Ljg2Ny0xMDAuMDEgQzI3NS40MzksMTMyLjM5NiwyNzUuNDM5LDEyOC4xMjgsMjczLjMzNiwxMjQuNDg4IE0yMjUuNDE5LDE3Mi44OThjMCwxLjQ4LTAuODkxLDIuODQ5LTIuMTc0LDMuNTlsLTczLjcxLDQyLjUyNyBjLTEuMjgyLDAuNzQtMi44ODgsMC43NC00LjE3LDBsLTczLjc2Ny00Mi41MjdjLTEuMjgyLTAuNzQxLTIuMTc5LTIuMTA5LTIuMTc5LTMuNTlWODcuODQzYzAtMS40ODEsMC44ODQtMi44NDksMi4xNjctMy41OSBsNzMuNzA3LTQyLjUyN2MxLjI4Mi0wLjc0MSwyLjg4Ni0wLjc0MSw0LjE2OCwwbDczLjc3Miw0Mi41MjdjMS4yODMsMC43NDEsMi4xODYsMi4xMDksMi4xODYsMy41OVYxNzIuODk4eicvPg0KPC9zdmc+">
42
44
  <style>
43
45
  body {
44
46
  font-family:Arial, "Helvetica Neue", Helvetica, sans-serif;
@@ -14,7 +14,6 @@ const { flatConfigSchema } = require("./flat-config-schema");
14
14
  const { RuleValidator } = require("./rule-validator");
15
15
  const { defaultConfig } = require("./default-config");
16
16
  const recommendedConfig = require("../../conf/eslint-recommended");
17
- const allConfig = require("../../conf/eslint-all");
18
17
 
19
18
  //-----------------------------------------------------------------------------
20
19
  // Helpers
@@ -58,7 +57,11 @@ class FlatConfigArray extends ConfigArray {
58
57
  schema: flatConfigSchema
59
58
  });
60
59
 
61
- this.unshift(...baseConfig);
60
+ if (baseConfig[Symbol.iterator]) {
61
+ this.unshift(...baseConfig);
62
+ } else {
63
+ this.unshift(baseConfig);
64
+ }
62
65
  }
63
66
 
64
67
  /* eslint-disable class-methods-use-this -- Desired as instance method */
@@ -75,7 +78,13 @@ class FlatConfigArray extends ConfigArray {
75
78
  }
76
79
 
77
80
  if (config === "eslint:all") {
78
- return allConfig;
81
+
82
+ /*
83
+ * Load `eslint-all.js` here instead of at the top level to avoid loading all rule modules
84
+ * when it isn't necessary. `eslint-all.js` reads `meta` of rule objects to filter out deprecated ones,
85
+ * so requiring `eslint-all.js` module loads all rule modules as a consequence.
86
+ */
87
+ return require("../../conf/eslint-all");
79
88
  }
80
89
 
81
90
  return config;
@@ -57,11 +57,47 @@ function getRuleFromConfig(ruleId, config) {
57
57
  return rule;
58
58
  }
59
59
 
60
+ /**
61
+ * Gets a complete options schema for a rule.
62
+ * @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
63
+ * @returns {Object} JSON Schema for the rule's options.
64
+ */
65
+ function getRuleOptionsSchema(rule) {
66
+
67
+ if (!rule) {
68
+ return null;
69
+ }
70
+
71
+ const schema = rule.schema || rule.meta && rule.meta.schema;
72
+
73
+ if (Array.isArray(schema)) {
74
+ if (schema.length) {
75
+ return {
76
+ type: "array",
77
+ items: schema,
78
+ minItems: 0,
79
+ maxItems: schema.length
80
+ };
81
+ }
82
+ return {
83
+ type: "array",
84
+ minItems: 0,
85
+ maxItems: 0
86
+ };
87
+
88
+ }
89
+
90
+ // Given a full schema, leave it alone
91
+ return schema || null;
92
+ }
93
+
94
+
60
95
  //-----------------------------------------------------------------------------
61
96
  // Exports
62
97
  //-----------------------------------------------------------------------------
63
98
 
64
99
  module.exports = {
65
100
  parseRuleId,
66
- getRuleFromConfig
101
+ getRuleFromConfig,
102
+ getRuleOptionsSchema
67
103
  };
@@ -10,7 +10,11 @@
10
10
  //-----------------------------------------------------------------------------
11
11
 
12
12
  const ajv = require("../shared/ajv")();
13
- const { parseRuleId, getRuleFromConfig } = require("./flat-config-helpers");
13
+ const {
14
+ parseRuleId,
15
+ getRuleFromConfig,
16
+ getRuleOptionsSchema
17
+ } = require("./flat-config-helpers");
14
18
  const ruleReplacements = require("../../conf/replacements.json");
15
19
 
16
20
  //-----------------------------------------------------------------------------
@@ -61,40 +65,6 @@ function throwRuleNotFoundError({ pluginName, ruleName }, config) {
61
65
  throw new TypeError(errorMessage);
62
66
  }
63
67
 
64
- /**
65
- * Gets a complete options schema for a rule.
66
- * @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
67
- * @returns {Object} JSON Schema for the rule's options.
68
- */
69
- function getRuleOptionsSchema(rule) {
70
-
71
- if (!rule) {
72
- return null;
73
- }
74
-
75
- const schema = rule.schema || rule.meta && rule.meta.schema;
76
-
77
- if (Array.isArray(schema)) {
78
- if (schema.length) {
79
- return {
80
- type: "array",
81
- items: schema,
82
- minItems: 0,
83
- maxItems: schema.length
84
- };
85
- }
86
- return {
87
- type: "array",
88
- minItems: 0,
89
- maxItems: 0
90
- };
91
-
92
- }
93
-
94
- // Given a full schema, leave it alone
95
- return schema || null;
96
- }
97
-
98
68
  //-----------------------------------------------------------------------------
99
69
  // Exports
100
70
  //-----------------------------------------------------------------------------
@@ -800,14 +800,21 @@ function parse(text, languageOptions, filePath) {
800
800
  * problem that ESLint identified just like any other.
801
801
  */
802
802
  try {
803
+ debug("Parsing:", filePath);
803
804
  const parseResult = (typeof parser.parseForESLint === "function")
804
805
  ? parser.parseForESLint(textToParse, parserOptions)
805
806
  : { ast: parser.parse(textToParse, parserOptions) };
807
+
808
+ debug("Parsing successful:", filePath);
806
809
  const ast = parseResult.ast;
807
810
  const parserServices = parseResult.services || {};
808
811
  const visitorKeys = parseResult.visitorKeys || evk.KEYS;
812
+
813
+ debug("Scope analysis:", filePath);
809
814
  const scopeManager = parseResult.scopeManager || analyzeScope(ast, languageOptions, visitorKeys);
810
815
 
816
+ debug("Scope analysis successful:", filePath);
817
+
811
818
  return {
812
819
  success: true,
813
820