@putout/eslint 3.3.0 → 3.5.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/lib/eslint.js CHANGED
@@ -1,21 +1,29 @@
1
1
  'use strict';
2
2
 
3
- const process = require('process');
4
- const {simpleImport} = require('./simple-import.js');
3
+ const process = require('node:process');
5
4
  const tryToCatch = require('try-to-catch');
6
5
 
6
+ const {simpleImport} = require('./simple-import.js');
7
+ const {isIgnored} = require('./ignore');
8
+
7
9
  const {keys} = Object;
8
10
  const eslintId = ' (eslint)';
11
+
9
12
  const overrideConfigFile = process.env.ESLINT_CONFIG_FILE;
10
13
  const noESLint = process.env.NO_ESLINT;
11
14
  const noESLintWarnings = process.env.NO_ESLINT_WARNINGS;
12
15
 
16
+ const NO_FLAT_CONFIG_FOUND = 'Could not find config file.';
17
+
13
18
  const WARNING = 1;
14
19
 
15
20
  const noConfigFound = (config, configError) => {
16
21
  if (configError && configError.messageTemplate === 'no-config-found')
17
22
  return true;
18
23
 
24
+ if (configError?.message === NO_FLAT_CONFIG_FOUND)
25
+ return true;
26
+
19
27
  if (configError)
20
28
  return false;
21
29
 
@@ -106,6 +114,9 @@ function convertToPlace({ruleId = 'parser', message, line = 0, column = 0, sever
106
114
  if (severity === WARNING && noESLintWarnings)
107
115
  return null;
108
116
 
117
+ if (isIgnored(message))
118
+ return null;
119
+
109
120
  return {
110
121
  rule,
111
122
  message: replaceControlChars(message),
@@ -96,7 +96,10 @@ async function getESLintRunner({cwd, findFlat, findRC, overrideConfigFile}) {
96
96
  }),
97
97
  ]);
98
98
 
99
- if (rcConfig.length > flatConfig.length)
99
+ const noConfigFound = !rcConfig && !flatConfig;
100
+ const foundRConfig = rcConfig.length > flatConfig.length;
101
+
102
+ if (noConfigFound || foundRConfig)
100
103
  return getOldESLint;
101
104
 
102
105
  return getFlatESLint;
package/lib/ignore.js ADDED
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ const MESSAGES = [
4
+ `Parsing error: Cannot use keyword 'await' outside an async function`,
5
+ `Parsing error: The keyword 'yield' is reserved`,
6
+ `Parsing error: Unexpected reserved word 'await'`,
7
+ `Parsing error: Unexpected reserved word 'yield'`,
8
+ ];
9
+
10
+ module.exports.isIgnored = (message) => {
11
+ for (const current of MESSAGES) {
12
+ if (message.includes(current))
13
+ return true;
14
+ }
15
+
16
+ return false;
17
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/eslint",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Wrapper that simplifies ESLint API and makes it compatible with 🐊Putout",