eslint-plugin-putout 15.8.1 → 16.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/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const wrap = require('./wrap');
3
+ const {createPlugin} = require('@putout/eslint/create-plugin');
4
4
  const markdown = require('./markdown');
5
5
  const json = require('./json');
6
6
  const yaml = require('./yaml');
@@ -12,7 +12,7 @@ const getRule = (a) => ({
12
12
  });
13
13
 
14
14
  const getWrapRule = (a) => ({
15
- [a]: wrap(require(`./${a}`)),
15
+ [a]: createPlugin(require(`./${a}`)),
16
16
  });
17
17
 
18
18
  module.exports.rules = {
@@ -93,9 +93,10 @@ const recommended = {
93
93
  'putout/nonblock-statement-body-newline': 'error',
94
94
  'putout/putout': 'error',
95
95
 
96
- 'node/no-unsupported-features/es-syntax': 'off',
97
- 'node/no-missing-import': 'off',
98
- 'node/no-missing-require': 'off',
96
+ 'n/no-unsupported-features/es-syntax': 'off',
97
+ 'n/no-missing-import': 'off',
98
+ 'n/no-missing-require': 'off',
99
+ 'n/no-process-exit': 'off',
99
100
  },
100
101
  overrides: [
101
102
  ...markdown,
@@ -105,7 +106,7 @@ const recommended = {
105
106
  ...ts,
106
107
  ],
107
108
  plugins: [
108
- 'node',
109
+ 'n',
109
110
  ],
110
111
  };
111
112
 
package/lib/markdown.js CHANGED
@@ -10,14 +10,15 @@ const commonRules = {
10
10
  'eol-last': 'off',
11
11
  'no-unreachable': 'off',
12
12
  'no-constant-condition': 'off',
13
- 'node/no-extraneous-require': 'off',
14
- 'node/no-extraneous-import': 'off',
15
- 'node/no-unpublished-require': 'off',
16
- 'node/no-unpublished-import': 'off',
17
- 'node/no-missing-require': 'off',
18
- 'node/no-missing-import': 'off',
19
- 'node/no-unsupported-features/es-syntax': 'off',
20
- 'node/no-unsupported-features/node-builtins': 'off',
13
+ 'n/no-extraneous-require': 'off',
14
+ 'n/no-extraneous-import': 'off',
15
+ 'n/no-unpublished-require': 'off',
16
+ 'n/no-unpublished-import': 'off',
17
+ 'n/no-missing-require': 'off',
18
+ 'n/no-missing-import': 'off',
19
+ 'n/no-unsupported-features/es-syntax': 'off',
20
+ 'n/no-unsupported-features/n-builtins': 'off',
21
+ 'n/no-process-exit': 'off',
21
22
  };
22
23
  const parserOptions = {
23
24
  requireConfigFile: false,
@@ -29,6 +29,7 @@ module.exports = {
29
29
  category: 'putout',
30
30
  recommended: true,
31
31
  },
32
+ schema: {},
32
33
  fixable: 'code',
33
34
  },
34
35
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-putout",
3
- "version": "15.8.1",
3
+ "version": "16.1.0",
4
4
  "type": "commonjs",
5
5
  "description": "ESLint plugin for 🐊Putout",
6
6
  "release": false,
@@ -19,6 +19,7 @@
19
19
  ],
20
20
  "author": "coderaiser",
21
21
  "main": "lib/index.js",
22
+ "commitType": "colon",
22
23
  "scripts": {
23
24
  "wisdom": "madrun wisdom",
24
25
  "test": "madrun test",
@@ -39,11 +40,12 @@
39
40
  "@babel/plugin-syntax-class-properties": "^7.12.1",
40
41
  "@babel/traverse": "^7.16.3",
41
42
  "@putout/engine-parser": "^5.0.0",
43
+ "@putout/eslint": "^1.1.0",
42
44
  "@putout/eslint-config": "^7.0.0",
43
45
  "@typescript-eslint/eslint-plugin": "^5.5.0",
44
46
  "@typescript-eslint/parser": "^5.4.0",
45
47
  "align-spaces": "^1.0.0",
46
- "eslint-plugin-node": "^11.0.0",
48
+ "eslint-plugin-n": "^15.2.4",
47
49
  "try-catch": "^3.0.0",
48
50
  "typescript": "^4.5.2"
49
51
  },
