Skip to content

Commit 81998ae

Browse files
committed
feature: @putout/plugin-npmignore: convert-loc-to-lock
1 parent 1e9df44 commit 81998ae

9 files changed

Lines changed: 79 additions & 1 deletion

File tree

packages/plugin-npmignore/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ npm i @putout/plugin-npmignore -D
1919

2020
-[add](#add);
2121
-[sort](#sort);
22+
-[convert-loc-to-lock](#convert-loc-to-lock);
2223

2324
## Config
2425

@@ -34,7 +35,8 @@ npm i @putout/plugin-npmignore -D
3435
"*.config.*"
3536
]
3637
}],
37-
"npmignore/sort": "on"
38+
"npmignore/sort": "on",
39+
"npmignore/convert-loc-to-lock": "on"
3840
}
3941
}
4042
```
@@ -82,6 +84,16 @@ node_modules
8284
coverage# sort
8385
```
8486

87+
## convert-loc-to-lock
88+
89+
Adds `.*` into .npmignore.
90+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/8c665c8eecdff7801ddb33f9c57199aa/3138e6dd8deaa74754987b090e1f3f77a364c6d2).
91+
92+
```diff
93+
-*.loc
94+
+*.lock
95+
```
96+
8597
## License
8698

8799
MIT
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__putout_processor_ignore(["*.lock"]);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__putout_processor_ignore([
2+
'*.loc'
3+
]);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {operator, types} from 'putout';
2+
3+
const {isStringLiteral} = types;
4+
const {
5+
__ignore,
6+
setLiteralValue,
7+
} = operator;
8+
9+
export const report = () => `Use '*.lock' instead of '*.loc'`;
10+
11+
export const fix = (path) => {
12+
setLiteralValue(path, '*.lock');
13+
};
14+
15+
export const traverse = ({push}) => ({
16+
[__ignore]: (path) => {
17+
const elements = path.get('arguments.0.elements');
18+
19+
for (const element of elements) {
20+
if (isStringLiteral(element.node, {value: '*.loc'}))
21+
push(element);
22+
}
23+
},
24+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {createTest} from '@putout/test';
2+
import * as plugin from './index.js';
3+
4+
const test = createTest(import.meta.url, {
5+
plugins: [
6+
['convert-loc-to-lock', plugin],
7+
],
8+
});
9+
10+
test('npmignore: convert-loc-to-lock: report', (t) => {
11+
t.report('convert-loc-to-lock', `Use '*.lock' instead of '*.loc'`);
12+
t.end();
13+
});
14+
15+
test('npmignore: convert-loc-to-lock: transform', (t) => {
16+
t.transform('convert-loc-to-lock');
17+
t.end();
18+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import * as convertLocToLock from './convert-loc-to-lock/index.js';
12
import * as add from './add/index.js';
23
import * as sort from './sort/index.js';
34

45
export const rules = {
56
add,
67
sort,
8+
'convert-loc-to-lock': convertLocToLock,
79
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
__putout_processor_ignore([
2+
"*.lock",
3+
"*.log",
4+
"*.config.*",
5+
"*.lock",
6+
"",
7+
".*",
8+
"",
9+
"coverage"
10+
]);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__putout_processor_ignore([
2+
'*.loc'
3+
]);

packages/plugin-npmignore/test/npmignore.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ test('plugin-npmignore: transform: sort', (t) => {
3838
t.transform('sort');
3939
t.end();
4040
});
41+
42+
test('plugin-npmignore: transform: convert-loc-to-lock', (t) => {
43+
t.transform('convert-loc-to-lock');
44+
t.end();
45+
});

0 commit comments

Comments
 (0)