Skip to content

Commit 8b729c0

Browse files
committed
feature: @putout/engine-processor: add support of 'lint()' export in processors
1 parent e6d3ff0 commit 8b729c0

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/engine-processor/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,23 @@ export const merge = (source, list) => {
7070
};
7171
```
7272

73+
Instead of `find` and `fix` you can use `lint`:
74+
75+
```js
76+
export const files = [
77+
'*.js',
78+
];
79+
80+
export const lint = async (source, {fix}) => {
81+
const [code, places] = await eslint(source, {fix});
82+
return [code, places];
83+
};
84+
```
85+
86+
## License
87+
88+
MIT
89+
7390
## License
7491

7592
MIT

packages/engine-processor/lib/processor.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ async function getFiles({name, fix, rawSource, processorRunners}) {
114114
find = stubFind,
115115
fix: fixFind = id,
116116
merge: runnersMerge = id,
117+
lint,
117118
} = currentRunner;
118119

119120
if (!isMatch(name))
@@ -123,7 +124,9 @@ async function getFiles({name, fix, rawSource, processorRunners}) {
123124

124125
isProcessed = true;
125126

126-
if (fix)
127+
if (lint)
128+
[processedSource, processedPlaces] = await lint(rawSource, {fix});
129+
else if (fix)
127130
processedSource = await fixFind(rawSource);
128131
else
129132
processedPlaces = await find(rawSource);

0 commit comments

Comments
 (0)