eslint-import-resolver-node
Advanced tools
Comparing version 0.3.4 to 0.3.5
58
index.js
@@ -1,47 +0,51 @@ | ||
var resolve = require('resolve') | ||
, path = require('path') | ||
'use strict'; | ||
var log = require('debug')('eslint-plugin-import:resolver:node') | ||
const resolve = require('resolve'); | ||
const path = require('path'); | ||
exports.interfaceVersion = 2 | ||
const log = require('debug')('eslint-plugin-import:resolver:node'); | ||
exports.interfaceVersion = 2; | ||
exports.resolve = function (source, file, config) { | ||
log('Resolving:', source, 'from:', file) | ||
var resolvedPath | ||
log('Resolving:', source, 'from:', file); | ||
let resolvedPath; | ||
if (resolve.isCore(source)) { | ||
log('resolved to core') | ||
return { found: true, path: null } | ||
log('resolved to core'); | ||
return { found: true, path: null }; | ||
} | ||
try { | ||
resolvedPath = resolve.sync(source, opts(file, config)) | ||
log('Resolved to:', resolvedPath) | ||
return { found: true, path: resolvedPath } | ||
resolvedPath = resolve.sync(source, opts(file, config)); | ||
log('Resolved to:', resolvedPath); | ||
return { found: true, path: resolvedPath }; | ||
} catch (err) { | ||
log('resolve threw error:', err) | ||
return { found: false } | ||
log('resolve threw error:', err); | ||
return { found: false }; | ||
} | ||
} | ||
}; | ||
function opts(file, config) { | ||
return Object.assign({ | ||
// more closely matches Node (#333) | ||
// plus 'mjs' for native modules! (#939) | ||
extensions: ['.mjs', '.js', '.json', '.node'], | ||
}, | ||
config, | ||
{ | ||
// path.resolve will handle paths relative to CWD | ||
basedir: path.dirname(path.resolve(file)), | ||
packageFilter: packageFilter, | ||
// more closely matches Node (#333) | ||
// plus 'mjs' for native modules! (#939) | ||
extensions: ['.mjs', '.js', '.json', '.node'], | ||
}, | ||
config, | ||
{ | ||
// path.resolve will handle paths relative to CWD | ||
basedir: path.dirname(path.resolve(file)), | ||
packageFilter: packageFilter, | ||
}) | ||
}); | ||
} | ||
function packageFilter(pkg) { | ||
if (pkg['jsnext:main']) { | ||
pkg['main'] = pkg['jsnext:main'] | ||
if (pkg.module) { | ||
pkg.main = pkg.module; | ||
} else if (pkg['jsnext:main']) { | ||
pkg.main = pkg['jsnext:main']; | ||
} | ||
return pkg | ||
return pkg; | ||
} |
{ | ||
"name": "eslint-import-resolver-node", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "Node default behavior import resolution plugin for eslint-plugin-import.", | ||
@@ -17,3 +17,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "https://github.com/benmosher/eslint-plugin-import" | ||
"url": "https://github.com/import-js/eslint-plugin-import" | ||
}, | ||
@@ -30,20 +30,15 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/benmosher/eslint-plugin-import/issues" | ||
"url": "https://github.com/import-js/eslint-plugin-import/issues" | ||
}, | ||
"homepage": "https://github.com/benmosher/eslint-plugin-import", | ||
"homepage": "https://github.com/import-js/eslint-plugin-import", | ||
"dependencies": { | ||
"debug": "^2.6.9", | ||
"resolve": "^1.13.1" | ||
"debug": "^3.2.7", | ||
"resolve": "^1.20.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"coveralls": "^3.0.0", | ||
"coveralls": "^3.1.0", | ||
"mocha": "^3.5.3", | ||
"nyc": "^11.7.1" | ||
}, | ||
"nyc": { | ||
"exclude": [ | ||
"test/" | ||
] | ||
"nyc": "^11.9.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42
4688
4
+ Addeddebug@3.2.7(transitive)
+ Addedms@2.1.3(transitive)
- Removeddebug@2.6.9(transitive)
- Removedms@2.0.0(transitive)
Updateddebug@^3.2.7
Updatedresolve@^1.20.0