eslint-plugin-putout 25.0.3 → 25.1.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 +42 -1
- package/lib/index.mjs +2 -6
- package/lib/json.mjs +1 -1
- package/lib/{plugin.js → plugin.mjs} +4 -3
- package/lib/ts.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,32 @@ npm i putout eslint eslint-plugin-putout -D
|
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
### Plugin
|
|
21
|
+
|
|
22
|
+
To use `putout` as ESLint plugin you can use in `eslint.config.js`
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import putout from 'eslint-plugin-putout';
|
|
26
|
+
|
|
27
|
+
export default [
|
|
28
|
+
rules: {
|
|
29
|
+
'putout/putout': 'error',
|
|
30
|
+
},
|
|
31
|
+
plugins: {
|
|
32
|
+
putout,
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Preset
|
|
38
|
+
|
|
39
|
+
Also you can import one of predefined preset:
|
|
40
|
+
|
|
41
|
+
- ✅ **recommended** - all rules enabled;
|
|
42
|
+
- ✅ **safe** - dangerous rules disabled;
|
|
43
|
+
- ✅ **safeAlign** - dangerous rules disabled + add whitespaces on empty lines;
|
|
44
|
+
|
|
45
|
+
Here is how it can look like:
|
|
21
46
|
|
|
22
47
|
```js
|
|
23
48
|
import {recommended} from 'eslint-plugin-putout';
|
|
@@ -25,6 +50,22 @@ import {recommended} from 'eslint-plugin-putout';
|
|
|
25
50
|
export default recommended;
|
|
26
51
|
```
|
|
27
52
|
|
|
53
|
+
Or with [`defineConfig`](https://eslint.org/blog/2025/03/flat-config-extends-define-config-global-ignores/):
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import {defineConfig} from 'eslint/config';
|
|
57
|
+
import putout from 'eslint-plugin-putout';
|
|
58
|
+
|
|
59
|
+
export default defineConfig({
|
|
60
|
+
plugins: {
|
|
61
|
+
putout,
|
|
62
|
+
},
|
|
63
|
+
extends: [
|
|
64
|
+
"putout/recommended",
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
28
69
|
Then configure the rules you want to use under the rules section.
|
|
29
70
|
|
|
30
71
|
```json
|
package/lib/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import json from './json.mjs';
|
|
|
5
5
|
import html from './html.mjs';
|
|
6
6
|
import ts from './ts.mjs';
|
|
7
7
|
import jsxConfig, {jsx} from './jsx.mjs';
|
|
8
|
-
import putout from './plugin.
|
|
8
|
+
import * as putout from './plugin.mjs';
|
|
9
9
|
|
|
10
10
|
const n = nPlugin.configs['flat/mixed-esm-and-cjs'];
|
|
11
11
|
|
|
@@ -139,8 +139,4 @@ export const configs = {
|
|
|
139
139
|
esm,
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
export {
|
|
145
|
-
rules,
|
|
146
|
-
};
|
|
142
|
+
export default putout;
|
package/lib/json.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import {createRequire} from 'node:module';
|
|
2
|
+
import {createPlugin} from '@putout/eslint/create-plugin';
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
4
5
|
|
|
5
6
|
const getRule = (a) => ({
|
|
6
7
|
[a]: require(`./${a}`),
|
|
@@ -10,7 +11,7 @@ const getWrapRule = (a) => ({
|
|
|
10
11
|
[a]: createPlugin(require(`./${a}`)),
|
|
11
12
|
});
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
export const rules = {
|
|
14
15
|
...getWrapRule('array-element-newline'),
|
|
15
16
|
...getWrapRule('single-property-destructuring'),
|
|
16
17
|
...getWrapRule('multiple-properties-destructuring'),
|
package/lib/ts.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import tseslint from 'typescript-eslint';
|
|
|
4
4
|
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
|
5
5
|
import stylisticTs from '@stylistic/eslint-plugin-ts';
|
|
6
6
|
import {jsx} from './jsx.mjs';
|
|
7
|
-
import plugin from './plugin.
|
|
7
|
+
import * as plugin from './plugin.mjs';
|
|
8
8
|
|
|
9
9
|
const {assign} = Object;
|
|
10
10
|
|