@putout/eslint 1.5.0 → 1.7.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.
Files changed (3) hide show
  1. package/README.md +13 -2
  2. package/lib/eslint.js +14 -2
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -13,6 +13,16 @@ Wrapper that simplifies [**ESLint**](https://eslint.org/) API and makes it compa
13
13
  npm i @putout/eslint
14
14
  ```
15
15
 
16
+ ## Environemnt Variables
17
+
18
+ - ☝️ To set custom config file for **ESLint** use `ESLINT_CONFIG_FILE` env variable:
19
+ - ☝️ To disable **ESLint** support use `NO_ESLINT=1` env variable:
20
+ - ☝️ If you want to ignore **ESLint** warnings (which is unfixable errors in 🐊**Putout** language) use `NO_ESLINT_WARNINGS=1`:
21
+
22
+
23
+ ```sh
24
+ NO_ESLINT_WARNINGS=1 putout --fix lib
25
+
16
26
  ## API
17
27
 
18
28
  ### `eslint(options)`
@@ -35,7 +45,7 @@ const [source, places] = await eslint({
35
45
 
36
46
  Isn't it looks similar to 🐊**Putout** way? It definitely is! But... It has a couple differences you should remember:
37
47
 
38
- - ☝️ *[🐊**Putout** returns object with `code` and `places` properties](https://github.com/coderaiser/putout#plugins).*
48
+ - ☝️ *[🐊**Putout** returns object with `code` and `places` properties](https://github.com/coderaiser/putout#plugins), and **ESLint* returns a tuple**
39
49
  - ☝️ ***ESLint** has a `name` property that is used to calculate configuration file.*
40
50
 
41
51
  And you can even override any of **ESLint** ⚙️ options with help of `config` property:
@@ -53,7 +63,7 @@ const [source, places] = await eslint({
53
63
  });
54
64
  ```
55
65
 
56
- If you want to apply 🐊**Putout** transformations using [`putout/putout`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#readme) **ESLint** rule, enable 🐊**Putout** with the same called flag lowercased:
66
+ If you want to apply 🐊**Putout** transformations using [`putout/putout`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#readme) **ESLint** rule, enable 🐊**Putout** with the same called but lowercased flag:
57
67
 
58
68
  ```js
59
69
  const [source, places] = await eslint({
@@ -153,6 +163,7 @@ When you need to run **ESLint** with one plugin (*rule*), just use `lint` it wil
153
163
 
154
164
  ```js
155
165
  const lint = require('@putout/eslint/lint');
166
+ const {createPlugin} = require('@putout/eslint/create-plugin');
156
167
  const removeDebugger = require('./remove-debugger');
157
168
 
158
169
  const [code, places] = lint('debugger', {
package/lib/eslint.js CHANGED
@@ -6,6 +6,10 @@ const tryToCatch = require('try-to-catch');
6
6
  const {keys} = Object;
7
7
  const eslintId = ' (eslint)';
8
8
  const overrideConfigFile = process.env.ESLINT_CONFIG_FILE;
9
+ const noESLint = process.env.NO_ESLINT;
10
+ const noESLintWarnings = process.env.NO_ESLINT_WARNINGS;
11
+
12
+ const WARNING = 1;
9
13
 
10
14
  const noConfigFound = (config, configError) => {
11
15
  if (configError && configError.messageTemplate === 'no-config-found')
@@ -30,6 +34,9 @@ module.exports = async ({name, code, fix, config, putout = false}) => {
30
34
  [],
31
35
  ];
32
36
 
37
+ if (noESLint)
38
+ return noChanges;
39
+
33
40
  const [, ESLint] = await tryToCatch(simpleImport, './get-eslint.mjs');
34
41
 
35
42
  if (!ESLint)
@@ -74,7 +81,9 @@ module.exports = async ({name, code, fix, config, putout = false}) => {
74
81
 
75
82
  const [report] = results;
76
83
  const {output} = report;
77
- const places = report.messages.map(convertToPlace);
84
+ const places = report.messages
85
+ .map(convertToPlace)
86
+ .filter(Boolean);
78
87
 
79
88
  return [
80
89
  output || code,
@@ -87,9 +96,12 @@ module.exports._noConfigFound = noConfigFound;
87
96
  const parseRule = (rule) => rule || 'parser';
88
97
 
89
98
  module.exports.convertToPlace = convertToPlace;
90
- function convertToPlace({ruleId = 'parser', message, line = 0, column = 0}) {
99
+ function convertToPlace({ruleId = 'parser', message, line = 0, column = 0, severity}) {
91
100
  const rule = `${parseRule(ruleId)}${eslintId}`;
92
101
 
102
+ if (severity === WARNING && noESLintWarnings)
103
+ return null;
104
+
93
105
  return {
94
106
  rule,
95
107
  message: replaceControlChars(message),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/eslint",
3
- "version": "1.5.0",
3
+ "version": "1.7.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",
@@ -43,13 +43,13 @@
43
43
  "eslint-plugin-n": "^15.2.4",
44
44
  "eslint-plugin-putout": "^16.0.0",
45
45
  "just-camel-case": "^4.0.2",
46
- "lerna": "^5.0.0",
46
+ "lerna": "^6.0.1",
47
47
  "madrun": "^9.0.0",
48
48
  "mock-require": "^3.0.3",
49
49
  "montag": "^1.0.0",
50
50
  "nodemon": "^2.0.1",
51
51
  "putout": "*",
52
- "supertape": "^7.0.0",
52
+ "supertape": "^8.0.0",
53
53
  "try-catch": "^3.0.0"
54
54
  },
55
55
  "license": "MIT",