eslint-import-resolver-node 0.3.4 → 0.3.7
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/index.js +53 -31
- package/package.json +9 -15
- package/CHANGELOG.md +0 -63
package/index.js
CHANGED
|
@@ -1,47 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
, path = require('path')
|
|
1
|
+
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
const resolve = require('resolve');
|
|
4
|
+
const isCoreModule = require('is-core-module');
|
|
5
|
+
const path = require('path');
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
const log = require('debug')('eslint-plugin-import:resolver:node');
|
|
8
|
+
|
|
9
|
+
exports.interfaceVersion = 2;
|
|
7
10
|
|
|
8
11
|
exports.resolve = function (source, file, config) {
|
|
9
|
-
log('Resolving:', source, 'from:', file)
|
|
10
|
-
|
|
12
|
+
log('Resolving:', source, 'from:', file);
|
|
13
|
+
let resolvedPath;
|
|
11
14
|
|
|
12
|
-
if (
|
|
13
|
-
log('resolved to core')
|
|
14
|
-
return { found: true, path: null }
|
|
15
|
+
if (isCoreModule(source)) {
|
|
16
|
+
log('resolved to core');
|
|
17
|
+
return { found: true, path: null };
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
try {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
const cachedFilter = function (pkg, dir) { return packageFilter(pkg, dir, config); };
|
|
22
|
+
resolvedPath = resolve.sync(source, opts(file, config, cachedFilter));
|
|
23
|
+
log('Resolved to:', resolvedPath);
|
|
24
|
+
return { found: true, path: resolvedPath };
|
|
21
25
|
} catch (err) {
|
|
22
|
-
log('resolve threw error:', err)
|
|
23
|
-
return { found: false }
|
|
26
|
+
log('resolve threw error:', err);
|
|
27
|
+
return { found: false };
|
|
24
28
|
}
|
|
25
|
-
}
|
|
29
|
+
};
|
|
26
30
|
|
|
27
|
-
function opts(file, config) {
|
|
31
|
+
function opts(file, config, packageFilter) {
|
|
28
32
|
return Object.assign({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
33
|
+
// more closely matches Node (#333)
|
|
34
|
+
// plus 'mjs' for native modules! (#939)
|
|
35
|
+
extensions: ['.mjs', '.js', '.json', '.node'],
|
|
36
|
+
},
|
|
37
|
+
config,
|
|
38
|
+
{
|
|
39
|
+
// path.resolve will handle paths relative to CWD
|
|
40
|
+
basedir: path.dirname(path.resolve(file)),
|
|
41
|
+
packageFilter,
|
|
42
|
+
});
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
function identity(x) { return x; }
|
|
46
|
+
|
|
47
|
+
function packageFilter(pkg, dir, config) {
|
|
48
|
+
let found = false;
|
|
49
|
+
const file = path.join(dir, 'dummy.js');
|
|
50
|
+
if (pkg.module) {
|
|
51
|
+
try {
|
|
52
|
+
resolve.sync(String(pkg.module).replace(/^(?:\.\/)?/, './'), opts(file, config, identity));
|
|
53
|
+
pkg.main = pkg.module;
|
|
54
|
+
found = true;
|
|
55
|
+
} catch (err) {
|
|
56
|
+
log('resolve threw error trying to find pkg.module:', err);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (!found && pkg['jsnext:main']) {
|
|
60
|
+
try {
|
|
61
|
+
resolve.sync(String(pkg['jsnext:main']).replace(/^(?:\.\/)?/, './'), opts(file, config, identity));
|
|
62
|
+
pkg.main = pkg['jsnext:main'];
|
|
63
|
+
found = true;
|
|
64
|
+
} catch (err) {
|
|
65
|
+
log('resolve threw error trying to find pkg[\'jsnext:main\']:', err);
|
|
66
|
+
}
|
|
45
67
|
}
|
|
46
|
-
return pkg
|
|
68
|
+
return pkg;
|
|
47
69
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-import-resolver-node",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "Node default behavior import resolution plugin for eslint-plugin-import.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -9,12 +9,11 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"prepublishOnly": "cp ../../{LICENSE,.npmrc} ./",
|
|
11
11
|
"tests-only": "nyc mocha",
|
|
12
|
-
"test": "npm run tests-only"
|
|
13
|
-
"coveralls": "nyc report --reporter lcovonly && cd ../.. && coveralls < ./resolvers/node/coverage/lcov.info"
|
|
12
|
+
"test": "npm run tests-only"
|
|
14
13
|
},
|
|
15
14
|
"repository": {
|
|
16
15
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/
|
|
16
|
+
"url": "https://github.com/import-js/eslint-plugin-import"
|
|
18
17
|
},
|
|
19
18
|
"keywords": [
|
|
20
19
|
"eslint",
|
|
@@ -26,22 +25,17 @@
|
|
|
26
25
|
"author": "Ben Mosher (me@benmosher.com)",
|
|
27
26
|
"license": "MIT",
|
|
28
27
|
"bugs": {
|
|
29
|
-
"url": "https://github.com/
|
|
28
|
+
"url": "https://github.com/import-js/eslint-plugin-import/issues"
|
|
30
29
|
},
|
|
31
|
-
"homepage": "https://github.com/
|
|
30
|
+
"homepage": "https://github.com/import-js/eslint-plugin-import",
|
|
32
31
|
"dependencies": {
|
|
33
|
-
"debug": "^2.
|
|
34
|
-
"
|
|
32
|
+
"debug": "^3.2.7",
|
|
33
|
+
"is-core-module": "^2.11.0",
|
|
34
|
+
"resolve": "^1.22.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"chai": "^3.5.0",
|
|
38
|
-
"coveralls": "^3.0.0",
|
|
39
38
|
"mocha": "^3.5.3",
|
|
40
|
-
"nyc": "^11.
|
|
41
|
-
},
|
|
42
|
-
"nyc": {
|
|
43
|
-
"exclude": [
|
|
44
|
-
"test/"
|
|
45
|
-
]
|
|
39
|
+
"nyc": "^11.9.0"
|
|
46
40
|
}
|
|
47
41
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
All notable changes to this resolver will be documented in this file.
|
|
3
|
-
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
|
-
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).
|
|
5
|
-
|
|
6
|
-
## Unreleased
|
|
7
|
-
|
|
8
|
-
## v0.3.4 - 2020-06-16
|
|
9
|
-
### Added
|
|
10
|
-
- add `.node` extension ([#1663])
|
|
11
|
-
|
|
12
|
-
## v0.3.3 - 2020-01-10
|
|
13
|
-
### Changed
|
|
14
|
-
- [meta] copy LICENSE file to all npm packages on prepublish ([#1595], thanks [@opichals])
|
|
15
|
-
|
|
16
|
-
## v0.3.2 - 2018-01-05
|
|
17
|
-
### Added
|
|
18
|
-
- `.mjs` extension detected by default to support `experimental-modules` ([#939])
|
|
19
|
-
|
|
20
|
-
### Deps
|
|
21
|
-
- update `debug`, `resolve`
|
|
22
|
-
|
|
23
|
-
## v0.3.1 - 2017-06-23
|
|
24
|
-
### Changed
|
|
25
|
-
- bumped `debug` dep to match other packages
|
|
26
|
-
|
|
27
|
-
## v0.3.0 - 2016-12-15
|
|
28
|
-
### Changed
|
|
29
|
-
- bumped `resolve` to fix issues with Node builtins (thanks [@SkeLLLa] and [@ljharb])
|
|
30
|
-
|
|
31
|
-
### Fixed
|
|
32
|
-
- use `files` in `package.json` to ship only `index.js` ([#531], thanks for noticing [@lukeapage])
|
|
33
|
-
|
|
34
|
-
## v0.2.3 - 2016-08-20
|
|
35
|
-
### Added
|
|
36
|
-
- debug logging (use `DEBUG=eslint-plugin-import:resolver:node eslint [...]`)
|
|
37
|
-
|
|
38
|
-
## v0.2.2 - 2016-07-14
|
|
39
|
-
### Fixed
|
|
40
|
-
- Node resolver no longer declares the import plugin as a `peerDependency`. See [#437]
|
|
41
|
-
for a well-articulated and thoughtful expression of why this doesn't make sense.
|
|
42
|
-
Thanks [@jasonkarns] for the issue and the PR to fix it ([#438]).
|
|
43
|
-
|
|
44
|
-
Also, apologies to the others who expressed this before, but I never understood
|
|
45
|
-
what the problem was.😅
|
|
46
|
-
|
|
47
|
-
## v0.2.1
|
|
48
|
-
### Fixed
|
|
49
|
-
- find files with `.json` extensions (#333, thanks for noticing @jfmengels)
|
|
50
|
-
|
|
51
|
-
[#438]: https://github.com/benmosher/eslint-plugin-import/pull/438
|
|
52
|
-
|
|
53
|
-
[#1663]: https://github.com/benmosher/eslint-plugin-import/issues/1663
|
|
54
|
-
[#1595]: https://github.com/benmosher/eslint-plugin-import/pull/1595
|
|
55
|
-
[#939]: https://github.com/benmosher/eslint-plugin-import/issues/939
|
|
56
|
-
[#531]: https://github.com/benmosher/eslint-plugin-import/issues/531
|
|
57
|
-
[#437]: https://github.com/benmosher/eslint-plugin-import/issues/437
|
|
58
|
-
|
|
59
|
-
[@jasonkarns]: https://github.com/jasonkarns
|
|
60
|
-
[@lukeapage]: https://github.com/lukeapage
|
|
61
|
-
[@SkeLLLa]: https://github.com/SkeLLLa
|
|
62
|
-
[@ljharb]: https://github.com/ljharb
|
|
63
|
-
[@opichals]: https://github.com/opichals
|