Skip to content

Commit 6fed785

Browse files
committed
feature(putout) putout/lib/cli/process-file -> putout/process-file
1 parent 8ff69cf commit 6fed785

File tree

36 files changed

+133
-20
lines changed

36 files changed

+133
-20
lines changed

.putout.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"match": {
3-
"**/packages/plugin-*": {
3+
"**/packages/{remark-putout,engine-processor,{plugin,processor}-*}": {
44
"putout": "on"
55
},
66
"**/packages/plugin-*/*.md{json}": {

packages/babel-plugin-putout/.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"mocha": true
77
},
88
"rules": {
9-
"node/no-unsupported-features/es-syntax": "off"
9+
"node/no-missing-require": "off"
1010
},
1111
"extends": [
1212
"plugin:node/recommended",
+2-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"rules": {
3-
"convert-esm-to-commonjs": "on"
4-
},
5-
"ignore": [
6-
"lib"
7-
]
3+
"putout": "on"
4+
}
85
}

packages/babel-plugin-putout/lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const {
66
transform,
77
} = require('putout');
88

9-
const parseOptions = require('putout/lib/parse-options');
9+
const parseOptions = require('putout/parse-options');
1010

1111
module.exports = () => {
1212
let code = '';

packages/engine-processor/.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2+
"overrides": [{
3+
"files": "test/*.js",
4+
"rules": {
5+
"node/no-missing-require": "off"
6+
}
7+
}],
28
"extends": [
39
"plugin:node/recommended",
410
"plugin:putout/recommended"

packages/engine-processor/test/processor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {join} = require('path');
55

66
const test = require('supertape');
77
const stub = require('@cloudcmd/stub');
8-
const processFile = require('putout/lib/cli/process-file');
8+
const processFile = require('putout/process-file');
99
const {getFilePatterns} = require('..');
1010
const {runProcessors} = require('..');
1111

packages/eslint-plugin-putout/.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2+
"overrides": [{
3+
"files": "lib/putout/index.js",
4+
"rules": {
5+
"node/no-missing-require": "off"
6+
}
7+
}],
28
"extends": [
39
"plugin:node/recommended",
410
"plugin:eslint-plugin/recommended",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"putout": "on"
4+
}
5+
}

packages/eslint-plugin-putout/lib/putout/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const {
88
parse,
99
} = require('putout');
1010

11-
const parseOptions = require('putout/lib/parse-options');
11+
const parseOptions = require('putout/parse-options');
1212

1313
const cwd = process.cwd();
1414
const getContextOptions = ({options}) => {

packages/plugin-putout/README.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ npm i @putout/plugin-putout -D
2121
"putout/convert-to-no-transform-code": "on",
2222
"putout/convert-replace-with": "on",
2323
"putout/convert-replace-with-multiple": "on",
24-
"putout/convert-babel-types": "on"
24+
"putout/convert-babel-types": "on",
25+
"putout/shorten-putout-exports": "on"
2526
}
2627
}
2728
```
@@ -118,6 +119,20 @@ const {
118119
} = require('putout').types;
119120
```
120121

122+
## shorten-putout-exports
123+
124+
### ❌ Incorrect code example
125+
126+
```js
127+
const parseOptions = require('putout/parse-options');
128+
```
129+
130+
### ✅ Correct code Example
131+
132+
```js
133+
const parseOptions = require('putout/parse-options');
134+
```
135+
121136
## License
122137

123138
MIT

packages/plugin-putout/lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ module.exports.rules = {
1212
...getRule('convert-babel-types'),
1313
...getRule('rename-operate-to-operator'),
1414
...getRule('replace-operate-with-operator'),
15+
...getRule('shorten-putout-exports'),
1516
};
1617

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('putout/parse-options');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('putout/lib/parse-options');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('putout/process-file');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('putout/lib/cli/process-file');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
module.exports.report = () => 'Shorten require path to putout exports';
4+
5+
module.exports.replace = () => ({
6+
'require("putout/lib/cli/process-file")': 'require("putout/process-file")',
7+
'require("putout/lib/parse-options")': 'require("putout/parse-options")',
8+
});
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
const test = require('@putout/test')(__dirname, {
4+
'putout/shorten-putout-exports': require('.'),
5+
});
6+
7+
test('plugin-putout: convert-putout-exports: report', (t) => {
8+
t.report('shorten-putout-exports', 'Shorten require path to putout exports');
9+
t.end();
10+
});
11+
12+
test('plugin-putout: transform', (t) => {
13+
t.transform('shorten-putout-exports');
14+
t.end();
15+
});
16+
17+
test('plugin-putout: transform: parse options', (t) => {
18+
t.transform('parse-options');
19+
t.end();
20+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('putout/process-file');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('putout/lib/cli/process-file');

packages/plugin-putout/test/putout.js

+5
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ test('plugin-putout: transform', (t) => {
99
t.end();
1010
});
1111

12+
test('plugin-putout: transform: shorten putout exports', (t) => {
13+
t.transform('shorten-putout-exports');
14+
t.end();
15+
});
16+

packages/processor-css/.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2+
"overrides": [{
3+
"files": "test/*.js",
4+
"rules": {
5+
"node/no-missing-require": "off"
6+
}
7+
}],
28
"extends": [
39
"plugin:node/recommended",
410
"plugin:putout/recommended"

packages/processor-css/test/css.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const mockRequire = require('mock-require');
88

99
const stub = require('@cloudcmd/stub');
1010
const {runProcessors} = require('@putout/engine-processor');
11-
const processFile = require('putout/lib/cli/process-file');
11+
const processFile = require('putout/process-file');
1212

1313
const {stopAll, reRequire} = mockRequire;
1414

packages/processor-ignore/.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2+
"overrides": [{
3+
"files": "test/*.js",
4+
"rules": {
5+
"node/no-missing-require": "off"
6+
}
7+
}],
28
"extends": [
39
"plugin:node/recommended",
410
"plugin:putout/recommended"

packages/processor-ignore/test/ignore.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {readFile} = require('fs/promises');
55

66
const test = require('supertape');
77
const {runProcessors} = require('@putout/engine-processor');
8-
const processFile = require('putout/lib/cli/process-file');
8+
const processFile = require('putout/process-file');
99

1010
const process = getProcess({
1111
processors: [

packages/processor-javascript/.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2+
"overrides": [{
3+
"files": "test/*.js",
4+
"rules": {
5+
"node/no-missing-require": "off"
6+
}
7+
}],
28
"extends": [
39
"plugin:node/recommended",
410
"plugin:putout/recommended"

packages/processor-javascript/test/javascript.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {readFile} = require('fs/promises');
55

66
const test = require('supertape');
77
const {runProcessors} = require('@putout/engine-processor');
8-
const processFile = require('putout/lib/cli/process-file');
8+
const processFile = require('putout/process-file');
99

1010
test('putout: processor: javascript', async (t) => {
1111
const inputName = join(__dirname, 'fixture', 'simple.js');

packages/processor-json/.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2+
"overrides": [{
3+
"files": "test/*.js",
4+
"rules": {
5+
"node/no-missing-require": "off"
6+
}
7+
}],
28
"extends": [
39
"plugin:node/recommended",
410
"plugin:putout/recommended"

packages/processor-json/.putout.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"putout": "on"
4+
}
5+
}

packages/processor-json/test/json.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {readFile} = require('fs/promises');
55

66
const test = require('supertape');
77
const {runProcessors} = require('@putout/engine-processor');
8-
const processFile = require('putout/lib/cli/process-file');
8+
const processFile = require('putout/process-file');
99

1010
const process = getProcess({
1111
extension: 'json',

packages/processor-markdown/.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2+
"overrides": [{
3+
"files": "test/*.js",
4+
"rules": {
5+
"node/no-missing-require": "off"
6+
}
7+
}],
28
"extends": [
39
"plugin:node/recommended",
410
"plugin:putout/recommended"

packages/processor-markdown/test/markdown.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {readFile} = require('fs/promises');
55

66
const test = require('supertape');
77
const {runProcessors} = require('@putout/engine-processor');
8-
const processFile = require('putout/lib/cli/process-file');
8+
const processFile = require('putout/process-file');
99

1010
test('putout: processor: markdown', async (t) => {
1111
const {

packages/processor-yaml/.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2+
"overrides": [{
3+
"files": "test/*.js",
4+
"rules": {
5+
"node/no-missing-require": "off"
6+
}
7+
}],
28
"extends": [
39
"plugin:node/recommended",
410
"plugin:putout/recommended"

packages/processor-yaml/test/yaml.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {readFile} = require('fs/promises');
55

66
const test = require('supertape');
77
const {runProcessors} = require('@putout/engine-processor');
8-
const processFile = require('putout/lib/cli/process-file');
8+
const processFile = require('putout/process-file');
99

1010
test('putout: processor: yaml', async (t) => {
1111
const ext = '.yml';

packages/putout/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"exports": {
99
".": "./lib/putout.js",
1010
"./parse-options": "./lib/parse-options/index.js",
11-
"./lib/parse-options": "./lib/parse-options/index.js",
12-
"./lib/cli/process-file": "./lib/cli/process-file.js",
11+
"./process-file": "./lib/cli/process-file.js",
1312
"./cli": "./lib/cli/index.js"
1413
},
1514
"bin": {

packages/remark-putout/.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"rules": {
3+
"node/no-missing-require": "off"
4+
},
25
"extends": [
36
"plugin:node/recommended",
47
"plugin:putout/recommended"

packages/remark-putout/lib/putout.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const tryCatch = require('try-catch');
44
const visit = require('unist-util-visit');
55

66
const putout = require('putout');
7-
const parseOptions = require('putout/lib/parse-options');
7+
const parseOptions = require('putout/parse-options');
88

99
module.exports = (options) => (node, file) => {
1010
visit(node, 'code', process(file, options));

0 commit comments

Comments
 (0)