@putout/plugin-esm 8.8.0 β 9.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.
- package/README.md +4 -32
- package/lib/index.js +0 -2
- package/package.json +1 -1
- package/lib/add-index-to-import/index.js +0 -37
package/README.md
CHANGED
|
@@ -72,38 +72,6 @@ npm i putout @putout/plugin-esm -D
|
|
|
72
72
|
|
|
73
73
|
## Rules
|
|
74
74
|
|
|
75
|
-
### add-index-to-import
|
|
76
|
-
|
|
77
|
-
> `import` a directory URL is unsupported. Instead
|
|
78
|
-
>
|
|
79
|
-
> (c) [nodejs.org](https://nodejs.org/api/errors.html#err_unsupported_dir_import)
|
|
80
|
-
|
|
81
|
-
ESM doesn't add `index.js`, so it can be left after [`@putout/plugin-convert-esm-to-commonjs`](https://github.com/coderaiser/putout/blob/master/packages/plugin-convert-esm-to-commonjs#readme).
|
|
82
|
-
|
|
83
|
-
Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/b7c489710767efee95ecf3dd16e232a2/9f974f0a345ef4d0cb39b011097dff82e6c32b75).
|
|
84
|
-
|
|
85
|
-
#### β Example of incorrect code
|
|
86
|
-
|
|
87
|
-
```js
|
|
88
|
-
import insertRust from './insert-rust';
|
|
89
|
-
import addAction from './add-action';
|
|
90
|
-
|
|
91
|
-
export * as read from './vfs/read';
|
|
92
|
-
|
|
93
|
-
export const rules = {};
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
#### β
Example of correct code
|
|
97
|
-
|
|
98
|
-
```js
|
|
99
|
-
import insertRust from './insert-rust/index.js';
|
|
100
|
-
import addAction from './add-action/index.js';
|
|
101
|
-
|
|
102
|
-
export * as read from './vfs/read/index.js';
|
|
103
|
-
|
|
104
|
-
export const rules = {};
|
|
105
|
-
```
|
|
106
|
-
|
|
107
75
|
### apply-export-from
|
|
108
76
|
|
|
109
77
|
> The `export` declaration is used to export values from a JavaScript module.
|
|
@@ -524,6 +492,10 @@ import {isPrev} from '#is';
|
|
|
524
492
|
|
|
525
493
|
### resolve-imported-file
|
|
526
494
|
|
|
495
|
+
> `import` a directory URL is unsupported.
|
|
496
|
+
>
|
|
497
|
+
> (c) [nodejs.org](https://nodejs.org/api/errors.html#err_unsupported_dir_import)
|
|
498
|
+
|
|
527
499
|
Check out in π**Putout Editor**:
|
|
528
500
|
|
|
529
501
|
- β
[`resolve-imported-file`](https://putout.cloudcmd.io/#/gist/241489cb2781dd37ec96baf0115cde4e/83c2f2e9f490850b7fda432f8d25ae6a64ed07e3);
|
package/lib/index.js
CHANGED
|
@@ -5,7 +5,6 @@ import * as applyNamespaceToImportedFile from './apply-namespace-to-imported-fil
|
|
|
5
5
|
import * as mergeExportDeclarations from './merge-export-declarations/index.js';
|
|
6
6
|
import * as removeUselessExportSpecifiers from './remove-useless-export-specifiers/index.js';
|
|
7
7
|
import * as mergeDeclarationWithExport from './merge-declaration-with-export/index.js';
|
|
8
|
-
import * as addIndexToImport from './add-index-to-import/index.js';
|
|
9
8
|
import * as declareImportsFirst from './declare-imports-first/index.js';
|
|
10
9
|
import * as groupImportsBySource from './group-imports-by-source/index.js';
|
|
11
10
|
import * as removeQuotesFromImportAssertions from './remove-quotes-from-import-assertions/index.js';
|
|
@@ -19,7 +18,6 @@ import * as resolveImportedFile from './resolve-imported-file/index.js';
|
|
|
19
18
|
import * as shortenImportedFile from './shorten-imported-file/index.js';
|
|
20
19
|
|
|
21
20
|
export const rules = {
|
|
22
|
-
'add-index-to-import': addIndexToImport,
|
|
23
21
|
'apply-export-from': applyExportFrom,
|
|
24
22
|
'convert-assert-to-with': convertAssertToWith,
|
|
25
23
|
'declare-imports-first': declareImportsFirst,
|
package/package.json
CHANGED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {extname} from 'node:path';
|
|
2
|
-
import {operator} from 'putout';
|
|
3
|
-
|
|
4
|
-
const {setLiteralValue} = operator;
|
|
5
|
-
|
|
6
|
-
export const report = (path) => {
|
|
7
|
-
const {value} = path.node.source;
|
|
8
|
-
return `Add 'index.js' to import: '${value}' -> '${value}/index.js'`;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const fix = (path) => {
|
|
12
|
-
const {source} = path.node;
|
|
13
|
-
const {value} = source;
|
|
14
|
-
|
|
15
|
-
setLiteralValue(source, `${value}/index.js`);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const traverse = ({push}) => ({
|
|
19
|
-
'ImportDeclaration|ExportNamedDeclaration': (path) => {
|
|
20
|
-
const {node} = path;
|
|
21
|
-
const {source} = node;
|
|
22
|
-
|
|
23
|
-
if (!source)
|
|
24
|
-
return;
|
|
25
|
-
|
|
26
|
-
const {value} = source;
|
|
27
|
-
const ext = extname(value);
|
|
28
|
-
|
|
29
|
-
if (ext)
|
|
30
|
-
return;
|
|
31
|
-
|
|
32
|
-
if (!value.startsWith('.'))
|
|
33
|
-
return;
|
|
34
|
-
|
|
35
|
-
push(path);
|
|
36
|
-
},
|
|
37
|
-
});
|