eslint-import-resolver-node 0.3.1 → 0.3.5

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 (4) hide show
  1. package/LICENSE +22 -0
  2. package/index.js +32 -27
  3. package/package.json +17 -11
  4. package/CHANGELOG.md +0 -45
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Ben Mosher
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/index.js CHANGED
@@ -1,46 +1,51 @@
1
- var resolve = require('resolve')
2
- , path = require('path')
1
+ 'use strict';
3
2
 
4
- var log = require('debug')('eslint-plugin-import:resolver:node')
3
+ const resolve = require('resolve');
4
+ const path = require('path');
5
5
 
6
- exports.interfaceVersion = 2
6
+ const log = require('debug')('eslint-plugin-import:resolver:node');
7
+
8
+ exports.interfaceVersion = 2;
7
9
 
8
10
  exports.resolve = function (source, file, config) {
9
- log('Resolving:', source, 'from:', file)
10
- var resolvedPath
11
+ log('Resolving:', source, 'from:', file);
12
+ let resolvedPath;
11
13
 
12
14
  if (resolve.isCore(source)) {
13
- log('resolved to core')
14
- return { found: true, path: null }
15
+ log('resolved to core');
16
+ return { found: true, path: null };
15
17
  }
16
18
 
17
19
  try {
18
- resolvedPath = resolve.sync(source, opts(file, config))
19
- log('Resolved to:', resolvedPath)
20
- return { found: true, path: resolvedPath }
20
+ resolvedPath = resolve.sync(source, opts(file, config));
21
+ log('Resolved to:', resolvedPath);
22
+ return { found: true, path: resolvedPath };
21
23
  } catch (err) {
22
- log('resolve threw error:', err)
23
- return { found: false }
24
+ log('resolve threw error:', err);
25
+ return { found: false };
24
26
  }
25
- }
27
+ };
26
28
 
27
29
  function opts(file, config) {
28
30
  return Object.assign({
29
- // more closely matches Node (#333)
30
- extensions: ['.js', '.json'],
31
- },
32
- config,
33
- {
34
- // path.resolve will handle paths relative to CWD
35
- basedir: path.dirname(path.resolve(file)),
36
- packageFilter: packageFilter,
37
-
38
- })
31
+ // more closely matches Node (#333)
32
+ // plus 'mjs' for native modules! (#939)
33
+ extensions: ['.mjs', '.js', '.json', '.node'],
34
+ },
35
+ config,
36
+ {
37
+ // path.resolve will handle paths relative to CWD
38
+ basedir: path.dirname(path.resolve(file)),
39
+ packageFilter: packageFilter,
40
+
41
+ });
39
42
  }
40
43
 
41
44
  function packageFilter(pkg) {
42
- if (pkg['jsnext:main']) {
43
- pkg['main'] = pkg['jsnext:main']
45
+ if (pkg.module) {
46
+ pkg.main = pkg.module;
47
+ } else if (pkg['jsnext:main']) {
48
+ pkg.main = pkg['jsnext:main'];
44
49
  }
45
- return pkg
50
+ return pkg;
46
51
  }
package/package.json CHANGED
@@ -1,15 +1,20 @@
1
1
  {
2
2
  "name": "eslint-import-resolver-node",
3
- "version": "0.3.1",
3
+ "version": "0.3.5",
4
4
  "description": "Node default behavior import resolution plugin for eslint-plugin-import.",
5
5
  "main": "index.js",
6
- "files": ["index.js"],
6
+ "files": [
7
+ "index.js"
8
+ ],
7
9
  "scripts": {
8
- "test": "nyc mocha"
10
+ "prepublishOnly": "cp ../../{LICENSE,.npmrc} ./",
11
+ "tests-only": "nyc mocha",
12
+ "test": "npm run tests-only",
13
+ "coveralls": "nyc report --reporter lcovonly && cd ../.. && coveralls < ./resolvers/node/coverage/lcov.info"
9
14
  },
10
15
  "repository": {
11
16
  "type": "git",
12
- "url": "https://github.com/benmosher/eslint-plugin-import"
17
+ "url": "https://github.com/import-js/eslint-plugin-import"
13
18
  },
14
19
  "keywords": [
15
20
  "eslint",
@@ -21,16 +26,17 @@
21
26
  "author": "Ben Mosher (me@benmosher.com)",
22
27
  "license": "MIT",
23
28
  "bugs": {
24
- "url": "https://github.com/benmosher/eslint-plugin-import/issues"
29
+ "url": "https://github.com/import-js/eslint-plugin-import/issues"
25
30
  },
26
- "homepage": "https://github.com/benmosher/eslint-plugin-import",
31
+ "homepage": "https://github.com/import-js/eslint-plugin-import",
27
32
  "dependencies": {
28
- "debug": "^2.6.8",
29
- "resolve": "^1.2.0"
33
+ "debug": "^3.2.7",
34
+ "resolve": "^1.20.0"
30
35
  },
31
36
  "devDependencies": {
32
- "chai": "^3.4.1",
33
- "mocha": "^2.3.4",
34
- "nyc": "^7.0.0"
37
+ "chai": "^3.5.0",
38
+ "coveralls": "^3.1.0",
39
+ "mocha": "^3.5.3",
40
+ "nyc": "^11.9.0"
35
41
  }
36
42
  }
package/CHANGELOG.md DELETED
@@ -1,45 +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
-
9
- ## v0.3.1 - 2017-06-23
10
- ### Changed
11
- - bumped `debug` dep to match other packages
12
-
13
- ## v0.3.0 - 2016-12-15
14
- ### Changed
15
- - bumped `resolve` to fix issues with Node builtins (thanks [@SkeLLLa] and [@ljharb])
16
-
17
- ### Fixed
18
- - use `files` in `package.json` to ship only `index.js` ([#531], thanks for noticing [@lukeapage])
19
-
20
- ## v0.2.3 - 2016-08-20
21
- ### Added
22
- - debug logging (use `DEBUG=eslint-plugin-import:resolver:node eslint [...]`)
23
-
24
- ## v0.2.2 - 2016-07-14
25
- ### Fixed
26
- - Node resolver no longer declares the import plugin as a `peerDependency`. See [#437]
27
- for a well-articulated and thoughtful expression of why this doesn't make sense.
28
- Thanks [@jasonkarns] for the issue and the PR to fix it ([#438]).
29
-
30
- Also, apologies to the others who expressed this before, but I never understood
31
- what the problem was.😅
32
-
33
- ## v0.2.1
34
- ### Fixed
35
- - find files with `.json` extensions (#333, thanks for noticing @jfmengels)
36
-
37
- [#438]: https://github.com/benmosher/eslint-plugin-import/pull/438
38
-
39
- [#531]: https://github.com/benmosher/eslint-plugin-import/issues/531
40
- [#437]: https://github.com/benmosher/eslint-plugin-import/issues/437
41
-
42
- [@jasonkarns]: https://github.com/jasonkarns
43
- [@lukeapage]: https://github.com/lukeapage
44
- [@SkeLLLa]: https://github.com/SkeLLLa
45
- [@ljharb]: https://github.com/ljharb