@putout/plugin-gitignore 5.0.0 → 6.0.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.
Files changed (2) hide show
  1. package/lib/gitignore.js +19 -60
  2. package/package.json +3 -3
package/lib/gitignore.js CHANGED
@@ -1,63 +1,22 @@
1
- import {types, operator} from 'putout';
1
+ import {operator} from 'putout';
2
2
 
3
- const {__ignore} = operator;
4
- const {StringLiteral} = types;
5
- const getValue = ({value}) => value;
3
+ const {ignore, __ignore} = operator;
4
+ const {
5
+ match,
6
+ replace,
7
+ report,
8
+ } = ignore(__ignore, {
9
+ name: '.gitignore',
10
+ list: [
11
+ '.idea',
12
+ '*.swp',
13
+ 'yarn-error.log',
14
+ 'coverage',
15
+ ],
16
+ });
6
17
 
7
- const names = [
8
- '.idea',
9
- '*.swp',
10
- 'yarn-error.log',
11
- 'coverage',
12
- ];
13
-
14
- export const report = () => `Dot files should be added to .gitignore`;
15
-
16
- export const match = ({options}) => {
17
- const {dismiss = []} = options;
18
- const newNames = filterNames(names, dismiss);
19
-
20
- return {
21
- [__ignore]: ({__array}) => {
22
- const list = __array.elements.map(getValue);
23
-
24
- for (const name of newNames) {
25
- if (!list.includes(name))
26
- return true;
27
- }
28
-
29
- return false;
30
- },
31
- };
18
+ export {
19
+ match,
20
+ replace,
21
+ report,
32
22
  };
33
-
34
- export const replace = ({options}) => {
35
- const {dismiss = []} = options;
36
- const newNames = filterNames(names, dismiss);
37
-
38
- return {
39
- [__ignore]: ({__array}, path) => {
40
- const list = __array.elements.map(getValue);
41
-
42
- for (const name of newNames) {
43
- if (!list.includes(name))
44
- __array.elements.push(StringLiteral(name));
45
- }
46
-
47
- return path;
48
- },
49
- };
50
- };
51
-
52
- function filterNames(names, dismiss) {
53
- const newNames = [];
54
-
55
- for (const name of names) {
56
- if (dismiss.includes(name))
57
- continue;
58
-
59
- newNames.push(name);
60
- }
61
-
62
- return newNames;
63
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-gitignore",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with .gitignore",
@@ -33,8 +33,8 @@
33
33
  "devDependencies": {
34
34
  "@putout/test": "^9.0.0",
35
35
  "c8": "^9.0.0",
36
- "eslint": "^9.0.0-alpha.0",
37
- "eslint-plugin-n": "^17.0.0-0",
36
+ "eslint": "^9.0.0",
37
+ "eslint-plugin-n": "^17.0.0",
38
38
  "eslint-plugin-putout": "^22.0.0",
39
39
  "lerna": "^6.0.1",
40
40
  "madrun": "^10.0.0",