package/lib/wrap.js DELETED
@@ -1,127 +0,0 @@
1
- 'use strict';
2
-
3
- const prepare = (plugin, context, options) => (node) => {
4
- const {filter, report} = plugin;
5
-
6
- const source = context.getSourceCode();
7
- const filename = context.getFilename();
8
- const getText = source.getText.bind(source);
9
- const getCommentsBefore = source.getCommentsBefore.bind(source);
10
- const getCommentsAfter = source.getCommentsAfter.bind(source);
11
- const getCommentsInside = source.getCommentsInside.bind(source);
12
-
13
- const getSpacesBeforeNode = createGetSpacesBeforeNode({
14
- getText,
15
- });
16
-
17
- const getSpacesAfterNode = createGetSpacesAfterNode({
18
- getText,
19
- });
20
-
21
- const text = getText(node);
22
-
23
- const result = filter({
24
- text,
25
- node,
26
- options,
27
- getText,
28
- getCommentsBefore,
29
- getCommentsAfter,
30
- getCommentsInside,
31
- getSpacesBeforeNode,
32
- getSpacesAfterNode,
33
- filename,
34
- });
35
-
36
- if (!result)
37
- return;
38
-
39
- const fix = prepareFix(plugin.fix, {
40
- filename,
41
- node,
42
- text,
43
- getText,
44
- });
45
-
46
- context.report({
47
- node,
48
- message: report(node),
49
- fix,
50
- });
51
- };
52
-
53
- const prepareFix = (fix, {node, text, getText, filename}) => (fixer) => {
54
- const fixed = fix({
55
- node,
56
- text,
57
- getText,
58
- filename,
59
- });
60
-
61
- return [
62
- fixer.replaceText(node, fixed),
63
- ];
64
- };
65
-
66
- module.exports = (plugin) => {
67
- const meta = getMeta(plugin);
68
-
69
- return {
70
- meta,
71
- create(context) {
72
- const {options} = context;
73
- const prepared = prepare(plugin, context, options);
74
- const names = plugin.include({options});
75
-
76
- return getTraversers(names, prepared);
77
- },
78
- };
79
- };
80
-
81
- function getMeta(plugin) {
82
- const {
83
- type = 'layout',
84
- recommended = true,
85
- fixable = 'whitespace',
86
- } = plugin;
87
-
88
- return {
89
- type,
90
- docs: {
91
- recommended,
92
- },
93
- fixable,
94
- };
95
- }
96
-
97
- function getTraversers(names, plugin) {
98
- const traversers = {};
99
-
100
- for (const name of names)
101
- traversers[name] = plugin;
102
-
103
- return traversers;
104
- }
105
-
106
- const createGetSpacesBeforeNode = ({getText}) => (node, text = getText(node)) => {
107
- let spaces = '';
108
- let i = 0;
109
-
110
- while (!spaces || /^[ \n]+$/.test(spaces))
111
- spaces = getText(node, ++i)
112
- .replace(text, '');
113
-
114
- return spaces.slice(1);
115
- };
116
-
117
- const createGetSpacesAfterNode = ({getText}) => (node, {text = getText(node)}) => {
118
- let spaces = '';
119
- let i = 0;
120
-
121
- while (!spaces || /^[ \n;]+$/.test(spaces))
122
- spaces = getText(node, 0, ++i)
123
- .replace(text, '');
124
-
125
- return spaces.slice(0, -1);
126
- };
127
-