@putout/plugin-package-json 11.0.0 → 11.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/README.md +22 -14
- package/lib/index.js +0 -6
- package/lib/package-json.js +8 -0
- package/lib/remove-dot-slash-from-bin/index.js +47 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,12 +16,16 @@ npm i @putout/plugin-package-json -D
|
|
|
16
16
|
- ✅ [add-type](#add-type);
|
|
17
17
|
- ✅ [apply-js-extension](#apply-js-extension);
|
|
18
18
|
- ✅ [apply-https-to-repository-url](#apply-https-to-repository-url);
|
|
19
|
-
- ✅ [find-file](#find-file);
|
|
20
19
|
- ✅ [remove-nyc](#remove-nyc);
|
|
21
20
|
- ✅ [remove-commit-type](#remove-commit-type);
|
|
22
21
|
- ✅ [remove-imports-nesting](#remove-imports-nesting);
|
|
23
22
|
- ✅ [remove-duplicate-keywords](#remove-duplicate-keywords);
|
|
23
|
+
- ✅ [remove-dot-slash-from-bin](#remove-dot-slash-from-bin);
|
|
24
|
+
|
|
25
|
+
## Filesystem rules
|
|
26
|
+
|
|
24
27
|
- ✅ [remove-exports-with-missing-files](#remove-exports-with-missing-files);
|
|
28
|
+
- ✅ [find-file](#find-file);
|
|
25
29
|
|
|
26
30
|
## Config
|
|
27
31
|
|
|
@@ -34,6 +38,7 @@ npm i @putout/plugin-package-json -D
|
|
|
34
38
|
"package-json/remove-nyc": "on",
|
|
35
39
|
"package-json/remove-commit-type": "on",
|
|
36
40
|
"package-json/remove-imports-nesting": "on",
|
|
41
|
+
"package-json/remove-dot-slash-from-bin": "bin",
|
|
37
42
|
"package-json/remove-exports-with-missing-files": "off",
|
|
38
43
|
"package-json/find-file": "off"
|
|
39
44
|
}
|
|
@@ -171,31 +176,34 @@ Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/eb12c902c
|
|
|
171
176
|
}
|
|
172
177
|
```
|
|
173
178
|
|
|
174
|
-
## remove-
|
|
179
|
+
## remove-dot-slash-from-bin
|
|
175
180
|
|
|
176
|
-
|
|
181
|
+
Fixes `npm` warnings:
|
|
182
|
+
|
|
183
|
+
> "npm warn publish bin[c8]" script name was cleaned
|
|
177
184
|
|
|
185
|
+
Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/ef444a1679d00b8bb41a209e76499921/24a4a06d0db2d8b487b5ca5ff40290c8b3e24e3d).
|
|
178
186
|
```diff
|
|
179
187
|
{
|
|
180
|
-
"
|
|
181
|
-
- "
|
|
182
|
-
|
|
183
|
-
- }
|
|
184
|
-
+ "#get-imports": "./lib/shorten-imported-file/get-imports/index.js"
|
|
188
|
+
"bin": {
|
|
189
|
+
- "c8": "./bin/c8.js"
|
|
190
|
+
+ "c8": "bin/c8.js"
|
|
185
191
|
}
|
|
186
192
|
}
|
|
187
193
|
```
|
|
188
194
|
|
|
189
|
-
##
|
|
195
|
+
## remove-imports-nesting
|
|
190
196
|
|
|
191
|
-
|
|
192
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/325233d19fde0acacadbcf1f42dd3bb2/124a50fe0e92c6c3cab24f8b87c33b202dc3e540).
|
|
197
|
+
Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/3527617ece2bfd9c39875db50a8a6245/2f3c6248b7b0ab539212b747f3cd480dc77ce3f1).
|
|
193
198
|
|
|
194
199
|
```diff
|
|
195
200
|
{
|
|
196
|
-
"
|
|
197
|
-
|
|
198
|
-
|
|
201
|
+
"imports": {
|
|
202
|
+
- "#get-imports": {
|
|
203
|
+
- "default": "./lib/shorten-imported-file/get-imports/index.js"
|
|
204
|
+
- }
|
|
205
|
+
+ "#get-imports": "./lib/shorten-imported-file/get-imports/index.js"
|
|
206
|
+
}
|
|
199
207
|
}
|
|
200
208
|
```
|
|
201
209
|
|
package/lib/index.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import * as applyJsExtension from './apply-js-extension/index.js';
|
|
2
|
-
import * as removeImportsNesting from './remove-imports-nesting/index.js';
|
|
3
1
|
import {rules as packageJson} from './package-json.js';
|
|
4
2
|
import * as findFile from './find-file/index.js';
|
|
5
3
|
import * as removeExportsWithMissingFiles from './remove-exports-with-missing-files/index.js';
|
|
6
|
-
import * as removeDuplicateKeywords from './remove-duplicate-keywords/index.js';
|
|
7
4
|
|
|
8
5
|
export const rules = {
|
|
9
6
|
...packageJson,
|
|
10
7
|
'find-file': ['off', findFile],
|
|
11
8
|
'remove-exports-with-missing-files': ['off', removeExportsWithMissingFiles],
|
|
12
|
-
'remove-duplicate-keywords': removeDuplicateKeywords,
|
|
13
|
-
'remove-imports-nesting': removeImportsNesting,
|
|
14
|
-
'apply-js-extension': applyJsExtension,
|
|
15
9
|
};
|
package/lib/package-json.js
CHANGED
|
@@ -2,10 +2,18 @@ import * as addType from './add-type/index.js';
|
|
|
2
2
|
import * as removeNyc from './remove-nyc/index.js';
|
|
3
3
|
import * as removeCommitType from './remove-commit-type/index.js';
|
|
4
4
|
import * as applyHttpsToRepositoryUrl from './apply-https-to-repository-url/index.js';
|
|
5
|
+
import * as removeDuplicateKeywords from './remove-duplicate-keywords/index.js';
|
|
6
|
+
import * as removeDotSlashFromBin from './remove-dot-slash-from-bin/index.js';
|
|
7
|
+
import * as applyJsExtension from './apply-js-extension/index.js';
|
|
8
|
+
import * as removeImportsNesting from './remove-imports-nesting/index.js';
|
|
5
9
|
|
|
6
10
|
export const rules = {
|
|
7
11
|
'add-type': addType,
|
|
8
12
|
'remove-nyc': removeNyc,
|
|
9
13
|
'remove-commit-type': removeCommitType,
|
|
10
14
|
'apply-https-to-repository-url': applyHttpsToRepositoryUrl,
|
|
15
|
+
'remove-duplicate-keywords': removeDuplicateKeywords,
|
|
16
|
+
'remove-imports-nesting': removeImportsNesting,
|
|
17
|
+
'apply-js-extension': applyJsExtension,
|
|
18
|
+
'remove-dot-slash-from-bin': removeDotSlashFromBin,
|
|
11
19
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {operator, types} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {isObjectExpression} = types;
|
|
4
|
+
const {
|
|
5
|
+
getProperty,
|
|
6
|
+
__json,
|
|
7
|
+
setLiteralValue,
|
|
8
|
+
} = operator;
|
|
9
|
+
|
|
10
|
+
const dropDotSlash = (a) => a.slice(2);
|
|
11
|
+
|
|
12
|
+
export const report = (path) => {
|
|
13
|
+
const {value} = path.node;
|
|
14
|
+
const newValue = dropDotSlash(value);
|
|
15
|
+
|
|
16
|
+
return `Avoid './' in 'bin': '${value}' -> '${newValue}'`;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const fix = (path) => {
|
|
20
|
+
const {value} = path.node;
|
|
21
|
+
const newValue = dropDotSlash(value);
|
|
22
|
+
|
|
23
|
+
setLiteralValue(path, newValue);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const traverse = ({push}) => ({
|
|
27
|
+
[__json](path) {
|
|
28
|
+
const arg = path.get('arguments.0');
|
|
29
|
+
const bin = getProperty(arg, 'bin');
|
|
30
|
+
|
|
31
|
+
if (!bin)
|
|
32
|
+
return;
|
|
33
|
+
|
|
34
|
+
const object = bin.get('value');
|
|
35
|
+
|
|
36
|
+
if (!isObjectExpression(object))
|
|
37
|
+
return;
|
|
38
|
+
|
|
39
|
+
for (const property of object.get('properties')) {
|
|
40
|
+
const valuePath = property.get('value');
|
|
41
|
+
const {value} = valuePath.node;
|
|
42
|
+
|
|
43
|
+
if (value.startsWith('./'))
|
|
44
|
+
push(valuePath);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-package-json",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout plugin for package.json",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@putout/eslint-flat": "^4.0.0",
|
|
35
35
|
"@putout/test": "^15.0.0",
|
|
36
|
-
"c8": "^10.0.0",
|
|
37
36
|
"eslint": "^10.0.0",
|
|
38
37
|
"eslint-plugin-n": "^17.0.0",
|
|
39
38
|
"eslint-plugin-putout": "^31.0.0",
|
|
40
39
|
"madrun": "^13.0.0",
|
|
41
|
-
"nodemon": "^3.0.1"
|
|
40
|
+
"nodemon": "^3.0.1",
|
|
41
|
+
"superc8": "^12.0.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"putout": ">=42"
|