eslint-plugin-putout 16.5.0 β 16.6.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 +20 -16
- package/lib/index.js +4 -20
- package/lib/jsx.js +26 -0
- package/lib/markdown.js +17 -1
- package/lib/ts.js +3 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -21,12 +21,8 @@ Add `putout` to the plugins section of your `.eslintrc.json` configuration file.
|
|
|
21
21
|
|
|
22
22
|
```json
|
|
23
23
|
{
|
|
24
|
-
"extends": [
|
|
25
|
-
|
|
26
|
-
],
|
|
27
|
-
"plugins": [
|
|
28
|
-
"putout"
|
|
29
|
-
]
|
|
24
|
+
"extends": ["plugin:putout/recommended"],
|
|
25
|
+
"plugins": ["putout"]
|
|
30
26
|
}
|
|
31
27
|
```
|
|
32
28
|
|
|
@@ -123,12 +119,8 @@ When using π**Putout** in IDE with `--fix` on save, or when you want to disab
|
|
|
123
119
|
|
|
124
120
|
```json
|
|
125
121
|
{
|
|
126
|
-
"extends": [
|
|
127
|
-
|
|
128
|
-
],
|
|
129
|
-
"plugins": [
|
|
130
|
-
"putout"
|
|
131
|
-
]
|
|
122
|
+
"extends": ["plugin:putout/safe"],
|
|
123
|
+
"plugins": ["putout"]
|
|
132
124
|
}
|
|
133
125
|
```
|
|
134
126
|
|
|
@@ -162,16 +154,28 @@ Disabled π**Putout** rules:
|
|
|
162
154
|
|
|
163
155
|
When you want to enable ability to align spaces on empty lines, while have all benefits of `safe` preset: use `safe+align`.
|
|
164
156
|
|
|
157
|
+
### jsx
|
|
158
|
+
|
|
159
|
+
When you need to support `jsx` in files using `js` extension, use:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"extends": [
|
|
164
|
+
"plugin:putout/jsx"
|
|
165
|
+
],
|
|
166
|
+
"plugins": [
|
|
167
|
+
"putout"
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
165
172
|
## Flat
|
|
166
173
|
|
|
167
174
|
The time is came for a [FlatConfig](https://eslint.org/blog/2022/08/new-config-system-part-2/). To use it with `eslint-plugin-putout` add to `eslint.config.js`:
|
|
168
175
|
|
|
169
176
|
```js
|
|
170
177
|
const {recommended} = require('eslint-plugin-putout/config');
|
|
171
|
-
module.exports = [
|
|
172
|
-
...recommended, {
|
|
173
|
-
},
|
|
174
|
-
];
|
|
178
|
+
module.exports = [...recommended, {}];
|
|
175
179
|
```
|
|
176
180
|
|
|
177
181
|
`safe` and `safeAlign` supported as well.
|
package/lib/index.js
CHANGED
|
@@ -6,15 +6,13 @@ const json = require('./json');
|
|
|
6
6
|
const yaml = require('./yaml');
|
|
7
7
|
const html = require('./html');
|
|
8
8
|
const ts = require('./ts');
|
|
9
|
-
|
|
9
|
+
const jsx = require('./jsx');
|
|
10
10
|
const getRule = (a) => ({
|
|
11
11
|
[a]: require(`./${a}`),
|
|
12
12
|
});
|
|
13
|
-
|
|
14
13
|
const getWrapRule = (a) => ({
|
|
15
14
|
[a]: createPlugin(require(`./${a}`)),
|
|
16
15
|
});
|
|
17
|
-
|
|
18
16
|
module.exports.rules = {
|
|
19
17
|
...getWrapRule('array-element-newline'),
|
|
20
18
|
...getWrapRule('single-property-destructuring'),
|
|
@@ -50,17 +48,14 @@ module.exports.rules = {
|
|
|
50
48
|
...getRule('remove-empty-newline-after-import'),
|
|
51
49
|
...getRule('remove-empty-newline-between-declarations'),
|
|
52
50
|
};
|
|
53
|
-
|
|
54
51
|
const config = require('@putout/eslint-config');
|
|
55
52
|
const {rules} = config;
|
|
56
|
-
|
|
57
53
|
const recommended = {
|
|
58
54
|
...config,
|
|
59
55
|
rules: {
|
|
60
56
|
...rules,
|
|
61
57
|
'no-debugger': 'off',
|
|
62
58
|
'no-unused-vars': 'off',
|
|
63
|
-
|
|
64
59
|
'putout/array-element-newline': 'error',
|
|
65
60
|
'putout/single-property-destructuring': 'error',
|
|
66
61
|
'putout/multiple-properties-destructuring': 'error',
|
|
@@ -94,24 +89,14 @@ const recommended = {
|
|
|
94
89
|
'putout/tape-remove-newline-before-t-end': 'error',
|
|
95
90
|
'putout/nonblock-statement-body-newline': 'error',
|
|
96
91
|
'putout/putout': 'error',
|
|
97
|
-
|
|
98
92
|
'n/no-unsupported-features/es-syntax': 'off',
|
|
99
93
|
'n/no-missing-import': 'off',
|
|
100
94
|
'n/no-missing-require': 'off',
|
|
101
95
|
'n/no-process-exit': 'off',
|
|
102
96
|
},
|
|
103
|
-
overrides: [
|
|
104
|
-
|
|
105
|
-
...json,
|
|
106
|
-
...yaml,
|
|
107
|
-
...html,
|
|
108
|
-
...ts,
|
|
109
|
-
],
|
|
110
|
-
plugins: [
|
|
111
|
-
'n',
|
|
112
|
-
],
|
|
97
|
+
overrides: [...markdown, ...json, ...yaml, ...html, ...ts, ...jsx],
|
|
98
|
+
plugins: ['n'],
|
|
113
99
|
};
|
|
114
|
-
|
|
115
100
|
const safe = {
|
|
116
101
|
...recommended,
|
|
117
102
|
rules: {
|
|
@@ -143,9 +128,9 @@ const safe = {
|
|
|
143
128
|
}],
|
|
144
129
|
},
|
|
145
130
|
};
|
|
146
|
-
|
|
147
131
|
module.exports.configs = {
|
|
148
132
|
recommended,
|
|
133
|
+
'jsx': jsx.jsx,
|
|
149
134
|
safe,
|
|
150
135
|
'safe+align': {
|
|
151
136
|
...safe,
|
|
@@ -155,4 +140,3 @@ module.exports.configs = {
|
|
|
155
140
|
},
|
|
156
141
|
},
|
|
157
142
|
};
|
|
158
|
-
|
package/lib/jsx.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const jsx = {
|
|
4
|
+
rules: {
|
|
5
|
+
'react/jsx-indent': 'error',
|
|
6
|
+
'react/jsx-wrap-multilines': ['error', {
|
|
7
|
+
arrow: 'ignore',
|
|
8
|
+
return: 'parens-new-line',
|
|
9
|
+
declaration: 'ignore',
|
|
10
|
+
}],
|
|
11
|
+
},
|
|
12
|
+
plugins: ['react'],
|
|
13
|
+
settings: {
|
|
14
|
+
react: {
|
|
15
|
+
version: 'latest',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
module.exports = [{
|
|
21
|
+
files: ['*.jsx'],
|
|
22
|
+
...jsx,
|
|
23
|
+
}];
|
|
24
|
+
|
|
25
|
+
module.exports.jsx = jsx;
|
|
26
|
+
|
package/lib/markdown.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const parserOpts = require('@putout/engine-parser/babel/options');
|
|
4
4
|
const parserPlugins = require('@putout/engine-parser/babel/plugins');
|
|
5
5
|
const [ts, tsx] = require('./ts');
|
|
6
|
+
const {jsx} = require('./jsx');
|
|
6
7
|
|
|
7
8
|
const commonRules = {
|
|
8
9
|
'no-undef': 'off',
|
|
@@ -38,20 +39,35 @@ const parserOptions = {
|
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
module.exports = [{
|
|
41
|
-
files: ['*.md{js}'
|
|
42
|
+
files: ['*.md{js}'],
|
|
42
43
|
rules: commonRules,
|
|
43
44
|
parser: '@babel/eslint-parser/experimental-worker',
|
|
44
45
|
parserOptions,
|
|
46
|
+
}, {
|
|
47
|
+
files: ['*.md{jsx}'],
|
|
48
|
+
rules: {
|
|
49
|
+
...commonRules,
|
|
50
|
+
...jsx.rules,
|
|
51
|
+
},
|
|
52
|
+
plugins: jsx.plugins,
|
|
53
|
+
parser: '@babel/eslint-parser/experimental-worker',
|
|
54
|
+
parserOptions,
|
|
45
55
|
}, {
|
|
46
56
|
...tsx,
|
|
57
|
+
...jsx,
|
|
47
58
|
files: '*.md{tsx}',
|
|
48
59
|
rules: {
|
|
49
60
|
...commonRules,
|
|
50
61
|
...ts.rules,
|
|
62
|
+
...jsx.rules,
|
|
51
63
|
'@typescript-eslint/no-unused-vars': 'off',
|
|
52
64
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
53
65
|
'@typescript-eslint/no-inferrable-types': 'off',
|
|
54
66
|
},
|
|
67
|
+
plugins: [
|
|
68
|
+
...tsx.plugins,
|
|
69
|
+
...jsx.plugins,
|
|
70
|
+
],
|
|
55
71
|
}, {
|
|
56
72
|
...ts,
|
|
57
73
|
files: '*.md{ts}',
|
package/lib/ts.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {rules} = require('@putout/eslint-config');
|
|
4
|
+
const jsx = require('./jsx');
|
|
5
|
+
|
|
4
6
|
const warnOnUnsupportedTypeScriptVersion = false;
|
|
5
7
|
|
|
6
8
|
const extensionRules = {
|
|
@@ -91,6 +93,7 @@ const ts = {
|
|
|
91
93
|
module.exports = [
|
|
92
94
|
ts, {
|
|
93
95
|
...ts,
|
|
96
|
+
...jsx.jsx,
|
|
94
97
|
files: '*.tsx',
|
|
95
98
|
parserOptions: {
|
|
96
99
|
warnOnUnsupportedTypeScriptVersion,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-putout",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.6.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "ESLint plugin for πPutout",
|
|
6
6
|
"release": false,
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"@typescript-eslint/parser": "^5.4.0",
|
|
52
52
|
"align-spaces": "^1.0.0",
|
|
53
53
|
"eslint-plugin-n": "^15.2.4",
|
|
54
|
+
"eslint-plugin-react": "^7.32.2",
|
|
54
55
|
"try-catch": "^3.0.0",
|
|
55
56
|
"typescript": "^4.5.2"
|
|
56
57
|
},
|